@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/storage/entity-canonical-id-migration.ts"],"sourcesContent":["import { createHash, randomUUID } from \"node:crypto\";\nimport {\n access,\n lstat,\n readFile,\n readdir,\n realpath,\n rename,\n stat as statFile,\n unlink,\n writeFile,\n} from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { lstatSync, readFileSync } from \"node:fs\";\nimport { z } from \"zod\";\nimport { computeSupersessionKey, normalizeSupersessionKey } from \"../temporal-supersession.js\";\nimport type { EntityFile, MemoryFile } from \"../types.js\";\nimport { log } from \"../logger.js\";\nimport { isErrnoCode } from \"../utils/errno.js\";\nimport { withHeldFileLock } from \"../utils/serialize-mutations.js\";\nimport { RECALL_FALLBACK_DIRS } from \"../utils/category-dir.js\";\nimport { assertPathInsideRoot } from \"../utils/path-containment.js\";\nimport { withEntityCanonicalMutationLock } from \"./entity-canonical-id-lock.js\";\nimport { assertSafeEntityId } from \"./entity-id-safety.js\";\nimport { isMalformedEntityRecord } from \"../utils/malformed-entity-record.js\";\nimport {\n isMacOsReplicationJunkBasename,\n warnIgnoredMacOsReplicationJunk,\n} from \"../utils/macos-replication-junk.js\";\n\nimport {\n ENTITY_CANONICAL_ID_MIGRATION_FILE,\n ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER,\n ENTITY_CANONICAL_ID_RECONCILE_MARKER,\n resolveHistoricalEntityCanonicalId,\n} from \"./entity-canonical-id-references.js\";\n\nconst ENTITY_CANONICAL_ID_MIGRATION_VERSION = 1;\nconst ENTITY_CANONICAL_ID_MIGRATION_LOCK_STALE_MS = 60_000;\nconst ENTITY_CANONICAL_ID_MIGRATION_LOCK_MAX_WAIT_MS = 300_000;\nconst TOMBSTONE_LOCK_STALE_MS = 30_000;\nconst TOMBSTONE_LOCK_MAX_WAIT_MS = 5_000;\nconst MEMORY_REWRITE_MAX_PASSES = 3;\nconst ENTITY_MAPPING_RESCAN_MAX_PASSES = 3;\n\nconst EntityCanonicalIdMigrationStateSchema = z.object({\n version: z.literal(ENTITY_CANONICAL_ID_MIGRATION_VERSION),\n complete: z.boolean(),\n mappings: z.record(z.string(), z.string().min(1)),\n completionFingerprint: z.string().optional(),\n /**\n * Pairs the migration refused to resolve, PARKED rather than dropped.\n * Deleting the record would strand the collision: once an operator removes\n * the legacy file, no later scan can rediscover the mapping, so references\n * still naming the legacy id would never be rewritten. Optional so a journal\n * written by an older build still parses.\n */\n blocked: z.record(z.string(), z.string().min(1)).optional(),\n});\n\ntype EntityCanonicalIdMigrationState = z.infer<typeof EntityCanonicalIdMigrationStateSchema>;\n\nexport interface EntityCanonicalIdMigrationDependencies {\n stateDir: string;\n entitiesDir: string;\n normalizeEntityName(raw: string, type: string): string;\n resolveEntityFilePath(id: string): string | null;\n readStorageSecureFile(filePath: string): Promise<string>;\n writeStorageSecureFile(filePath: string, content: string, forceEncrypt?: boolean): Promise<void>;\n isEncryptedStorageFile(filePath: string): Promise<boolean>;\n snapshotBeforeWrite(filePath: string, trigger: \"write\"): Promise<void>;\n parseEntityFile(content: string): EntityFile;\n serializeEntityFile(entity: EntityFile): string;\n serializeMemoryWithEntityRef(memory: MemoryFile, entityRef: string): string;\n readMemoryByPath(filePath: string): Promise<MemoryFile | null>;\n readAllMemories(): Promise<MemoryFile[]>;\n readAllColdMemories(): Promise<MemoryFile[]>;\n readArchivedMemories(): Promise<MemoryFile[]>;\n validateMemoryScanRoots?(): Promise<void>;\n rewriteProjectedEntityReferences(mappings: Readonly<Record<string, string>>): Promise<void>;\n rewriteProjectedMemoryEntityReference(\n memoryId: string,\n previousEntityRef: string,\n nextEntityRef: string,\n ): Promise<void>;\n invalidateKnowledgeIndexCache(): void;\n invalidateAllMemoriesCache(): void;\n invalidateColdMemoriesCache(): void;\n bumpMemoryStatusVersion(): void;\n readMigrationFingerprint?(): Promise<string>;\n}\n\nasync function fingerprintPath(filePath: string): Promise<string> {\n let fileStat;\n try {\n fileStat = await lstat(filePath);\n } catch (error) {\n if (!isErrnoCode(error, \"ENOENT\")) throw error;\n }\n return fileStat\n ? `${fileStat.dev}:${fileStat.ino}:${fileStat.mtimeMs}:${fileStat.ctimeMs}:${fileStat.size}`\n : \"missing\";\n}\n\nasync function fingerprintEntityEntries(entitiesDir: string): Promise<string> {\n let names: string[];\n try {\n names = (await readdir(entitiesDir))\n .filter((name) => path.extname(name) === \".md\" && !isMacOsReplicationJunkBasename(name))\n .sort();\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return \"missing\";\n throw error;\n }\n const hash = createHash(\"sha256\");\n for (const name of names) {\n hash.update(`${name.length}:${name}:`);\n try {\n const entry = await lstat(path.join(entitiesDir, name), { bigint: true });\n hash.update(`${entry.dev}:${entry.ino}:${entry.size}:${entry.mtimeNs}:${entry.ctimeNs}`);\n } catch (error) {\n if (!isErrnoCode(error, \"ENOENT\")) throw error;\n hash.update(\"missing\");\n }\n hash.update(\"\\n\");\n }\n return hash.digest(\"hex\");\n}\n\n/**\n * Completion fingerprint for migration inputs only. Entity entry identities\n * catch same-path edits that do not change the directory inode; the cooperative\n * sentinel covers managed writes. Memory-corpus writes stay excluded so plain\n * fact writes do not reopen migration.\n */\nexport async function getFingerprint(\n baseDir: string,\n entitiesDir: string,\n getEntityMutationVersion: () => string,\n): Promise<string> {\n const [\n entityDirectoryFingerprint,\n entityEntriesFingerprint,\n aliasFingerprint,\n reconcileFingerprint,\n consumingFingerprint,\n ] = await Promise.all([\n fingerprintPath(entitiesDir),\n fingerprintEntityEntries(entitiesDir),\n fingerprintPath(path.join(baseDir, \"config\", \"aliases.json\")),\n fingerprintPath(path.join(baseDir, \"state\", ENTITY_CANONICAL_ID_RECONCILE_MARKER)),\n fingerprintPath(path.join(baseDir, \"state\", ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER)),\n ]);\n return [\n entityDirectoryFingerprint,\n entityEntriesFingerprint,\n aliasFingerprint,\n reconcileFingerprint,\n consumingFingerprint,\n getEntityMutationVersion(),\n ].join(\":\");\n}\n\nexport async function validateRoots(\n baseDir: string,\n entitiesDir: string,\n stateDir: string,\n archiveDir: string,\n): Promise<void> {\n let baseStat;\n try {\n baseStat = await lstat(baseDir);\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (baseStat.isSymbolicLink() || !baseStat.isDirectory()) {\n throw new Error(`Refusing entity canonical-id migration through unsafe memory root: ${baseDir}.`);\n }\n const memoryRoot = await realpath(baseDir);\n const roots = [\n entitiesDir,\n stateDir,\n ...RECALL_FALLBACK_DIRS.map((directory) => path.join(baseDir, directory)),\n path.join(baseDir, \"cold\"),\n archiveDir,\n ];\n for (const root of roots) {\n let rootStat;\n try {\n rootStat = await lstat(root);\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) continue;\n throw error;\n }\n if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {\n throw new Error(`Refusing entity canonical-id migration through unsafe memory root: ${root}.`);\n }\n assertPathInsideRoot(memoryRoot, await realpath(root), root);\n }\n}\n\nfunction statePath(deps: EntityCanonicalIdMigrationDependencies): string {\n return path.join(deps.stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE);\n}\n\nasync function assertSafeMigrationStateFile(\n deps: EntityCanonicalIdMigrationDependencies,\n): Promise<void> {\n const migrationStatePath = statePath(deps);\n let fileStat;\n try {\n fileStat = await lstat(migrationStatePath);\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (fileStat.isSymbolicLink() || !fileStat.isFile()) {\n throw new Error(\n `Refusing entity canonical-id migration through unsafe migration state file: ${migrationStatePath}.`,\n );\n }\n const [stateRoot, stateFile] = await Promise.all([\n realpath(deps.stateDir),\n realpath(migrationStatePath),\n ]);\n assertPathInsideRoot(stateRoot, stateFile, migrationStatePath);\n}\nasync function assertSafeTombstoneFile(\n deps: EntityCanonicalIdMigrationDependencies,\n tombstonePath: string,\n): Promise<boolean> {\n let fileStat;\n try {\n fileStat = await lstat(tombstonePath);\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return false;\n throw error;\n }\n if (fileStat.isSymbolicLink() || !fileStat.isFile()) {\n throw new Error(\n `Refusing entity canonical-id migration through unsafe tombstone ledger: ${tombstonePath}.`,\n );\n }\n const [stateRoot, tombstoneFile] = await Promise.all([\n realpath(deps.stateDir),\n realpath(tombstonePath),\n ]);\n assertPathInsideRoot(stateRoot, tombstoneFile, tombstonePath);\n return true;\n}\n\nfunction lockPath(deps: EntityCanonicalIdMigrationDependencies): string {\n return path.join(deps.stateDir, \"entity-canonical-id-migration.lock\");\n}\n\n\nasync function readState(\n deps: EntityCanonicalIdMigrationDependencies\n): Promise<EntityCanonicalIdMigrationState | null> {\n await assertSafeMigrationStateFile(deps);\n let raw: string;\n try {\n raw = await readFile(statePath(deps), \"utf-8\");\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return null;\n throw error;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw new Error(\"Invalid entity canonical-id migration state.\");\n }\n const result = EntityCanonicalIdMigrationStateSchema.safeParse(parsed);\n if (!result.success) throw new Error(\"Invalid entity canonical-id migration state.\");\n for (const mappings of [result.data.mappings, result.data.blocked ?? {}]) {\n for (const [legacyId, canonicalId] of Object.entries(mappings)) {\n assertSafeEntityId(legacyId);\n assertSafeEntityId(canonicalId);\n }\n }\n return result.data;\n}\n\nasync function writeState(\n deps: EntityCanonicalIdMigrationDependencies,\n state: EntityCanonicalIdMigrationState\n): Promise<void> {\n const destination = statePath(deps);\n const temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;\n try {\n await writeFile(temporary, `${JSON.stringify(state, null, 2)}\\n`, \"utf-8\");\n await rename(temporary, destination);\n } finally {\n await unlink(temporary).catch(() => undefined);\n }\n}\n\n/**\n * Every journal publish — additive merges, completion markers, prunes —\n * serializes under the entity MUTATION lock (issue #2213 review): entity\n * writers, post-persist repair settles, and tombstone appends revalidate\n * the journal identity under that lock, so an unlocked publish could land\n * inside their resolve→write window and strand the write on a superseded\n * id space.\n */\nasync function publishState(\n deps: EntityCanonicalIdMigrationDependencies,\n state: EntityCanonicalIdMigrationState\n): Promise<void> {\n await withEntityCanonicalMutationLock(deps.stateDir, async () => {\n await writeState(deps, state);\n });\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await access(filePath);\n return true;\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return false;\n throw error;\n }\n}\n\nasync function sameFileIdentity(leftPath: string, rightPath: string): Promise<boolean> {\n try {\n const [left, right] = await Promise.all([statFile(leftPath), statFile(rightPath)]);\n return left.dev === right.dev && left.ino === right.ino;\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return false;\n throw error;\n }\n}\n\nasync function assertNotSymlink(filePath: string, label: string): Promise<void> {\n let stat;\n try {\n stat = await lstat(filePath);\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (stat.isSymbolicLink()) {\n throw new Error(`Refusing entity canonical-id migration through symlink: ${label}.`);\n }\n}\nasync function assertNotMemorySymlink(filePath: string): Promise<void> {\n let stat;\n try {\n stat = await lstat(filePath);\n } catch (error) {\n if (isErrnoCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (stat.isSymbolicLink()) {\n throw new Error(`Refusing entity canonical-id migration through symlinked memory: ${filePath}.`);\n }\n}\nasync function assertEntityContentUnchanged(\n deps: EntityCanonicalIdMigrationDependencies,\n filePath: string,\n expectedContent: string,\n legacyId: string,\n): Promise<void> {\n const latestContent = await deps.readStorageSecureFile(filePath);\n if (latestContent !== expectedContent) {\n throw new Error(`Legacy entity id ${legacyId} changed while migration was running; retry migration.`);\n }\n}\n\n/**\n * Fail-closed entity-entry validation for the startup path: refuses a\n * symlinked or non-directory entities root and any symlinked entry, without\n * taking the migration lock. Exported so `ensureDirectories()` can run it\n * before deferring the migration (#3139) — the same check\n * `migrateLegacyEntityCanonicalIds` performs under the lock.\n */\nexport async function readSafeEntityEntries(entitiesDir: string): Promise<string[]> {\n const rootStat = await lstat(entitiesDir);\n if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {\n throw new Error(\"Refusing entity canonical-id migration through a symlinked or non-directory entities root.\");\n }\n const entries = await readdir(entitiesDir);\n for (const entry of entries) {\n await assertNotSymlink(path.join(entitiesDir, entry), entry);\n }\n return entries;\n}\n\n/**\n * Legacy ids the migration cannot resolve on its own, mapped to the canonical\n * id they collide with. Two entity files describing one entity is an ORDINARY\n * operator state, and picking a winner would silently drop whichever side lost.\n * So the pair is skipped and reported: reads of the legacy id keep working\n * exactly as they did before the migration ran.\n */\nexport type BlockedEntityPairs = Map<string, string>;\n\ninterface EntityScanNotes {\n junk: Set<string>;\n malformed: Set<string>;\n}\n\nasync function discoverMappings(\n deps: EntityCanonicalIdMigrationDependencies,\n knownMappings: Readonly<Record<string, string>> = {},\n blocked: BlockedEntityPairs = new Map(),\n scanNotes?: EntityScanNotes,\n): Promise<Record<string, string>> {\n const mappings: Record<string, string> = {};\n const canonicalOwners = new Map<string, string[]>();\n // Blocks describe THIS scan of the directory, so they are rebuilt per pass.\n // Accumulating them across a run would let a collision another writer has\n // since resolved keep pruning its now-valid mapping: the entity file gets\n // renamed while the pruned mapping skips the reference rewrite, stranding\n // memories on a filename that no longer exists.\n blocked.clear();\n const entityEntries = await readSafeEntityEntries(deps.entitiesDir);\n for (const entry of entityEntries) {\n // AppleDouble (`._*`) and `.DS_Store` are Finder metadata, not entity\n // files. A real file that cannot be parsed is left in place: this scan\n // runs during directory init, and aborting it took the daemon down.\n // Skipping is the same outcome as the old throw (the file is not\n // rewritten) without refusing to boot. Symlink checks above still run.\n if (isMacOsReplicationJunkBasename(entry)) {\n scanNotes?.junk.add(entry);\n continue;\n }\n if (!entry.endsWith(\".md\")) continue;\n const legacyId = entry.slice(0, -\".md\".length);\n assertSafeEntityId(legacyId);\n const legacyPath = deps.resolveEntityFilePath(legacyId);\n if (legacyPath === null) continue;\n const entityContent = await deps.readStorageSecureFile(legacyPath);\n if (isMalformedEntityRecord(entityContent)) {\n scanNotes?.malformed.add(entry);\n continue;\n }\n const entity = deps.parseEntityFile(entityContent);\n if (!entity.name.trim() || !entity.type.trim()) {\n scanNotes?.malformed.add(entry);\n continue;\n }\n const canonicalId = deps.normalizeEntityName(entity.name, entity.type);\n assertSafeEntityId(canonicalId);\n if (legacyId === canonicalId) continue;\n const canonicalPath = deps.resolveEntityFilePath(canonicalId);\n if (canonicalPath === null) continue;\n const canonicalExists = await fileExists(canonicalPath);\n if (\n canonicalExists\n && await sameFileIdentity(legacyPath, canonicalPath)\n && knownMappings[legacyId] === canonicalId\n ) continue;\n if (canonicalExists) {\n const canonicalContent = await deps.readStorageSecureFile(canonicalPath);\n if (entityContent !== canonicalContent) {\n blocked.set(legacyId, canonicalId);\n continue;\n }\n }\n canonicalOwners.set(canonicalId, [...(canonicalOwners.get(canonicalId) ?? []), legacyId]);\n mappings[legacyId] = canonicalId;\n }\n // A canonical id claimed by more than one legacy file has no non-arbitrary\n // winner, and readdir order is not stable (§6) - so the \"winner\" would differ\n // between hosts reading identical data. Block every claimant instead.\n for (const [canonicalId, claimants] of canonicalOwners) {\n if (claimants.length < 2) continue;\n for (const legacyId of claimants) {\n blocked.set(legacyId, canonicalId);\n delete mappings[legacyId];\n }\n }\n return mappings;\n}\n\nasync function rewriteReferences(\n deps: EntityCanonicalIdMigrationDependencies,\n mappings: Readonly<Record<string, string>>,\n refreshLock: () => Promise<boolean>\n): Promise<{ rewroteColdMemory: boolean }> {\n let rewroteColdMemory = false;\n for (let pass = 0; pass < MEMORY_REWRITE_MAX_PASSES; pass += 1) {\n deps.invalidateAllMemoriesCache();\n deps.invalidateColdMemoriesCache();\n const [hotMemories, coldMemories, archivedMemories] = await Promise.all([\n deps.readAllMemories(),\n deps.readAllColdMemories(),\n deps.readArchivedMemories(),\n ]);\n const seenPaths = new Set<string>();\n let rewroteAny = false;\n for (const memory of [...hotMemories, ...coldMemories, ...archivedMemories]) {\n const memoryPath = path.resolve(memory.path);\n if (seenPaths.has(memoryPath)) continue;\n seenPaths.add(memoryPath);\n const previousEntityRef = memory.frontmatter.entityRef;\n const canonicalId = previousEntityRef ? mappings[previousEntityRef] : undefined;\n if (!previousEntityRef || !canonicalId) continue;\n await assertNotMemorySymlink(memory.path);\n const observedMemoryFingerprint = await fingerprintPath(memory.path);\n if (observedMemoryFingerprint === \"missing\") continue;\n if (!(await refreshLock())) throw new Error(\"Lost entity canonical-id migration lock.\");\n const latestMemory = await deps.readMemoryByPath(memory.path);\n if (!latestMemory) continue;\n const latestMemoryFingerprint = await fingerprintPath(latestMemory.path);\n if (latestMemoryFingerprint !== observedMemoryFingerprint) continue;\n const latestPreviousEntityRef = latestMemory.frontmatter.entityRef;\n const latestCanonicalId = latestPreviousEntityRef ? mappings[latestPreviousEntityRef] : undefined;\n if (!latestPreviousEntityRef || !latestCanonicalId) continue;\n const memoryEncrypted = await deps.isEncryptedStorageFile(latestMemory.path);\n if ((await fingerprintPath(latestMemory.path)) !== latestMemoryFingerprint) continue;\n await deps.snapshotBeforeWrite(latestMemory.path, \"write\");\n if ((await fingerprintPath(latestMemory.path)) !== latestMemoryFingerprint) continue;\n await deps.writeStorageSecureFile(\n latestMemory.path,\n deps.serializeMemoryWithEntityRef(latestMemory, latestCanonicalId),\n memoryEncrypted,\n );\n await deps.rewriteProjectedMemoryEntityReference(\n latestMemory.frontmatter.id,\n latestPreviousEntityRef,\n latestCanonicalId,\n );\n rewroteAny = true;\n rewroteColdMemory ||= latestMemory.path.includes(`${path.sep}cold${path.sep}`);\n }\n if (!rewroteAny) return { rewroteColdMemory };\n }\n throw new Error(\"Memory references changed while entity canonical-id migration was running; retry migration.\");\n}\n\nfunction rewriteTombstoneLine(\n line: string,\n mappings: Readonly<Record<string, string>>,\n normalizedMappings: ReadonlyMap<string, string>,\n): string {\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n return line;\n }\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) return line;\n\n const tombstone = parsed as Record<string, unknown>;\n let changed = false;\n if (typeof tombstone.entityRef === \"string\") {\n const canonicalId = mappings[tombstone.entityRef];\n if (canonicalId) {\n tombstone.entityRef = canonicalId;\n changed = true;\n }\n }\n if (typeof tombstone.supersessionKey === \"string\") {\n const separator = tombstone.supersessionKey.indexOf(\"::\");\n if (separator < 0) return changed ? JSON.stringify(tombstone) : line;\n const normalizedLegacyId = normalizeSupersessionKey(tombstone.supersessionKey.slice(0, separator));\n const canonicalId = normalizedMappings.get(normalizedLegacyId);\n if (canonicalId) {\n const canonicalKey = computeSupersessionKey(canonicalId, tombstone.supersessionKey.slice(separator + 2));\n if (canonicalKey) {\n tombstone.supersessionKey = canonicalKey;\n changed = true;\n }\n }\n }\n return changed ? JSON.stringify(tombstone) : line;\n}\n\nasync function rewriteTombstoneReferences(\n deps: EntityCanonicalIdMigrationDependencies,\n mappings: Readonly<Record<string, string>>,\n refreshLock: () => Promise<boolean>\n): Promise<void> {\n const tombstonePath = path.join(deps.stateDir, \"tombstones.jsonl\");\n const normalizedMappings = new Map<string, string>();\n for (const [legacyId, canonicalId] of Object.entries(mappings)) {\n const normalizedLegacyId = normalizeSupersessionKey(legacyId);\n if (normalizedLegacyId && !normalizedMappings.has(normalizedLegacyId)) {\n normalizedMappings.set(normalizedLegacyId, canonicalId);\n }\n }\n\n await withHeldFileLock(\n path.join(deps.stateDir, \"tombstones.lock\"),\n {\n staleMs: TOMBSTONE_LOCK_STALE_MS,\n maxWaitMs: TOMBSTONE_LOCK_MAX_WAIT_MS,\n },\n async (acquired, tombstoneLock) => {\n if (!acquired) throw new Error(\"Timed out waiting for active tombstone migration.\");\n if (!(await assertSafeTombstoneFile(deps, tombstonePath))) return;\n const tombstoneEncrypted = await deps.isEncryptedStorageFile(tombstonePath);\n const original = await deps.readStorageSecureFile(tombstonePath);\n let changed = false;\n const rewritten = original\n .split(\"\\n\")\n .map((line) => {\n const next = rewriteTombstoneLine(line, mappings, normalizedMappings);\n changed ||= next !== line;\n return next;\n })\n .join(\"\\n\");\n if (!changed) return;\n if (!(await refreshLock())) throw new Error(\"Lost entity canonical-id migration lock.\");\n if (!(await tombstoneLock.refresh())) throw new Error(\"Lost tombstone migration lock.\");\n await deps.snapshotBeforeWrite(tombstonePath, \"write\");\n await deps.writeStorageSecureFile(tombstonePath, rewritten, tombstoneEncrypted);\n },\n );\n}\n\nasync function rewriteRelationshipTargets(\n deps: EntityCanonicalIdMigrationDependencies,\n mappings: Readonly<Record<string, string>>,\n refreshLock: () => Promise<boolean>\n): Promise<boolean> {\n let rewritten = false;\n const entries = await readSafeEntityEntries(deps.entitiesDir);\n for (const entry of entries) {\n if (!entry.endsWith(\".md\") || isMacOsReplicationJunkBasename(entry)) continue;\n const entityPath = deps.resolveEntityFilePath(entry.slice(0, -\".md\".length));\n if (entityPath === null) continue;\n const observedEntityFingerprint = await fingerprintPath(entityPath);\n if (observedEntityFingerprint === \"missing\") continue;\n const entityRaw = await deps.readStorageSecureFile(entityPath);\n if (isMalformedEntityRecord(entityRaw)) continue;\n const entity = deps.parseEntityFile(entityRaw);\n const relationships = entity.relationships.map((relationship) => {\n const target = mappings[relationship.target];\n return target ? { ...relationship, target } : relationship;\n });\n if (relationships.every((relationship, index) => relationship === entity.relationships[index])) continue;\n const rewroteEntity = await withEntityCanonicalMutationLock(\n deps.stateDir,\n async (refreshEntityLock) => {\n if (!(await refreshLock())) throw new Error(\"Lost entity canonical-id migration lock.\");\n const latestRaw = await deps.readStorageSecureFile(entityPath);\n if (isMalformedEntityRecord(latestRaw)) return false;\n const latestEntity = deps.parseEntityFile(latestRaw);\n if ((await fingerprintPath(entityPath)) !== observedEntityFingerprint) return false;\n const latestRelationships = latestEntity.relationships.map((relationship) => {\n const target = mappings[relationship.target];\n return target ? { ...relationship, target } : relationship;\n });\n if (latestRelationships.every((relationship, index) => relationship === latestEntity.relationships[index])) {\n return false;\n }\n const entityEncrypted = await deps.isEncryptedStorageFile(entityPath);\n if (!(await refreshEntityLock())) throw new Error(\"Lost entity mutation lock.\");\n if ((await fingerprintPath(entityPath)) !== observedEntityFingerprint) return false;\n await deps.snapshotBeforeWrite(entityPath, \"write\");\n if ((await fingerprintPath(entityPath)) !== observedEntityFingerprint) return false;\n await deps.writeStorageSecureFile(\n entityPath,\n deps.serializeEntityFile({ ...latestEntity, relationships: latestRelationships }),\n entityEncrypted,\n );\n return true;\n },\n );\n rewritten ||= rewroteEntity;\n }\n return rewritten;\n}\n\nasync function rewriteKnownReferences(\n deps: EntityCanonicalIdMigrationDependencies,\n mappings: Readonly<Record<string, string>>,\n refreshLock: () => Promise<boolean>,\n): Promise<boolean> {\n await rewriteRelationshipTargets(deps, mappings, refreshLock);\n let rewroteColdMemory = (await rewriteReferences(deps, mappings, refreshLock)).rewroteColdMemory;\n await rewriteTombstoneReferences(deps, mappings, refreshLock);\n await deps.rewriteProjectedEntityReferences(mappings);\n const finalMemoryPass = await rewriteReferences(deps, mappings, refreshLock);\n rewroteColdMemory ||= finalMemoryPass.rewroteColdMemory;\n return rewroteColdMemory;\n}\n\nfunction wouldCreateMappingCycle(\n mappings: Readonly<Record<string, string>>,\n legacyId: string,\n canonicalId: string,\n): boolean {\n let current = canonicalId;\n const seen = new Set<string>();\n while (true) {\n if (current === legacyId) return true;\n if (seen.has(current)) return false;\n seen.add(current);\n const next = mappings[current];\n if (!next || next === current) return false;\n current = next;\n }\n}\n\nfunction rejectMappingCycles(\n existing: Readonly<Record<string, string>>,\n discovered: Readonly<Record<string, string>>,\n): Record<string, string> {\n const accepted: Record<string, string> = {};\n const merged = { ...existing };\n for (const [legacyId, canonicalId] of Object.entries(discovered)) {\n if (\n merged[legacyId] === undefined &&\n wouldCreateMappingCycle(merged, legacyId, canonicalId)\n ) continue;\n accepted[legacyId] = canonicalId;\n merged[legacyId] = canonicalId;\n }\n return accepted;\n}\n\nfunction mergeDiscoveredMappings(\n existing: Readonly<Record<string, string>>,\n discovered: Readonly<Record<string, string>>,\n): Record<string, string> {\n const merged = { ...existing };\n const canonicalOwners = new Map<string, string>();\n for (const [legacyId, canonicalId] of Object.entries(discovered)) {\n const previousMapping = merged[legacyId];\n if (previousMapping !== undefined && previousMapping !== canonicalId) {\n continue;\n }\n if (previousMapping === undefined && wouldCreateMappingCycle(merged, legacyId, canonicalId)) continue;\n const previousOwner = canonicalOwners.get(canonicalId);\n if (previousOwner !== undefined && previousOwner !== legacyId) {\n throw new Error(\n `Cannot migrate legacy entity ids ${previousOwner} and ${legacyId}: both normalize to ${canonicalId}.`,\n );\n }\n merged[legacyId] = canonicalId;\n canonicalOwners.set(canonicalId, legacyId);\n }\n return merged;\n}\nfunction collapseMappings(mappings: Readonly<Record<string, string>>): Record<string, string> {\n const collapsed: Record<string, string> = {};\n for (const legacyId of Object.keys(mappings)) {\n let current = legacyId;\n const seen = new Set<string>();\n while (true) {\n const next = mappings[current];\n if (!next || next === current) break;\n if (seen.has(current)) {\n throw new Error(`Entity canonical-id migration mapping cycle includes ${legacyId}.`);\n }\n seen.add(current);\n current = next;\n }\n if (current !== legacyId) collapsed[legacyId] = current;\n }\n return collapsed;\n}\n\ntype EntityFileMigrationResult = {\n deferred: boolean;\n progressed: boolean;\n /** The pair collided on content; skipped and reported, never migrated. */\n blocked?: boolean;\n};\n\nasync function migrateEntityFilePair(\n deps: EntityCanonicalIdMigrationDependencies,\n legacyId: string,\n canonicalId: string,\n refreshMigrationLock: () => Promise<boolean>,\n): Promise<EntityFileMigrationResult> {\n return withEntityCanonicalMutationLock(deps.stateDir, async (refreshEntityLock) => {\n assertSafeEntityId(legacyId);\n assertSafeEntityId(canonicalId);\n const legacyPath = deps.resolveEntityFilePath(legacyId);\n const canonicalPath = deps.resolveEntityFilePath(canonicalId);\n if (legacyPath === null || canonicalPath === null) {\n throw new Error(\"Invalid entity canonical-id migration path.\");\n }\n await assertNotSymlink(legacyPath, legacyId);\n await assertNotSymlink(canonicalPath, canonicalId);\n const legacyExists = await fileExists(legacyPath);\n const canonicalExists = await fileExists(canonicalPath);\n if (!legacyExists && !canonicalExists) return { deferred: true, progressed: false };\n if (legacyExists && canonicalExists) {\n if (await sameFileIdentity(legacyPath, canonicalPath)) return { deferred: false, progressed: false };\n const [legacyContent, canonicalContent, legacyEncrypted, canonicalEncrypted] = await Promise.all([\n deps.readStorageSecureFile(legacyPath),\n deps.readStorageSecureFile(canonicalPath),\n deps.isEncryptedStorageFile(legacyPath),\n deps.isEncryptedStorageFile(canonicalPath),\n ]);\n if (legacyContent !== canonicalContent) {\n // A mapping persisted by an older build, or a file changed since\n // discovery. Same verdict as discovery: skip the pair, keep both files.\n return { deferred: false, progressed: false, blocked: true };\n }\n if (legacyEncrypted && !canonicalEncrypted) {\n if (!(await refreshMigrationLock()) || !(await refreshEntityLock())) {\n throw new Error(\"Lost entity canonical-id migration lock.\");\n }\n await deps.snapshotBeforeWrite(canonicalPath, \"write\");\n await deps.writeStorageSecureFile(canonicalPath, legacyContent, true);\n if ((await deps.readStorageSecureFile(canonicalPath)) !== legacyContent) {\n throw new Error(`Cannot verify migrated entity id ${canonicalId}.`);\n }\n }\n if (!(await refreshMigrationLock()) || !(await refreshEntityLock())) {\n throw new Error(\"Lost entity canonical-id migration lock.\");\n }\n await deps.snapshotBeforeWrite(legacyPath, \"write\");\n await assertNotSymlink(legacyPath, legacyId);\n await assertEntityContentUnchanged(deps, legacyPath, legacyContent, legacyId);\n await unlink(legacyPath);\n return { deferred: false, progressed: true };\n }\n if (!legacyExists) return { deferred: false, progressed: false };\n if (!(await refreshMigrationLock()) || !(await refreshEntityLock())) {\n throw new Error(\"Lost entity canonical-id migration lock.\");\n }\n const entityEncrypted = await deps.isEncryptedStorageFile(legacyPath);\n const entityContent = await deps.readStorageSecureFile(legacyPath);\n await assertNotSymlink(legacyPath, legacyId);\n await assertEntityContentUnchanged(deps, legacyPath, entityContent, legacyId);\n // A journal entry must not relocate Finder metadata or a record this scan\n // would leave in place. readStorageSecureFile has already decrypted, so\n // the check is on that plaintext. The mapping stays for a later repair.\n if (\n isMacOsReplicationJunkBasename(path.basename(legacyPath))\n || isMalformedEntityRecord(entityContent)\n ) {\n return { deferred: false, progressed: false };\n }\n let canonicalFingerprintAfterWrite: string | null = null;\n try {\n await deps.writeStorageSecureFile(canonicalPath, entityContent, entityEncrypted);\n canonicalFingerprintAfterWrite = await fingerprintPath(canonicalPath);\n if ((await deps.readStorageSecureFile(canonicalPath)) !== entityContent) {\n throw new Error(`Cannot verify migrated entity id ${canonicalId}.`);\n }\n if (!(await refreshMigrationLock()) || !(await refreshEntityLock())) {\n throw new Error(\"Lost entity canonical-id migration lock.\");\n }\n await deps.snapshotBeforeWrite(legacyPath, \"write\");\n await assertNotSymlink(legacyPath, legacyId);\n await assertEntityContentUnchanged(deps, legacyPath, entityContent, legacyId);\n await unlink(legacyPath);\n } catch (error) {\n if (!canonicalExists && canonicalFingerprintAfterWrite !== null) {\n try {\n if ((await fingerprintPath(canonicalPath)) === canonicalFingerprintAfterWrite) {\n await assertNotSymlink(canonicalPath, canonicalId);\n await unlink(canonicalPath);\n }\n } catch {\n // Preserve the migration error when cleanup races another writer.\n }\n }\n throw error;\n }\n return { deferred: false, progressed: true };\n });\n}\n\nexport async function migrateLegacyEntityCanonicalIds(\n deps: EntityCanonicalIdMigrationDependencies,\n): Promise<string | undefined> {\n return withHeldFileLock(\n lockPath(deps),\n {\n staleMs: ENTITY_CANONICAL_ID_MIGRATION_LOCK_STALE_MS,\n maxWaitMs: ENTITY_CANONICAL_ID_MIGRATION_LOCK_MAX_WAIT_MS,\n },\n async (acquired, lock) => {\n if (!acquired) throw new Error(\"Timed out waiting for active entity canonical-id migration.\");\n await deps.validateMemoryScanRoots?.();\n await readSafeEntityEntries(deps.entitiesDir);\n // A raw-byte writer (offline sync, consolidation-undo, governance\n // restore) may have landed memory bytes this process never vetted; the\n // marker requests ONE reference-reconciliation pass (issue #2213). The\n // observed generation is RENAMED aside before the pass so a request made\n // WHILE this run scans creates a fresh marker that survives finish() —\n // and a `.consuming` file left by a crashed run still owes its pass.\n const reconcileMarkerPath = path.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_MARKER);\n const consumingMarkerPath = path.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER);\n let reconcileRequested = await fileExists(consumingMarkerPath);\n if (await fileExists(reconcileMarkerPath)) {\n try {\n await rename(reconcileMarkerPath, consumingMarkerPath);\n reconcileRequested = true;\n } catch (error) {\n if (!isErrnoCode(error, \"ENOENT\")) throw error;\n }\n }\n let state: EntityCanonicalIdMigrationState = await readState(deps) ?? {\n version: ENTITY_CANONICAL_ID_MIGRATION_VERSION,\n complete: false,\n mappings: {},\n };\n const blocked: BlockedEntityPairs = new Map();\n const scanNotes: EntityScanNotes = { junk: new Set(), malformed: new Set() };\n // Parks for pairs whose files are GONE, tracked separately from\n // collision parks: pruneBlocked drops these (the canonical file is gone\n // too), and the rescan's blocked.clear() would otherwise silence them\n // before finish() reports anything.\n const staleParked: BlockedEntityPairs = new Map();\n // ONE aggregated line per run, not one per pair per restart: this used to\n // abort the daemon, so the operator needs the whole list and the remedy.\n const finish = async (): Promise<string | undefined> => {\n if (blocked.size > 0) {\n const pairs = [...blocked].map(([legacyId, canonicalId]) => `${legacyId} -> ${canonicalId}`).join(\", \");\n log.warn(\n `entity canonical-id migration skipped ${blocked.size} unresolvable pair(s): ${pairs}. `\n + \"Both files were kept and the legacy id still resolves; merge or delete one side to migrate it.\",\n );\n }\n if (staleParked.size > 0) {\n const pairs = [...staleParked].map(([legacyId, canonicalId]) => `${legacyId} -> ${canonicalId}`).join(\", \");\n log.warn(\n `entity canonical-id migration dropped ${staleParked.size} mapping(s) whose entity files are gone: ${pairs}. `\n + \"The stale journal entries were removed; references to those legacy ids do not resolve either way.\",\n );\n }\n warnIgnoredMacOsReplicationJunk(deps.entitiesDir, scanNotes.junk.size, (message) => {\n log.warn(`entity canonical-id migration ${message}`);\n });\n if (scanNotes.malformed.size > 0) {\n const names = [...scanNotes.malformed].sort().join(\", \");\n log.warn(\n `entity canonical-id migration skipped ${scanNotes.malformed.size} malformed entity file(s): ${names}. `\n + \"Each file was left in place; startup continues. Fix or remove the file to migrate it.\",\n );\n }\n // Every finish() path either just rewrote references (main/reconcile\n // paths), has none to rewrite (empty mappings), or observed no marker\n // (stable no-op) — so the CONSUMED generation is removed here. A fresh\n // marker written mid-run is untouched, and a crash before this point\n // leaves `.consuming` set for the next run (the rewrite is idempotent).\n if (reconcileRequested) {\n await unlink(consumingMarkerPath).catch((error: unknown) => {\n if (!isErrnoCode(error, \"ENOENT\")) throw error;\n });\n }\n // A FRESH marker written while this run scanned means bytes landed the\n // pass may not have covered. Withholding the completion fingerprint\n // makes the runner's stability check fail, so it immediately retries —\n // and the retry consumes the fresh generation. ORDER MATTERS: read the\n // fingerprint BEFORE the marker check. A marker landing after the\n // fingerprint read but before the check is caught by the check; one\n // landing after the check is absent from the returned fingerprint, so\n // the live marker mismatches the runner's cached completion and the\n // next ensure() re-invokes. Checking first left a window where the\n // fingerprint could SEAL a marker the check never saw.\n const completionFingerprint = await deps.readMigrationFingerprint?.();\n if (await fileExists(reconcileMarkerPath)) return undefined;\n if (completionFingerprint !== undefined && state.completionFingerprint !== completionFingerprint) {\n state = { ...state, complete: true, completionFingerprint };\n await publishState(deps, state);\n }\n return completionFingerprint;\n };\n /**\n * Drop blocked pairs from the working set. Discovery only refuses to\n * ADD them; a mapping persisted by an earlier run would otherwise still\n * be applied - migrating one claimant and rewriting every reference onto\n * the canonical file, i.e. picking the winner this fix exists to avoid,\n * off stale state rather than what is on disk.\n */\n /** @returns true when a park was promoted back into the mapping set. */\n const pruneBlocked = async (): Promise<boolean> => {\n const current = state;\n if (!current) return false;\n // THIS scan's verdict wins over the journal: normalization can change\n // between runs, so a stale parked target would otherwise be promoted\n // later and rewrite references onto an id that does not exist.\n let revived = false;\n const parked: Record<string, string> = { ...(current.blocked ?? {}) };\n const active: Record<string, string> = {};\n for (const [legacyId, canonicalId] of Object.entries(current.mappings)) {\n if (!blocked.has(legacyId)) active[legacyId] = canonicalId;\n }\n for (const [legacyId, canonicalId] of blocked) parked[legacyId] = canonicalId;\n // A parked pair whose legacy file is gone was resolved by keeping the\n // canonical side. The rename is moot; the reference rewrite is not, and\n // this record is the only thing that can still perform it.\n // A park survives ONLY while this scan re-establishes the collision.\n // Anything else - the scan found a real migration, or found the source\n // needs none (already canonical under a newer normalization) - makes\n // the record obsolete, and keeping it lets a later deletion promote a\n // target the entity never occupied.\n for (const [legacyId, canonicalId] of Object.entries(parked)) {\n if (blocked.has(legacyId)) continue;\n delete parked[legacyId];\n if (active[legacyId] !== undefined) continue;\n const legacyPath = deps.resolveEntityFilePath(legacyId);\n if (legacyPath !== null && (await fileExists(legacyPath))) continue;\n // Resolve the parked target through ACTIVE moves before deciding\n // its file is gone: a parked A -> B beside an active B -> C must\n // promote to A -> C and rewrite, not drop because B was moved\n // out-of-band. Only a target with no surviving file may drop.\n let target = canonicalId;\n const seenTargets = new Set<string>();\n while (active[target] !== undefined && !seenTargets.has(target)) {\n seenTargets.add(target);\n target = active[target]!;\n }\n const targetPath = deps.resolveEntityFilePath(target);\n if (targetPath === null || !(await fileExists(targetPath))) {\n staleParked.set(legacyId, canonicalId);\n continue;\n }\n active[legacyId] = target;\n revived = true;\n }\n // Reviving a whole chain at once yields A -> B -> C, and each rewrite\n // surface makes a different number of passes over it - so collapse\n // transitively before anything consumes the set.\n const collapsed = collapseMappings(active);\n // Parked targets follow ACTIVE moves only: hopping over a still-blocked\n // link would jump to an id the migration has not been allowed to reach.\n for (const [legacyId, canonicalId] of Object.entries(parked)) {\n const moved = collapsed[canonicalId];\n if (moved !== undefined && moved !== legacyId) parked[legacyId] = moved;\n }\n const same = (a: Record<string, string>, b: Record<string, string>): boolean =>\n Object.keys(a).length === Object.keys(b).length\n && Object.entries(a).every(([key, value]) => b[key] === value);\n if (same(collapsed, current.mappings) && same(parked, current.blocked ?? {})) return revived;\n // Parking/removing an active mapping mid-entity-write would land an\n // alias/activity/relationship mutation on a now-unrelated canonical\n // claimant — the reconcile pass rewrites references, it cannot move\n // a misplaced mutation. publishState serializes under the lock.\n state = { ...current, mappings: collapsed, blocked: parked };\n await publishState(deps, state);\n return revived;\n };\n const previousMappings = state.mappings;\n const collapsedMappings = collapseMappings(previousMappings);\n const mappingsChanged =\n Object.keys(collapsedMappings).length !== Object.keys(previousMappings).length\n || Object.entries(collapsedMappings).some(([legacyId, canonicalId]) =>\n previousMappings[legacyId] !== canonicalId\n );\n state = { ...state, mappings: collapsedMappings };\n for (let migrationPass = 0; migrationPass < ENTITY_MAPPING_RESCAN_MAX_PASSES; migrationPass += 1) {\n if (!(await lock.refresh())) throw new Error(\"Lost entity canonical-id migration lock.\");\n const discoveredBefore = rejectMappingCycles(\n state.mappings,\n await discoverMappings(deps, state.mappings, blocked, scanNotes),\n );\n const revivedBefore = await pruneBlocked();\n const mergedBefore = collapseMappings(mergeDiscoveredMappings(state.mappings, discoveredBefore));\n // Stable completed journal → no-op (issue #2213). Retained mappings are\n // read-compat state whose references were already rewritten (to\n // convergence) before `complete: true` was persisted, so re-running\n // `rewriteKnownReferences` here re-read the ENTIRE hot+cold+archived\n // corpus — twice — and invalidated every memory cache on EVERY\n // `ensureDirectories()`. On a write-active daemon that was a\n // self-sustaining hot loop (multi-GB/s of re-reads, caches never warm,\n // recall degraded to the fallback path). A park revived by THIS run's\n // pruneBlocked still owes its reference rewrite: it falls through to\n // the main flow below, which demotes `complete` BEFORE rewriting — so\n // a crash mid-rewrite resumes, which the old in-place rewrite did not.\n if (\n state.complete\n && Object.keys(discoveredBefore).length === 0\n && !mappingsChanged\n && !revivedBefore\n ) {\n // Stable journal, but a raw-byte writer requested reconciliation:\n // run ONE bounded rewrite pass over the retained mappings, then let\n // finish() consume the marker.\n if (reconcileRequested && Object.keys(state.mappings).length > 0) {\n const rewroteColdMemory = await rewriteKnownReferences(\n deps,\n state.mappings,\n () => lock.refresh(),\n );\n deps.invalidateKnowledgeIndexCache();\n deps.invalidateAllMemoriesCache();\n if (rewroteColdMemory) deps.invalidateColdMemoriesCache();\n deps.bumpMemoryStatusVersion();\n }\n return finish();\n }\n if (\n state.complete\n || Object.keys(discoveredBefore).length > 0\n || Object.keys(mergedBefore).length !== Object.keys(state.mappings).length\n ) {\n state = { ...state, complete: false, mappings: mergedBefore };\n await publishState(deps, state);\n }\n if (Object.keys(state.mappings).length === 0) {\n if (!(await lock.refresh())) throw new Error(\"Lost entity canonical-id migration lock.\");\n const discoveredAfter = rejectMappingCycles(\n state.mappings,\n await discoverMappings(deps, state.mappings, blocked, scanNotes),\n );\n // Reconcile before declaring completion: this rescan can resolve a\n // park (another writer removed the legacy file), and completing\n // without promoting it strands its references behind a fingerprint\n // that already reflects the deletion - so no later run revisits it.\n const revivedInRescan = await pruneBlocked();\n if (Object.keys(discoveredAfter).length === 0 && !revivedInRescan) {\n await publishState(deps, { ...state, complete: true });\n return finish();\n }\n state = {\n ...state,\n complete: false,\n mappings: collapseMappings(mergeDiscoveredMappings(state.mappings, discoveredAfter)),\n };\n await publishState(deps, state);\n continue;\n }\n let pendingMappings = Object.entries(state.mappings);\n while (pendingMappings.length > 0) {\n const deferredMappings: Array<[string, string]> = [];\n let progressed = false;\n for (const [legacyId, canonicalId] of pendingMappings) {\n const result = await migrateEntityFilePair(\n deps,\n legacyId,\n canonicalId,\n () => lock.refresh(),\n );\n if (result.blocked) blocked.set(legacyId, canonicalId);\n else if (result.deferred) deferredMappings.push([legacyId, canonicalId]);\n progressed ||= result.progressed;\n }\n if (deferredMappings.length === 0) break;\n if (!progressed) {\n // Deferred means both files are missing: no later pass can help\n // these pairs, so park them all instead of Fatal-exiting.\n for (const [legacyId, canonicalId] of deferredMappings) {\n blocked.set(legacyId, canonicalId);\n staleParked.set(legacyId, canonicalId);\n }\n break;\n }\n pendingMappings = deferredMappings;\n }\n await pruneBlocked();\n\n const rewroteColdMemory = await rewriteKnownReferences(\n deps,\n state.mappings,\n () => lock.refresh(),\n );\n deps.invalidateKnowledgeIndexCache();\n deps.invalidateAllMemoriesCache();\n if (rewroteColdMemory) deps.invalidateColdMemoriesCache();\n deps.bumpMemoryStatusVersion();\n\n if (!(await lock.refresh())) throw new Error(\"Lost entity canonical-id migration lock.\");\n const discoveredAfter = rejectMappingCycles(\n state.mappings,\n await discoverMappings(deps, state.mappings, blocked, scanNotes),\n );\n // A park resolved after the rewrite pass is promoted here, and a\n // promotion still has to be APPLIED. Completing on `discoveredAfter`\n // alone fingerprints the post-deletion corpus, so the runner never\n // retries and those references stay stranded.\n const revivedAfterRewrite = await pruneBlocked();\n if (Object.keys(discoveredAfter).length === 0 && !revivedAfterRewrite) {\n await publishState(deps, { ...state, complete: true });\n return finish();\n }\n state = {\n ...state,\n complete: false,\n mappings: collapseMappings(mergeDiscoveredMappings(state.mappings, discoveredAfter)),\n };\n await publishState(deps, state);\n }\n throw new Error(\"Entity canonical-id migration mappings changed while migration was running; retry migration.\");\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,kBAAkB;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,OACK;AACP,OAAO,UAAU;AAEjB,SAAS,SAAS;AAuBlB,IAAM,wCAAwC;AAC9C,IAAM,8CAA8C;AACpD,IAAM,iDAAiD;AACvD,IAAM,0BAA0B;AAChC,IAAM,6BAA6B;AACnC,IAAM,4BAA4B;AAClC,IAAM,mCAAmC;AAEzC,IAAM,wCAAwC,EAAE,OAA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tB,MAAM;AAAA,UACN,MAAM,iBAAiB,MAAM,MAAM,UAAU,SAAS,SAAS;AAAA,QACjE;AAKA,cAAM,sBAAsB,MAAM,aAAa;AAC/C,YAAI,OAAO,KAAK,eAAe,EAAE,WAAW,KAAK,CAAC,qBAAqB;AACrE,gBAAM,aAAa,MAAM,EAAE,GAAG,OAAO,UAAU,KAAK,CAAC;AACrD,iBAAO,OAAO;AAAA,QAChB;AACA,gBAAQ;AAAA,UACN,GAAG;AAAA,UACH,UAAU;AAAA,UACV,UAAU,iBAAiB,wBAAwB,MAAM,UAAU,eAAe,CAAC;AAAA,QACrF;AACA,cAAM,aAAa,MAAM,KAAK;AAAA,MAChC;AACA,YAAM,IAAI,MAAM,8FAA8F;AAAA,IAChH;AAAA,EACF;AACF;","names":["rewroteColdMemory","discoveredAfter"]}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-MPC7TYTZ.js";
|
|
9
9
|
import {
|
|
10
10
|
importCapsule
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-A3UFV4K3.js";
|
|
12
12
|
import {
|
|
13
13
|
isSharedContextWriteInputError
|
|
14
14
|
} from "./chunk-IFBSZGW3.js";
|
|
@@ -41,7 +41,13 @@ import {
|
|
|
41
41
|
computeWhoKnows,
|
|
42
42
|
loadWhoKnowsEntities,
|
|
43
43
|
validateWhoKnowsInput
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-2ONKXEC7.js";
|
|
45
|
+
import {
|
|
46
|
+
trustResultFor
|
|
47
|
+
} from "./chunk-GNVZQ5JN.js";
|
|
48
|
+
import {
|
|
49
|
+
renderEpistemicHedge
|
|
50
|
+
} from "./chunk-YN2UN7N3.js";
|
|
45
51
|
import {
|
|
46
52
|
getTrustZoneStoreStatus,
|
|
47
53
|
isTrustZoneName,
|
|
@@ -51,15 +57,9 @@ import {
|
|
|
51
57
|
seedTrustZoneDemoDataset,
|
|
52
58
|
summarizeTrustZonePromotionReadiness
|
|
53
59
|
} from "./chunk-JWX2Q6HS.js";
|
|
54
|
-
import {
|
|
55
|
-
trustResultFor
|
|
56
|
-
} from "./chunk-GNVZQ5JN.js";
|
|
57
|
-
import {
|
|
58
|
-
renderEpistemicHedge
|
|
59
|
-
} from "./chunk-YN2UN7N3.js";
|
|
60
60
|
import {
|
|
61
61
|
summarizeHourlyStatus
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-2AKIVSHP.js";
|
|
63
63
|
import {
|
|
64
64
|
planSessionTranscriptMigration
|
|
65
65
|
} from "./chunk-WWDO7ZWM.js";
|
|
@@ -69,6 +69,10 @@ import {
|
|
|
69
69
|
import {
|
|
70
70
|
runRecallWhy
|
|
71
71
|
} from "./chunk-3NL4ALUP.js";
|
|
72
|
+
import {
|
|
73
|
+
DEFAULT_TRAVERSE_LIMIT,
|
|
74
|
+
selectTraverseNeighbors
|
|
75
|
+
} from "./chunk-YE4JBZO5.js";
|
|
72
76
|
import {
|
|
73
77
|
assertIdInNavigationWindow
|
|
74
78
|
} from "./chunk-5KVT6G5U.js";
|
|
@@ -78,13 +82,12 @@ import {
|
|
|
78
82
|
import {
|
|
79
83
|
planDisclosureStep
|
|
80
84
|
} from "./chunk-FLDXEJFX.js";
|
|
81
|
-
import {
|
|
82
|
-
DEFAULT_TRAVERSE_LIMIT,
|
|
83
|
-
selectTraverseNeighbors
|
|
84
|
-
} from "./chunk-YE4JBZO5.js";
|
|
85
85
|
import {
|
|
86
86
|
parseNavigateLinkType
|
|
87
87
|
} from "./chunk-7O5EW7KX.js";
|
|
88
|
+
import {
|
|
89
|
+
decideDisclosureEscalation
|
|
90
|
+
} from "./chunk-H7XKCNR6.js";
|
|
88
91
|
import {
|
|
89
92
|
toRecallExplainJson
|
|
90
93
|
} from "./chunk-WUL6LDJ4.js";
|
|
@@ -95,18 +98,15 @@ import {
|
|
|
95
98
|
import {
|
|
96
99
|
takeNavigateBudget
|
|
97
100
|
} from "./chunk-VYDGHJIN.js";
|
|
98
|
-
import {
|
|
99
|
-
decideDisclosureEscalation
|
|
100
|
-
} from "./chunk-H7XKCNR6.js";
|
|
101
101
|
import {
|
|
102
102
|
readAggregateExtractionWatermark
|
|
103
|
-
} from "./chunk-
|
|
103
|
+
} from "./chunk-FT75AQ74.js";
|
|
104
104
|
import {
|
|
105
105
|
ReplicaDivergenceMonitor
|
|
106
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-B6SPPYGJ.js";
|
|
107
107
|
import {
|
|
108
108
|
buildEmbeddingAwareSnapshotStream
|
|
109
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-CCL2OXFO.js";
|
|
110
110
|
import {
|
|
111
111
|
recordObjectiveStateSnapshotsFromObservedMessages
|
|
112
112
|
} from "./chunk-Z64TS5V4.js";
|
|
@@ -130,16 +130,16 @@ import {
|
|
|
130
130
|
} from "./chunk-ERMT5WQM.js";
|
|
131
131
|
import {
|
|
132
132
|
readProjectedHarmonicGraph
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-WY66J4PI.js";
|
|
134
134
|
import {
|
|
135
135
|
wrapWorkLayerContext
|
|
136
136
|
} from "./chunk-EI6V5UXY.js";
|
|
137
137
|
import {
|
|
138
138
|
CONNECTOR_LABEL_MAX_LENGTH
|
|
139
|
-
} from "./chunk-
|
|
139
|
+
} from "./chunk-JX3E4XCW.js";
|
|
140
140
|
import {
|
|
141
141
|
isValidConnectorId
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-QA3Y2O6H.js";
|
|
143
143
|
import {
|
|
144
144
|
formatProfileTraceAscii
|
|
145
145
|
} from "./chunk-DOWACHYO.js";
|
|
@@ -160,6 +160,9 @@ import {
|
|
|
160
160
|
composeRecallContext,
|
|
161
161
|
renderAuthorityBoundContent
|
|
162
162
|
} from "./chunk-NVKO5YKP.js";
|
|
163
|
+
import {
|
|
164
|
+
callDeepRecallPolicyLlm
|
|
165
|
+
} from "./chunk-E3NBMTTX.js";
|
|
163
166
|
import {
|
|
164
167
|
renderDeepRecallResult
|
|
165
168
|
} from "./chunk-RF2SMMPP.js";
|
|
@@ -173,9 +176,6 @@ import {
|
|
|
173
176
|
CrossNamespaceBudget,
|
|
174
177
|
toBudgetWarning
|
|
175
178
|
} from "./chunk-UFGFMWAD.js";
|
|
176
|
-
import {
|
|
177
|
-
callDeepRecallPolicyLlm
|
|
178
|
-
} from "./chunk-E3NBMTTX.js";
|
|
179
179
|
import {
|
|
180
180
|
buildProposedActions,
|
|
181
181
|
buildQualityScore,
|
|
@@ -183,17 +183,22 @@ import {
|
|
|
183
183
|
listMemoryGovernanceRuns,
|
|
184
184
|
readMemoryGovernanceRunArtifact,
|
|
185
185
|
runMemoryGovernance
|
|
186
|
-
} from "./chunk-
|
|
186
|
+
} from "./chunk-6ZAU7LAR.js";
|
|
187
187
|
import {
|
|
188
188
|
CorpusWatermarkCache,
|
|
189
189
|
computeServiceCorpusCensus
|
|
190
|
-
} from "./chunk-
|
|
190
|
+
} from "./chunk-4FM35YIA.js";
|
|
191
191
|
import {
|
|
192
192
|
ExtractionDeadlineError
|
|
193
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-43TUWQNR.js";
|
|
194
|
+
import {
|
|
195
|
+
groupTurnsByExtractionScope,
|
|
196
|
+
hasPinnedCaptureScope,
|
|
197
|
+
scopeProfilePlanIdentity
|
|
198
|
+
} from "./chunk-KZMRMKC7.js";
|
|
194
199
|
import {
|
|
195
200
|
LocalLlmClient
|
|
196
|
-
} from "./chunk-
|
|
201
|
+
} from "./chunk-74AY3S7U.js";
|
|
197
202
|
import {
|
|
198
203
|
defaultCapsulesDir
|
|
199
204
|
} from "./chunk-ZY2MNJR6.js";
|
|
@@ -203,12 +208,10 @@ import {
|
|
|
203
208
|
enqueuePassiveCorrectionNotification,
|
|
204
209
|
parseBriefingFocus,
|
|
205
210
|
parseBriefingWindow
|
|
206
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-A6JDT6QF.js";
|
|
207
212
|
import {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
scopeProfilePlanIdentity
|
|
211
|
-
} from "./chunk-KZMRMKC7.js";
|
|
213
|
+
withBriefingDeadline
|
|
214
|
+
} from "./chunk-X2KO4FK5.js";
|
|
212
215
|
import {
|
|
213
216
|
meetingsBuild,
|
|
214
217
|
meetingsGet,
|
|
@@ -245,7 +248,7 @@ import {
|
|
|
245
248
|
} from "./chunk-AWD36R4D.js";
|
|
246
249
|
import {
|
|
247
250
|
resolveEffectiveDeepRecallConfig
|
|
248
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-AJG2TAMR.js";
|
|
249
252
|
import {
|
|
250
253
|
buildProcedurePersistBody,
|
|
251
254
|
normalizeProcedureSteps,
|
|
@@ -261,7 +264,7 @@ import {
|
|
|
261
264
|
qmdCollectionPathParts,
|
|
262
265
|
qmdResultPathCandidates,
|
|
263
266
|
selfDeps
|
|
264
|
-
} from "./chunk-
|
|
267
|
+
} from "./chunk-JIJAWTRK.js";
|
|
265
268
|
import {
|
|
266
269
|
namespaceCollectionName
|
|
267
270
|
} from "./chunk-LXXIV7Y2.js";
|
|
@@ -273,7 +276,7 @@ import {
|
|
|
273
276
|
createVersion,
|
|
274
277
|
getVersion,
|
|
275
278
|
revertToVersion
|
|
276
|
-
} from "./chunk-
|
|
279
|
+
} from "./chunk-564YP3DW.js";
|
|
277
280
|
import {
|
|
278
281
|
MEMORY_CORPUS_VERSION_SENTINEL,
|
|
279
282
|
bumpMemoryCorpusVersionForDir
|
|
@@ -282,10 +285,13 @@ import {
|
|
|
282
285
|
HistoricalEntityCanonicalIdCache,
|
|
283
286
|
canonicalizeEntityRefFrontmatter,
|
|
284
287
|
repairContentAfterJournalMoveSync
|
|
285
|
-
} from "./chunk-
|
|
288
|
+
} from "./chunk-A5L5KGDI.js";
|
|
286
289
|
import {
|
|
287
290
|
supersessionKeysForFact
|
|
288
291
|
} from "./chunk-5WITETWU.js";
|
|
292
|
+
import {
|
|
293
|
+
withCaptureWriteLockBackoff
|
|
294
|
+
} from "./chunk-7VLBZKNB.js";
|
|
289
295
|
import {
|
|
290
296
|
FallbackLlmClient,
|
|
291
297
|
gatewayTaskChainOptions
|
|
@@ -293,9 +299,6 @@ import {
|
|
|
293
299
|
import {
|
|
294
300
|
fallbackLlmRuntimeContextFromConfig
|
|
295
301
|
} from "./chunk-YIJECSIX.js";
|
|
296
|
-
import {
|
|
297
|
-
withCaptureWriteLockBackoff
|
|
298
|
-
} from "./chunk-7VLBZKNB.js";
|
|
299
302
|
import {
|
|
300
303
|
DEFAULT_RECALL_DISCLOSURE,
|
|
301
304
|
isRecallDisclosure
|
|
@@ -312,11 +315,11 @@ import {
|
|
|
312
315
|
} from "./chunk-YLXETSAH.js";
|
|
313
316
|
import {
|
|
314
317
|
splitCanonicalWriteRequest
|
|
315
|
-
} from "./chunk-
|
|
318
|
+
} from "./chunk-2S6JADBB.js";
|
|
316
319
|
import {
|
|
317
|
-
|
|
320
|
+
buildWithBriefingLocation,
|
|
318
321
|
daySummaryAutoOptions
|
|
319
|
-
} from "./chunk-
|
|
322
|
+
} from "./chunk-S4OZKPBS.js";
|
|
320
323
|
import {
|
|
321
324
|
STRUCTURED_ATTRIBUTE_LIMITS,
|
|
322
325
|
buildAccessWriteRequestFingerprint,
|
|
@@ -334,16 +337,16 @@ import {
|
|
|
334
337
|
} from "./chunk-SDXBR5QO.js";
|
|
335
338
|
import {
|
|
336
339
|
reapplyCategoryCoercion
|
|
337
|
-
} from "./chunk-
|
|
340
|
+
} from "./chunk-HQUYENKK.js";
|
|
338
341
|
import {
|
|
339
342
|
exportCapsule
|
|
340
|
-
} from "./chunk-
|
|
343
|
+
} from "./chunk-KQAFEZQX.js";
|
|
341
344
|
import {
|
|
342
345
|
evaluateActionConfidence
|
|
343
346
|
} from "./chunk-Z2YFLXHU.js";
|
|
344
347
|
import {
|
|
345
348
|
createOfflineSyncManifestStream
|
|
346
|
-
} from "./chunk-
|
|
349
|
+
} from "./chunk-UQBOPCDK.js";
|
|
347
350
|
import {
|
|
348
351
|
offlineSyncStorageForSnapshot
|
|
349
352
|
} from "./chunk-KQXRVELF.js";
|
|
@@ -399,7 +402,7 @@ import {
|
|
|
399
402
|
enforceNamespaceAllowList,
|
|
400
403
|
isNamespaceAllowed,
|
|
401
404
|
tokenCapabilityStore
|
|
402
|
-
} from "./chunk-
|
|
405
|
+
} from "./chunk-YO2JEX2Z.js";
|
|
403
406
|
import {
|
|
404
407
|
computeContentHash
|
|
405
408
|
} from "./chunk-5FVVY2EB.js";
|
|
@@ -426,7 +429,7 @@ import {
|
|
|
426
429
|
buildOfflineSyncSnapshotFromBase,
|
|
427
430
|
normalizeOfflineSyncChangeset,
|
|
428
431
|
readOfflineSyncFileContentChunk
|
|
429
|
-
} from "./chunk-
|
|
432
|
+
} from "./chunk-TEH5MDX5.js";
|
|
430
433
|
import {
|
|
431
434
|
compileOfflineSyncExcludeGlobs
|
|
432
435
|
} from "./chunk-63LFM77Z.js";
|
|
@@ -449,7 +452,7 @@ import {
|
|
|
449
452
|
memorySearchThroughScope,
|
|
450
453
|
mergeMemorySearchDefaultFallback,
|
|
451
454
|
resolveMemorySearchDefaultFallback
|
|
452
|
-
} from "./chunk-
|
|
455
|
+
} from "./chunk-S5CQI2KF.js";
|
|
453
456
|
import {
|
|
454
457
|
canReadNamespace,
|
|
455
458
|
canWriteNamespace,
|
|
@@ -508,7 +511,7 @@ import {
|
|
|
508
511
|
EngramAccessForbiddenError,
|
|
509
512
|
EngramAccessInputError,
|
|
510
513
|
NamespaceNotWritableError
|
|
511
|
-
} from "./chunk-
|
|
514
|
+
} from "./chunk-LGEH473S.js";
|
|
512
515
|
import {
|
|
513
516
|
abortError,
|
|
514
517
|
isAbortError,
|
|
@@ -4268,45 +4271,39 @@ function formatZodIssues(error) {
|
|
|
4268
4271
|
const path17 = hasNumeric ? issue.path.filter((p) => typeof p === "string").join(".") || "(root)" : issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
4269
4272
|
const options = enumOptionsFromIssue(issue);
|
|
4270
4273
|
const suffix = options ? `. Valid: ${options.join(", ")}` : "";
|
|
4271
|
-
parts.push(`${path17}: ${issue
|
|
4274
|
+
parts.push(`${path17}: ${humanReadableIssueMessage(issue, path17, hasNumeric)}${suffix}`);
|
|
4272
4275
|
}
|
|
4273
4276
|
return parts.length > 0 ? `request validation failed: ${parts.join("; ")}` : "request validation failed";
|
|
4274
4277
|
}
|
|
4275
4278
|
function enumOptionsFromIssue(issue) {
|
|
4276
|
-
if (issue.code
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4279
|
+
if (issue.code !== "invalid_value") return void 0;
|
|
4280
|
+
const rawValues = "values" in issue ? issue.values : void 0;
|
|
4281
|
+
return Array.isArray(rawValues) ? rawValues.map((opt) => String(opt)) : void 0;
|
|
4282
|
+
}
|
|
4283
|
+
function humanReadableIssueMessage(issue, pathLabel, hasNumericPath) {
|
|
4284
|
+
if (issue.code !== "invalid_type") return issue.message;
|
|
4285
|
+
const expected = issue.expected;
|
|
4286
|
+
if (issue.message.endsWith("received undefined")) return issue.message;
|
|
4287
|
+
if (hasNumericPath && expected) {
|
|
4288
|
+
return `${pathLabel} must be an array of ${expected}s`;
|
|
4289
|
+
}
|
|
4290
|
+
const fieldName = issue.path.length > 0 ? String(issue.path[issue.path.length - 1]) : "value";
|
|
4291
|
+
switch (expected) {
|
|
4292
|
+
case "string":
|
|
4293
|
+
return `${fieldName} must be a string`;
|
|
4294
|
+
case "boolean":
|
|
4295
|
+
return `${fieldName} must be a boolean`;
|
|
4296
|
+
case "number":
|
|
4297
|
+
return `${fieldName} must be a number`;
|
|
4298
|
+
case "array":
|
|
4299
|
+
return `${fieldName} must be an array`;
|
|
4300
|
+
case "object":
|
|
4301
|
+
return `${fieldName} must be an object`;
|
|
4302
|
+
default:
|
|
4303
|
+
return issue.message;
|
|
4281
4304
|
}
|
|
4282
|
-
return void 0;
|
|
4283
4305
|
}
|
|
4284
4306
|
var registry = /* @__PURE__ */ new Map();
|
|
4285
|
-
var humanReadableErrorMap = (issue, ctx) => {
|
|
4286
|
-
if (issue.code === z.ZodIssueCode.invalid_type) {
|
|
4287
|
-
if (issue.received === "undefined") return { message: ctx.defaultError };
|
|
4288
|
-
if (issue.path.some((p) => typeof p === "number")) {
|
|
4289
|
-
const arrField = issue.path.filter((p) => typeof p === "string").join(".");
|
|
4290
|
-
return { message: `${arrField} must be an array of ${issue.expected}s` };
|
|
4291
|
-
}
|
|
4292
|
-
const fieldName = issue.path.length > 0 ? String(issue.path[issue.path.length - 1]) : "value";
|
|
4293
|
-
switch (issue.expected) {
|
|
4294
|
-
case "string":
|
|
4295
|
-
return { message: `${fieldName} must be a string` };
|
|
4296
|
-
case "boolean":
|
|
4297
|
-
return { message: `${fieldName} must be a boolean` };
|
|
4298
|
-
case "number":
|
|
4299
|
-
return { message: `${fieldName} must be a number` };
|
|
4300
|
-
case "array":
|
|
4301
|
-
return { message: `${fieldName} must be an array` };
|
|
4302
|
-
case "object":
|
|
4303
|
-
return { message: `${fieldName} must be an object` };
|
|
4304
|
-
default:
|
|
4305
|
-
return { message: ctx.defaultError };
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4308
|
-
return { message: ctx.defaultError };
|
|
4309
|
-
};
|
|
4310
4307
|
function defineOperation(spec) {
|
|
4311
4308
|
if (registry.has(spec.name)) {
|
|
4312
4309
|
throw new Error(`access-boundary: operation already registered: ${spec.name}`);
|
|
@@ -4314,7 +4311,7 @@ function defineOperation(spec) {
|
|
|
4314
4311
|
const bound = {
|
|
4315
4312
|
spec,
|
|
4316
4313
|
run: async (rawInput, ctx) => {
|
|
4317
|
-
const parseResult = spec.schema.safeParse(rawInput
|
|
4314
|
+
const parseResult = spec.schema.safeParse(rawInput);
|
|
4318
4315
|
if (!parseResult.success) {
|
|
4319
4316
|
throw new EngramAccessInputError(formatZodIssues(parseResult.error));
|
|
4320
4317
|
}
|
|
@@ -4332,7 +4329,14 @@ function operationRequiresAuthorizedNamespace(name) {
|
|
|
4332
4329
|
if (name === "namespace_writable") return false;
|
|
4333
4330
|
if (IMPLICIT_HTTP_NAMESPACE_OPERATIONS.has(name)) return true;
|
|
4334
4331
|
let schema = registry.get(name)?.spec.schema;
|
|
4335
|
-
while (schema instanceof z.
|
|
4332
|
+
while (schema instanceof z.ZodType && !(schema instanceof z.ZodObject)) {
|
|
4333
|
+
const wrapper = schema;
|
|
4334
|
+
const sides = [wrapper.in, wrapper.out].filter(
|
|
4335
|
+
(side) => side instanceof z.ZodType && !(side instanceof z.ZodTransform)
|
|
4336
|
+
);
|
|
4337
|
+
if (sides.length !== 1) break;
|
|
4338
|
+
schema = sides[0];
|
|
4339
|
+
}
|
|
4336
4340
|
return schema instanceof z.ZodObject && Object.hasOwn(schema.shape, "namespace");
|
|
4337
4341
|
}
|
|
4338
4342
|
function operationUsesPrincipalNamespace(name) {
|
|
@@ -7607,7 +7611,6 @@ var AccessObserveWriteSurface = class {
|
|
|
7607
7611
|
throw new EngramAccessInputError("briefing is disabled");
|
|
7608
7612
|
}
|
|
7609
7613
|
const namespace = this.deps.resolveReadableNamespace(request.namespace, request.principal);
|
|
7610
|
-
const storage = await this.deps.orchestrator.getStorage(namespace);
|
|
7611
7614
|
const token = typeof request.since === "string" && request.since.trim().length > 0 ? request.since.trim() : config.briefing.defaultWindow;
|
|
7612
7615
|
const window = parseBriefingWindow(token);
|
|
7613
7616
|
if (!window) {
|
|
@@ -7630,23 +7633,27 @@ var AccessObserveWriteSurface = class {
|
|
|
7630
7633
|
const format = request.format === "json" ? "json" : request.format === "markdown" ? "markdown" : config.briefing.defaultFormat;
|
|
7631
7634
|
const maxFollowups = typeof request.maxFollowups === "number" && Number.isFinite(request.maxFollowups) ? Math.max(0, Math.min(10, Math.floor(request.maxFollowups))) : config.briefing.maxFollowups;
|
|
7632
7635
|
const calendarSource = config.briefing.calendarSource ? new FileCalendarSource(config.briefing.calendarSource) : void 0;
|
|
7633
|
-
const result = await
|
|
7634
|
-
storage
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7636
|
+
const result = await withBriefingDeadline(async (signal) => {
|
|
7637
|
+
const storage = await this.deps.orchestrator.getStorage(namespace);
|
|
7638
|
+
return buildWithBriefingLocation(request.includeLocation, storage.dir, window.from.toISOString(), config.location, () => buildBriefing({
|
|
7639
|
+
storage,
|
|
7640
|
+
namespace,
|
|
7641
|
+
window,
|
|
7642
|
+
focus,
|
|
7643
|
+
calendarSource,
|
|
7644
|
+
maxFollowups,
|
|
7645
|
+
allowLlm: config.briefing.llmFollowups,
|
|
7646
|
+
openaiApiKey: config.openaiApiKey,
|
|
7647
|
+
openaiBaseUrl: config.openaiBaseUrl,
|
|
7648
|
+
model: config.model,
|
|
7649
|
+
// Without a direct OpenAI key, route follow-ups through the configured
|
|
7650
|
+
// LLM chain (gateway model source or local LLM) — same fallback every
|
|
7651
|
+
// other LLM feature uses. A configured key keeps its precedence so
|
|
7652
|
+
// existing deployments are unchanged.
|
|
7653
|
+
followupGenerator: config.openaiApiKey ? void 0 : this.deps.orchestrator.briefingChainFollowupGenerator,
|
|
7654
|
+
abortSignal: signal
|
|
7655
|
+
}));
|
|
7656
|
+
}, request.abortSignal);
|
|
7650
7657
|
return {
|
|
7651
7658
|
format,
|
|
7652
7659
|
window: result.window,
|
|
@@ -18790,4 +18797,4 @@ export {
|
|
|
18790
18797
|
EngramAccessService,
|
|
18791
18798
|
AccessAdminOpsSurface
|
|
18792
18799
|
};
|
|
18793
|
-
//# sourceMappingURL=chunk-
|
|
18800
|
+
//# sourceMappingURL=chunk-GBGU5OZP.js.map
|