@remnic/core 9.49.0 → 9.49.1
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/abstraction-nodes.d.ts +12 -1
- package/dist/abstraction-nodes.js +9 -2
- package/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +48 -48
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +49 -49
- package/dist/access-boundary.d.ts +10 -10
- package/dist/access-boundary.js +48 -48
- package/dist/access-cli.js +132 -127
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +10 -10
- package/dist/access-extraction-force-flush.js +48 -48
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +10 -10
- package/dist/access-http-lifecycle-flush.d.ts +10 -10
- package/dist/access-http-offline-stream.d.ts +10 -10
- package/dist/access-http-query.js +48 -48
- package/dist/access-http.d.ts +10 -10
- package/dist/access-http.js +60 -60
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +48 -48
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +48 -48
- package/dist/access-mcp.d.ts +10 -10
- package/dist/access-mcp.js +55 -55
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight--H6HwN85.d.ts → access-namespace-preflight-DuDU301-.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +48 -48
- package/dist/access-observe-write-surface.d.ts +10 -10
- package/dist/access-observe-write-surface.js +48 -48
- package/dist/access-offline-manifest.d.ts +8 -8
- package/dist/access-offline-manifest.js +3 -3
- package/dist/access-operations-batch.js +51 -51
- package/dist/access-operations.d.ts +13 -13
- package/dist/access-operations.js +54 -54
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +48 -48
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +48 -48
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +48 -48
- package/dist/access-schema.d.ts +105 -105
- package/dist/access-schema.js +4 -4
- package/dist/{access-service-DvXOzCrM.d.ts → access-service--_3T_v23.d.ts} +7 -7
- package/dist/access-service-helpers.d.ts +10 -10
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +48 -48
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +3 -2
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-7O6RP2RT.js → auto-sync-QFQGOEO2.js} +4 -4
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +12 -12
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +4 -4
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/{capsule-merge-6GFHWECG.js → capsule-merge-KXTRZ23Z.js} +4 -4
- package/dist/{catalog-Iwbk9h5E.d.ts → catalog-DjUmUIal.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +3 -3
- package/dist/causal-chain.js +3 -3
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +16 -16
- package/dist/causal-retrieval.js +3 -3
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory.d.ts +51 -2
- package/dist/causal-trajectory.js +8 -2
- package/dist/{chunk-EY64JLOM.js → chunk-24BKGKGO.js} +30 -19
- package/dist/chunk-24BKGKGO.js.map +1 -0
- package/dist/{chunk-ICP53SKG.js → chunk-2HIJHXB3.js} +2 -2
- package/dist/{chunk-BXLOS5AJ.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-LZGCJSQR.js → chunk-3LD4N2TF.js} +151 -37
- package/dist/chunk-3LD4N2TF.js.map +1 -0
- package/dist/{chunk-5JRC6BYS.js → chunk-47J4EDGR.js} +11 -11
- package/dist/{chunk-2VHLLPTX.js → chunk-4EABKPZS.js} +4 -4
- package/dist/{chunk-RJV6Q2FT.js → chunk-4JWJMRPJ.js} +2 -2
- package/dist/{chunk-MXPB6PJQ.js → chunk-4S3ECH3U.js} +2 -2
- package/dist/{chunk-CGASUJVP.js → chunk-5V6IXHPI.js} +4 -4
- package/dist/{chunk-R5IGA2NH.js → chunk-5XCN4XBU.js} +4 -4
- package/dist/{chunk-2RPJ4NEE.js → chunk-64BHFFKZ.js} +2 -2
- package/dist/{chunk-FQC3DHH2.js → chunk-66SE3BNH.js} +2 -2
- package/dist/{chunk-TERNBNJB.js → chunk-6FC3IZ26.js} +2 -2
- package/dist/{chunk-K7VKAHFE.js → chunk-6XGEBQ3R.js} +4 -4
- package/dist/{chunk-JFLOOTXU.js → chunk-7BLWBSRL.js} +3 -3
- package/dist/{chunk-ABR2HEJO.js → chunk-7NDM2PNK.js} +3 -3
- package/dist/{chunk-JXZ7NLYH.js → chunk-7VWZ4LRW.js} +2 -2
- package/dist/{chunk-RN53QBM4.js → chunk-A4QMKFFO.js} +5 -1
- package/dist/chunk-A4QMKFFO.js.map +1 -0
- package/dist/chunk-ACPCA4NO.js +321 -0
- package/dist/chunk-ACPCA4NO.js.map +1 -0
- package/dist/chunk-AMTEYNYK.js +72 -0
- package/dist/chunk-AMTEYNYK.js.map +1 -0
- package/dist/{chunk-R6YJI3HE.js → chunk-AW4QUFQF.js} +1 -1
- package/dist/{chunk-P65YJEEL.js → chunk-AXFWMRKI.js} +2 -2
- package/dist/{chunk-WG5HSQ4P.js → chunk-BAKXNQ3C.js} +2 -2
- package/dist/{chunk-NM2WP3B7.js → chunk-BJYET5TX.js} +2 -2
- package/dist/{chunk-HLKPRWF4.js → chunk-DATDLJAO.js} +6 -6
- package/dist/chunk-DJUKBGAD.js +260 -0
- package/dist/chunk-DJUKBGAD.js.map +1 -0
- package/dist/{chunk-DX3XRGLH.js → chunk-DQTCGVFK.js} +2 -2
- package/dist/{chunk-IPBNC77A.js → chunk-E633OXMH.js} +11 -11
- package/dist/{chunk-J7T4MX7P.js → chunk-EEAMSNSG.js} +12 -1
- package/dist/chunk-EEAMSNSG.js.map +1 -0
- package/dist/{chunk-Z5UC3OKB.js → chunk-ELQCS47S.js} +7 -7
- package/dist/{chunk-FMXJ555A.js → chunk-EURCX6PS.js} +2 -2
- package/dist/{chunk-MZZR3J6M.js → chunk-FV7YQTN3.js} +2 -2
- package/dist/chunk-G73MCJKL.js +20 -0
- package/dist/chunk-G73MCJKL.js.map +1 -0
- package/dist/{chunk-3R6D33UF.js → chunk-GGBSF2X7.js} +2 -2
- package/dist/{chunk-SYUBB3WM.js → chunk-GKEYXXKX.js} +2 -2
- package/dist/{chunk-5AGR7SAI.js → chunk-GSEPRIZC.js} +3 -3
- package/dist/{chunk-UTVZKHJK.js → chunk-GUKBW4HL.js} +2 -2
- package/dist/chunk-GXSOUIA4.js +293 -0
- package/dist/chunk-GXSOUIA4.js.map +1 -0
- package/dist/{chunk-2F6NP3NT.js → chunk-HDQUQBPW.js} +2 -2
- package/dist/{chunk-6HMYUWXR.js → chunk-HTP6XRUI.js} +2 -2
- package/dist/{chunk-UYUYZ4WY.js → chunk-IARXXZU4.js} +2 -2
- package/dist/{chunk-MNB5RMAY.js → chunk-IIFFC3RL.js} +2 -2
- package/dist/{chunk-VDX2J7OX.js → chunk-IPLYGWQF.js} +6 -6
- package/dist/{chunk-NZBZ7IS2.js → chunk-JDCQK3C5.js} +2 -2
- package/dist/{chunk-C3KVFJH5.js → chunk-JI62YGPI.js} +2 -2
- package/dist/{chunk-LULR4IUW.js → chunk-KATEWTQJ.js} +2 -2
- package/dist/{chunk-BMCHFWGX.js → chunk-KMWYZTIE.js} +2 -2
- package/dist/{chunk-JGSKJHF7.js → chunk-KQS72GCR.js} +2 -2
- package/dist/{chunk-3S63QIFQ.js → chunk-LAQ33B5D.js} +1 -1
- package/dist/chunk-LAQ33B5D.js.map +1 -0
- package/dist/chunk-LNTUXKBT.js +224 -0
- package/dist/chunk-LNTUXKBT.js.map +1 -0
- package/dist/{chunk-2RIWJUSQ.js → chunk-LQKXVQZR.js} +12 -12
- package/dist/{chunk-LQL7ARIC.js → chunk-LTOAJXZB.js} +4 -4
- package/dist/{chunk-QKD65RGL.js → chunk-LYMNZZIM.js} +2 -2
- package/dist/{chunk-W4FBGYGK.js → chunk-M4MP34AQ.js} +189 -5
- package/dist/chunk-M4MP34AQ.js.map +1 -0
- package/dist/{chunk-3PY7VHV7.js → chunk-MCA2X4WH.js} +2 -2
- package/dist/{chunk-S5NZBKKQ.js → chunk-N3CXAYPJ.js} +3 -3
- package/dist/{chunk-WQIHRA5F.js → chunk-N3LL5NEU.js} +2 -2
- package/dist/{chunk-Z4U6U3M3.js → chunk-NKL25FCF.js} +2 -2
- package/dist/{chunk-LMDRGRJ2.js → chunk-NOB2T2FC.js} +2 -2
- package/dist/{chunk-P2OTGMTR.js → chunk-NSGU76YO.js} +2 -2
- package/dist/{chunk-L6DCVUCA.js → chunk-O76MWTVS.js} +2 -2
- package/dist/{chunk-WZFAPHIK.js → chunk-OIOZ6MOP.js} +3 -3
- package/dist/{chunk-DNHVPZOD.js → chunk-P26YHAQH.js} +201 -1
- package/dist/chunk-P26YHAQH.js.map +1 -0
- package/dist/{chunk-UMOO7IY7.js → chunk-P2KBDJJ6.js} +2 -2
- package/dist/{chunk-KVJRXN2E.js → chunk-P4QOYG52.js} +125 -13
- package/dist/chunk-P4QOYG52.js.map +1 -0
- package/dist/chunk-P77QX3ID.js +332 -0
- package/dist/chunk-P77QX3ID.js.map +1 -0
- package/dist/{chunk-SXWHN7GC.js → chunk-PDEKQWDV.js} +2 -2
- package/dist/{chunk-ENEA47UC.js → chunk-PLCHU56K.js} +3 -3
- package/dist/{chunk-IXPKESVP.js → chunk-PWIMF7LP.js} +37 -37
- package/dist/{chunk-RHTO4HTL.js → chunk-PWLB4TRK.js} +2 -2
- package/dist/{chunk-RVYVMQK4.js → chunk-QSYL5CXK.js} +3 -3
- package/dist/{chunk-B6KGGRUL.js → chunk-QWLW3VQH.js} +2 -2
- package/dist/{chunk-YQIVWS7Y.js → chunk-RBPH3GZV.js} +405 -101
- package/dist/chunk-RBPH3GZV.js.map +1 -0
- package/dist/{chunk-JBPKEARU.js → chunk-RKNJBZ55.js} +4 -4
- package/dist/{chunk-QCECHYZL.js → chunk-RVO6TCTU.js} +6 -6
- package/dist/{chunk-SHDZNSK4.js → chunk-S2SJEOTM.js} +2 -2
- package/dist/{chunk-ULWHRQEQ.js → chunk-S75UQ3T3.js} +3 -3
- package/dist/{chunk-LXOM6IQU.js → chunk-SEF4IOFE.js} +2 -2
- package/dist/{chunk-I3YHVVT4.js → chunk-SHYIMIX5.js} +2 -2
- package/dist/{chunk-IZANPXMV.js → chunk-T35UJI5R.js} +86 -82
- package/dist/chunk-T35UJI5R.js.map +1 -0
- package/dist/{chunk-G5OB4XZX.js → chunk-VANZKHTN.js} +4 -4
- package/dist/{chunk-I4TQST3L.js → chunk-VFS3MK5F.js} +2 -2
- package/dist/chunk-VUDMT5CP.js +86 -0
- package/dist/chunk-VUDMT5CP.js.map +1 -0
- package/dist/{chunk-CMQZNEIF.js → chunk-WFLBP5GC.js} +8 -1
- package/dist/chunk-WFLBP5GC.js.map +1 -0
- package/dist/{chunk-SMPVHGHG.js → chunk-WPZX7MEA.js} +3 -3
- package/dist/{chunk-ZRWB5D4H.js → chunk-WT6UL3UA.js} +2 -2
- package/dist/{chunk-DQEMWVMT.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-JHMAYABJ.js → chunk-XL3TATMJ.js} +4 -4
- package/dist/{chunk-MC6XO7T4.js → chunk-YLBE6PLR.js} +2 -2
- package/dist/{chunk-OLX2HJFW.js → chunk-YLHM5BQQ.js} +4 -4
- package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
- package/dist/{chunk-GF22HWS2.js → chunk-Z54EM5YZ.js} +4 -4
- package/dist/{chunk-GVX3NAUU.js → chunk-ZDAYWJV6.js} +2 -2
- package/dist/{chunk-EYAIZBLM.js → chunk-ZJIFYUJI.js} +5 -5
- package/dist/{chunk-CNQQMB67.js → chunk-ZN4EYMKJ.js} +2 -2
- package/dist/{cli-PyAUaozE.d.ts → cli-BLNmNEMT.d.ts} +16 -14
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +96 -94
- package/dist/coding/pre-action-gate.d.ts +66 -0
- package/dist/coding/pre-action-gate.js +22 -0
- package/dist/commitment-ledger.js +2 -2
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +13 -13
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +12 -12
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +12 -12
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-provenance-check.js +4 -4
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/consolidation-undo.js +3 -3
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +3 -3
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +15 -15
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +23 -23
- package/dist/cue-anchors.d.ts +19 -1
- package/dist/cue-anchors.js +10 -2
- package/dist/dashboard-runtime.js +2 -2
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +10 -0
- package/dist/dependency-propagation-config.js +10 -0
- package/dist/dependency-propagation-config.js.map +1 -0
- package/dist/deterministic-order.d.ts +4 -0
- package/dist/deterministic-order.js +10 -0
- package/dist/deterministic-order.js.map +1 -0
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +12 -12
- package/dist/entity-schema.d.ts +1 -1
- package/dist/evals.js +2 -2
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/explicit-capture.js +6 -6
- package/dist/external-wiki-access.d.ts +10 -10
- package/dist/external-wiki-access.js +49 -49
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +10 -10
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +14 -0
- package/dist/extraction-normalization.js +22 -0
- package/dist/extraction-normalization.js.map +1 -0
- package/dist/extraction-prompt.d.ts +4 -3
- package/dist/extraction-prompt.js +3 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +18 -1
- package/dist/extraction.js +21 -19
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{first-start-migration-ZSHEFEI3.js → first-start-migration-626C5554.js} +5 -5
- package/dist/{forget-DNAJ66ZD.js → forget-GJ42LCBW.js} +2 -2
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-construction.d.ts +43 -0
- package/dist/harmonic-construction.js +26 -0
- package/dist/harmonic-construction.js.map +1 -0
- package/dist/harmonic-retrieval.d.ts +1 -0
- package/dist/harmonic-retrieval.js +10 -4
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +698 -696
- package/dist/index.js +207 -161
- package/dist/intent.d.ts +1 -1
- package/dist/json-store.d.ts +15 -1
- package/dist/json-store.js +11 -3
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +4 -4
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/archive-observations.js +2 -2
- package/dist/maintenance/atomic-file.d.ts +5 -0
- package/dist/maintenance/atomic-file.js +12 -0
- package/dist/maintenance/atomic-file.js.map +1 -0
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +12 -12
- package/dist/maintenance/migrate-observations.js +3 -3
- package/dist/maintenance/observation-ledger-utils.d.ts +1 -1
- package/dist/maintenance/observation-ledger-utils.js +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +13 -13
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +14 -14
- package/dist/maintenance/rebuild-observations.js +3 -3
- package/dist/{maintenance-j7sfNQdK.d.ts → maintenance-DKbKZi3u.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-snapshot.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +22 -22
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +12 -12
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/objective-state-writers.js +3 -3
- package/dist/objective-state.js +2 -2
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +2 -2
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +24 -24
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +33 -32
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +18 -18
- package/dist/{orchestrator-Haa9xVPV.d.ts → orchestrator-BRwD7ceU.d.ts} +7 -7
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +132 -127
- package/dist/page-versioning.js +3 -3
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-1h2GpiHP.d.ts → pipeline-DC-1C9T8.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-UdwoF71D.d.ts → qmd-DdeCEZdb.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-state.js +2 -2
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/relevance.js +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/{resolution-3K27T4VO.js → resolution-MDPNOEG6.js} +4 -4
- package/dist/resolution-MDPNOEG6.js.map +1 -0
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +8 -7
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/salvage-envelope.js +3 -3
- package/dist/schemas.d.ts +213 -116
- package/dist/schemas.js +1 -1
- package/dist/{scope-profiles-APjhSe-w.d.ts → scope-profiles-BXVq4Jv0.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +8 -8
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +13 -13
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/orama-backend.js +2 -2
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-CrySDbk3.d.ts → semantic-consolidation-CGYxfa8F.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -13
- package/dist/semantic-rule-promotion.js +12 -12
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +12 -12
- package/dist/{service-Da_BI4S8.d.ts → service-CBDBQFCN.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +11 -11
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +16 -16
- package/dist/{storage-D1apCiCS.d.ts → storage-V--MQi7w.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +11 -11
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +13 -2
- package/dist/temporal-supersession.js +1 -1
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/{tier-stats-OPTSBNRH.js → tier-stats-2JCZYEF7.js} +5 -5
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +3 -3
- package/dist/transfer/capsule-import.js +5 -5
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/trust-zones.js +2 -2
- package/dist/{types-D_Au9qJO.d.ts → types-D_a6Sqjz.d.ts} +25 -8
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-learner.js +3 -3
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/utility-runtime.js +4 -4
- package/dist/utility-telemetry.js +2 -2
- package/dist/verified-recall.js +12 -12
- package/dist/work-product-ledger.js +2 -2
- package/dist/write-envelope.d.ts +1 -1
- package/dist/write-envelope.js +2 -2
- package/package.json +32 -2
- package/src/abstraction-nodes.ts +182 -4
- package/src/causal-trajectory.ts +258 -3
- package/src/cli/harmonic-search.ts +23 -0
- package/src/cli/research-status-commands.ts +2 -1
- package/src/cli.ts +1 -24
- package/src/coding/pre-action-gate.test.ts +516 -0
- package/src/coding/pre-action-gate.ts +320 -0
- package/src/config.test.ts +85 -0
- package/src/config.ts +2 -0
- package/src/cue-anchors.test.ts +90 -0
- package/src/cue-anchors.ts +264 -11
- package/src/dependency-frontmatter.test.ts +83 -0
- package/src/dependency-propagation-config.ts +94 -0
- package/src/deterministic-order.ts +14 -0
- package/src/extraction-normalization.ts +71 -0
- package/src/extraction-prompt.ts +45 -11
- package/src/extraction.ts +48 -32
- package/src/faithfulness-graph-guard.test.ts +27 -0
- package/src/harmonic-construction.test.ts +1799 -0
- package/src/harmonic-construction.ts +367 -0
- package/src/harmonic-retrieval.ts +166 -25
- package/src/index.ts +4 -5
- package/src/json-store.ts +354 -12
- package/src/orchestration/consolidation-run.ts +192 -0
- package/src/orchestration/contradiction-linking-coordinator.ts +35 -1
- package/src/orchestration/dependency-propagation-triggers.test.ts +286 -0
- package/src/orchestration/dependency-propagation.test.ts +487 -0
- package/src/orchestration/dependency-propagation.ts +263 -0
- package/src/orchestration/dependency-revalidation.ts +173 -0
- package/src/orchestration/extraction-persist-deps.ts +93 -0
- package/src/orchestration/extraction-persist.ts +101 -94
- package/src/orchestration/harmonic-construction-persist.ts +86 -0
- package/src/orchestration/recall-internal.ts +1 -0
- package/src/orchestrator.ts +2 -1
- package/src/schemas.ts +15 -0
- package/src/storage.ts +14 -0
- package/src/temporal-supersession.ts +29 -1
- package/src/testing/orchestrator-lite.ts +27 -8
- package/src/testing/subjects/extraction-lifecycle.test.ts +91 -50
- package/src/types.ts +22 -7
- package/dist/chunk-3S63QIFQ.js.map +0 -1
- package/dist/chunk-CMQZNEIF.js.map +0 -1
- package/dist/chunk-DNHVPZOD.js.map +0 -1
- package/dist/chunk-EY64JLOM.js.map +0 -1
- package/dist/chunk-FZZ2QTJI.js +0 -111
- package/dist/chunk-FZZ2QTJI.js.map +0 -1
- package/dist/chunk-IZANPXMV.js.map +0 -1
- package/dist/chunk-J7T4MX7P.js.map +0 -1
- package/dist/chunk-KVJRXN2E.js.map +0 -1
- package/dist/chunk-LPSF4OQH.js +0 -47
- package/dist/chunk-LPSF4OQH.js.map +0 -1
- package/dist/chunk-LZGCJSQR.js.map +0 -1
- package/dist/chunk-OADWQ5CR.js +0 -115
- package/dist/chunk-OADWQ5CR.js.map +0 -1
- package/dist/chunk-RN53QBM4.js.map +0 -1
- package/dist/chunk-W4FBGYGK.js.map +0 -1
- package/dist/chunk-YQIVWS7Y.js.map +0 -1
- /package/dist/{auto-sync-7O6RP2RT.js.map → auto-sync-QFQGOEO2.js.map} +0 -0
- /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{capsule-merge-6GFHWECG.js.map → capsule-merge-KXTRZ23Z.js.map} +0 -0
- /package/dist/{chunk-ICP53SKG.js.map → chunk-2HIJHXB3.js.map} +0 -0
- /package/dist/{chunk-BXLOS5AJ.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-5JRC6BYS.js.map → chunk-47J4EDGR.js.map} +0 -0
- /package/dist/{chunk-2VHLLPTX.js.map → chunk-4EABKPZS.js.map} +0 -0
- /package/dist/{chunk-RJV6Q2FT.js.map → chunk-4JWJMRPJ.js.map} +0 -0
- /package/dist/{chunk-MXPB6PJQ.js.map → chunk-4S3ECH3U.js.map} +0 -0
- /package/dist/{chunk-CGASUJVP.js.map → chunk-5V6IXHPI.js.map} +0 -0
- /package/dist/{chunk-R5IGA2NH.js.map → chunk-5XCN4XBU.js.map} +0 -0
- /package/dist/{chunk-2RPJ4NEE.js.map → chunk-64BHFFKZ.js.map} +0 -0
- /package/dist/{chunk-FQC3DHH2.js.map → chunk-66SE3BNH.js.map} +0 -0
- /package/dist/{chunk-TERNBNJB.js.map → chunk-6FC3IZ26.js.map} +0 -0
- /package/dist/{chunk-K7VKAHFE.js.map → chunk-6XGEBQ3R.js.map} +0 -0
- /package/dist/{chunk-JFLOOTXU.js.map → chunk-7BLWBSRL.js.map} +0 -0
- /package/dist/{chunk-ABR2HEJO.js.map → chunk-7NDM2PNK.js.map} +0 -0
- /package/dist/{chunk-JXZ7NLYH.js.map → chunk-7VWZ4LRW.js.map} +0 -0
- /package/dist/{chunk-R6YJI3HE.js.map → chunk-AW4QUFQF.js.map} +0 -0
- /package/dist/{chunk-P65YJEEL.js.map → chunk-AXFWMRKI.js.map} +0 -0
- /package/dist/{chunk-WG5HSQ4P.js.map → chunk-BAKXNQ3C.js.map} +0 -0
- /package/dist/{chunk-NM2WP3B7.js.map → chunk-BJYET5TX.js.map} +0 -0
- /package/dist/{chunk-HLKPRWF4.js.map → chunk-DATDLJAO.js.map} +0 -0
- /package/dist/{chunk-DX3XRGLH.js.map → chunk-DQTCGVFK.js.map} +0 -0
- /package/dist/{chunk-IPBNC77A.js.map → chunk-E633OXMH.js.map} +0 -0
- /package/dist/{chunk-Z5UC3OKB.js.map → chunk-ELQCS47S.js.map} +0 -0
- /package/dist/{chunk-FMXJ555A.js.map → chunk-EURCX6PS.js.map} +0 -0
- /package/dist/{chunk-MZZR3J6M.js.map → chunk-FV7YQTN3.js.map} +0 -0
- /package/dist/{chunk-3R6D33UF.js.map → chunk-GGBSF2X7.js.map} +0 -0
- /package/dist/{chunk-SYUBB3WM.js.map → chunk-GKEYXXKX.js.map} +0 -0
- /package/dist/{chunk-5AGR7SAI.js.map → chunk-GSEPRIZC.js.map} +0 -0
- /package/dist/{chunk-UTVZKHJK.js.map → chunk-GUKBW4HL.js.map} +0 -0
- /package/dist/{chunk-2F6NP3NT.js.map → chunk-HDQUQBPW.js.map} +0 -0
- /package/dist/{chunk-6HMYUWXR.js.map → chunk-HTP6XRUI.js.map} +0 -0
- /package/dist/{chunk-UYUYZ4WY.js.map → chunk-IARXXZU4.js.map} +0 -0
- /package/dist/{chunk-MNB5RMAY.js.map → chunk-IIFFC3RL.js.map} +0 -0
- /package/dist/{chunk-VDX2J7OX.js.map → chunk-IPLYGWQF.js.map} +0 -0
- /package/dist/{chunk-NZBZ7IS2.js.map → chunk-JDCQK3C5.js.map} +0 -0
- /package/dist/{chunk-C3KVFJH5.js.map → chunk-JI62YGPI.js.map} +0 -0
- /package/dist/{chunk-LULR4IUW.js.map → chunk-KATEWTQJ.js.map} +0 -0
- /package/dist/{chunk-BMCHFWGX.js.map → chunk-KMWYZTIE.js.map} +0 -0
- /package/dist/{chunk-JGSKJHF7.js.map → chunk-KQS72GCR.js.map} +0 -0
- /package/dist/{chunk-2RIWJUSQ.js.map → chunk-LQKXVQZR.js.map} +0 -0
- /package/dist/{chunk-LQL7ARIC.js.map → chunk-LTOAJXZB.js.map} +0 -0
- /package/dist/{chunk-QKD65RGL.js.map → chunk-LYMNZZIM.js.map} +0 -0
- /package/dist/{chunk-3PY7VHV7.js.map → chunk-MCA2X4WH.js.map} +0 -0
- /package/dist/{chunk-S5NZBKKQ.js.map → chunk-N3CXAYPJ.js.map} +0 -0
- /package/dist/{chunk-WQIHRA5F.js.map → chunk-N3LL5NEU.js.map} +0 -0
- /package/dist/{chunk-Z4U6U3M3.js.map → chunk-NKL25FCF.js.map} +0 -0
- /package/dist/{chunk-LMDRGRJ2.js.map → chunk-NOB2T2FC.js.map} +0 -0
- /package/dist/{chunk-P2OTGMTR.js.map → chunk-NSGU76YO.js.map} +0 -0
- /package/dist/{chunk-L6DCVUCA.js.map → chunk-O76MWTVS.js.map} +0 -0
- /package/dist/{chunk-WZFAPHIK.js.map → chunk-OIOZ6MOP.js.map} +0 -0
- /package/dist/{chunk-UMOO7IY7.js.map → chunk-P2KBDJJ6.js.map} +0 -0
- /package/dist/{chunk-SXWHN7GC.js.map → chunk-PDEKQWDV.js.map} +0 -0
- /package/dist/{chunk-ENEA47UC.js.map → chunk-PLCHU56K.js.map} +0 -0
- /package/dist/{chunk-IXPKESVP.js.map → chunk-PWIMF7LP.js.map} +0 -0
- /package/dist/{chunk-RHTO4HTL.js.map → chunk-PWLB4TRK.js.map} +0 -0
- /package/dist/{chunk-RVYVMQK4.js.map → chunk-QSYL5CXK.js.map} +0 -0
- /package/dist/{chunk-B6KGGRUL.js.map → chunk-QWLW3VQH.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-QCECHYZL.js.map → chunk-RVO6TCTU.js.map} +0 -0
- /package/dist/{chunk-SHDZNSK4.js.map → chunk-S2SJEOTM.js.map} +0 -0
- /package/dist/{chunk-ULWHRQEQ.js.map → chunk-S75UQ3T3.js.map} +0 -0
- /package/dist/{chunk-LXOM6IQU.js.map → chunk-SEF4IOFE.js.map} +0 -0
- /package/dist/{chunk-I3YHVVT4.js.map → chunk-SHYIMIX5.js.map} +0 -0
- /package/dist/{chunk-G5OB4XZX.js.map → chunk-VANZKHTN.js.map} +0 -0
- /package/dist/{chunk-I4TQST3L.js.map → chunk-VFS3MK5F.js.map} +0 -0
- /package/dist/{chunk-SMPVHGHG.js.map → chunk-WPZX7MEA.js.map} +0 -0
- /package/dist/{chunk-ZRWB5D4H.js.map → chunk-WT6UL3UA.js.map} +0 -0
- /package/dist/{chunk-DQEMWVMT.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-JHMAYABJ.js.map → chunk-XL3TATMJ.js.map} +0 -0
- /package/dist/{chunk-MC6XO7T4.js.map → chunk-YLBE6PLR.js.map} +0 -0
- /package/dist/{chunk-OLX2HJFW.js.map → chunk-YLHM5BQQ.js.map} +0 -0
- /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
- /package/dist/{chunk-GF22HWS2.js.map → chunk-Z54EM5YZ.js.map} +0 -0
- /package/dist/{chunk-GVX3NAUU.js.map → chunk-ZDAYWJV6.js.map} +0 -0
- /package/dist/{chunk-EYAIZBLM.js.map → chunk-ZJIFYUJI.js.map} +0 -0
- /package/dist/{chunk-CNQQMB67.js.map → chunk-ZN4EYMKJ.js.map} +0 -0
- /package/dist/{resolution-3K27T4VO.js.map → coding/pre-action-gate.js.map} +0 -0
- /package/dist/{first-start-migration-ZSHEFEI3.js.map → first-start-migration-626C5554.js.map} +0 -0
- /package/dist/{forget-DNAJ66ZD.js.map → forget-GJ42LCBW.js.map} +0 -0
- /package/dist/{tier-stats-OPTSBNRH.js.map → tier-stats-2JCZYEF7.js.map} +0 -0
|
@@ -1,25 +1,114 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCueAnchorStoreDir,
|
|
3
3
|
validateCueAnchor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ACPCA4NO.js";
|
|
5
5
|
import {
|
|
6
|
+
HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY,
|
|
6
7
|
resolveAbstractionNodeStoreDir,
|
|
7
8
|
validateAbstractionNode
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DJUKBGAD.js";
|
|
10
|
+
import {
|
|
11
|
+
compareDeterministicStrings
|
|
12
|
+
} from "./chunk-G73MCJKL.js";
|
|
13
|
+
import {
|
|
14
|
+
stripAttributesSuffix
|
|
15
|
+
} from "./chunk-R3DJVOSM.js";
|
|
16
|
+
import {
|
|
17
|
+
isValidityExpiredNow
|
|
18
|
+
} from "./chunk-6CIAGZ6X.js";
|
|
9
19
|
import {
|
|
10
20
|
countRecallTokenOverlap,
|
|
11
21
|
normalizeRecallTokens
|
|
12
22
|
} from "./chunk-ZBJMUXZH.js";
|
|
23
|
+
import {
|
|
24
|
+
inferMemoryStatus,
|
|
25
|
+
toMemoryPathRel
|
|
26
|
+
} from "./chunk-7RJUVTVF.js";
|
|
13
27
|
import {
|
|
14
28
|
throwIfAborted
|
|
15
29
|
} from "./chunk-BTTPKDIL.js";
|
|
16
30
|
import {
|
|
17
|
-
|
|
31
|
+
listJsonFilesStrict,
|
|
18
32
|
readJsonFile
|
|
19
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-P77QX3ID.js";
|
|
20
34
|
|
|
21
35
|
// src/harmonic-retrieval.ts
|
|
22
36
|
import path from "path";
|
|
37
|
+
async function readSourceMemories(options) {
|
|
38
|
+
const sourceMemories = /* @__PURE__ */ new Map();
|
|
39
|
+
try {
|
|
40
|
+
const { StorageManager } = await import("./storage.js");
|
|
41
|
+
const storage = new StorageManager(options.memoryDir);
|
|
42
|
+
const [hotMemories, coldMemories] = await Promise.all([
|
|
43
|
+
storage.readAllMemories({ abortSignal: options.abortSignal }),
|
|
44
|
+
storage.readAllColdMemories()
|
|
45
|
+
]);
|
|
46
|
+
for (const memory of [...hotMemories, ...coldMemories]) {
|
|
47
|
+
throwIfAborted(options.abortSignal, "harmonic retrieval aborted");
|
|
48
|
+
sourceMemories.set(memory.frontmatter.id, memory);
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
throwIfAborted(options.abortSignal, "harmonic retrieval aborted");
|
|
52
|
+
sourceMemories.clear();
|
|
53
|
+
}
|
|
54
|
+
return sourceMemories;
|
|
55
|
+
}
|
|
56
|
+
function projectSourceBackedNode(node, sourceMemories, memoryDir, temporalExpiredInInjection, nowMs) {
|
|
57
|
+
const sourceMemoryIds = node.sourceMemoryIds ?? [];
|
|
58
|
+
if (sourceMemoryIds.length === 0) return node;
|
|
59
|
+
const activeSourceMemoryIds = sourceMemoryIds.filter((memoryId) => {
|
|
60
|
+
const memory = sourceMemories.get(memoryId);
|
|
61
|
+
return memory !== void 0 && inferMemoryStatus(memory.frontmatter, toMemoryPathRel(memoryDir, memory.path)) === "active" && (temporalExpiredInInjection || !isValidityExpiredNow(memory.frontmatter, nowMs));
|
|
62
|
+
});
|
|
63
|
+
if (activeSourceMemoryIds.length === 0) return null;
|
|
64
|
+
const activeMemories = activeSourceMemoryIds.flatMap((memoryId) => {
|
|
65
|
+
const memory = sourceMemories.get(memoryId);
|
|
66
|
+
return memory ? [memory] : [];
|
|
67
|
+
});
|
|
68
|
+
const activeContents = activeMemories.map(
|
|
69
|
+
(memory) => memory.frontmatter.structuredAttributes ? stripAttributesSuffix(memory.content) : memory.content
|
|
70
|
+
);
|
|
71
|
+
let metadata;
|
|
72
|
+
const insertedAtRaw = node.metadata?.[HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY];
|
|
73
|
+
if (insertedAtRaw) {
|
|
74
|
+
try {
|
|
75
|
+
const insertedAt = JSON.parse(insertedAtRaw);
|
|
76
|
+
const activeInsertedAt = activeSourceMemoryIds.flatMap((memoryId) => {
|
|
77
|
+
const value = insertedAt[memoryId];
|
|
78
|
+
return typeof value === "string" ? [[memoryId, value]] : [];
|
|
79
|
+
});
|
|
80
|
+
if (activeInsertedAt.length > 0) {
|
|
81
|
+
metadata = {
|
|
82
|
+
[HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY]: JSON.stringify(Object.fromEntries(activeInsertedAt))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
metadata = void 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
...node,
|
|
91
|
+
sourceMemoryIds: activeSourceMemoryIds,
|
|
92
|
+
title: activeContents[0]?.slice(0, 80) ?? node.title,
|
|
93
|
+
summary: activeContents.slice(0, 3).join("; ").slice(0, 400),
|
|
94
|
+
tags: [...new Set(activeMemories.flatMap((memory) => memory.frontmatter.tags))].sort(compareDeterministicStrings),
|
|
95
|
+
entityRefs: [
|
|
96
|
+
...new Set(
|
|
97
|
+
activeMemories.flatMap(
|
|
98
|
+
(memory) => typeof memory.frontmatter.entityRef === "string" ? [memory.frontmatter.entityRef] : []
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
].sort(compareDeterministicStrings),
|
|
102
|
+
metadata
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function anchorMatchesProjectedNode(anchor, nodeRef, node, allowLegacyAttribution) {
|
|
106
|
+
const activeSourceMemoryIds = node.sourceMemoryIds ?? [];
|
|
107
|
+
if (activeSourceMemoryIds.length === 0) return true;
|
|
108
|
+
if (!anchor.sourceMemoryIdsByNodeRef) return allowLegacyAttribution;
|
|
109
|
+
const anchorSourceMemoryIds = anchor.sourceMemoryIdsByNodeRef[nodeRef] ?? [];
|
|
110
|
+
return anchorSourceMemoryIds.some((sourceMemoryId) => activeSourceMemoryIds.includes(sourceMemoryId));
|
|
111
|
+
}
|
|
23
112
|
function scoreNode(node, queryTokens) {
|
|
24
113
|
const matchedFields = [];
|
|
25
114
|
let score = 0;
|
|
@@ -50,7 +139,7 @@ function scoreNode(node, queryTokens) {
|
|
|
50
139
|
}
|
|
51
140
|
return { score, matchedFields };
|
|
52
141
|
}
|
|
53
|
-
function scoreAnchor(anchor, queryTokens) {
|
|
142
|
+
function scoreAnchor(anchor, queryTokens, eligibleNodeTags) {
|
|
54
143
|
const matchedFields = [];
|
|
55
144
|
let score = 0;
|
|
56
145
|
const valueMatches = countRecallTokenOverlap(queryTokens, anchor.anchorValue);
|
|
@@ -66,7 +155,7 @@ function scoreAnchor(anchor, queryTokens) {
|
|
|
66
155
|
score += typeMatches;
|
|
67
156
|
matchedFields.push("anchorType");
|
|
68
157
|
}
|
|
69
|
-
const tagMatches = countRecallTokenOverlap(queryTokens,
|
|
158
|
+
const tagMatches = countRecallTokenOverlap(queryTokens, eligibleNodeTags.join(" "));
|
|
70
159
|
if (tagMatches > 0) {
|
|
71
160
|
score += tagMatches * 2;
|
|
72
161
|
matchedFields.push("anchorTags");
|
|
@@ -75,7 +164,7 @@ function scoreAnchor(anchor, queryTokens) {
|
|
|
75
164
|
}
|
|
76
165
|
async function readAbstractionNodes(options) {
|
|
77
166
|
const rootDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);
|
|
78
|
-
const files = await
|
|
167
|
+
const files = await listJsonFilesStrict(path.join(rootDir, "nodes"), { allowMissingDirectory: true });
|
|
79
168
|
const nodes = [];
|
|
80
169
|
for (const filePath of files) {
|
|
81
170
|
try {
|
|
@@ -88,7 +177,7 @@ async function readAbstractionNodes(options) {
|
|
|
88
177
|
async function readCueAnchors(options) {
|
|
89
178
|
const abstractionRoot = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);
|
|
90
179
|
const rootDir = resolveCueAnchorStoreDir(abstractionRoot);
|
|
91
|
-
const files = await
|
|
180
|
+
const files = await listJsonFilesStrict(rootDir, { allowMissingDirectory: true });
|
|
92
181
|
const anchors = [];
|
|
93
182
|
for (const filePath of files) {
|
|
94
183
|
try {
|
|
@@ -103,8 +192,25 @@ async function searchHarmonicRetrieval(options) {
|
|
|
103
192
|
const queryTokens = new Set(normalizeRecallTokens(options.query, ["what", "which"]));
|
|
104
193
|
if (queryTokens.size === 0 || options.maxResults <= 0) return [];
|
|
105
194
|
const nodes = await readAbstractionNodes(options);
|
|
195
|
+
const sourceBackedNodes = nodes.filter((node) => (node.sourceMemoryIds?.length ?? 0) > 0);
|
|
196
|
+
const sourceMemories = sourceBackedNodes.length > 0 ? await readSourceMemories(options) : /* @__PURE__ */ new Map();
|
|
197
|
+
const legacyCompatibleNodeRefs = /* @__PURE__ */ new Set();
|
|
198
|
+
const nowMs = Date.now();
|
|
199
|
+
const eligibleNodes = nodes.flatMap((node) => {
|
|
200
|
+
const projected = projectSourceBackedNode(
|
|
201
|
+
node,
|
|
202
|
+
sourceMemories,
|
|
203
|
+
options.memoryDir,
|
|
204
|
+
options.temporalExpiredInInjection === true,
|
|
205
|
+
nowMs
|
|
206
|
+
);
|
|
207
|
+
if (projected && (node.sourceMemoryIds?.length ?? 0) > 0 && projected.sourceMemoryIds?.length === node.sourceMemoryIds?.length) {
|
|
208
|
+
legacyCompatibleNodeRefs.add(node.nodeId);
|
|
209
|
+
}
|
|
210
|
+
return projected ? [projected] : [];
|
|
211
|
+
});
|
|
106
212
|
const candidates = /* @__PURE__ */ new Map();
|
|
107
|
-
for (const node of
|
|
213
|
+
for (const node of eligibleNodes) {
|
|
108
214
|
throwIfAborted(options.abortSignal, "harmonic retrieval aborted");
|
|
109
215
|
const { score, matchedFields } = scoreNode(node, queryTokens);
|
|
110
216
|
if (score <= 0) continue;
|
|
@@ -119,12 +225,18 @@ async function searchHarmonicRetrieval(options) {
|
|
|
119
225
|
if (options.anchorsEnabled) {
|
|
120
226
|
throwIfAborted(options.abortSignal, "harmonic retrieval aborted");
|
|
121
227
|
const anchors = await readCueAnchors(options);
|
|
122
|
-
const nodeIndex = new Map(
|
|
228
|
+
const nodeIndex = new Map(eligibleNodes.map((node) => [node.nodeId, node]));
|
|
123
229
|
for (const anchor of anchors) {
|
|
124
230
|
throwIfAborted(options.abortSignal, "harmonic retrieval aborted");
|
|
125
|
-
const
|
|
231
|
+
const eligibleNodeRefs = anchor.nodeRefs.filter((nodeRef) => {
|
|
232
|
+
const node = nodeIndex.get(nodeRef);
|
|
233
|
+
return node !== void 0 && anchorMatchesProjectedNode(anchor, nodeRef, node, legacyCompatibleNodeRefs.has(nodeRef));
|
|
234
|
+
});
|
|
235
|
+
const eligibleNodeTags = new Set(eligibleNodeRefs.flatMap((nodeRef) => nodeIndex.get(nodeRef)?.tags ?? []));
|
|
236
|
+
const eligibleAnchorTags = anchor.tags?.filter((tag) => eligibleNodeTags.has(tag)) ?? [];
|
|
237
|
+
const { score, matchedFields } = scoreAnchor(anchor, queryTokens, eligibleAnchorTags);
|
|
126
238
|
if (score <= 0) continue;
|
|
127
|
-
for (const nodeRef of
|
|
239
|
+
for (const nodeRef of eligibleNodeRefs) {
|
|
128
240
|
const node = nodeIndex.get(nodeRef);
|
|
129
241
|
if (!node) continue;
|
|
130
242
|
const existing = candidates.get(nodeRef) ?? {
|
|
@@ -167,4 +279,4 @@ async function searchHarmonicRetrieval(options) {
|
|
|
167
279
|
export {
|
|
168
280
|
searchHarmonicRetrieval
|
|
169
281
|
};
|
|
170
|
-
//# sourceMappingURL=chunk-
|
|
282
|
+
//# sourceMappingURL=chunk-P4QOYG52.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/harmonic-retrieval.ts"],"sourcesContent":["import path from \"node:path\";\nimport { listJsonFilesStrict, readJsonFile } from \"./json-store.js\";\nimport { throwIfAborted } from \"./abort-error.js\";\nimport { inferMemoryStatus, toMemoryPathRel } from \"./memory-lifecycle-ledger-utils.js\";\n import {\n HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY,\n resolveAbstractionNodeStoreDir,\n validateAbstractionNode,\n type AbstractionNode,\n } from \"./abstraction-nodes.js\";\nimport { resolveCueAnchorStoreDir, validateCueAnchor, type CueAnchor, type CueAnchorType } from \"./cue-anchors.js\";\nimport { compareDeterministicStrings } from \"./deterministic-order.js\";\nimport { countRecallTokenOverlap, normalizeRecallTokens } from \"./recall-tokenization.js\";\nimport { stripAttributesSuffix } from \"./structured-attributes.js\";\nimport { isValidityExpiredNow } from \"./temporal-validity.js\";\nimport type { MemoryFile } from \"./types.js\";\n\ntype SourceMemoryMap = Map<string, MemoryFile>;\n\nasync function readSourceMemories(options: {\n memoryDir: string;\n abortSignal?: AbortSignal;\n}): Promise<SourceMemoryMap> {\n const sourceMemories: SourceMemoryMap = new Map();\n try {\n const { StorageManager } = await import(\"./storage.js\");\n const storage = new StorageManager(options.memoryDir);\n const [hotMemories, coldMemories] = await Promise.all([\n storage.readAllMemories({ abortSignal: options.abortSignal }),\n storage.readAllColdMemories(),\n ]);\n for (const memory of [...hotMemories, ...coldMemories]) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n sourceMemories.set(memory.frontmatter.id, memory);\n }\n } catch {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n // Source validation fails closed when the authorized memory directory is\n // unreadable. Source-less nodes remain eligible for retrieval.\n sourceMemories.clear();\n }\n return sourceMemories;\n}\n\nfunction projectSourceBackedNode(\n node: AbstractionNode,\n sourceMemories: SourceMemoryMap,\n memoryDir: string,\n temporalExpiredInInjection: boolean,\n nowMs: number\n): AbstractionNode | null {\n const sourceMemoryIds = node.sourceMemoryIds ?? [];\n if (sourceMemoryIds.length === 0) return node;\n\n const activeSourceMemoryIds = sourceMemoryIds.filter((memoryId) => {\n const memory = sourceMemories.get(memoryId);\n return (\n memory !== undefined &&\n inferMemoryStatus(memory.frontmatter, toMemoryPathRel(memoryDir, memory.path)) === \"active\" &&\n (temporalExpiredInInjection || !isValidityExpiredNow(memory.frontmatter, nowMs))\n );\n });\n if (activeSourceMemoryIds.length === 0) return null;\n\n const activeMemories = activeSourceMemoryIds.flatMap((memoryId) => {\n const memory = sourceMemories.get(memoryId);\n return memory ? [memory] : [];\n });\n const activeContents = activeMemories.map((memory) =>\n memory.frontmatter.structuredAttributes ? stripAttributesSuffix(memory.content) : memory.content\n );\n let metadata: Record<string, string> | undefined;\n const insertedAtRaw = node.metadata?.[HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY];\n if (insertedAtRaw) {\n try {\n const insertedAt = JSON.parse(insertedAtRaw) as Record<string, unknown>;\n const activeInsertedAt = activeSourceMemoryIds.flatMap((memoryId) => {\n const value = insertedAt[memoryId];\n return typeof value === \"string\" ? [[memoryId, value] as const] : [];\n });\n if (activeInsertedAt.length > 0) {\n metadata = {\n [HARMONIC_SOURCE_MEMORY_INSERTED_AT_KEY]: JSON.stringify(Object.fromEntries(activeInsertedAt)),\n };\n }\n } catch {\n metadata = undefined;\n }\n }\n\n return {\n ...node,\n sourceMemoryIds: activeSourceMemoryIds,\n title: activeContents[0]?.slice(0, 80) ?? node.title,\n summary: activeContents.slice(0, 3).join(\"; \").slice(0, 400),\n tags: [...new Set(activeMemories.flatMap((memory) => memory.frontmatter.tags))].sort(compareDeterministicStrings),\n entityRefs: [\n ...new Set(\n activeMemories.flatMap((memory) =>\n typeof memory.frontmatter.entityRef === \"string\" ? [memory.frontmatter.entityRef] : []\n )\n ),\n ].sort(compareDeterministicStrings),\n metadata,\n };\n}\n\nfunction anchorMatchesProjectedNode(\n anchor: CueAnchor,\n nodeRef: string,\n node: AbstractionNode,\n allowLegacyAttribution: boolean\n): boolean {\n const activeSourceMemoryIds = node.sourceMemoryIds ?? [];\n if (activeSourceMemoryIds.length === 0) return true;\n if (!anchor.sourceMemoryIdsByNodeRef) return allowLegacyAttribution;\n const anchorSourceMemoryIds = anchor.sourceMemoryIdsByNodeRef[nodeRef] ?? [];\n return anchorSourceMemoryIds.some((sourceMemoryId) => activeSourceMemoryIds.includes(sourceMemoryId));\n}\n\nexport interface HarmonicMatchedAnchor {\n anchorId: string;\n anchorType: CueAnchorType;\n anchorValue: string;\n}\n\nexport interface HarmonicRetrievalResult {\n node: AbstractionNode;\n score: number;\n nodeScore: number;\n anchorScore: number;\n matchedFields: string[];\n matchedAnchors: HarmonicMatchedAnchor[];\n}\n\ninterface HarmonicCandidate {\n node: AbstractionNode;\n nodeScore: number;\n anchorScore: number;\n matchedFields: Set<string>;\n matchedAnchors: Map<string, HarmonicMatchedAnchor>;\n}\n\nfunction scoreNode(node: AbstractionNode, queryTokens: Set<string>): { score: number; matchedFields: string[] } {\n const matchedFields: string[] = [];\n let score = 0;\n\n const titleMatches = countRecallTokenOverlap(queryTokens, node.title);\n if (titleMatches > 0) {\n score += titleMatches * 3;\n matchedFields.push(\"title\");\n }\n\n const summaryMatches = countRecallTokenOverlap(queryTokens, node.summary);\n if (summaryMatches > 0) {\n score += summaryMatches * 3;\n matchedFields.push(\"summary\");\n }\n\n const tagMatches = countRecallTokenOverlap(queryTokens, node.tags?.join(\" \"));\n if (tagMatches > 0) {\n score += tagMatches * 2;\n matchedFields.push(\"tags\");\n }\n\n const entityMatches = countRecallTokenOverlap(queryTokens, node.entityRefs?.join(\" \"));\n if (entityMatches > 0) {\n score += entityMatches * 2;\n matchedFields.push(\"entityRefs\");\n }\n\n const kindMatches = countRecallTokenOverlap(queryTokens, `${node.kind} ${node.abstractionLevel}`);\n if (kindMatches > 0) {\n score += kindMatches;\n matchedFields.push(\"kind\");\n }\n\n return { score, matchedFields };\n}\n\nfunction scoreAnchor(\n anchor: CueAnchor,\n queryTokens: Set<string>,\n eligibleNodeTags: readonly string[]\n): { score: number; matchedFields: string[] } {\n const matchedFields: string[] = [];\n let score = 0;\n\n const valueMatches = countRecallTokenOverlap(queryTokens, anchor.anchorValue);\n const normalizedMatches = countRecallTokenOverlap(queryTokens, anchor.normalizedCue);\n const cueMatches = Math.max(valueMatches, normalizedMatches);\n if (cueMatches > 0) {\n score += cueMatches * 4;\n if (valueMatches > 0) matchedFields.push(\"anchorValue\");\n if (normalizedMatches > 0) matchedFields.push(\"anchor\");\n }\n\n const typeMatches = countRecallTokenOverlap(queryTokens, anchor.anchorType);\n if (typeMatches > 0) {\n score += typeMatches;\n matchedFields.push(\"anchorType\");\n }\n\n const tagMatches = countRecallTokenOverlap(queryTokens, eligibleNodeTags.join(\" \"));\n if (tagMatches > 0) {\n score += tagMatches * 2;\n matchedFields.push(\"anchorTags\");\n }\n\n return { score, matchedFields };\n}\n\nasync function readAbstractionNodes(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n}): Promise<AbstractionNode[]> {\n const rootDir = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const files = await listJsonFilesStrict(path.join(rootDir, \"nodes\"), { allowMissingDirectory: true });\n const nodes: AbstractionNode[] = [];\n for (const filePath of files) {\n try {\n nodes.push(validateAbstractionNode(await readJsonFile(filePath)));\n } catch {\n // fail-open: invalid artifacts stay visible via status tooling instead of recall\n }\n }\n return nodes;\n}\n\nasync function readCueAnchors(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n}): Promise<CueAnchor[]> {\n const abstractionRoot = resolveAbstractionNodeStoreDir(options.memoryDir, options.abstractionNodeStoreDir);\n const rootDir = resolveCueAnchorStoreDir(abstractionRoot);\n const files = await listJsonFilesStrict(rootDir, { allowMissingDirectory: true });\n const anchors: CueAnchor[] = [];\n for (const filePath of files) {\n try {\n anchors.push(validateCueAnchor(await readJsonFile(filePath)));\n } catch {\n // fail-open: invalid artifacts stay visible via status tooling instead of recall\n }\n }\n return anchors;\n}\n\nexport async function searchHarmonicRetrieval(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n query: string;\n maxResults: number;\n sessionKey?: string;\n anchorsEnabled: boolean;\n abortSignal?: AbortSignal;\n temporalExpiredInInjection?: boolean;\n}): Promise<HarmonicRetrievalResult[]> {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const queryTokens = new Set(normalizeRecallTokens(options.query, [\"what\", \"which\"]));\n if (queryTokens.size === 0 || options.maxResults <= 0) return [];\n\n const nodes = await readAbstractionNodes(options);\n const sourceBackedNodes = nodes.filter((node) => (node.sourceMemoryIds?.length ?? 0) > 0);\n const sourceMemories: SourceMemoryMap =\n sourceBackedNodes.length > 0 ? await readSourceMemories(options) : new Map<string, MemoryFile>();\n const legacyCompatibleNodeRefs = new Set<string>();\n const nowMs = Date.now();\n const eligibleNodes = nodes.flatMap((node) => {\n const projected = projectSourceBackedNode(\n node,\n sourceMemories,\n options.memoryDir,\n options.temporalExpiredInInjection === true,\n nowMs\n );\n if (\n projected &&\n (node.sourceMemoryIds?.length ?? 0) > 0 &&\n projected.sourceMemoryIds?.length === node.sourceMemoryIds?.length\n ) {\n legacyCompatibleNodeRefs.add(node.nodeId);\n }\n return projected ? [projected] : [];\n });\n const candidates = new Map<string, HarmonicCandidate>();\n\n for (const node of eligibleNodes) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const { score, matchedFields } = scoreNode(node, queryTokens);\n if (score <= 0) continue;\n candidates.set(node.nodeId, {\n node,\n nodeScore: score,\n anchorScore: 0,\n matchedFields: new Set(matchedFields),\n matchedAnchors: new Map(),\n });\n }\n\n if (options.anchorsEnabled) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const anchors = await readCueAnchors(options);\n const nodeIndex = new Map(eligibleNodes.map((node) => [node.nodeId, node]));\n for (const anchor of anchors) {\n throwIfAborted(options.abortSignal, \"harmonic retrieval aborted\");\n const eligibleNodeRefs = anchor.nodeRefs.filter((nodeRef) => {\n const node = nodeIndex.get(nodeRef);\n return (\n node !== undefined &&\n anchorMatchesProjectedNode(anchor, nodeRef, node, legacyCompatibleNodeRefs.has(nodeRef))\n );\n });\n const eligibleNodeTags = new Set(eligibleNodeRefs.flatMap((nodeRef) => nodeIndex.get(nodeRef)?.tags ?? []));\n const eligibleAnchorTags = anchor.tags?.filter((tag) => eligibleNodeTags.has(tag)) ?? [];\n const { score, matchedFields } = scoreAnchor(anchor, queryTokens, eligibleAnchorTags);\n if (score <= 0) continue;\n for (const nodeRef of eligibleNodeRefs) {\n const node = nodeIndex.get(nodeRef);\n if (!node) continue;\n const existing = candidates.get(nodeRef) ?? {\n node,\n nodeScore: 0,\n anchorScore: 0,\n matchedFields: new Set<string>(),\n matchedAnchors: new Map<string, HarmonicMatchedAnchor>(),\n };\n existing.anchorScore += score;\n existing.matchedFields.add(\"anchor\");\n for (const field of matchedFields) existing.matchedFields.add(field);\n existing.matchedAnchors.set(anchor.anchorId, {\n anchorId: anchor.anchorId,\n anchorType: anchor.anchorType,\n anchorValue: anchor.anchorValue,\n });\n candidates.set(nodeRef, existing);\n }\n }\n }\n\n return [...candidates.values()]\n .map((candidate) => {\n let score = candidate.nodeScore + candidate.anchorScore;\n if (options.sessionKey && candidate.node.sessionKey === options.sessionKey) score += 0.5;\n return {\n node: candidate.node,\n score,\n nodeScore: candidate.nodeScore,\n anchorScore: candidate.anchorScore,\n matchedFields: [...candidate.matchedFields].sort(),\n matchedAnchors: [...candidate.matchedAnchors.values()].sort(\n (left, right) =>\n left.anchorType.localeCompare(right.anchorType) || left.anchorValue.localeCompare(right.anchorValue)\n ),\n };\n })\n .filter((result) => result.nodeScore > 0 || result.anchorScore > 0)\n .sort(\n (left, right) =>\n right.score - left.score ||\n right.anchorScore - left.anchorScore ||\n right.node.recordedAt.localeCompare(left.node.recordedAt)\n )\n .slice(0, options.maxResults);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAmBjB,eAAe,mBAAmB,SAGL;AAC3B,QAAM,iBAAkC,oBAAI,IAAI;AACjD,MAAI;AACJ,UAAM,EAAE,eAAe,IAAI,MAAM,OAAO,cAAc;AACtD,UAAM,UAAU,IAAI,eAAe,QAAQ,S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,QACrD,CAAC,MAAM,UACL,KAAK,WAAW,cAAc,MAAM,UAAU,KAAK,KAAK,YAAY,cAAc,MAAM,WAAW;AAAA,MACvG;AAAA,IACF;AAAA,EACF,CAAC,EACA,OAAO,CAAC,WAAW,OAAO,YAAY,KAAK,OAAO,cAAc,CAAC,EACjE;AAAA,IACC,CAAC,MAAM,UACL,MAAM,QAAQ,KAAK,SACnB,MAAM,cAAc,KAAK,eACzB,MAAM,KAAK,WAAW,cAAc,KAAK,KAAK,UAAU;AAAA,EAC5D,EACC,MAAM,GAAG,QAAQ,UAAU;AAChC;","names":[]}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// src/json-store.ts
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
|
+
import {
|
|
4
|
+
lstat,
|
|
5
|
+
mkdir,
|
|
6
|
+
open,
|
|
7
|
+
readFile,
|
|
8
|
+
readdir,
|
|
9
|
+
rename,
|
|
10
|
+
unlink,
|
|
11
|
+
utimes,
|
|
12
|
+
writeFile
|
|
13
|
+
} from "fs/promises";
|
|
14
|
+
import path from "path";
|
|
15
|
+
function hasErrorCode(error, code) {
|
|
16
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
17
|
+
}
|
|
18
|
+
async function listJsonFilesStrictInner(dir, allowMissingDirectory) {
|
|
19
|
+
let entries;
|
|
20
|
+
try {
|
|
21
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
if (allowMissingDirectory && hasErrorCode(error, "ENOENT")) return [];
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const entry of entries) {
|
|
28
|
+
const fullPath = path.join(dir, entry.name);
|
|
29
|
+
if (entry.isDirectory()) {
|
|
30
|
+
out.push(...await listJsonFilesStrictInner(fullPath, false));
|
|
31
|
+
} else if (entry.isFile() && entry.name.endsWith(".json")) {
|
|
32
|
+
out.push(fullPath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return out.sort();
|
|
36
|
+
}
|
|
37
|
+
async function listJsonFilesStrict(dir, options = {}) {
|
|
38
|
+
return listJsonFilesStrictInner(dir, options.allowMissingDirectory === true);
|
|
39
|
+
}
|
|
40
|
+
async function listJsonFiles(dir) {
|
|
41
|
+
try {
|
|
42
|
+
return await listJsonFilesStrict(dir);
|
|
43
|
+
} catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function listNamedFiles(dir, fileName) {
|
|
48
|
+
try {
|
|
49
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
50
|
+
const out = [];
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const fullPath = path.join(dir, entry.name);
|
|
53
|
+
if (entry.isDirectory()) {
|
|
54
|
+
out.push(...await listNamedFiles(fullPath, fileName));
|
|
55
|
+
} else if (entry.isFile() && entry.name === fileName) {
|
|
56
|
+
out.push(fullPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out.sort();
|
|
60
|
+
} catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
var jsonStoreMutationTails = /* @__PURE__ */ new Map();
|
|
65
|
+
var JSON_STORE_LOCK_RETRY_MS = 25;
|
|
66
|
+
var JSON_STORE_LOCK_STALE_MS = 6e4;
|
|
67
|
+
var JSON_STORE_LOCK_TIMEOUT_MS = 1e4;
|
|
68
|
+
var jsonStoreMutationLockTestHooks = null;
|
|
69
|
+
function setJsonStoreMutationLockTestHooks(hooks) {
|
|
70
|
+
jsonStoreMutationLockTestHooks = hooks;
|
|
71
|
+
}
|
|
72
|
+
function jsonStoreLockRetryMs() {
|
|
73
|
+
return jsonStoreMutationLockTestHooks?.retryMs ?? JSON_STORE_LOCK_RETRY_MS;
|
|
74
|
+
}
|
|
75
|
+
function jsonStoreLockStaleMs() {
|
|
76
|
+
return jsonStoreMutationLockTestHooks?.staleLockMs ?? JSON_STORE_LOCK_STALE_MS;
|
|
77
|
+
}
|
|
78
|
+
function jsonStoreLockTimeoutMs() {
|
|
79
|
+
return jsonStoreMutationLockTestHooks?.timeoutMs ?? JSON_STORE_LOCK_TIMEOUT_MS;
|
|
80
|
+
}
|
|
81
|
+
async function closeAndRemoveJsonStoreReclaimGuard(reclaimPath, reclaimHandle) {
|
|
82
|
+
await reclaimHandle.close().catch(() => void 0);
|
|
83
|
+
await unlink(reclaimPath).catch((error) => {
|
|
84
|
+
if (!hasErrorCode(error, "ENOENT")) throw error;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async function removeStaleJsonStoreReclaimGuard(reclaimPath) {
|
|
88
|
+
let initial;
|
|
89
|
+
try {
|
|
90
|
+
initial = await readJsonStoreLockState(reclaimPath);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (hasErrorCode(error, "ENOENT")) return;
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
if (Date.now() - initial.mtimeMs <= jsonStoreLockStaleMs()) return;
|
|
96
|
+
let ownerPid;
|
|
97
|
+
try {
|
|
98
|
+
const metadata = JSON.parse(initial.content);
|
|
99
|
+
ownerPid = typeof metadata.pid === "number" && Number.isInteger(metadata.pid) ? metadata.pid : void 0;
|
|
100
|
+
} catch {
|
|
101
|
+
ownerPid = void 0;
|
|
102
|
+
}
|
|
103
|
+
if (ownerPid !== void 0 && processIsRunning(ownerPid)) return;
|
|
104
|
+
let confirmed;
|
|
105
|
+
try {
|
|
106
|
+
confirmed = await readJsonStoreLockState(reclaimPath);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (hasErrorCode(error, "ENOENT")) return;
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
if (!sameJsonStoreLockState(initial, confirmed)) return;
|
|
112
|
+
await unlink(reclaimPath).catch((error) => {
|
|
113
|
+
if (!hasErrorCode(error, "ENOENT")) throw error;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async function acquireJsonStoreReclaimGuard(reclaimPath) {
|
|
117
|
+
try {
|
|
118
|
+
return await open(reclaimPath, "wx", 384);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (!hasErrorCode(error, "EEXIST")) throw error;
|
|
121
|
+
await removeStaleJsonStoreReclaimGuard(reclaimPath);
|
|
122
|
+
try {
|
|
123
|
+
return await open(reclaimPath, "wx", 384);
|
|
124
|
+
} catch (retryError) {
|
|
125
|
+
if (hasErrorCode(retryError, "EEXIST")) return void 0;
|
|
126
|
+
throw retryError;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function waitForJsonStoreLock() {
|
|
131
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
132
|
+
setTimeout(resolve, jsonStoreLockRetryMs());
|
|
133
|
+
return promise;
|
|
134
|
+
}
|
|
135
|
+
function processIsRunning(pid) {
|
|
136
|
+
try {
|
|
137
|
+
process.kill(pid, 0);
|
|
138
|
+
return true;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return !hasErrorCode(error, "ESRCH");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function readJsonStoreLockState(lockPath) {
|
|
144
|
+
const lockStat = await lstat(lockPath);
|
|
145
|
+
if (!lockStat.isFile()) {
|
|
146
|
+
throw new Error(`JSON store mutation lock is not a regular file: ${lockPath}`);
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
mtimeMs: lockStat.mtimeMs,
|
|
150
|
+
size: lockStat.size,
|
|
151
|
+
ino: typeof lockStat.ino === "number" ? lockStat.ino : void 0,
|
|
152
|
+
content: await readFile(lockPath, "utf8")
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function sameJsonStoreLockState(left, right) {
|
|
156
|
+
return left.mtimeMs === right.mtimeMs && left.size === right.size && left.ino === right.ino && left.content === right.content;
|
|
157
|
+
}
|
|
158
|
+
async function removeJsonStoreMutationLockIfOwned(lockPath, token) {
|
|
159
|
+
try {
|
|
160
|
+
const state = await readJsonStoreLockState(lockPath);
|
|
161
|
+
const metadata = JSON.parse(state.content);
|
|
162
|
+
if (metadata.token === token) await unlink(lockPath);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (!hasErrorCode(error, "ENOENT") && !(error instanceof SyntaxError)) throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async function removeStaleJsonStoreLock(lockPath) {
|
|
168
|
+
const reclaimPath = `${lockPath}.reclaim`;
|
|
169
|
+
const reclaimHandle = await acquireJsonStoreReclaimGuard(reclaimPath);
|
|
170
|
+
if (!reclaimHandle) return;
|
|
171
|
+
try {
|
|
172
|
+
await reclaimHandle.writeFile(JSON.stringify({ pid: process.pid }), "utf8");
|
|
173
|
+
await jsonStoreMutationLockTestHooks?.afterReclaimGuardWrite?.(reclaimPath, String(process.pid));
|
|
174
|
+
let initial;
|
|
175
|
+
try {
|
|
176
|
+
initial = await readJsonStoreLockState(lockPath);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (hasErrorCode(error, "ENOENT")) return;
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
if (Date.now() - initial.mtimeMs <= jsonStoreLockStaleMs()) return;
|
|
182
|
+
let ownerPid;
|
|
183
|
+
try {
|
|
184
|
+
const metadata = JSON.parse(initial.content);
|
|
185
|
+
ownerPid = typeof metadata.pid === "number" && Number.isInteger(metadata.pid) ? metadata.pid : void 0;
|
|
186
|
+
} catch {
|
|
187
|
+
ownerPid = void 0;
|
|
188
|
+
}
|
|
189
|
+
if (ownerPid !== void 0 && processIsRunning(ownerPid)) return;
|
|
190
|
+
let confirmed;
|
|
191
|
+
try {
|
|
192
|
+
confirmed = await readJsonStoreLockState(lockPath);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if (hasErrorCode(error, "ENOENT")) return;
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
if (!sameJsonStoreLockState(initial, confirmed)) return;
|
|
198
|
+
await unlink(lockPath).catch((error) => {
|
|
199
|
+
if (!hasErrorCode(error, "ENOENT")) throw error;
|
|
200
|
+
});
|
|
201
|
+
} finally {
|
|
202
|
+
await closeAndRemoveJsonStoreReclaimGuard(reclaimPath, reclaimHandle);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function confirmJsonStoreMutationLockOwnership(lockPath, token, deadline) {
|
|
206
|
+
const reclaimPath = `${lockPath}.reclaim`;
|
|
207
|
+
while (true) {
|
|
208
|
+
const reclaimHandle = await acquireJsonStoreReclaimGuard(reclaimPath);
|
|
209
|
+
if (!reclaimHandle) {
|
|
210
|
+
if (Date.now() >= deadline) return false;
|
|
211
|
+
await waitForJsonStoreLock();
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
try {
|
|
216
|
+
const state = await readJsonStoreLockState(lockPath);
|
|
217
|
+
const metadata = JSON.parse(state.content);
|
|
218
|
+
return metadata.token === token;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
if (hasErrorCode(error, "ENOENT") || error instanceof SyntaxError) return false;
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
} finally {
|
|
224
|
+
await closeAndRemoveJsonStoreReclaimGuard(reclaimPath, reclaimHandle);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function acquireJsonStoreMutationFileLock(key) {
|
|
229
|
+
const lockPath = `${path.resolve(key)}.mutation.lock`;
|
|
230
|
+
await mkdir(path.dirname(lockPath), { recursive: true });
|
|
231
|
+
const token = randomUUID();
|
|
232
|
+
const deadline = Date.now() + jsonStoreLockTimeoutMs();
|
|
233
|
+
while (true) {
|
|
234
|
+
let handle;
|
|
235
|
+
try {
|
|
236
|
+
handle = await open(lockPath, "wx", 384);
|
|
237
|
+
} catch (error) {
|
|
238
|
+
if (!hasErrorCode(error, "EEXIST")) throw error;
|
|
239
|
+
await removeStaleJsonStoreLock(lockPath).catch((staleError) => {
|
|
240
|
+
if (!hasErrorCode(staleError, "ENOENT")) throw staleError;
|
|
241
|
+
});
|
|
242
|
+
if (Date.now() >= deadline) {
|
|
243
|
+
throw new Error(`Timed out acquiring JSON store mutation lock: ${lockPath}`);
|
|
244
|
+
}
|
|
245
|
+
await waitForJsonStoreLock();
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
await jsonStoreMutationLockTestHooks?.beforeLockOwnerWrite?.(lockPath, token);
|
|
250
|
+
await handle.writeFile(JSON.stringify({ pid: process.pid, token }), "utf8");
|
|
251
|
+
} finally {
|
|
252
|
+
await handle.close().catch(() => void 0);
|
|
253
|
+
}
|
|
254
|
+
await jsonStoreMutationLockTestHooks?.beforeLockOwnershipConfirm?.(lockPath, token);
|
|
255
|
+
if (!await confirmJsonStoreMutationLockOwnership(lockPath, token, deadline)) {
|
|
256
|
+
await removeJsonStoreMutationLockIfOwned(lockPath, token);
|
|
257
|
+
if (Date.now() >= deadline) {
|
|
258
|
+
throw new Error(`Timed out acquiring JSON store mutation lock: ${lockPath}`);
|
|
259
|
+
}
|
|
260
|
+
await waitForJsonStoreLock();
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const heartbeat = setInterval(
|
|
264
|
+
() => {
|
|
265
|
+
void readFile(lockPath, "utf8").then((content) => {
|
|
266
|
+
const metadata = JSON.parse(content);
|
|
267
|
+
if (metadata.token !== token) return;
|
|
268
|
+
const now = /* @__PURE__ */ new Date();
|
|
269
|
+
return utimes(lockPath, now, now);
|
|
270
|
+
}).catch(() => void 0);
|
|
271
|
+
},
|
|
272
|
+
Math.max(1, Math.floor(jsonStoreLockStaleMs() / 3))
|
|
273
|
+
);
|
|
274
|
+
heartbeat.unref();
|
|
275
|
+
return async () => {
|
|
276
|
+
clearInterval(heartbeat);
|
|
277
|
+
try {
|
|
278
|
+
const metadata = JSON.parse(await readFile(lockPath, "utf8"));
|
|
279
|
+
if (metadata.token === token) await unlink(lockPath);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (!hasErrorCode(error, "ENOENT")) throw error;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async function withJsonStoreMutationLock(key, operation) {
|
|
287
|
+
const normalizedKey = path.resolve(key);
|
|
288
|
+
const previous = jsonStoreMutationTails.get(normalizedKey) ?? Promise.resolve();
|
|
289
|
+
const { promise: current, resolve: release } = Promise.withResolvers();
|
|
290
|
+
const tail = previous.catch(() => void 0).then(() => current);
|
|
291
|
+
jsonStoreMutationTails.set(normalizedKey, tail);
|
|
292
|
+
await previous.catch(() => void 0);
|
|
293
|
+
let releaseFileLock;
|
|
294
|
+
try {
|
|
295
|
+
releaseFileLock = await acquireJsonStoreMutationFileLock(normalizedKey);
|
|
296
|
+
return await operation();
|
|
297
|
+
} finally {
|
|
298
|
+
try {
|
|
299
|
+
await releaseFileLock?.();
|
|
300
|
+
} finally {
|
|
301
|
+
release();
|
|
302
|
+
if (jsonStoreMutationTails.get(normalizedKey) === tail) {
|
|
303
|
+
jsonStoreMutationTails.delete(normalizedKey);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
async function readJsonFile(filePath) {
|
|
309
|
+
return JSON.parse(await readFile(filePath, "utf8"));
|
|
310
|
+
}
|
|
311
|
+
async function writeJsonFileAtomic(filePath, value) {
|
|
312
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
313
|
+
const tempPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
314
|
+
try {
|
|
315
|
+
await writeFile(tempPath, JSON.stringify(value, null, 2), "utf8");
|
|
316
|
+
await rename(tempPath, filePath);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
await unlink(tempPath).catch(() => void 0);
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export {
|
|
324
|
+
listJsonFilesStrict,
|
|
325
|
+
listJsonFiles,
|
|
326
|
+
listNamedFiles,
|
|
327
|
+
setJsonStoreMutationLockTestHooks,
|
|
328
|
+
withJsonStoreMutationLock,
|
|
329
|
+
readJsonFile,
|
|
330
|
+
writeJsonFileAtomic
|
|
331
|
+
};
|
|
332
|
+
//# sourceMappingURL=chunk-P77QX3ID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/json-store.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { Dirent } from \"node:fs\";\nimport {\n lstat,\n mkdir,\n open,\n readFile,\n readdir,\n rename,\n unlink,\n utimes,\n writeFile,\n type FileHandle,\n} from \"node:fs/promises\";\nimport path from \"node:path\";\n\nfunction hasErrorCode(error: unknown, code: string): boolean {\n return typeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: unknown }).code === code;\n}\n\nasync function listJsonFilesStrictInner(dir: string, allowMissingDirectory: boolean): Promise<string[]> {\n let entries: Dirent[];\n try {\n entries = await readdir(dir, { withFileTypes: true });\n } catch (error) {\n if (allowMissingDirectory && hasErrorCode(error, \"ENOENT\")) return [];\n throw error;\n }\n const out: string[] = [];\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n out.push(...(await listJsonFilesStrictInner(fullPath, false)));\n } else if (entry.isFile() && entry.name.endsWith(\".json\")) {\n out.push(fullPath);\n }\n }\n return out.sort();\n}\n\nexport async function listJsonFilesStrict(\n dir: string,\n options: { allowMissingDirectory?: boolean } = {}\n): Promise<string[]> {\n return listJsonFilesStrictInner(dir, options.allowMissingDirectory === true);\n}\n\nexport async function listJsonFiles(dir: string): Promise<string[]> {\n try {\n return await listJsonFilesStrict(dir);\n } catch {\n return [];\n }\n}\n\nexport async function listNamedFiles(dir: string, fileName: string): Promise<string[]> {\n try {\n const entries = await readdir(dir, { withFileTypes: true });\n const out: string[] = [];\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n out.push(...(await listNamedFiles(fullPath, fileName)));\n } else if (entry.isFile() && entry.name === fileName) {\n out.push(fullPath);\n }\n }\n return out.sort();\n } catch {\n return [];\n }\n}\n\nconst jsonStoreMutationTails = new Map<string, Promise<void>>();\n\nconst JSON_STORE_LOCK_RETRY_MS = 25;\nconst JSON_STORE_LOCK_STALE_MS = 60_000;\nconst JSON_STORE_LOCK_TIMEOUT_MS = 10_000;\n\ntype JsonStoreMutationLockTestHooks = {\n beforeLockOwnerWrite?: (lockPath: string, ownerToken: string) => Promise<void> | void;\n beforeLockOwnershipConfirm?: (lockPath: string, ownerToken: string) => Promise<void> | void;\n afterReclaimGuardWrite?: (reclaimPath: string, ownerToken: string) => Promise<void> | void;\n retryMs?: number;\n staleLockMs?: number;\n timeoutMs?: number;\n};\n\nlet jsonStoreMutationLockTestHooks: JsonStoreMutationLockTestHooks | null = null;\n\nexport function setJsonStoreMutationLockTestHooks(hooks: JsonStoreMutationLockTestHooks | null): void {\n jsonStoreMutationLockTestHooks = hooks;\n}\n\nfunction jsonStoreLockRetryMs(): number {\n return jsonStoreMutationLockTestHooks?.retryMs ?? JSON_STORE_LOCK_RETRY_MS;\n}\n\nfunction jsonStoreLockStaleMs(): number {\n return jsonStoreMutationLockTestHooks?.staleLockMs ?? JSON_STORE_LOCK_STALE_MS;\n}\n\nfunction jsonStoreLockTimeoutMs(): number {\n return jsonStoreMutationLockTestHooks?.timeoutMs ?? JSON_STORE_LOCK_TIMEOUT_MS;\n}\n\nasync function closeAndRemoveJsonStoreReclaimGuard(reclaimPath: string, reclaimHandle: FileHandle): Promise<void> {\n await reclaimHandle.close().catch(() => undefined);\n await unlink(reclaimPath).catch((error) => {\n if (!hasErrorCode(error, \"ENOENT\")) throw error;\n });\n}\n\nasync function removeStaleJsonStoreReclaimGuard(reclaimPath: string): Promise<void> {\n let initial: JsonStoreLockState;\n try {\n initial = await readJsonStoreLockState(reclaimPath);\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (Date.now() - initial.mtimeMs <= jsonStoreLockStaleMs()) return;\n\n let ownerPid: number | undefined;\n try {\n const metadata = JSON.parse(initial.content) as { pid?: unknown };\n ownerPid = typeof metadata.pid === \"number\" && Number.isInteger(metadata.pid) ? metadata.pid : undefined;\n } catch {\n ownerPid = undefined;\n }\n if (ownerPid !== undefined && processIsRunning(ownerPid)) return;\n\n let confirmed: JsonStoreLockState;\n try {\n confirmed = await readJsonStoreLockState(reclaimPath);\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (!sameJsonStoreLockState(initial, confirmed)) return;\n await unlink(reclaimPath).catch((error) => {\n if (!hasErrorCode(error, \"ENOENT\")) throw error;\n });\n}\n\nasync function acquireJsonStoreReclaimGuard(reclaimPath: string): Promise<FileHandle | undefined> {\n try {\n return await open(reclaimPath, \"wx\", 0o600);\n } catch (error) {\n if (!hasErrorCode(error, \"EEXIST\")) throw error;\n await removeStaleJsonStoreReclaimGuard(reclaimPath);\n try {\n return await open(reclaimPath, \"wx\", 0o600);\n } catch (retryError) {\n if (hasErrorCode(retryError, \"EEXIST\")) return undefined;\n throw retryError;\n }\n }\n}\n\nfunction waitForJsonStoreLock(): Promise<void> {\n const { promise, resolve } = Promise.withResolvers<void>();\n setTimeout(resolve, jsonStoreLockRetryMs());\n return promise;\n}\n\nfunction processIsRunning(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return !hasErrorCode(error, \"ESRCH\");\n }\n}\n\ntype JsonStoreLockState = {\n mtimeMs: number;\n size: number;\n ino: number | undefined;\n content: string;\n};\n\nasync function readJsonStoreLockState(lockPath: string): Promise<JsonStoreLockState> {\n const lockStat = await lstat(lockPath);\n if (!lockStat.isFile()) {\n throw new Error(`JSON store mutation lock is not a regular file: ${lockPath}`);\n }\n return {\n mtimeMs: lockStat.mtimeMs,\n size: lockStat.size,\n ino: typeof lockStat.ino === \"number\" ? lockStat.ino : undefined,\n content: await readFile(lockPath, \"utf8\"),\n };\n}\n\nfunction sameJsonStoreLockState(left: JsonStoreLockState, right: JsonStoreLockState): boolean {\n return (\n left.mtimeMs === right.mtimeMs &&\n left.size === right.size &&\n left.ino === right.ino &&\n left.content === right.content\n );\n}\n\nasync function removeJsonStoreMutationLockIfOwned(lockPath: string, token: string): Promise<void> {\n try {\n const state = await readJsonStoreLockState(lockPath);\n const metadata = JSON.parse(state.content) as { token?: unknown };\n if (metadata.token === token) await unlink(lockPath);\n } catch (error) {\n if (!hasErrorCode(error, \"ENOENT\") && !(error instanceof SyntaxError)) throw error;\n }\n}\n\nasync function removeStaleJsonStoreLock(lockPath: string): Promise<void> {\n const reclaimPath = `${lockPath}.reclaim`;\n const reclaimHandle = await acquireJsonStoreReclaimGuard(reclaimPath);\n if (!reclaimHandle) return;\n try {\n await reclaimHandle.writeFile(JSON.stringify({ pid: process.pid }), \"utf8\");\n await jsonStoreMutationLockTestHooks?.afterReclaimGuardWrite?.(reclaimPath, String(process.pid));\n\n let initial: JsonStoreLockState;\n try {\n initial = await readJsonStoreLockState(lockPath);\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (Date.now() - initial.mtimeMs <= jsonStoreLockStaleMs()) return;\n let ownerPid: number | undefined;\n try {\n const metadata = JSON.parse(initial.content) as { pid?: unknown };\n ownerPid = typeof metadata.pid === \"number\" && Number.isInteger(metadata.pid) ? metadata.pid : undefined;\n } catch {\n ownerPid = undefined;\n }\n if (ownerPid !== undefined && processIsRunning(ownerPid)) return;\n\n let confirmed: JsonStoreLockState;\n try {\n confirmed = await readJsonStoreLockState(lockPath);\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) return;\n throw error;\n }\n if (!sameJsonStoreLockState(initial, confirmed)) return;\n await unlink(lockPath).catch((error) => {\n if (!hasErrorCode(error, \"ENOENT\")) throw error;\n });\n } finally {\n await closeAndRemoveJsonStoreReclaimGuard(reclaimPath, reclaimHandle);\n }\n}\n\nasync function confirmJsonStoreMutationLockOwnership(\n lockPath: string,\n token: string,\n deadline: number\n): Promise<boolean> {\n const reclaimPath = `${lockPath}.reclaim`;\n while (true) {\n const reclaimHandle = await acquireJsonStoreReclaimGuard(reclaimPath);\n if (!reclaimHandle) {\n if (Date.now() >= deadline) return false;\n await waitForJsonStoreLock();\n continue;\n }\n try {\n try {\n const state = await readJsonStoreLockState(lockPath);\n const metadata = JSON.parse(state.content) as { token?: unknown };\n return metadata.token === token;\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\") || error instanceof SyntaxError) return false;\n throw error;\n }\n } finally {\n await closeAndRemoveJsonStoreReclaimGuard(reclaimPath, reclaimHandle);\n }\n }\n}\n\nasync function acquireJsonStoreMutationFileLock(key: string): Promise<() => Promise<void>> {\n const lockPath = `${path.resolve(key)}.mutation.lock`;\n await mkdir(path.dirname(lockPath), { recursive: true });\n const token = randomUUID();\n const deadline = Date.now() + jsonStoreLockTimeoutMs();\n while (true) {\n let handle: FileHandle;\n try {\n handle = await open(lockPath, \"wx\", 0o600);\n } catch (error) {\n if (!hasErrorCode(error, \"EEXIST\")) throw error;\n await removeStaleJsonStoreLock(lockPath).catch((staleError) => {\n if (!hasErrorCode(staleError, \"ENOENT\")) throw staleError;\n });\n if (Date.now() >= deadline) {\n throw new Error(`Timed out acquiring JSON store mutation lock: ${lockPath}`);\n }\n await waitForJsonStoreLock();\n continue;\n }\n try {\n await jsonStoreMutationLockTestHooks?.beforeLockOwnerWrite?.(lockPath, token);\n await handle.writeFile(JSON.stringify({ pid: process.pid, token }), \"utf8\");\n } finally {\n await handle.close().catch(() => undefined);\n }\n await jsonStoreMutationLockTestHooks?.beforeLockOwnershipConfirm?.(lockPath, token);\n\n if (!(await confirmJsonStoreMutationLockOwnership(lockPath, token, deadline))) {\n await removeJsonStoreMutationLockIfOwned(lockPath, token);\n if (Date.now() >= deadline) {\n throw new Error(`Timed out acquiring JSON store mutation lock: ${lockPath}`);\n }\n await waitForJsonStoreLock();\n continue;\n }\n\n const heartbeat = setInterval(\n () => {\n void readFile(lockPath, \"utf8\")\n .then((content) => {\n const metadata = JSON.parse(content) as { token?: unknown };\n if (metadata.token !== token) return;\n const now = new Date();\n return utimes(lockPath, now, now);\n })\n .catch(() => undefined);\n },\n Math.max(1, Math.floor(jsonStoreLockStaleMs() / 3))\n );\n heartbeat.unref();\n return async () => {\n clearInterval(heartbeat);\n try {\n const metadata = JSON.parse(await readFile(lockPath, \"utf8\")) as { token?: unknown };\n if (metadata.token === token) await unlink(lockPath);\n } catch (error) {\n if (!hasErrorCode(error, \"ENOENT\")) throw error;\n }\n };\n }\n}\n\nexport async function withJsonStoreMutationLock<T>(key: string, operation: () => Promise<T>): Promise<T> {\n const normalizedKey = path.resolve(key);\n const previous = jsonStoreMutationTails.get(normalizedKey) ?? Promise.resolve();\n const { promise: current, resolve: release } = Promise.withResolvers<void>();\n const tail = previous.catch(() => undefined).then(() => current);\n jsonStoreMutationTails.set(normalizedKey, tail);\n await previous.catch(() => undefined);\n let releaseFileLock: (() => Promise<void>) | undefined;\n try {\n releaseFileLock = await acquireJsonStoreMutationFileLock(normalizedKey);\n return await operation();\n } finally {\n try {\n await releaseFileLock?.();\n } finally {\n release();\n if (jsonStoreMutationTails.get(normalizedKey) === tail) {\n jsonStoreMutationTails.delete(normalizedKey);\n }\n }\n }\n}\n\nexport async function readJsonFile(filePath: string): Promise<unknown> {\n return JSON.parse(await readFile(filePath, \"utf8\")) as unknown;\n}\n\nexport async function writeJsonFileAtomic(filePath: string, value: unknown): Promise<void> {\n await mkdir(path.dirname(filePath), { recursive: true });\n const tempPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`;\n try {\n await writeFile(tempPath, JSON.stringify(value, null, 2), \"utf8\");\n await rename(tempPath, filePath);\n } catch (error) {\n await unlink(tempPath).catch(() => undefined);\n throw error;\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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-3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-SOBJ6NEY.js";
|
|
4
4
|
import {
|
|
5
5
|
summarizeDisclosureTokens
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NSGU76YO.js";
|
|
7
7
|
import {
|
|
8
8
|
summarizeRetrievedMemoryProvenance
|
|
9
9
|
} from "./chunk-I4WBNM3M.js";
|
|
@@ -590,4 +590,4 @@ export {
|
|
|
590
590
|
renderRecallExplain,
|
|
591
591
|
parseRecallExplainFormat
|
|
592
592
|
};
|
|
593
|
-
//# sourceMappingURL=chunk-
|
|
593
|
+
//# sourceMappingURL=chunk-PDEKQWDV.js.map
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
} from "./chunk-M23RF3LJ.js";
|
|
5
5
|
import {
|
|
6
6
|
composeSalvagedEnvelope
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-66SE3BNH.js";
|
|
8
8
|
import {
|
|
9
9
|
StorageManager
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-24BKGKGO.js";
|
|
11
11
|
import {
|
|
12
12
|
parseContinuityImprovementLoops
|
|
13
13
|
} from "./chunk-LDXUBPMO.js";
|
|
@@ -1283,4 +1283,4 @@ export {
|
|
|
1283
1283
|
defaultTierMigrationCycleBudget,
|
|
1284
1284
|
CompoundingEngine
|
|
1285
1285
|
};
|
|
1286
|
-
//# sourceMappingURL=chunk-
|
|
1286
|
+
//# sourceMappingURL=chunk-PLCHU56K.js.map
|