@remnic/core 10.0.52 → 10.0.53
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 +24 -24
- package/dist/access-authorization-probe.js +25 -25
- package/dist/access-boundary.js +24 -24
- package/dist/access-cli.js +65 -65
- package/dist/access-extraction-force-flush.js +24 -24
- package/dist/access-http-briefing.js +25 -25
- package/dist/access-http-query.js +26 -26
- package/dist/access-http.js +40 -40
- package/dist/access-identity-continuity-surface.js +24 -24
- package/dist/access-lcm-surface.js +24 -24
- package/dist/access-mcp.js +33 -33
- package/dist/access-namespace-preflight.js +24 -24
- package/dist/access-observe-write-surface.js +24 -24
- package/dist/access-operations-batch.js +25 -25
- package/dist/access-operations.js +32 -32
- package/dist/access-recall-concurrency.js +24 -24
- package/dist/access-recall-response.js +24 -24
- package/dist/access-recall-surface.js +24 -24
- package/dist/access-service.js +24 -24
- package/dist/access-surface-catalog.js +26 -26
- package/dist/active-recall.js +9 -9
- package/dist/briefing.js +10 -10
- package/dist/buffer.js +5 -5
- package/dist/causal-consolidation.js +11 -11
- package/dist/{chunk-3NL4ALUP.js → chunk-24SIB3EW.js} +3 -3
- package/dist/{chunk-Y3T5KQCR.js → chunk-2EYCW2ET.js} +2 -2
- package/dist/{chunk-AHGOOZUC.js → chunk-34UVJNSG.js} +2 -2
- package/dist/{chunk-2EXF6IIB.js → chunk-3632XJMR.js} +2 -2
- package/dist/{chunk-KETS5A62.js → chunk-3H3PNQEF.js} +2 -2
- package/dist/{chunk-SFRBUBUZ.js → chunk-3LNAQLW4.js} +3 -3
- package/dist/{chunk-75BK4XGV.js → chunk-4BUJICMI.js} +10 -10
- package/dist/{chunk-KIWO4327.js → chunk-4W5B5Z6P.js} +2 -2
- package/dist/{chunk-B35EQQ7L.js → chunk-53OFDW3P.js} +3 -3
- package/dist/{chunk-2ONKXEC7.js → chunk-5LBBXI2A.js} +2 -2
- package/dist/{chunk-UCLJTGP3.js → chunk-65B5RFKQ.js} +2 -2
- package/dist/{chunk-KAJYSO3U.js → chunk-6CDNOREO.js} +2 -2
- package/dist/{chunk-POJRFSJM.js → chunk-7XGNGLAN.js} +2 -2
- package/dist/{chunk-A6JDT6QF.js → chunk-AO5ZOD32.js} +2 -2
- package/dist/{chunk-RA7YRL6H.js → chunk-AOSCGNIC.js} +3 -3
- package/dist/{chunk-LWMLBVGB.js → chunk-B43P3DTC.js} +2 -2
- package/dist/{chunk-UM3ZLT2X.js → chunk-CA6X37OB.js} +31 -28
- package/dist/chunk-CA6X37OB.js.map +1 -0
- package/dist/{chunk-VUMWVYMR.js → chunk-CIMD2MUR.js} +3 -3
- package/dist/{chunk-XRFLR3XF.js → chunk-DLZGSZVC.js} +22 -9
- package/dist/chunk-DLZGSZVC.js.map +1 -0
- package/dist/{chunk-5CWH2LKL.js → chunk-DOJBV6WR.js} +29 -14
- package/dist/chunk-DOJBV6WR.js.map +1 -0
- package/dist/{chunk-44EUCSG4.js → chunk-FFQNNFHX.js} +2 -2
- package/dist/{chunk-HEF4BRMT.js → chunk-FZLZUDJJ.js} +2 -2
- package/dist/{chunk-L3EFYRYK.js → chunk-GGFQAGOT.js} +7 -7
- package/dist/{chunk-ZLCBLDJO.js → chunk-GIRWNTMV.js} +2 -2
- package/dist/{chunk-EC2KVA27.js → chunk-H4DWSOBQ.js} +169 -105
- package/dist/chunk-H4DWSOBQ.js.map +1 -0
- package/dist/{chunk-SHNM7RIT.js → chunk-HJ4X4BGS.js} +2 -2
- package/dist/{chunk-MUNYUSBU.js → chunk-HJQ4NKKO.js} +2 -2
- package/dist/{chunk-V6Z4NAJZ.js → chunk-HM3ZTDAX.js} +2 -2
- package/dist/{chunk-EZS6QJNC.js → chunk-IFOCK3OJ.js} +2 -2
- package/dist/{chunk-LXXIV7Y2.js → chunk-JEX2JL3U.js} +7 -2
- package/dist/{chunk-LXXIV7Y2.js.map → chunk-JEX2JL3U.js.map} +1 -1
- package/dist/{chunk-DF6ZF2BN.js → chunk-LIVNX7WK.js} +2 -2
- package/dist/{chunk-WY66J4PI.js → chunk-LRVFS4KA.js} +2 -2
- package/dist/{chunk-LMB47UM6.js → chunk-LTDK6HBV.js} +2 -2
- package/dist/{chunk-HCIRR3BA.js → chunk-M4U25HLR.js} +2 -2
- package/dist/{chunk-YK7ZJPQM.js → chunk-MGN2RQRG.js} +2 -2
- package/dist/{chunk-G26YNEOC.js → chunk-NWA6IXR3.js} +1 -1
- package/dist/{chunk-G26YNEOC.js.map → chunk-NWA6IXR3.js.map} +1 -1
- package/dist/{chunk-JIJAWTRK.js → chunk-OCXDZJL4.js} +264 -194
- package/dist/chunk-OCXDZJL4.js.map +1 -0
- package/dist/{chunk-IUQXRRJB.js → chunk-OMWQO7H6.js} +2 -2
- package/dist/{chunk-7VO6E5UD.js → chunk-OVZIYLBZ.js} +6 -2
- package/dist/chunk-OVZIYLBZ.js.map +1 -0
- package/dist/{chunk-SPTPBKZX.js → chunk-OWNAWY6D.js} +2 -2
- package/dist/{chunk-XKDQTDXN.js → chunk-PFUXPTBT.js} +36 -15
- package/dist/chunk-PFUXPTBT.js.map +1 -0
- package/dist/{chunk-DQOGZZJA.js → chunk-QAHP5SBG.js} +3 -3
- package/dist/{chunk-GBGU5OZP.js → chunk-QF5EJ5VP.js} +13 -13
- package/dist/{chunk-FT75AQ74.js → chunk-QS5DUSBM.js} +2 -2
- package/dist/{chunk-72CBJ5VP.js → chunk-R3WZ74B2.js} +3 -3
- package/dist/{chunk-PDTNQLPC.js → chunk-RG3I2663.js} +2 -2
- package/dist/{chunk-CK6GCGMX.js → chunk-RTJJPW3C.js} +2 -2
- package/dist/{chunk-RJDYDF5K.js → chunk-TRAOZ2WP.js} +2 -2
- package/dist/{chunk-6ZAU7LAR.js → chunk-TTTPTQ6S.js} +2 -2
- package/dist/{chunk-JS44PBCM.js → chunk-U2A56LLF.js} +6 -6
- package/dist/{chunk-MC7PXJDP.js → chunk-UBOWDOL5.js} +5 -5
- package/dist/{chunk-4FM35YIA.js → chunk-UQYBPPVC.js} +2 -2
- package/dist/{chunk-OCRLJJOV.js → chunk-V4VCBFAL.js} +3 -3
- package/dist/{chunk-FNNGWN3O.js → chunk-VGE4PUY6.js} +2 -2
- package/dist/{chunk-5DVOBBTV.js → chunk-VV73XT3A.js} +2 -2
- package/dist/{chunk-GE3ZX6YK.js → chunk-W7NKMRAF.js} +2 -2
- package/dist/{chunk-AJJPXUE6.js → chunk-WBN66HPI.js} +2 -2
- package/dist/{chunk-XWJUFER3.js → chunk-WGFEGBFB.js} +2 -2
- package/dist/{chunk-43TUWQNR.js → chunk-XDKEHZUC.js} +2 -2
- package/dist/{chunk-ROAKLYOL.js → chunk-XHEKS4UN.js} +2 -2
- package/dist/{chunk-ZKK3VMWU.js → chunk-XVTB6BZS.js} +2 -2
- package/dist/{chunk-AZLD4CKG.js → chunk-Y56D5FSD.js} +17 -17
- package/dist/{chunk-MPWOAIIH.js → chunk-YDT3OEYF.js} +2 -2
- package/dist/{chunk-IN6U2BS5.js → chunk-YJHOVA42.js} +2 -2
- package/dist/{chunk-TC55M5PO.js → chunk-YLN4ZQV4.js} +2 -2
- package/dist/cli.js +50 -50
- package/dist/coding/export-okf-codegraph.js +9 -9
- package/dist/compounding/engine.js +11 -11
- package/dist/config.js +9 -9
- package/dist/connectors/codex-materialize-runner.js +10 -10
- package/dist/connectors/index.js +10 -10
- package/dist/convergence-refresh.js +12 -12
- package/dist/corpus-watermark.js +12 -12
- package/dist/entity-retrieval.js +10 -10
- package/dist/external-wiki-access.js +25 -25
- package/dist/extraction.js +14 -14
- package/dist/harmonic-retrieval.js +10 -10
- package/dist/index.js +65 -65
- package/dist/location/index.js +12 -12
- 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-operations.js +25 -25
- package/dist/memory-browse.js +5 -5
- package/dist/namespaces/migrate.js +11 -11
- package/dist/namespaces/search.d.ts.map +1 -1
- package/dist/namespaces/search.js +8 -8
- package/dist/namespaces/storage.js +10 -10
- package/dist/operator-doctor-corpus.js +13 -13
- package/dist/operator-toolkit.js +18 -18
- package/dist/orchestration/lifecycle-pending-fallback-drain.d.ts +18 -0
- package/dist/orchestration/lifecycle-pending-fallback-drain.d.ts.map +1 -0
- package/dist/orchestration/maintenance.d.ts +11 -13
- package/dist/orchestration/maintenance.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +20 -20
- package/dist/orchestration/qmd-maintenance-completion.d.ts +20 -0
- package/dist/orchestration/qmd-maintenance-completion.d.ts.map +1 -0
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +65 -65
- package/dist/qmd.js +2 -2
- package/dist/recall-composition-decision.js +2 -2
- package/dist/recall-navigation-operations.js +25 -25
- package/dist/recall-navigation.js +24 -24
- package/dist/recall-state-view-admission.js +5 -5
- package/dist/recall-why-service.js +5 -5
- package/dist/resume-bundles.js +9 -9
- package/dist/search/factory.js +7 -7
- package/dist/search/index.js +7 -7
- package/dist/search/lancedb-backend.d.ts +3 -0
- package/dist/search/lancedb-backend.d.ts.map +1 -1
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.d.ts +3 -0
- package/dist/search/meilisearch-backend.d.ts.map +1 -1
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/orama-backend.d.ts +3 -0
- package/dist/search/orama-backend.d.ts.map +1 -1
- package/dist/search/orama-backend.js +2 -2
- package/dist/search/port.d.ts +7 -0
- package/dist/search/port.d.ts.map +1 -1
- package/dist/search/port.js +1 -1
- package/dist/search/remote-backend.d.ts +2 -0
- package/dist/search/remote-backend.d.ts.map +1 -1
- package/dist/search/remote-backend.js +2 -2
- package/dist/semantic-consolidation.js +11 -11
- package/dist/semantic-rule-promotion.js +10 -10
- package/dist/semantic-rule-verifier.js +10 -10
- package/dist/source-agent-qualifier.js +13 -13
- package/dist/standup/build.js +10 -10
- package/dist/storage/entity-canonical-id-migration-adapter.d.ts +7 -1
- package/dist/storage/entity-canonical-id-migration-adapter.d.ts.map +1 -1
- package/dist/storage/entity-migration-maintenance-pending.d.ts +31 -0
- package/dist/storage/entity-migration-maintenance-pending.d.ts.map +1 -0
- package/dist/storage.d.ts +2 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +9 -9
- package/dist/support-passport/index.js +27 -27
- package/dist/transfer/export-okf.js +10 -10
- package/dist/verified-recall.js +10 -10
- package/dist/who-knows-cli.js +11 -11
- package/dist/who-knows.js +10 -10
- package/package.json +2 -2
- package/src/namespaces/search.test.ts +121 -0
- package/src/namespaces/search.ts +8 -0
- package/src/orchestration/lifecycle-pending-fallback-drain.ts +97 -0
- package/src/orchestration/maintenance.test.ts +443 -1
- package/src/orchestration/maintenance.ts +73 -95
- package/src/orchestration/qmd-maintenance-completion.ts +32 -0
- package/src/orchestrator.ts +8 -1
- package/src/search/lancedb-backend.ts +29 -12
- package/src/search/meilisearch-backend.test.ts +148 -0
- package/src/search/meilisearch-backend.ts +41 -14
- package/src/search/orama-backend.test.ts +75 -1
- package/src/search/orama-backend.ts +22 -7
- package/src/search/port.ts +7 -0
- package/src/search/remote-backend.ts +4 -0
- package/src/storage/entity-canonical-id-migration-adapter.ts +44 -9
- package/src/storage/entity-migration-maintenance-pending-helpers.test.ts +87 -0
- package/src/storage/entity-migration-maintenance-pending.test.ts +242 -0
- package/src/storage/entity-migration-maintenance-pending.ts +89 -0
- package/src/storage.ts +2 -2
- package/dist/chunk-5CWH2LKL.js.map +0 -1
- package/dist/chunk-7VO6E5UD.js.map +0 -1
- package/dist/chunk-EC2KVA27.js.map +0 -1
- package/dist/chunk-JIJAWTRK.js.map +0 -1
- package/dist/chunk-UM3ZLT2X.js.map +0 -1
- package/dist/chunk-XKDQTDXN.js.map +0 -1
- package/dist/chunk-XRFLR3XF.js.map +0 -1
- /package/dist/{chunk-3NL4ALUP.js.map → chunk-24SIB3EW.js.map} +0 -0
- /package/dist/{chunk-Y3T5KQCR.js.map → chunk-2EYCW2ET.js.map} +0 -0
- /package/dist/{chunk-AHGOOZUC.js.map → chunk-34UVJNSG.js.map} +0 -0
- /package/dist/{chunk-2EXF6IIB.js.map → chunk-3632XJMR.js.map} +0 -0
- /package/dist/{chunk-KETS5A62.js.map → chunk-3H3PNQEF.js.map} +0 -0
- /package/dist/{chunk-SFRBUBUZ.js.map → chunk-3LNAQLW4.js.map} +0 -0
- /package/dist/{chunk-75BK4XGV.js.map → chunk-4BUJICMI.js.map} +0 -0
- /package/dist/{chunk-KIWO4327.js.map → chunk-4W5B5Z6P.js.map} +0 -0
- /package/dist/{chunk-B35EQQ7L.js.map → chunk-53OFDW3P.js.map} +0 -0
- /package/dist/{chunk-2ONKXEC7.js.map → chunk-5LBBXI2A.js.map} +0 -0
- /package/dist/{chunk-UCLJTGP3.js.map → chunk-65B5RFKQ.js.map} +0 -0
- /package/dist/{chunk-KAJYSO3U.js.map → chunk-6CDNOREO.js.map} +0 -0
- /package/dist/{chunk-POJRFSJM.js.map → chunk-7XGNGLAN.js.map} +0 -0
- /package/dist/{chunk-A6JDT6QF.js.map → chunk-AO5ZOD32.js.map} +0 -0
- /package/dist/{chunk-RA7YRL6H.js.map → chunk-AOSCGNIC.js.map} +0 -0
- /package/dist/{chunk-LWMLBVGB.js.map → chunk-B43P3DTC.js.map} +0 -0
- /package/dist/{chunk-VUMWVYMR.js.map → chunk-CIMD2MUR.js.map} +0 -0
- /package/dist/{chunk-44EUCSG4.js.map → chunk-FFQNNFHX.js.map} +0 -0
- /package/dist/{chunk-HEF4BRMT.js.map → chunk-FZLZUDJJ.js.map} +0 -0
- /package/dist/{chunk-L3EFYRYK.js.map → chunk-GGFQAGOT.js.map} +0 -0
- /package/dist/{chunk-ZLCBLDJO.js.map → chunk-GIRWNTMV.js.map} +0 -0
- /package/dist/{chunk-SHNM7RIT.js.map → chunk-HJ4X4BGS.js.map} +0 -0
- /package/dist/{chunk-MUNYUSBU.js.map → chunk-HJQ4NKKO.js.map} +0 -0
- /package/dist/{chunk-V6Z4NAJZ.js.map → chunk-HM3ZTDAX.js.map} +0 -0
- /package/dist/{chunk-EZS6QJNC.js.map → chunk-IFOCK3OJ.js.map} +0 -0
- /package/dist/{chunk-DF6ZF2BN.js.map → chunk-LIVNX7WK.js.map} +0 -0
- /package/dist/{chunk-WY66J4PI.js.map → chunk-LRVFS4KA.js.map} +0 -0
- /package/dist/{chunk-LMB47UM6.js.map → chunk-LTDK6HBV.js.map} +0 -0
- /package/dist/{chunk-HCIRR3BA.js.map → chunk-M4U25HLR.js.map} +0 -0
- /package/dist/{chunk-YK7ZJPQM.js.map → chunk-MGN2RQRG.js.map} +0 -0
- /package/dist/{chunk-IUQXRRJB.js.map → chunk-OMWQO7H6.js.map} +0 -0
- /package/dist/{chunk-SPTPBKZX.js.map → chunk-OWNAWY6D.js.map} +0 -0
- /package/dist/{chunk-DQOGZZJA.js.map → chunk-QAHP5SBG.js.map} +0 -0
- /package/dist/{chunk-GBGU5OZP.js.map → chunk-QF5EJ5VP.js.map} +0 -0
- /package/dist/{chunk-FT75AQ74.js.map → chunk-QS5DUSBM.js.map} +0 -0
- /package/dist/{chunk-72CBJ5VP.js.map → chunk-R3WZ74B2.js.map} +0 -0
- /package/dist/{chunk-PDTNQLPC.js.map → chunk-RG3I2663.js.map} +0 -0
- /package/dist/{chunk-CK6GCGMX.js.map → chunk-RTJJPW3C.js.map} +0 -0
- /package/dist/{chunk-RJDYDF5K.js.map → chunk-TRAOZ2WP.js.map} +0 -0
- /package/dist/{chunk-6ZAU7LAR.js.map → chunk-TTTPTQ6S.js.map} +0 -0
- /package/dist/{chunk-JS44PBCM.js.map → chunk-U2A56LLF.js.map} +0 -0
- /package/dist/{chunk-MC7PXJDP.js.map → chunk-UBOWDOL5.js.map} +0 -0
- /package/dist/{chunk-4FM35YIA.js.map → chunk-UQYBPPVC.js.map} +0 -0
- /package/dist/{chunk-OCRLJJOV.js.map → chunk-V4VCBFAL.js.map} +0 -0
- /package/dist/{chunk-FNNGWN3O.js.map → chunk-VGE4PUY6.js.map} +0 -0
- /package/dist/{chunk-5DVOBBTV.js.map → chunk-VV73XT3A.js.map} +0 -0
- /package/dist/{chunk-GE3ZX6YK.js.map → chunk-W7NKMRAF.js.map} +0 -0
- /package/dist/{chunk-AJJPXUE6.js.map → chunk-WBN66HPI.js.map} +0 -0
- /package/dist/{chunk-XWJUFER3.js.map → chunk-WGFEGBFB.js.map} +0 -0
- /package/dist/{chunk-43TUWQNR.js.map → chunk-XDKEHZUC.js.map} +0 -0
- /package/dist/{chunk-ROAKLYOL.js.map → chunk-XHEKS4UN.js.map} +0 -0
- /package/dist/{chunk-ZKK3VMWU.js.map → chunk-XVTB6BZS.js.map} +0 -0
- /package/dist/{chunk-AZLD4CKG.js.map → chunk-Y56D5FSD.js.map} +0 -0
- /package/dist/{chunk-MPWOAIIH.js.map → chunk-YDT3OEYF.js.map} +0 -0
- /package/dist/{chunk-IN6U2BS5.js.map → chunk-YJHOVA42.js.map} +0 -0
- /package/dist/{chunk-TC55M5PO.js.map → chunk-YLN4ZQV4.js.map} +0 -0
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
normalizeQmdResultPath,
|
|
25
25
|
resolveNamespaceResultPath
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JEX2JL3U.js";
|
|
27
27
|
import {
|
|
28
28
|
withholdToolScopedFromSharedNamespace
|
|
29
29
|
} from "./chunk-S2V7RUCL.js";
|
|
@@ -287,13 +287,13 @@ import {
|
|
|
287
287
|
// src/storage.ts
|
|
288
288
|
import {
|
|
289
289
|
lstat as lstat5,
|
|
290
|
-
readdir as
|
|
290
|
+
readdir as readdir7,
|
|
291
291
|
readFile,
|
|
292
292
|
realpath as realpath3,
|
|
293
293
|
stat as stat3,
|
|
294
|
-
writeFile,
|
|
294
|
+
writeFile as writeFile2,
|
|
295
295
|
mkdir as mkdir2,
|
|
296
|
-
unlink as
|
|
296
|
+
unlink as unlink5,
|
|
297
297
|
appendFile,
|
|
298
298
|
open
|
|
299
299
|
} from "fs/promises";
|
|
@@ -322,7 +322,7 @@ function parseDriftProvenance(fm) {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
// src/storage.ts
|
|
325
|
-
import
|
|
325
|
+
import path16 from "path";
|
|
326
326
|
|
|
327
327
|
// src/storage/tombstone-migration-sources.ts
|
|
328
328
|
import { statSync } from "fs";
|
|
@@ -2947,17 +2947,75 @@ ${before.content}
|
|
|
2947
2947
|
}
|
|
2948
2948
|
};
|
|
2949
2949
|
|
|
2950
|
+
// src/storage/entity-migration-maintenance-pending.ts
|
|
2951
|
+
import { randomUUID } from "crypto";
|
|
2952
|
+
import { readdir as readdir4, rename, unlink as unlink3, writeFile } from "fs/promises";
|
|
2953
|
+
import path8 from "path";
|
|
2954
|
+
var ENTITY_MIGRATION_MAINTENANCE_PENDING_PREFIX = "entity-canonical-id-maintenance.pending";
|
|
2955
|
+
async function writeMaintenancePending(stateDir) {
|
|
2956
|
+
const name = `${ENTITY_MIGRATION_MAINTENANCE_PENDING_PREFIX}.${process.pid}-${randomUUID()}`;
|
|
2957
|
+
const destination = path8.join(stateDir, name);
|
|
2958
|
+
const temporary = `${destination}.tmp`;
|
|
2959
|
+
try {
|
|
2960
|
+
await writeFile(temporary, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2961
|
+
`, "utf-8");
|
|
2962
|
+
await rename(temporary, destination);
|
|
2963
|
+
} finally {
|
|
2964
|
+
await unlink3(temporary).catch(() => void 0);
|
|
2965
|
+
}
|
|
2966
|
+
return name;
|
|
2967
|
+
}
|
|
2968
|
+
async function listMaintenancePending(stateDir) {
|
|
2969
|
+
try {
|
|
2970
|
+
return (await readdir4(stateDir)).filter(
|
|
2971
|
+
(name) => name.startsWith(ENTITY_MIGRATION_MAINTENANCE_PENDING_PREFIX) && !name.endsWith(".tmp")
|
|
2972
|
+
);
|
|
2973
|
+
} catch (error) {
|
|
2974
|
+
if (isErrnoCode(error, "ENOENT")) return [];
|
|
2975
|
+
throw error;
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
async function clearMaintenancePending(stateDir, names) {
|
|
2979
|
+
for (const name of names) {
|
|
2980
|
+
try {
|
|
2981
|
+
await unlink3(path8.join(stateDir, name));
|
|
2982
|
+
} catch (error) {
|
|
2983
|
+
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
async function settleMaintenancePending(stateDir, held, outcome) {
|
|
2988
|
+
if (await outcome !== false) await clearMaintenancePending(stateDir, held);
|
|
2989
|
+
}
|
|
2990
|
+
var settlements = /* @__PURE__ */ new Map();
|
|
2991
|
+
function trackMaintenanceSettlement(stateDir, settling) {
|
|
2992
|
+
let tracked = settlements.get(stateDir);
|
|
2993
|
+
if (!tracked) {
|
|
2994
|
+
tracked = /* @__PURE__ */ new Set();
|
|
2995
|
+
settlements.set(stateDir, tracked);
|
|
2996
|
+
}
|
|
2997
|
+
const done = tracked;
|
|
2998
|
+
done.add(settling);
|
|
2999
|
+
void settling.finally(() => done.delete(settling));
|
|
3000
|
+
}
|
|
3001
|
+
|
|
2950
3002
|
// src/storage/entity-canonical-id-migration-adapter.ts
|
|
2951
3003
|
async function runLegacyEntityCanonicalIdMigration(host, parseEntityFile2, serializeEntityFile2, serializeMemoryWithEntityRef2) {
|
|
2952
3004
|
const readMigrationFingerprint = () => getFingerprint(host.baseDir, host.entitiesDir, () => String(host.getEntityMutationVersion()));
|
|
2953
3005
|
let rewroteReferences = false;
|
|
3006
|
+
const owed = await listMaintenancePending(host.stateDir);
|
|
3007
|
+
let armed;
|
|
3008
|
+
const armPending = () => armed ??= writeMaintenancePending(host.stateDir);
|
|
2954
3009
|
const completionFingerprint = await migrateLegacyEntityCanonicalIds({
|
|
2955
3010
|
stateDir: host.stateDir,
|
|
2956
3011
|
entitiesDir: host.entitiesDir,
|
|
2957
3012
|
normalizeEntityName: host.normalizeEntityName.bind(host),
|
|
2958
3013
|
resolveEntityFilePath: host.resolveEntityFilePath.bind(host),
|
|
2959
3014
|
readStorageSecureFile: host.readStorageSecureFile.bind(host),
|
|
2960
|
-
writeStorageSecureFile:
|
|
3015
|
+
writeStorageSecureFile: async (filePath, content, forceEncrypt) => {
|
|
3016
|
+
await armPending();
|
|
3017
|
+
return host.writeStorageSecureFile(filePath, content, forceEncrypt);
|
|
3018
|
+
},
|
|
2961
3019
|
isEncryptedStorageFile: host.isEncryptedFileHeader.bind(host),
|
|
2962
3020
|
snapshotBeforeWrite: host.snapshotBeforeWrite.bind(host),
|
|
2963
3021
|
parseEntityFile: parseEntityFile2,
|
|
@@ -2968,8 +3026,14 @@ async function runLegacyEntityCanonicalIdMigration(host, parseEntityFile2, seria
|
|
|
2968
3026
|
readAllColdMemories: host.readAllColdMemories.bind(host),
|
|
2969
3027
|
readArchivedMemories: host.readArchivedMemories.bind(host),
|
|
2970
3028
|
validateMemoryScanRoots: () => validateRoots(host.baseDir, host.entitiesDir, host.stateDir, host.archiveDir),
|
|
2971
|
-
rewriteProjectedEntityReferences: (mappings) =>
|
|
2972
|
-
|
|
3029
|
+
rewriteProjectedEntityReferences: async (mappings) => {
|
|
3030
|
+
await armPending();
|
|
3031
|
+
return rewriteProjectedEntityReferences(host.baseDir, mappings);
|
|
3032
|
+
},
|
|
3033
|
+
rewriteProjectedMemoryEntityReference: async (memoryId, previousEntityRef, nextEntityRef) => {
|
|
3034
|
+
await armPending();
|
|
3035
|
+
return rewriteProjectedMemoryEntityReference(host.baseDir, memoryId, previousEntityRef, nextEntityRef);
|
|
3036
|
+
},
|
|
2973
3037
|
invalidateKnowledgeIndexCache: host.invalidateKnowledgeIndexCache.bind(host),
|
|
2974
3038
|
invalidateAllMemoriesCache: host.invalidateAllMemoriesCache.bind(host),
|
|
2975
3039
|
invalidateColdMemoriesCache: host.invalidateColdMemoriesCache.bind(host),
|
|
@@ -2979,9 +3043,15 @@ async function runLegacyEntityCanonicalIdMigration(host, parseEntityFile2, seria
|
|
|
2979
3043
|
},
|
|
2980
3044
|
readMigrationFingerprint
|
|
2981
3045
|
});
|
|
2982
|
-
if (completionFingerprint !== void 0 && rewroteReferences) {
|
|
3046
|
+
if (completionFingerprint !== void 0 && (rewroteReferences || owed.length > 0) && host.onEntityMigrationComplete) {
|
|
3047
|
+
const held = armed ? [...owed, await armed] : owed;
|
|
2983
3048
|
try {
|
|
2984
|
-
host.onEntityMigrationComplete
|
|
3049
|
+
const outcome = host.onEntityMigrationComplete();
|
|
3050
|
+
const settling = settleMaintenancePending(host.stateDir, held, outcome).catch(() => {
|
|
3051
|
+
log.warn("entity migration: search maintenance scheduling failed");
|
|
3052
|
+
});
|
|
3053
|
+
if (outcome instanceof Promise) trackMaintenanceSettlement(host.stateDir, settling);
|
|
3054
|
+
else await settling;
|
|
2985
3055
|
} catch {
|
|
2986
3056
|
log.warn("entity migration: search maintenance scheduling failed");
|
|
2987
3057
|
}
|
|
@@ -3108,7 +3178,7 @@ import {
|
|
|
3108
3178
|
readFileSync,
|
|
3109
3179
|
realpathSync
|
|
3110
3180
|
} from "fs";
|
|
3111
|
-
import
|
|
3181
|
+
import path9 from "path";
|
|
3112
3182
|
function resolveSafeAliasRoots(baseDir, configDir) {
|
|
3113
3183
|
let baseStat;
|
|
3114
3184
|
try {
|
|
@@ -3135,8 +3205,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
|
|
|
3135
3205
|
return memoryRoot;
|
|
3136
3206
|
}
|
|
3137
3207
|
function readEntityAliasConfigSync(baseDir) {
|
|
3138
|
-
const configDir =
|
|
3139
|
-
const aliasPath =
|
|
3208
|
+
const configDir = path9.join(baseDir, "config");
|
|
3209
|
+
const aliasPath = path9.join(configDir, "aliases.json");
|
|
3140
3210
|
let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
|
|
3141
3211
|
if (memoryRoot === void 0) return void 0;
|
|
3142
3212
|
let aliasPreflight;
|
|
@@ -3198,7 +3268,7 @@ function decodeYamlScalar(value) {
|
|
|
3198
3268
|
|
|
3199
3269
|
// src/orchestration/qmd-result-resolver.ts
|
|
3200
3270
|
import { existsSync } from "fs";
|
|
3201
|
-
import
|
|
3271
|
+
import path10 from "path";
|
|
3202
3272
|
var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
3203
3273
|
...ALL_CATEGORY_DIRS,
|
|
3204
3274
|
"activity",
|
|
@@ -3220,7 +3290,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
|
3220
3290
|
]);
|
|
3221
3291
|
var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
|
|
3222
3292
|
function qmdCollectionPathParts(resultPath) {
|
|
3223
|
-
if (!resultPath ||
|
|
3293
|
+
if (!resultPath || path10.isAbsolute(resultPath)) return null;
|
|
3224
3294
|
if (resultPath.trim().startsWith("qmd://")) {
|
|
3225
3295
|
try {
|
|
3226
3296
|
const parsed = new URL(resultPath.trim());
|
|
@@ -3245,9 +3315,9 @@ function qmdCollectionPathParts(resultPath) {
|
|
|
3245
3315
|
}
|
|
3246
3316
|
function qmdResultPathCandidates(storageDir, resultPath) {
|
|
3247
3317
|
const candidates = /* @__PURE__ */ new Set();
|
|
3248
|
-
const storageRoot =
|
|
3318
|
+
const storageRoot = path10.resolve(storageDir);
|
|
3249
3319
|
const addCandidate = (candidate) => {
|
|
3250
|
-
const resolved =
|
|
3320
|
+
const resolved = path10.resolve(candidate);
|
|
3251
3321
|
if (isPathInsideStorageRoot(storageRoot, resolved)) {
|
|
3252
3322
|
candidates.add(resolved);
|
|
3253
3323
|
}
|
|
@@ -3255,18 +3325,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
3255
3325
|
const addRelativeCandidates = (relativePath) => {
|
|
3256
3326
|
const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
3257
3327
|
if (!normalized) return;
|
|
3258
|
-
addCandidate(
|
|
3328
|
+
addCandidate(path10.join(storageRoot, normalized));
|
|
3259
3329
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3260
|
-
addCandidate(
|
|
3330
|
+
addCandidate(path10.join(storageRoot, "facts", normalized));
|
|
3261
3331
|
}
|
|
3262
3332
|
};
|
|
3263
|
-
if (
|
|
3333
|
+
if (path10.isAbsolute(resultPath)) {
|
|
3264
3334
|
addCandidate(resultPath);
|
|
3265
|
-
const relative2 =
|
|
3266
|
-
if (relative2 && !relative2.startsWith("..") && !
|
|
3267
|
-
const normalized = relative2.split(
|
|
3335
|
+
const relative2 = path10.relative(storageRoot, path10.resolve(resultPath));
|
|
3336
|
+
if (relative2 && !relative2.startsWith("..") && !path10.isAbsolute(relative2)) {
|
|
3337
|
+
const normalized = relative2.split(path10.sep).join("/");
|
|
3268
3338
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3269
|
-
addCandidate(
|
|
3339
|
+
addCandidate(path10.join(storageRoot, "facts", normalized));
|
|
3270
3340
|
}
|
|
3271
3341
|
}
|
|
3272
3342
|
} else {
|
|
@@ -3282,9 +3352,9 @@ function normalizeFlatQmdResults(results, config, collection = config.qmdCollect
|
|
|
3282
3352
|
}));
|
|
3283
3353
|
}
|
|
3284
3354
|
function withHotFactsPath(memoryDir, resolved) {
|
|
3285
|
-
const relative2 =
|
|
3355
|
+
const relative2 = path10.relative(path10.resolve(memoryDir), resolved).split(path10.sep).join("/");
|
|
3286
3356
|
if (!/^\d{4}-\d{2}-\d{2}\//.test(relative2) || existsSync(resolved)) return resolved;
|
|
3287
|
-
const hot =
|
|
3357
|
+
const hot = path10.join(path10.resolve(memoryDir), "facts", relative2);
|
|
3288
3358
|
return existsSync(hot) ? hot : resolved;
|
|
3289
3359
|
}
|
|
3290
3360
|
function storageDirOrNull(storage) {
|
|
@@ -3315,7 +3385,7 @@ var QmdResultResolver = class {
|
|
|
3315
3385
|
const seenStorageDirs = /* @__PURE__ */ new Set();
|
|
3316
3386
|
const addStorage = (storage) => {
|
|
3317
3387
|
const storageDir = storageDirOrNull(storage);
|
|
3318
|
-
const storageKey = storageDir ?
|
|
3388
|
+
const storageKey = storageDir ? path10.resolve(storageDir) : `storage-without-dir-${storages.length}`;
|
|
3319
3389
|
if (seenStorageDirs.has(storageKey)) return;
|
|
3320
3390
|
seenStorageDirs.add(storageKey);
|
|
3321
3391
|
storages.push(storage);
|
|
@@ -3345,7 +3415,7 @@ var QmdResultResolver = class {
|
|
|
3345
3415
|
continue;
|
|
3346
3416
|
}
|
|
3347
3417
|
try {
|
|
3348
|
-
const coldRoot =
|
|
3418
|
+
const coldRoot = path10.join(storageDir, "cold");
|
|
3349
3419
|
for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
|
|
3350
3420
|
const memory = await storage.readMemoryByPath(candidate);
|
|
3351
3421
|
if (memory) return memory;
|
|
@@ -3395,9 +3465,9 @@ var QmdResultResolver = class {
|
|
|
3395
3465
|
error: err.message
|
|
3396
3466
|
});
|
|
3397
3467
|
}
|
|
3398
|
-
if (!
|
|
3468
|
+
if (!path10.isAbsolute(fallbackResultPath)) return null;
|
|
3399
3469
|
}
|
|
3400
|
-
if (
|
|
3470
|
+
if (path10.isAbsolute(fallbackResultPath)) {
|
|
3401
3471
|
if (!fallbackStorageDir) {
|
|
3402
3472
|
return await fallbackStorage.readMemoryByPath(fallbackResultPath);
|
|
3403
3473
|
}
|
|
@@ -3454,17 +3524,17 @@ var QmdResultResolver = class {
|
|
|
3454
3524
|
if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
|
|
3455
3525
|
memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
|
|
3456
3526
|
}
|
|
3457
|
-
const absoluteInsideMemoryRoot =
|
|
3527
|
+
const absoluteInsideMemoryRoot = path10.isAbsolute(result.path) && isPathInsideStorageRoot(path10.resolve(config.memoryDir), path10.resolve(result.path));
|
|
3458
3528
|
const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
|
|
3459
3529
|
const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
|
|
3460
|
-
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured ||
|
|
3530
|
+
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path10.isAbsolute(result.path) && !isPathInsideStorageRoot(path10.resolve(config.memoryDir), path10.resolve(result.path)));
|
|
3461
3531
|
return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
|
|
3462
3532
|
}
|
|
3463
3533
|
async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
|
|
3464
3534
|
const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
|
|
3465
3535
|
if (!memory) return null;
|
|
3466
3536
|
let ownerNamespace = null;
|
|
3467
|
-
if (
|
|
3537
|
+
if (path10.isAbsolute(memory.path)) {
|
|
3468
3538
|
const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
|
|
3469
3539
|
ownerNamespace = ownerStorage?.namespace ?? null;
|
|
3470
3540
|
if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
|
|
@@ -3485,17 +3555,17 @@ var QmdResultResolver = class {
|
|
|
3485
3555
|
};
|
|
3486
3556
|
}
|
|
3487
3557
|
async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
|
|
3488
|
-
const resolvedPath =
|
|
3558
|
+
const resolvedPath = path10.resolve(resultPath);
|
|
3489
3559
|
const config = this.getConfig();
|
|
3490
|
-
const memoryRoot =
|
|
3491
|
-
const namespacesRoot =
|
|
3560
|
+
const memoryRoot = path10.resolve(config.memoryDir);
|
|
3561
|
+
const namespacesRoot = path10.join(memoryRoot, "namespaces");
|
|
3492
3562
|
const fallbackStorageDir = storageDirOrNull(fallbackStorage);
|
|
3493
3563
|
const matches = [];
|
|
3494
3564
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
3495
3565
|
const maybeAddStorage = (storage, namespace) => {
|
|
3496
3566
|
const storageDir = storageDirOrNull(storage);
|
|
3497
3567
|
if (!storageDir) return;
|
|
3498
|
-
const candidateRoot =
|
|
3568
|
+
const candidateRoot = path10.resolve(storageDir);
|
|
3499
3569
|
if (seenDirs.has(candidateRoot)) return;
|
|
3500
3570
|
if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
|
|
3501
3571
|
if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
@@ -3513,7 +3583,7 @@ var QmdResultResolver = class {
|
|
|
3513
3583
|
candidateNamespaces.add(ns);
|
|
3514
3584
|
}
|
|
3515
3585
|
if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
3516
|
-
const relativeToNamespaces =
|
|
3586
|
+
const relativeToNamespaces = path10.relative(namespacesRoot, resolvedPath);
|
|
3517
3587
|
const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
|
|
3518
3588
|
if (namespaceSegment) {
|
|
3519
3589
|
candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
|
|
@@ -4175,7 +4245,7 @@ function fuseDay(date, inputs, options = {}) {
|
|
|
4175
4245
|
|
|
4176
4246
|
// src/wearables/fusion/store.ts
|
|
4177
4247
|
import { createHash as createHash2 } from "crypto";
|
|
4178
|
-
import * as
|
|
4248
|
+
import * as path11 from "path";
|
|
4179
4249
|
var FUSION_KIND = "wearable-fusion";
|
|
4180
4250
|
function hashFusionBody(conversations) {
|
|
4181
4251
|
return createHash2("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
|
|
@@ -4362,7 +4432,7 @@ var FusionArtifactStore = class {
|
|
|
4362
4432
|
`invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
|
|
4363
4433
|
);
|
|
4364
4434
|
}
|
|
4365
|
-
return
|
|
4435
|
+
return path11.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
|
|
4366
4436
|
}
|
|
4367
4437
|
async writeFusedDay(date, serialized) {
|
|
4368
4438
|
const filePath = this.fusedDayPath(date);
|
|
@@ -4399,7 +4469,7 @@ var FusionArtifactStore = class {
|
|
|
4399
4469
|
}
|
|
4400
4470
|
/** List dates with stored fused artifacts, newest first. */
|
|
4401
4471
|
async listFusedDays() {
|
|
4402
|
-
const fusionDir =
|
|
4472
|
+
const fusionDir = path11.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4403
4473
|
await this.assertPathContained(fusionDir);
|
|
4404
4474
|
let entries;
|
|
4405
4475
|
try {
|
|
@@ -4443,10 +4513,10 @@ var FusionArtifactStore = class {
|
|
|
4443
4513
|
try {
|
|
4444
4514
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
4445
4515
|
} catch {
|
|
4446
|
-
rootReal =
|
|
4516
|
+
rootReal = path11.resolve(this.memoryDir);
|
|
4447
4517
|
}
|
|
4448
4518
|
await this.assertNoEscape(rootReal, this.wearablesDir);
|
|
4449
|
-
await this.assertNoEscape(rootReal,
|
|
4519
|
+
await this.assertNoEscape(rootReal, path11.dirname(targetPath));
|
|
4450
4520
|
await this.assertNoEscape(rootReal, targetPath);
|
|
4451
4521
|
await this.assertFusionDirNotSymlinked();
|
|
4452
4522
|
}
|
|
@@ -4460,7 +4530,7 @@ var FusionArtifactStore = class {
|
|
|
4460
4530
|
* (a fresh write creates a real directory lexically under the root).
|
|
4461
4531
|
*/
|
|
4462
4532
|
async assertFusionDirNotSymlinked() {
|
|
4463
|
-
const fusionDir =
|
|
4533
|
+
const fusionDir = path11.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4464
4534
|
let stat4;
|
|
4465
4535
|
try {
|
|
4466
4536
|
stat4 = await this.io.lstat(fusionDir);
|
|
@@ -4596,7 +4666,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
|
|
|
4596
4666
|
|
|
4597
4667
|
// src/meetings/store.ts
|
|
4598
4668
|
import { createHash as createHash3 } from "crypto";
|
|
4599
|
-
import * as
|
|
4669
|
+
import * as path12 from "path";
|
|
4600
4670
|
var MEETINGS_DIR_NAME = "meetings";
|
|
4601
4671
|
var MEETING_KIND = "meeting";
|
|
4602
4672
|
var MEETING_FORMAT_VERSION = 1;
|
|
@@ -4765,7 +4835,7 @@ var MeetingRecordStore = class {
|
|
|
4765
4835
|
constructor(memoryDir, io) {
|
|
4766
4836
|
this.memoryDir = memoryDir;
|
|
4767
4837
|
this.io = io;
|
|
4768
|
-
this.meetingsDir =
|
|
4838
|
+
this.meetingsDir = path12.join(memoryDir, MEETINGS_DIR_NAME);
|
|
4769
4839
|
}
|
|
4770
4840
|
memoryDir;
|
|
4771
4841
|
io;
|
|
@@ -4781,7 +4851,7 @@ var MeetingRecordStore = class {
|
|
|
4781
4851
|
if (idDate !== date) {
|
|
4782
4852
|
throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
|
|
4783
4853
|
}
|
|
4784
|
-
return
|
|
4854
|
+
return path12.join(this.meetingsDir, date, `${id}.md`);
|
|
4785
4855
|
}
|
|
4786
4856
|
/** Idempotently persist a record: skip the write when contentHash is unchanged. */
|
|
4787
4857
|
async saveMeetingRecord(record) {
|
|
@@ -4812,7 +4882,7 @@ var MeetingRecordStore = class {
|
|
|
4812
4882
|
if (!isValidTranscriptDate(date)) {
|
|
4813
4883
|
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
4814
4884
|
}
|
|
4815
|
-
const dayDir =
|
|
4885
|
+
const dayDir = path12.join(this.meetingsDir, date);
|
|
4816
4886
|
await this.assertPathContained(dayDir);
|
|
4817
4887
|
let entries;
|
|
4818
4888
|
try {
|
|
@@ -4880,10 +4950,10 @@ var MeetingRecordStore = class {
|
|
|
4880
4950
|
try {
|
|
4881
4951
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
4882
4952
|
} catch {
|
|
4883
|
-
rootReal =
|
|
4953
|
+
rootReal = path12.resolve(this.memoryDir);
|
|
4884
4954
|
}
|
|
4885
4955
|
await this.assertNoEscape(rootReal, this.meetingsDir);
|
|
4886
|
-
await this.assertNoEscape(rootReal,
|
|
4956
|
+
await this.assertNoEscape(rootReal, path12.dirname(targetPath));
|
|
4887
4957
|
await this.assertNoEscape(rootReal, targetPath);
|
|
4888
4958
|
await this.assertNotSymlink(this.meetingsDir, "directory");
|
|
4889
4959
|
const dayDir = this.dayDirWithin(targetPath);
|
|
@@ -4893,11 +4963,11 @@ var MeetingRecordStore = class {
|
|
|
4893
4963
|
/** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
|
|
4894
4964
|
* `targetPath` is the meetings root itself. */
|
|
4895
4965
|
dayDirWithin(targetPath) {
|
|
4896
|
-
const rel =
|
|
4897
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
4898
|
-
const first = rel.split(
|
|
4966
|
+
const rel = path12.relative(this.meetingsDir, targetPath);
|
|
4967
|
+
if (rel === "" || rel.startsWith("..") || path12.isAbsolute(rel)) return null;
|
|
4968
|
+
const first = rel.split(path12.sep)[0];
|
|
4899
4969
|
if (first === void 0 || first.length === 0) return null;
|
|
4900
|
-
return
|
|
4970
|
+
return path12.join(this.meetingsDir, first);
|
|
4901
4971
|
}
|
|
4902
4972
|
async assertNotSymlink(target, kind) {
|
|
4903
4973
|
let stat4;
|
|
@@ -4908,7 +4978,7 @@ var MeetingRecordStore = class {
|
|
|
4908
4978
|
throw err;
|
|
4909
4979
|
}
|
|
4910
4980
|
if (stat4.isSymbolicLink) {
|
|
4911
|
-
const label =
|
|
4981
|
+
const label = path12.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
|
|
4912
4982
|
throw new Error(
|
|
4913
4983
|
`meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
4914
4984
|
);
|
|
@@ -4932,8 +5002,8 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
|
4932
5002
|
|
|
4933
5003
|
// src/storage/buffer-session-files.ts
|
|
4934
5004
|
import { createHash as createHash4 } from "crypto";
|
|
4935
|
-
import { lstat as lstat4, readdir as
|
|
4936
|
-
import
|
|
5005
|
+
import { lstat as lstat4, readdir as readdir5, unlink as unlink4 } from "fs/promises";
|
|
5006
|
+
import path13 from "path";
|
|
4937
5007
|
function isMissing(err) {
|
|
4938
5008
|
return err?.code === "ENOENT";
|
|
4939
5009
|
}
|
|
@@ -4976,10 +5046,10 @@ var BufferSessionFiles = class {
|
|
|
4976
5046
|
io;
|
|
4977
5047
|
dirVerified = false;
|
|
4978
5048
|
get dir() {
|
|
4979
|
-
return
|
|
5049
|
+
return path13.join(this.stateDir, "buffer");
|
|
4980
5050
|
}
|
|
4981
5051
|
fileFor(key) {
|
|
4982
|
-
return
|
|
5052
|
+
return path13.join(this.dir, bufferSessionFileName(key));
|
|
4983
5053
|
}
|
|
4984
5054
|
/**
|
|
4985
5055
|
* Refuse a symlinked buffer directory: following it would send buffered
|
|
@@ -5010,7 +5080,7 @@ var BufferSessionFiles = class {
|
|
|
5010
5080
|
async remove(key) {
|
|
5011
5081
|
await this.assertDirSafe();
|
|
5012
5082
|
try {
|
|
5013
|
-
await
|
|
5083
|
+
await unlink4(this.fileFor(key));
|
|
5014
5084
|
} catch (err) {
|
|
5015
5085
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5016
5086
|
}
|
|
@@ -5018,7 +5088,7 @@ var BufferSessionFiles = class {
|
|
|
5018
5088
|
async listFiles() {
|
|
5019
5089
|
await this.assertDirSafe();
|
|
5020
5090
|
try {
|
|
5021
|
-
const dirents = await
|
|
5091
|
+
const dirents = await readdir5(this.dir, { withFileTypes: true });
|
|
5022
5092
|
return dirents.filter((d) => d.isFile() && d.name.endsWith(".json")).map((d) => d.name);
|
|
5023
5093
|
} catch (err) {
|
|
5024
5094
|
if (err instanceof Error && isMissing(asFsError(err))) return [];
|
|
@@ -5032,7 +5102,7 @@ var BufferSessionFiles = class {
|
|
|
5032
5102
|
const entries = /* @__PURE__ */ new Map();
|
|
5033
5103
|
for (const name of names) {
|
|
5034
5104
|
try {
|
|
5035
|
-
const body = JSON.parse(await this.io.read(
|
|
5105
|
+
const body = JSON.parse(await this.io.read(path13.join(this.dir, name)));
|
|
5036
5106
|
const parsed = entryFromBody(body);
|
|
5037
5107
|
if (!parsed) throw new Error("invalid buffer session file shape");
|
|
5038
5108
|
if (entries.has(parsed.key)) {
|
|
@@ -5056,7 +5126,7 @@ var BufferSessionFiles = class {
|
|
|
5056
5126
|
async readLegacy(hasSessionFiles) {
|
|
5057
5127
|
let raw;
|
|
5058
5128
|
try {
|
|
5059
|
-
raw = await this.io.read(
|
|
5129
|
+
raw = await this.io.read(path13.join(this.stateDir, "buffer.json"));
|
|
5060
5130
|
} catch (err) {
|
|
5061
5131
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
5062
5132
|
if (err instanceof Error && isMissing(asFsError(err))) return null;
|
|
@@ -5089,7 +5159,7 @@ var BufferSessionFiles = class {
|
|
|
5089
5159
|
await this.save(key, entry);
|
|
5090
5160
|
}
|
|
5091
5161
|
try {
|
|
5092
|
-
await
|
|
5162
|
+
await unlink4(path13.join(this.stateDir, "buffer.json"));
|
|
5093
5163
|
} catch (err) {
|
|
5094
5164
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5095
5165
|
}
|
|
@@ -5118,7 +5188,7 @@ var BufferSessionFiles = class {
|
|
|
5118
5188
|
for (const name of existing) {
|
|
5119
5189
|
if (live.has(name)) continue;
|
|
5120
5190
|
try {
|
|
5121
|
-
await
|
|
5191
|
+
await unlink4(path13.join(this.dir, name));
|
|
5122
5192
|
} catch (err) {
|
|
5123
5193
|
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5124
5194
|
}
|
|
@@ -5127,12 +5197,12 @@ var BufferSessionFiles = class {
|
|
|
5127
5197
|
};
|
|
5128
5198
|
|
|
5129
5199
|
// src/storage/supersession-audit.ts
|
|
5130
|
-
import { readdir as
|
|
5131
|
-
import
|
|
5200
|
+
import { readdir as readdir6 } from "fs/promises";
|
|
5201
|
+
import path14 from "path";
|
|
5132
5202
|
async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
|
|
5133
5203
|
let entries;
|
|
5134
5204
|
try {
|
|
5135
|
-
entries = await
|
|
5205
|
+
entries = await readdir6(lookup.correctionsDir, { withFileTypes: true });
|
|
5136
5206
|
} catch (error) {
|
|
5137
5207
|
if (isErrnoCode(error, "ENOENT")) return false;
|
|
5138
5208
|
throw error;
|
|
@@ -5140,7 +5210,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
|
|
|
5140
5210
|
for (const entry of entries) {
|
|
5141
5211
|
if (isMacOsReplicationJunkBasename(entry.name)) continue;
|
|
5142
5212
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
5143
|
-
const memory = await lookup.readMemoryByPath(
|
|
5213
|
+
const memory = await lookup.readMemoryByPath(path14.join(lookup.correctionsDir, entry.name));
|
|
5144
5214
|
if (memory?.frontmatter.category === "correction" && (memory.frontmatter.sourceMemoryId === oldMemoryId || memory.frontmatter.sourceMemoryId === void 0 && memory.frontmatter.lineage?.includes(oldMemoryId)) && memory.frontmatter.lineage?.includes(newMemoryId) && stripAttributesSuffix(memory.content) === auditBody && (structuredAttributes === void 0 || Object.entries(structuredAttributes).every(
|
|
5145
5215
|
([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
|
|
5146
5216
|
))) {
|
|
@@ -5230,14 +5300,14 @@ Reason: ${reason}`;
|
|
|
5230
5300
|
}
|
|
5231
5301
|
|
|
5232
5302
|
// src/storage/dropped-extraction-chunk.ts
|
|
5233
|
-
import { randomUUID } from "crypto";
|
|
5303
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
5234
5304
|
import { mkdir } from "fs/promises";
|
|
5235
|
-
import
|
|
5305
|
+
import path15 from "path";
|
|
5236
5306
|
async function saveDroppedExtractionChunk(stateDir, writeSecureFile, bufferKey, reason, turns) {
|
|
5237
|
-
const droppedDir =
|
|
5307
|
+
const droppedDir = path15.join(stateDir, "dropped");
|
|
5238
5308
|
await mkdir(droppedDir, { recursive: true });
|
|
5239
5309
|
const safeKey = bufferKey.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 80) || "default";
|
|
5240
|
-
const filePath =
|
|
5310
|
+
const filePath = path15.join(droppedDir, `${Date.now()}-${randomUUID2().slice(0, 8)}-${safeKey}.json`);
|
|
5241
5311
|
const payload = { bufferKey, reason, droppedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
5242
5312
|
await writeSecureFile(filePath, JSON.stringify(payload, null, 2));
|
|
5243
5313
|
return filePath;
|
|
@@ -6243,17 +6313,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
6243
6313
|
}
|
|
6244
6314
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
6245
6315
|
function inferEntityTypeFromFilename(pathRel) {
|
|
6246
|
-
const basename =
|
|
6316
|
+
const basename = path16.basename(pathRel, ".md").toLowerCase();
|
|
6247
6317
|
const separator = basename.indexOf("-");
|
|
6248
6318
|
if (separator <= 0) return void 0;
|
|
6249
6319
|
const candidate = basename.slice(0, separator);
|
|
6250
6320
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
6251
6321
|
}
|
|
6252
6322
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
6253
|
-
const normalizedPath = pathRel.split(
|
|
6323
|
+
const normalizedPath = pathRel.split(path16.sep).join("/");
|
|
6254
6324
|
let normalizedFrontmatter = frontmatter;
|
|
6255
6325
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
6256
|
-
const basename =
|
|
6326
|
+
const basename = path16.basename(pathRel, ".md");
|
|
6257
6327
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
6258
6328
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
6259
6329
|
normalizedFrontmatter = {
|
|
@@ -6726,9 +6796,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6726
6796
|
this.entitySchemas = entitySchemas;
|
|
6727
6797
|
this.deletionRevisionStore = new DeletionRevisionStore({
|
|
6728
6798
|
baseDir,
|
|
6729
|
-
deletionRevisionMetadataPath:
|
|
6730
|
-
invalidationCommitMetadataPath:
|
|
6731
|
-
deletionRevisionLockPath:
|
|
6799
|
+
deletionRevisionMetadataPath: path16.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
|
|
6800
|
+
invalidationCommitMetadataPath: path16.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
|
|
6801
|
+
deletionRevisionLockPath: path16.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
|
|
6732
6802
|
assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
|
|
6733
6803
|
});
|
|
6734
6804
|
this.casRevisions = new CasRevisionHost(baseDir);
|
|
@@ -6882,7 +6952,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6882
6952
|
onCatalogWrite;
|
|
6883
6953
|
/** Post-write embedding hook (#2019). Installed by the orchestrator; fire-and-forget. */
|
|
6884
6954
|
onMemoryWrite;
|
|
6885
|
-
/** Request search maintenance after
|
|
6955
|
+
/** Request search maintenance after an entity replay. false = refused; a Promise settles true once a pass served it. The pending marker stays until then. */
|
|
6886
6956
|
onEntityMigrationComplete;
|
|
6887
6957
|
notifyMemoryWrite(filePath) {
|
|
6888
6958
|
try {
|
|
@@ -6916,8 +6986,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6916
6986
|
}
|
|
6917
6987
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
6918
6988
|
isStateFilePath(filePath) {
|
|
6919
|
-
const rel =
|
|
6920
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
6989
|
+
const rel = path16.relative(this.stateDir, path16.resolve(filePath));
|
|
6990
|
+
return rel === "" || !rel.startsWith("..") && !path16.isAbsolute(rel);
|
|
6921
6991
|
}
|
|
6922
6992
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
6923
6993
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -7032,8 +7102,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7032
7102
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
7033
7103
|
*/
|
|
7034
7104
|
isColdOrArchiveTierPath(p) {
|
|
7035
|
-
const rel =
|
|
7036
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
7105
|
+
const rel = path16.relative(this.baseDir, p);
|
|
7106
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path16.sep}`) || rel.startsWith(`archive${path16.sep}`);
|
|
7037
7107
|
}
|
|
7038
7108
|
/**
|
|
7039
7109
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -7120,7 +7190,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7120
7190
|
void 0,
|
|
7121
7191
|
this.baseDir
|
|
7122
7192
|
);
|
|
7123
|
-
const rel =
|
|
7193
|
+
const rel = path16.relative(this.baseDir, filePath).split(path16.sep).join("/");
|
|
7124
7194
|
return `${rel}:${version.versionId}`;
|
|
7125
7195
|
} catch (err) {
|
|
7126
7196
|
log.warn(
|
|
@@ -7165,10 +7235,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7165
7235
|
_StorageManager.okfConformanceByDir.set(memoryDir, enabled !== false);
|
|
7166
7236
|
}
|
|
7167
7237
|
okfConformanceEnabled() {
|
|
7168
|
-
for (let dir = this.baseDir; ; dir =
|
|
7238
|
+
for (let dir = this.baseDir; ; dir = path16.dirname(dir)) {
|
|
7169
7239
|
const registered = _StorageManager.okfConformanceByDir.get(dir);
|
|
7170
7240
|
if (registered !== void 0) return registered;
|
|
7171
|
-
if (dir ===
|
|
7241
|
+
if (dir === path16.dirname(dir)) return true;
|
|
7172
7242
|
}
|
|
7173
7243
|
}
|
|
7174
7244
|
/**
|
|
@@ -7212,12 +7282,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7212
7282
|
}
|
|
7213
7283
|
identityFilePath(workspaceDir, namespace) {
|
|
7214
7284
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
7215
|
-
if (!rawNamespace) return
|
|
7285
|
+
if (!rawNamespace) return path16.join(workspaceDir, "IDENTITY.md");
|
|
7216
7286
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7217
|
-
return
|
|
7287
|
+
return path16.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
7218
7288
|
}
|
|
7219
7289
|
versionFilePath(kind) {
|
|
7220
|
-
return
|
|
7290
|
+
return path16.join(this.stateDir, `.${kind}-version.log`);
|
|
7221
7291
|
}
|
|
7222
7292
|
bumpSharedVersion(kind, fallbackMap) {
|
|
7223
7293
|
const filePath = this.versionFilePath(kind);
|
|
@@ -7324,7 +7394,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7324
7394
|
// memories.
|
|
7325
7395
|
// -------------------------------------------------------------------------
|
|
7326
7396
|
get wearablesDir() {
|
|
7327
|
-
return
|
|
7397
|
+
return path16.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
7328
7398
|
}
|
|
7329
7399
|
/**
|
|
7330
7400
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -7340,7 +7410,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7340
7410
|
if (!isValidTranscriptDate(date)) {
|
|
7341
7411
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
7342
7412
|
}
|
|
7343
|
-
return
|
|
7413
|
+
return path16.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
7344
7414
|
}
|
|
7345
7415
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
7346
7416
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -7366,8 +7436,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7366
7436
|
return this._fusionStore = new FusionArtifactStore(this.wearablesDir, this.baseDir, {
|
|
7367
7437
|
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
7368
7438
|
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
7369
|
-
readDir: (d) =>
|
|
7370
|
-
deleteFile: (p) =>
|
|
7439
|
+
readDir: (d) => readdir7(d),
|
|
7440
|
+
deleteFile: (p) => unlink5(p),
|
|
7371
7441
|
realpath: (p) => realpath3(p),
|
|
7372
7442
|
lstat: (p) => lstat5(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7373
7443
|
});
|
|
@@ -7384,8 +7454,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7384
7454
|
return this._meetingRecordStore = new MeetingRecordStore(this.baseDir, {
|
|
7385
7455
|
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
7386
7456
|
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
7387
|
-
readDir: (d) =>
|
|
7388
|
-
deleteFile: (p) =>
|
|
7457
|
+
readDir: (d) => readdir7(d),
|
|
7458
|
+
deleteFile: (p) => unlink5(p),
|
|
7389
7459
|
realpath: (p) => realpath3(p),
|
|
7390
7460
|
lstat: (p) => lstat5(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7391
7461
|
});
|
|
@@ -7454,25 +7524,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7454
7524
|
});
|
|
7455
7525
|
}
|
|
7456
7526
|
get factsDir() {
|
|
7457
|
-
return
|
|
7527
|
+
return path16.join(this.baseDir, "facts");
|
|
7458
7528
|
}
|
|
7459
7529
|
get correctionsDir() {
|
|
7460
|
-
return
|
|
7530
|
+
return path16.join(this.baseDir, "corrections");
|
|
7461
7531
|
}
|
|
7462
7532
|
get proceduresDir() {
|
|
7463
|
-
return
|
|
7533
|
+
return path16.join(this.baseDir, "procedures");
|
|
7464
7534
|
}
|
|
7465
7535
|
get reasoningTracesDir() {
|
|
7466
|
-
return
|
|
7536
|
+
return path16.join(this.baseDir, "reasoning-traces");
|
|
7467
7537
|
}
|
|
7468
7538
|
get entitiesDir() {
|
|
7469
|
-
return
|
|
7539
|
+
return path16.join(this.baseDir, "entities");
|
|
7470
7540
|
}
|
|
7471
7541
|
resolveEntityFilePath(name) {
|
|
7472
7542
|
if (typeof name !== "string") return null;
|
|
7473
|
-
const filePath =
|
|
7474
|
-
const relative2 =
|
|
7475
|
-
if (relative2 === "" || relative2.startsWith("..") ||
|
|
7543
|
+
const filePath = path16.resolve(this.entitiesDir, `${name}.md`);
|
|
7544
|
+
const relative2 = path16.relative(this.entitiesDir, filePath);
|
|
7545
|
+
if (relative2 === "" || relative2.startsWith("..") || path16.isAbsolute(relative2)) {
|
|
7476
7546
|
return null;
|
|
7477
7547
|
}
|
|
7478
7548
|
return filePath;
|
|
@@ -7483,7 +7553,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7483
7553
|
async readDependencyPropagationQueueFile(filePath) {
|
|
7484
7554
|
const target = await resolveSafeStoragePath(
|
|
7485
7555
|
this.baseDir,
|
|
7486
|
-
|
|
7556
|
+
path16.relative(
|
|
7487
7557
|
this.baseDir,
|
|
7488
7558
|
this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
|
|
7489
7559
|
)
|
|
@@ -7493,7 +7563,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7493
7563
|
async writeDependencyPropagationQueueFile(filePath, content) {
|
|
7494
7564
|
const target = await resolveSafeStoragePath(
|
|
7495
7565
|
this.baseDir,
|
|
7496
|
-
|
|
7566
|
+
path16.relative(
|
|
7497
7567
|
this.baseDir,
|
|
7498
7568
|
this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
|
|
7499
7569
|
)
|
|
@@ -7508,10 +7578,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7508
7578
|
});
|
|
7509
7579
|
}
|
|
7510
7580
|
assertManagedStoragePath(filePath, method) {
|
|
7511
|
-
const resolved =
|
|
7512
|
-
const base =
|
|
7513
|
-
const rel =
|
|
7514
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7581
|
+
const resolved = path16.resolve(filePath);
|
|
7582
|
+
const base = path16.resolve(this.baseDir);
|
|
7583
|
+
const rel = path16.relative(base, resolved);
|
|
7584
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path16.sep}`) || path16.isAbsolute(rel)) {
|
|
7515
7585
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
7516
7586
|
}
|
|
7517
7587
|
return resolved;
|
|
@@ -7548,7 +7618,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7548
7618
|
async digestOfflineSyncFile(filePath) {
|
|
7549
7619
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
7550
7620
|
const st = await stat3(target);
|
|
7551
|
-
const relPath =
|
|
7621
|
+
const relPath = path16.relative(this.baseDir, target).split(path16.sep).join("/");
|
|
7552
7622
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
7553
7623
|
const cached = cache.get(relPath);
|
|
7554
7624
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -7633,8 +7703,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7633
7703
|
const cache = this.offlineSyncDigestCache;
|
|
7634
7704
|
if (!cache) return;
|
|
7635
7705
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
7636
|
-
await mkdir2(
|
|
7637
|
-
await
|
|
7706
|
+
await mkdir2(path16.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
7707
|
+
await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
7638
7708
|
`, "utf-8");
|
|
7639
7709
|
}).catch((err) => {
|
|
7640
7710
|
log.warn(
|
|
@@ -7734,7 +7804,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7734
7804
|
}
|
|
7735
7805
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
7736
7806
|
const writeKey = this.resolveWriteKey();
|
|
7737
|
-
await mkdir2(
|
|
7807
|
+
await mkdir2(path16.dirname(filePath), { recursive: true });
|
|
7738
7808
|
if (writeKey === null) {
|
|
7739
7809
|
try {
|
|
7740
7810
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -7760,13 +7830,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7760
7830
|
this.notifyCatalogWriteForPath(filePath);
|
|
7761
7831
|
}
|
|
7762
7832
|
get stateDir() {
|
|
7763
|
-
return
|
|
7833
|
+
return path16.join(this.baseDir, "state");
|
|
7764
7834
|
}
|
|
7765
7835
|
get offlineSyncDigestCachePath() {
|
|
7766
|
-
return
|
|
7836
|
+
return path16.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
7767
7837
|
}
|
|
7768
7838
|
get entitySynthesisQueuePath() {
|
|
7769
|
-
return
|
|
7839
|
+
return path16.join(this.stateDir, "entity-synthesis-queue.json");
|
|
7770
7840
|
}
|
|
7771
7841
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
7772
7842
|
/**
|
|
@@ -7776,7 +7846,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7776
7846
|
* helpers are injected into the store).
|
|
7777
7847
|
*/
|
|
7778
7848
|
get tombstonesPath() {
|
|
7779
|
-
return
|
|
7849
|
+
return path16.join(this.stateDir, "tombstones.jsonl");
|
|
7780
7850
|
}
|
|
7781
7851
|
/**
|
|
7782
7852
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -8089,55 +8159,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8089
8159
|
return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
|
|
8090
8160
|
}
|
|
8091
8161
|
get questionsDir() {
|
|
8092
|
-
return
|
|
8162
|
+
return path16.join(this.baseDir, "questions");
|
|
8093
8163
|
}
|
|
8094
8164
|
get artifactsDir() {
|
|
8095
|
-
return
|
|
8165
|
+
return path16.join(this.baseDir, "artifacts");
|
|
8096
8166
|
}
|
|
8097
8167
|
get identityDir() {
|
|
8098
|
-
return
|
|
8168
|
+
return path16.join(this.baseDir, "identity");
|
|
8099
8169
|
}
|
|
8100
8170
|
get identityAnchorPath() {
|
|
8101
|
-
return
|
|
8171
|
+
return path16.join(this.identityDir, "identity-anchor.md");
|
|
8102
8172
|
}
|
|
8103
8173
|
get identityIncidentsDir() {
|
|
8104
|
-
return
|
|
8174
|
+
return path16.join(this.identityDir, "incidents");
|
|
8105
8175
|
}
|
|
8106
8176
|
get identityAuditsWeeklyDir() {
|
|
8107
|
-
return
|
|
8177
|
+
return path16.join(this.identityDir, "audits", "weekly");
|
|
8108
8178
|
}
|
|
8109
8179
|
get identityAuditsMonthlyDir() {
|
|
8110
|
-
return
|
|
8180
|
+
return path16.join(this.identityDir, "audits", "monthly");
|
|
8111
8181
|
}
|
|
8112
8182
|
get identityImprovementLoopsPath() {
|
|
8113
|
-
return
|
|
8183
|
+
return path16.join(this.identityDir, "improvement-loops.md");
|
|
8114
8184
|
}
|
|
8115
8185
|
get identityReflectionsPath() {
|
|
8116
|
-
return
|
|
8186
|
+
return path16.join(this.identityDir, "reflections.md");
|
|
8117
8187
|
}
|
|
8118
8188
|
get profilePath() {
|
|
8119
|
-
return
|
|
8189
|
+
return path16.join(this.baseDir, "profile.md");
|
|
8120
8190
|
}
|
|
8121
8191
|
get memoryActionsPath() {
|
|
8122
|
-
return
|
|
8192
|
+
return path16.join(this.stateDir, "memory-actions.jsonl");
|
|
8123
8193
|
}
|
|
8124
8194
|
get memoryLifecycleLedgerPath() {
|
|
8125
|
-
return
|
|
8195
|
+
return path16.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
8126
8196
|
}
|
|
8127
8197
|
get compressionGuidelinesPath() {
|
|
8128
|
-
return
|
|
8198
|
+
return path16.join(this.stateDir, "compression-guidelines.md");
|
|
8129
8199
|
}
|
|
8130
8200
|
get compressionGuidelineDraftPath() {
|
|
8131
|
-
return
|
|
8201
|
+
return path16.join(this.stateDir, "compression-guidelines.draft.md");
|
|
8132
8202
|
}
|
|
8133
8203
|
get compressionGuidelineStatePath() {
|
|
8134
|
-
return
|
|
8204
|
+
return path16.join(this.stateDir, "compression-guideline-state.json");
|
|
8135
8205
|
}
|
|
8136
8206
|
get compressionGuidelineDraftStatePath() {
|
|
8137
|
-
return
|
|
8207
|
+
return path16.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
8138
8208
|
}
|
|
8139
8209
|
get behaviorSignalsPath() {
|
|
8140
|
-
return
|
|
8210
|
+
return path16.join(this.stateDir, "behavior-signals.jsonl");
|
|
8141
8211
|
}
|
|
8142
8212
|
/**
|
|
8143
8213
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -8169,7 +8239,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8169
8239
|
* governance sweeps can treat it uniformly.
|
|
8170
8240
|
*/
|
|
8171
8241
|
get bufferSurpriseLedgerPath() {
|
|
8172
|
-
return
|
|
8242
|
+
return path16.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
8173
8243
|
}
|
|
8174
8244
|
/**
|
|
8175
8245
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -8232,7 +8302,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8232
8302
|
this.loadAliasesSync();
|
|
8233
8303
|
}
|
|
8234
8304
|
loadAliasesSync() {
|
|
8235
|
-
const aliasPath =
|
|
8305
|
+
const aliasPath = path16.join(this.baseDir, "config", "aliases.json");
|
|
8236
8306
|
this.userAliases = {};
|
|
8237
8307
|
const raw = readEntityAliasConfigSync(this.baseDir);
|
|
8238
8308
|
if (raw === void 0) return;
|
|
@@ -8270,9 +8340,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8270
8340
|
await mkdir2(this.baseDir, { recursive: true });
|
|
8271
8341
|
await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
8272
8342
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8273
|
-
await mkdir2(
|
|
8274
|
-
await mkdir2(
|
|
8275
|
-
await mkdir2(
|
|
8343
|
+
await mkdir2(path16.join(this.factsDir, today), { recursive: true });
|
|
8344
|
+
await mkdir2(path16.join(this.proceduresDir, today), { recursive: true });
|
|
8345
|
+
await mkdir2(path16.join(this.reasoningTracesDir, today), { recursive: true });
|
|
8276
8346
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
8277
8347
|
await mkdir2(this.entitiesDir, { recursive: true });
|
|
8278
8348
|
await mkdir2(this.stateDir, { recursive: true });
|
|
@@ -8282,7 +8352,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8282
8352
|
await mkdir2(this.identityIncidentsDir, { recursive: true });
|
|
8283
8353
|
await mkdir2(this.identityAuditsWeeklyDir, { recursive: true });
|
|
8284
8354
|
await mkdir2(this.identityAuditsMonthlyDir, { recursive: true });
|
|
8285
|
-
await mkdir2(
|
|
8355
|
+
await mkdir2(path16.join(this.baseDir, "config"), { recursive: true });
|
|
8286
8356
|
await this.entityCanonicalIdMigration.begin(options.waitForEntityMigration !== false, this.entitiesDir);
|
|
8287
8357
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
8288
8358
|
this.bumpMemoryCorpusVersion();
|
|
@@ -8305,11 +8375,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8305
8375
|
async resolveCategoryWritePath(category, id, today) {
|
|
8306
8376
|
if (category === "correction") {
|
|
8307
8377
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
8308
|
-
return
|
|
8378
|
+
return path16.join(this.correctionsDir, `${id}.md`);
|
|
8309
8379
|
}
|
|
8310
|
-
const datedDir =
|
|
8380
|
+
const datedDir = path16.join(getCategoryDir(this.baseDir, category), today);
|
|
8311
8381
|
await mkdir2(datedDir, { recursive: true });
|
|
8312
|
-
return
|
|
8382
|
+
return path16.join(datedDir, `${id}.md`);
|
|
8313
8383
|
}
|
|
8314
8384
|
async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
|
|
8315
8385
|
const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
|
|
@@ -8480,7 +8550,7 @@ ${sanitized.text}
|
|
|
8480
8550
|
}
|
|
8481
8551
|
});
|
|
8482
8552
|
} catch (err) {
|
|
8483
|
-
await
|
|
8553
|
+
await unlink5(filePath).catch(() => void 0);
|
|
8484
8554
|
this.invalidateAllMemoriesCache();
|
|
8485
8555
|
await this.rebuildTombstoneBlockedCaptureAfterInvalidationForPath(filePath);
|
|
8486
8556
|
throw err;
|
|
@@ -8688,7 +8758,7 @@ ${sanitized.text}
|
|
|
8688
8758
|
await this.ensureDirectories();
|
|
8689
8759
|
const now = /* @__PURE__ */ new Date();
|
|
8690
8760
|
const day = now.toISOString().slice(0, 10);
|
|
8691
|
-
const dir =
|
|
8761
|
+
const dir = path16.join(this.artifactsDir, day);
|
|
8692
8762
|
await mkdir2(dir, { recursive: true });
|
|
8693
8763
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
8694
8764
|
const fm = {
|
|
@@ -8715,7 +8785,7 @@ ${sanitized.text}
|
|
|
8715
8785
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
8716
8786
|
return "";
|
|
8717
8787
|
}
|
|
8718
|
-
const filePath =
|
|
8788
|
+
const filePath = path16.join(dir, `${id}.md`);
|
|
8719
8789
|
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(this.withOkfType(fm))}
|
|
8720
8790
|
|
|
8721
8791
|
${sanitized.text}
|
|
@@ -9009,7 +9079,7 @@ ${sanitized.text}
|
|
|
9009
9079
|
* per-process in-memory cache safe across process boundaries.
|
|
9010
9080
|
*/
|
|
9011
9081
|
invalidateColdMemoriesCache() {
|
|
9012
|
-
const coldRoot =
|
|
9082
|
+
const coldRoot = path16.join(this.baseDir, "cold");
|
|
9013
9083
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
9014
9084
|
this.bumpColdWriteVersion();
|
|
9015
9085
|
invalidateAllForDir(this.baseDir);
|
|
@@ -9127,7 +9197,7 @@ ${sanitized.text}
|
|
|
9127
9197
|
const correctionPaths = [];
|
|
9128
9198
|
const factPaths = [];
|
|
9129
9199
|
for (const filePath of filePaths) {
|
|
9130
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
9200
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path16.sep}`)) {
|
|
9131
9201
|
correctionPaths.push(filePath);
|
|
9132
9202
|
} else {
|
|
9133
9203
|
factPaths.push(filePath);
|
|
@@ -9191,10 +9261,10 @@ ${sanitized.text}
|
|
|
9191
9261
|
const root = this.archiveDir;
|
|
9192
9262
|
const readDir = async (dir) => {
|
|
9193
9263
|
try {
|
|
9194
|
-
const entries = (await
|
|
9264
|
+
const entries = (await readdir7(dir, { withFileTypes: true })).filter((e) => !isMacOsReplicationJunkBasename(e.name));
|
|
9195
9265
|
for (const entry of entries) {
|
|
9196
9266
|
checkCorpusReadAbort(options);
|
|
9197
|
-
const fullPath =
|
|
9267
|
+
const fullPath = path16.join(dir, entry.name);
|
|
9198
9268
|
if (entry.isDirectory()) {
|
|
9199
9269
|
await readDir(fullPath);
|
|
9200
9270
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -9234,7 +9304,7 @@ ${sanitized.text}
|
|
|
9234
9304
|
return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
|
|
9235
9305
|
}
|
|
9236
9306
|
resolveTierRootDir(tier) {
|
|
9237
|
-
return tier === "cold" ?
|
|
9307
|
+
return tier === "cold" ? path16.join(this.baseDir, "cold") : this.baseDir;
|
|
9238
9308
|
}
|
|
9239
9309
|
resolveMemoryDateDir(memory) {
|
|
9240
9310
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -9249,13 +9319,13 @@ ${sanitized.text}
|
|
|
9249
9319
|
buildTierMemoryPath(memory, tier) {
|
|
9250
9320
|
const root = this.resolveTierRootDir(tier);
|
|
9251
9321
|
if (this.isArtifactMemory(memory)) {
|
|
9252
|
-
return
|
|
9322
|
+
return path16.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9253
9323
|
}
|
|
9254
9324
|
if (memory.frontmatter.category === "correction") {
|
|
9255
|
-
return
|
|
9325
|
+
return path16.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
9256
9326
|
}
|
|
9257
9327
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
9258
|
-
return
|
|
9328
|
+
return path16.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9259
9329
|
}
|
|
9260
9330
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
9261
9331
|
assertNotOkfReservedBasename(targetPath);
|
|
@@ -9287,9 +9357,9 @@ ${memory.content}
|
|
|
9287
9357
|
});
|
|
9288
9358
|
} catch (err) {
|
|
9289
9359
|
if (priorDest === null) {
|
|
9290
|
-
await
|
|
9360
|
+
await unlink5(targetPath).catch(() => void 0);
|
|
9291
9361
|
} else {
|
|
9292
|
-
await
|
|
9362
|
+
await writeFile2(targetPath, priorDest).catch(() => void 0);
|
|
9293
9363
|
}
|
|
9294
9364
|
this.invalidateAllMemoriesCache();
|
|
9295
9365
|
throw err;
|
|
@@ -9334,8 +9404,8 @@ ${memory.content}
|
|
|
9334
9404
|
memory.frontmatter.entityRef = current.frontmatter.entityRef;
|
|
9335
9405
|
}
|
|
9336
9406
|
durable = true;
|
|
9337
|
-
const sourcePath =
|
|
9338
|
-
const destPath =
|
|
9407
|
+
const sourcePath = path16.resolve(current.path);
|
|
9408
|
+
const destPath = path16.resolve(targetPath);
|
|
9339
9409
|
if (sourcePath !== destPath) {
|
|
9340
9410
|
await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
|
|
9341
9411
|
this.invalidateAllMemoriesCache();
|
|
@@ -9359,8 +9429,8 @@ ${memory.content}
|
|
|
9359
9429
|
}
|
|
9360
9430
|
async migrateMemoryToTier(memory, targetTier) {
|
|
9361
9431
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
9362
|
-
const sourcePath =
|
|
9363
|
-
const destPath =
|
|
9432
|
+
const sourcePath = path16.resolve(memory.path);
|
|
9433
|
+
const destPath = path16.resolve(targetPath);
|
|
9364
9434
|
if (sourcePath === destPath) {
|
|
9365
9435
|
return { changed: false, targetPath };
|
|
9366
9436
|
}
|
|
@@ -9370,7 +9440,7 @@ ${memory.content}
|
|
|
9370
9440
|
return { changed, targetPath };
|
|
9371
9441
|
}
|
|
9372
9442
|
get archiveDir() {
|
|
9373
|
-
return
|
|
9443
|
+
return path16.join(this.baseDir, "archive");
|
|
9374
9444
|
}
|
|
9375
9445
|
/**
|
|
9376
9446
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -9383,7 +9453,7 @@ ${memory.content}
|
|
|
9383
9453
|
try {
|
|
9384
9454
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
9385
9455
|
const today = now.toISOString().slice(0, 10);
|
|
9386
|
-
const destDir =
|
|
9456
|
+
const destDir = path16.join(this.archiveDir, today);
|
|
9387
9457
|
await mkdir2(destDir, { recursive: true });
|
|
9388
9458
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9389
9459
|
const updatedFm = canonicalizeEntityRefOption(
|
|
@@ -9399,7 +9469,7 @@ ${memory.content}
|
|
|
9399
9469
|
|
|
9400
9470
|
${current.content}
|
|
9401
9471
|
`;
|
|
9402
|
-
const destPath =
|
|
9472
|
+
const destPath = path16.join(destDir, path16.basename(current.path));
|
|
9403
9473
|
const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
|
|
9404
9474
|
await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
|
|
9405
9475
|
if (typeof current.frontmatter.entityRef === "string") {
|
|
@@ -9416,7 +9486,7 @@ ${current.content}
|
|
|
9416
9486
|
await recordArchiveDelete2(
|
|
9417
9487
|
this.baseDir,
|
|
9418
9488
|
destPath,
|
|
9419
|
-
() =>
|
|
9489
|
+
() => unlink5(destPath).then(
|
|
9420
9490
|
() => true,
|
|
9421
9491
|
() => false
|
|
9422
9492
|
)
|
|
@@ -9633,7 +9703,7 @@ ${memory.content}
|
|
|
9633
9703
|
`;
|
|
9634
9704
|
await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
|
|
9635
9705
|
this.invalidateAllMemoriesCache();
|
|
9636
|
-
if (memory.path.includes(`${
|
|
9706
|
+
if (memory.path.includes(`${path16.sep}cold${path16.sep}`)) {
|
|
9637
9707
|
this.invalidateColdMemoriesCache();
|
|
9638
9708
|
}
|
|
9639
9709
|
});
|
|
@@ -9645,7 +9715,7 @@ ${memory.content}
|
|
|
9645
9715
|
}
|
|
9646
9716
|
if (mentionReentry && !entityMentionEpoch.neutral(memory.frontmatter, updated)) entityMentionEpoch.bump(this.baseDir);
|
|
9647
9717
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
9648
|
-
if (memory.path.includes(`${
|
|
9718
|
+
if (memory.path.includes(`${path16.sep}cold${path16.sep}`)) {
|
|
9649
9719
|
this.invalidateColdMemoriesCache();
|
|
9650
9720
|
}
|
|
9651
9721
|
try {
|
|
@@ -9747,7 +9817,7 @@ ${memory.content}
|
|
|
9747
9817
|
return saveDroppedExtractionChunk(this.stateDir, (file, content) => this.writeStorageSecureFile(file, content), bufferKey, reason, turns);
|
|
9748
9818
|
}
|
|
9749
9819
|
async loadMeta() {
|
|
9750
|
-
const metaPath =
|
|
9820
|
+
const metaPath = path16.join(this.stateDir, "meta.json");
|
|
9751
9821
|
try {
|
|
9752
9822
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
9753
9823
|
const parsed = JSON.parse(raw);
|
|
@@ -9780,7 +9850,7 @@ ${memory.content}
|
|
|
9780
9850
|
}
|
|
9781
9851
|
async saveMeta(state) {
|
|
9782
9852
|
await this.ensureDirectories();
|
|
9783
|
-
await this.writeStorageSecureFile(
|
|
9853
|
+
await this.writeStorageSecureFile(path16.join(this.stateDir, "meta.json"), JSON.stringify(state, null, 2));
|
|
9784
9854
|
}
|
|
9785
9855
|
async appendMemoryActionEvents(events) {
|
|
9786
9856
|
if (events.length === 0) return 0;
|
|
@@ -9849,7 +9919,7 @@ ${memory.content}
|
|
|
9849
9919
|
},
|
|
9850
9920
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
9851
9921
|
async () => {
|
|
9852
|
-
await mkdir2(
|
|
9922
|
+
await mkdir2(path16.dirname(target), { recursive: true });
|
|
9853
9923
|
}
|
|
9854
9924
|
);
|
|
9855
9925
|
}
|
|
@@ -9947,7 +10017,7 @@ ${memory.content}
|
|
|
9947
10017
|
async appendReextractJobs(events) {
|
|
9948
10018
|
if (events.length === 0) return 0;
|
|
9949
10019
|
await this.ensureDirectories();
|
|
9950
|
-
const filePath =
|
|
10020
|
+
const filePath = path16.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9951
10021
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
9952
10022
|
try {
|
|
9953
10023
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -9960,7 +10030,7 @@ ${memory.content}
|
|
|
9960
10030
|
}
|
|
9961
10031
|
async readReextractJobs(limit = 200) {
|
|
9962
10032
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
9963
|
-
const filePath =
|
|
10033
|
+
const filePath = path16.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9964
10034
|
try {
|
|
9965
10035
|
const raw = await this.readStorageSecureFile(filePath);
|
|
9966
10036
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -10125,8 +10195,8 @@ ${memory.content}
|
|
|
10125
10195
|
activationState: "active"
|
|
10126
10196
|
});
|
|
10127
10197
|
await Promise.all([
|
|
10128
|
-
|
|
10129
|
-
|
|
10198
|
+
unlink5(this.compressionGuidelineDraftPath).catch(() => void 0),
|
|
10199
|
+
unlink5(this.compressionGuidelineDraftStatePath).catch(() => void 0)
|
|
10130
10200
|
]);
|
|
10131
10201
|
return true;
|
|
10132
10202
|
}
|
|
@@ -10195,7 +10265,7 @@ ${question}
|
|
|
10195
10265
|
|
|
10196
10266
|
**Context:** ${context}
|
|
10197
10267
|
`;
|
|
10198
|
-
const filePath =
|
|
10268
|
+
const filePath = path16.join(this.questionsDir, `${id}.md`);
|
|
10199
10269
|
await this.writeStorageSecureFile(filePath, content);
|
|
10200
10270
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
10201
10271
|
this.invalidateQuestionsCache();
|
|
@@ -10239,7 +10309,7 @@ ${question}
|
|
|
10239
10309
|
}
|
|
10240
10310
|
async writeIdentity(workspaceDir, content, namespace) {
|
|
10241
10311
|
const identityPath = this.identityFilePath(workspaceDir, namespace);
|
|
10242
|
-
await
|
|
10312
|
+
await writeFile2(identityPath, content, "utf-8");
|
|
10243
10313
|
log.debug(`wrote consolidated IDENTITY.md (${content.length} chars)`);
|
|
10244
10314
|
}
|
|
10245
10315
|
/** Max size for IDENTITY.md before we stop appending reflections (15KB leaves room under 20KB gateway limit) */
|
|
@@ -10254,18 +10324,18 @@ ${question}
|
|
|
10254
10324
|
} catch {
|
|
10255
10325
|
}
|
|
10256
10326
|
const hygiene = opts?.hygiene;
|
|
10257
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
10327
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path16.basename(identityPath));
|
|
10258
10328
|
if (rotateEnabled) {
|
|
10259
10329
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
10260
10330
|
if (existing.length > maxBytes) {
|
|
10261
|
-
const archiveDir =
|
|
10331
|
+
const archiveDir = path16.join(workspaceDir, hygiene.archiveDir);
|
|
10262
10332
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
10263
10333
|
filePath: identityPath,
|
|
10264
10334
|
archiveDir,
|
|
10265
10335
|
archivePrefix: "IDENTITY",
|
|
10266
10336
|
keepTailChars: hygiene.rotateKeepTailChars
|
|
10267
10337
|
});
|
|
10268
|
-
await
|
|
10338
|
+
await writeFile2(identityPath, newContent, "utf-8");
|
|
10269
10339
|
existing = newContent;
|
|
10270
10340
|
log.info(`rotated IDENTITY.md to archive (size=${existing.length} chars, maxBytes=${maxBytes})`);
|
|
10271
10341
|
}
|
|
@@ -10298,7 +10368,7 @@ ${question}
|
|
|
10298
10368
|
|
|
10299
10369
|
${reflection}
|
|
10300
10370
|
`;
|
|
10301
|
-
await
|
|
10371
|
+
await writeFile2(identityPath, existing + section, "utf-8");
|
|
10302
10372
|
log.debug(`appended reflection to ${identityPath}`);
|
|
10303
10373
|
}
|
|
10304
10374
|
async readIdentityReflections() {
|
|
@@ -10518,7 +10588,7 @@ ${reflection}
|
|
|
10518
10588
|
if (entries.length === 0) return 0;
|
|
10519
10589
|
const memories = await this.readAllMemories();
|
|
10520
10590
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
10521
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
10591
|
+
const memoryPathMap = new Map(memories.map((m) => [path16.resolve(m.path), m]));
|
|
10522
10592
|
let updated = 0;
|
|
10523
10593
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
10524
10594
|
let entityRefMoved = false;
|
|
@@ -10526,7 +10596,7 @@ ${reflection}
|
|
|
10526
10596
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
10527
10597
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
10528
10598
|
for (const entry of entries) {
|
|
10529
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
10599
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path16.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
10530
10600
|
if (!memory) continue;
|
|
10531
10601
|
try {
|
|
10532
10602
|
const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
|
|
@@ -10558,7 +10628,7 @@ ${current.content}
|
|
|
10558
10628
|
if (warm) {
|
|
10559
10629
|
updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
|
|
10560
10630
|
}
|
|
10561
|
-
appliedPatches.set(
|
|
10631
|
+
appliedPatches.set(path16.resolve(memory.path), {
|
|
10562
10632
|
accessCount: entry.newCount,
|
|
10563
10633
|
lastAccessed: entry.lastAccessed
|
|
10564
10634
|
});
|
|
@@ -10576,7 +10646,7 @@ ${current.content}
|
|
|
10576
10646
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
10577
10647
|
if (cur) {
|
|
10578
10648
|
const reapplied = cur.map((m) => {
|
|
10579
|
-
const patch = appliedPatches.get(
|
|
10649
|
+
const patch = appliedPatches.get(path16.resolve(m.path));
|
|
10580
10650
|
return patch ? {
|
|
10581
10651
|
...m,
|
|
10582
10652
|
frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
|
|
@@ -10606,7 +10676,7 @@ ${current.content}
|
|
|
10606
10676
|
const pathsById = /* @__PURE__ */ new Map();
|
|
10607
10677
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
10608
10678
|
for (const filePath of filePaths) {
|
|
10609
|
-
const memoryId =
|
|
10679
|
+
const memoryId = path16.basename(filePath, ".md");
|
|
10610
10680
|
if (!wantedIds.has(memoryId)) continue;
|
|
10611
10681
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
10612
10682
|
paths.push(filePath);
|
|
@@ -10618,7 +10688,7 @@ ${current.content}
|
|
|
10618
10688
|
const preferredMatches = [];
|
|
10619
10689
|
for (const preferredPath of preferred) {
|
|
10620
10690
|
const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
|
|
10621
|
-
const directMatch = existingPaths.find((filePath) => directCandidates.has(
|
|
10691
|
+
const directMatch = existingPaths.find((filePath) => directCandidates.has(path16.resolve(filePath)));
|
|
10622
10692
|
if (directMatch) {
|
|
10623
10693
|
preferredMatches.push(directMatch);
|
|
10624
10694
|
continue;
|
|
@@ -10630,7 +10700,7 @@ ${current.content}
|
|
|
10630
10700
|
candidates.add(candidate);
|
|
10631
10701
|
}
|
|
10632
10702
|
}
|
|
10633
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
10703
|
+
const match = existingPaths.find((filePath) => candidates.has(path16.resolve(filePath)));
|
|
10634
10704
|
if (match) preferredMatches.push(match);
|
|
10635
10705
|
}
|
|
10636
10706
|
if (preferredMatches.length > 0) {
|
|
@@ -10952,21 +11022,21 @@ ${current.content}
|
|
|
10952
11022
|
}
|
|
10953
11023
|
}
|
|
10954
11024
|
get summariesDir() {
|
|
10955
|
-
return
|
|
11025
|
+
return path16.join(this.baseDir, "summaries");
|
|
10956
11026
|
}
|
|
10957
11027
|
async writeSummary(summary) {
|
|
10958
11028
|
await mkdir2(this.summariesDir, { recursive: true });
|
|
10959
|
-
const filePath =
|
|
11029
|
+
const filePath = path16.join(this.summariesDir, `${summary.id}.json`);
|
|
10960
11030
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
10961
11031
|
log.debug(`wrote summary ${summary.id}`);
|
|
10962
11032
|
}
|
|
10963
11033
|
async readSummaries() {
|
|
10964
11034
|
try {
|
|
10965
|
-
const files = await
|
|
11035
|
+
const files = await readdir7(this.summariesDir);
|
|
10966
11036
|
const summaries = [];
|
|
10967
11037
|
for (const file of files) {
|
|
10968
11038
|
if (isMacOsReplicationJunkBasename(file) || !file.endsWith(".json")) continue;
|
|
10969
|
-
const filePath =
|
|
11039
|
+
const filePath = path16.join(this.summariesDir, file);
|
|
10970
11040
|
const raw = await this.readStorageSecureFile(filePath);
|
|
10971
11041
|
summaries.push(JSON.parse(raw));
|
|
10972
11042
|
}
|
|
@@ -11036,13 +11106,13 @@ ${current.content}
|
|
|
11036
11106
|
return archived;
|
|
11037
11107
|
}
|
|
11038
11108
|
async saveTopics(topics) {
|
|
11039
|
-
const metaPath =
|
|
11109
|
+
const metaPath = path16.join(this.stateDir, "topics.json");
|
|
11040
11110
|
await mkdir2(this.stateDir, { recursive: true });
|
|
11041
11111
|
await this.writeStorageSecureFile(metaPath, JSON.stringify({ topics, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
11042
11112
|
log.debug(`saved ${topics.length} topic scores`);
|
|
11043
11113
|
}
|
|
11044
11114
|
async loadTopics() {
|
|
11045
|
-
const metaPath =
|
|
11115
|
+
const metaPath = path16.join(this.stateDir, "topics.json");
|
|
11046
11116
|
try {
|
|
11047
11117
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
11048
11118
|
return JSON.parse(raw);
|
|
@@ -11162,4 +11232,4 @@ export {
|
|
|
11162
11232
|
isValidBufferSurpriseEvent,
|
|
11163
11233
|
StorageManager3 as StorageManager
|
|
11164
11234
|
};
|
|
11165
|
-
//# sourceMappingURL=chunk-
|
|
11235
|
+
//# sourceMappingURL=chunk-OCXDZJL4.js.map
|