@remnic/core 10.0.60 → 10.0.61
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 +21 -20
- package/dist/access-authorization-probe.js +22 -21
- package/dist/access-boundary.js +21 -20
- package/dist/access-cli.js +64 -63
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.js +21 -20
- package/dist/access-http-briefing.js +22 -21
- package/dist/access-http-query.js +23 -22
- package/dist/access-http.js +39 -38
- package/dist/access-identity-continuity-surface.js +21 -20
- package/dist/access-lcm-surface.js +21 -20
- package/dist/access-mcp.js +31 -30
- package/dist/access-namespace-preflight.js +21 -20
- package/dist/access-observe-write-category.js +4 -4
- package/dist/access-observe-write-surface.js +21 -20
- package/dist/access-operations-batch.js +23 -22
- package/dist/access-operations.js +30 -29
- package/dist/access-recall-concurrency.js +21 -20
- package/dist/access-recall-response.js +21 -20
- package/dist/access-recall-surface.js +21 -20
- package/dist/access-schema.js +3 -3
- package/dist/access-service.js +21 -20
- package/dist/access-surface-catalog.js +23 -22
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/active-recall.js +6 -4
- package/dist/active-recall.js.map +1 -1
- package/dist/briefing.js +7 -5
- package/dist/buffer-persistence.d.ts +14 -3
- package/dist/buffer-persistence.d.ts.map +1 -1
- package/dist/buffer-persistence.js +1 -1
- package/dist/buffer-turn-helpers.d.ts +7 -0
- package/dist/buffer-turn-helpers.d.ts.map +1 -1
- package/dist/buffer-turn-helpers.js +5 -3
- package/dist/buffer.d.ts +2 -0
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +3 -3
- package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-GWVG7LGC.js} +2 -2
- package/dist/causal-consolidation.js +8 -6
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/{chunk-PRSF7DWT.js → chunk-23OEPU3K.js} +2 -2
- package/dist/{chunk-2EJAPJ5G.js → chunk-46U6L5DM.js} +2 -2
- package/dist/{chunk-NF5EHQTJ.js → chunk-6HTEPYOI.js} +4 -4
- package/dist/{chunk-TIS6T6UP.js → chunk-6T4CMKNP.js} +2 -2
- package/dist/{chunk-W37MS6SX.js → chunk-73A2DDDR.js} +2 -2
- package/dist/{chunk-X2TZWVCC.js → chunk-7AKPLEJV.js} +2 -2
- package/dist/{chunk-T4SMMTGY.js → chunk-7OKYO2UC.js} +2 -2
- package/dist/{chunk-WJC5KGYC.js → chunk-7ULSP7AU.js} +6 -6
- package/dist/{chunk-J53IBVMF.js → chunk-A4FZLM6Q.js} +2 -2
- package/dist/{chunk-KQAFEZQX.js → chunk-BUKK5SWA.js} +2 -2
- package/dist/{chunk-JRY55I6Z.js → chunk-C2AYUXEF.js} +2 -2
- package/dist/{chunk-PTJWUN4H.js → chunk-D3BYJSHX.js} +25 -25
- package/dist/{chunk-ADK5TMQL.js → chunk-D4WR56FR.js} +2 -2
- package/dist/{chunk-3DG2YAAX.js → chunk-DMYNM3WG.js} +59 -32
- package/dist/chunk-DMYNM3WG.js.map +1 -0
- package/dist/{chunk-66CC6L6R.js → chunk-DP22K7IC.js} +2 -2
- package/dist/{chunk-AWKADEMO.js → chunk-DTQJ7BRN.js} +3 -3
- package/dist/{chunk-IA3XZG4V.js → chunk-DZL5PBEJ.js} +2 -2
- package/dist/{chunk-7DHNBABU.js → chunk-EGCC5OJE.js} +3 -3
- package/dist/{chunk-N5H22V75.js → chunk-EJ4RS7I7.js} +2 -2
- package/dist/{chunk-MOB4JHG6.js → chunk-ENAPZQA6.js} +2 -2
- package/dist/{chunk-DF4SYU4Z.js → chunk-F2UAAI6B.js} +2 -2
- package/dist/{chunk-KXDUSGPM.js → chunk-FKNNWH7P.js} +2 -2
- package/dist/{chunk-74Z2BYEK.js → chunk-GNP4BV4Z.js} +2 -2
- package/dist/{chunk-LGLLCWA2.js → chunk-HWMGQDZI.js} +2 -2
- package/dist/{chunk-PIVSUPF2.js → chunk-IIUEHIQ2.js} +2 -2
- package/dist/{chunk-JFRO5HJY.js → chunk-IPN67KVR.js} +2 -2
- package/dist/chunk-JCL7RO2G.js +674 -0
- package/dist/chunk-JCL7RO2G.js.map +1 -0
- package/dist/{chunk-ZXEPLZUQ.js → chunk-JGSWWD33.js} +7 -7
- package/dist/{chunk-A3UFV4K3.js → chunk-JIYJIH5N.js} +2 -2
- package/dist/{chunk-M7KAJBO2.js → chunk-JKUVPVKR.js} +3 -3
- package/dist/{chunk-L5RMURVI.js → chunk-JL5FHZ7O.js} +29 -5
- package/dist/chunk-JL5FHZ7O.js.map +1 -0
- package/dist/{chunk-QWURVT5Z.js → chunk-L2HSSVVD.js} +2 -2
- package/dist/{chunk-VQ6H4DL6.js → chunk-L334PSLW.js} +4 -4
- package/dist/{chunk-UY67YP6Q.js → chunk-LIUI46BX.js} +2 -2
- package/dist/{chunk-4OFXLQJD.js → chunk-MPDLLLOG.js} +8 -3
- package/dist/chunk-MPDLLLOG.js.map +1 -0
- package/dist/{chunk-2HVCTFKG.js → chunk-MPJ7VHHA.js} +2 -2
- package/dist/{chunk-I6UTOUBK.js → chunk-N7RAABFM.js} +149 -344
- package/dist/chunk-N7RAABFM.js.map +1 -0
- package/dist/{chunk-RSYFSCKL.js → chunk-NSUGAIIB.js} +12 -12
- package/dist/{chunk-Z4EH5TSO.js → chunk-NXHBQC2O.js} +2 -2
- package/dist/{chunk-JEDS2QYV.js → chunk-OH55F76C.js} +2 -2
- package/dist/{chunk-GGHX4YHM.js → chunk-OUJ4DVR5.js} +2 -2
- package/dist/{chunk-2NLLXCJG.js → chunk-OWHERGF2.js} +2 -2
- package/dist/{chunk-4O4VAEWH.js → chunk-P5F7ISLV.js} +2 -2
- package/dist/{chunk-5XY46Z2W.js → chunk-PNVQNAJM.js} +3 -3
- package/dist/{chunk-HL643H2F.js → chunk-PRYDNBCO.js} +7 -7
- package/dist/{chunk-F3GX76LV.js → chunk-PUTH5REB.js} +2 -2
- package/dist/{chunk-IJFX4JRI.js → chunk-RBUR6USI.js} +7 -7
- package/dist/{chunk-JM2WJBP7.js → chunk-RZSHIJYY.js} +2 -2
- package/dist/{chunk-6BKSUA6P.js → chunk-SVTIWBSA.js} +2 -2
- package/dist/{chunk-M3GOWG2P.js → chunk-TBFAQHQZ.js} +2 -2
- package/dist/{chunk-ZRDEOC4X.js → chunk-TKCJI7WA.js} +2 -2
- package/dist/{chunk-NJZY5LOC.js → chunk-TLOAAOT3.js} +2 -2
- package/dist/{chunk-KZMRMKC7.js → chunk-U7MIMS2Y.js} +11 -1
- package/dist/chunk-U7MIMS2Y.js.map +1 -0
- package/dist/{chunk-X7Y7WX73.js → chunk-UVYI6VIX.js} +1 -1
- package/dist/{chunk-GJF337YM.js → chunk-VCYH2XUY.js} +2 -2
- package/dist/{chunk-UP2Q7U4G.js → chunk-WD2QH3JM.js} +2 -2
- package/dist/{chunk-MHSUEA32.js → chunk-WWSJQ7MP.js} +3 -3
- package/dist/{chunk-UIX4JLVV.js → chunk-XAFSZ4DP.js} +2 -2
- package/dist/{chunk-PJLJN23N.js → chunk-XICJL56Z.js} +2 -2
- package/dist/{chunk-C5GTIRIO.js → chunk-XJDSZFBZ.js} +18 -18
- package/dist/cli.js +52 -51
- package/dist/coding/export-okf-codegraph.js +6 -4
- package/dist/coding/export-okf-codegraph.js.map +1 -1
- package/dist/compounding/engine.js +8 -6
- package/dist/config.js +6 -4
- package/dist/connectors/codex-materialize-runner.js +7 -5
- package/dist/connectors/index.js +7 -5
- package/dist/convergence-refresh.js +9 -7
- package/dist/corpus-watermark.js +9 -7
- package/dist/deep-recall-http-glue.js +4 -4
- package/dist/entity-retrieval.js +7 -5
- package/dist/external-wiki-access.js +22 -21
- package/dist/extraction.js +7 -5
- package/dist/harmonic-retrieval.js +7 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -63
- package/dist/location/index.js +9 -7
- package/dist/maintenance/memory-governance.js +7 -5
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -5
- package/dist/maintenance/rebuild-memory-projection-runner.js +9 -7
- package/dist/maintenance/rebuild-memory-projection.js +8 -6
- package/dist/memory-browse-operations.js +22 -21
- package/dist/namespaces/migrate.js +8 -6
- package/dist/namespaces/search.js +3 -3
- package/dist/namespaces/storage.js +7 -5
- package/dist/operator-doctor-corpus.js +10 -8
- package/dist/operator-toolkit.js +15 -13
- package/dist/orchestration/buffer-drain-gate.d.ts +21 -0
- package/dist/orchestration/buffer-drain-gate.d.ts.map +1 -0
- package/dist/orchestration/buffer-drain-runner.d.ts +79 -0
- package/dist/orchestration/buffer-drain-runner.d.ts.map +1 -0
- package/dist/orchestration/buffer-drain-runner.js +780 -0
- package/dist/orchestration/buffer-drain-runner.js.map +1 -0
- package/dist/orchestration/buffer-swap.d.ts +12 -0
- package/dist/orchestration/buffer-swap.d.ts.map +1 -0
- package/dist/orchestration/maintenance.js +17 -15
- package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
- package/dist/orchestrator.d.ts +4 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +64 -63
- package/dist/recall-navigation-operations.js +22 -21
- package/dist/recall-navigation.js +21 -20
- package/dist/resume-bundles.js +6 -4
- package/dist/search/factory.js +2 -2
- package/dist/search/index.js +4 -4
- package/dist/semantic-consolidation.js +8 -6
- package/dist/semantic-rule-promotion.js +7 -5
- package/dist/semantic-rule-verifier.js +7 -5
- package/dist/source-agent-qualifier.js +7 -5
- package/dist/standup/build.js +7 -5
- package/dist/storage/buffer-drain-claims.d.ts +159 -0
- package/dist/storage/buffer-drain-claims.d.ts.map +1 -0
- package/dist/storage/buffer-drain-claims.js +18 -0
- package/dist/storage/buffer-drain-claims.js.map +1 -0
- package/dist/storage/buffer-session-files.d.ts +14 -2
- package/dist/storage/buffer-session-files.d.ts.map +1 -1
- package/dist/storage/buffer-session-files.js +22 -0
- package/dist/storage/buffer-session-files.js.map +1 -0
- package/dist/storage.d.ts +6 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -4
- package/dist/support-passport/index.js +24 -23
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/export-okf.js +7 -5
- package/dist/verified-recall.js +7 -5
- package/dist/who-knows-cli.js +8 -6
- package/dist/who-knows.js +7 -5
- package/package.json +32 -2
- package/src/buffer-drain-handover.test.ts +307 -0
- package/src/buffer-persistence.ts +27 -5
- package/src/buffer-turn-helpers.ts +16 -0
- package/src/buffer.ts +32 -2
- package/src/index.ts +1 -1
- package/src/orchestration/buffer-drain-gate.test.ts +40 -0
- package/src/orchestration/buffer-drain-gate.ts +38 -0
- package/src/orchestration/buffer-drain-runner.ts +312 -0
- package/src/orchestration/buffer-swap.ts +27 -0
- package/src/orchestration/turn-ingestion.ts +2 -0
- package/src/orchestrator.ts +9 -6
- package/src/storage/buffer-drain-claims.test.ts +448 -0
- package/src/storage/buffer-drain-claims.ts +593 -0
- package/src/storage/buffer-session-files.ts +50 -3
- package/src/storage.ts +8 -11
- package/src/testing/subjects/extraction-lifecycle.test.ts +34 -0
- package/dist/chunk-3DG2YAAX.js.map +0 -1
- package/dist/chunk-4OFXLQJD.js.map +0 -1
- package/dist/chunk-I6UTOUBK.js.map +0 -1
- package/dist/chunk-KZMRMKC7.js.map +0 -1
- package/dist/chunk-L5RMURVI.js.map +0 -1
- /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
- /package/dist/{chunk-PRSF7DWT.js.map → chunk-23OEPU3K.js.map} +0 -0
- /package/dist/{chunk-2EJAPJ5G.js.map → chunk-46U6L5DM.js.map} +0 -0
- /package/dist/{chunk-NF5EHQTJ.js.map → chunk-6HTEPYOI.js.map} +0 -0
- /package/dist/{chunk-TIS6T6UP.js.map → chunk-6T4CMKNP.js.map} +0 -0
- /package/dist/{chunk-W37MS6SX.js.map → chunk-73A2DDDR.js.map} +0 -0
- /package/dist/{chunk-X2TZWVCC.js.map → chunk-7AKPLEJV.js.map} +0 -0
- /package/dist/{chunk-T4SMMTGY.js.map → chunk-7OKYO2UC.js.map} +0 -0
- /package/dist/{chunk-WJC5KGYC.js.map → chunk-7ULSP7AU.js.map} +0 -0
- /package/dist/{chunk-J53IBVMF.js.map → chunk-A4FZLM6Q.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-BUKK5SWA.js.map} +0 -0
- /package/dist/{chunk-JRY55I6Z.js.map → chunk-C2AYUXEF.js.map} +0 -0
- /package/dist/{chunk-PTJWUN4H.js.map → chunk-D3BYJSHX.js.map} +0 -0
- /package/dist/{chunk-ADK5TMQL.js.map → chunk-D4WR56FR.js.map} +0 -0
- /package/dist/{chunk-66CC6L6R.js.map → chunk-DP22K7IC.js.map} +0 -0
- /package/dist/{chunk-AWKADEMO.js.map → chunk-DTQJ7BRN.js.map} +0 -0
- /package/dist/{chunk-IA3XZG4V.js.map → chunk-DZL5PBEJ.js.map} +0 -0
- /package/dist/{chunk-7DHNBABU.js.map → chunk-EGCC5OJE.js.map} +0 -0
- /package/dist/{chunk-N5H22V75.js.map → chunk-EJ4RS7I7.js.map} +0 -0
- /package/dist/{chunk-MOB4JHG6.js.map → chunk-ENAPZQA6.js.map} +0 -0
- /package/dist/{chunk-DF4SYU4Z.js.map → chunk-F2UAAI6B.js.map} +0 -0
- /package/dist/{chunk-KXDUSGPM.js.map → chunk-FKNNWH7P.js.map} +0 -0
- /package/dist/{chunk-74Z2BYEK.js.map → chunk-GNP4BV4Z.js.map} +0 -0
- /package/dist/{chunk-LGLLCWA2.js.map → chunk-HWMGQDZI.js.map} +0 -0
- /package/dist/{chunk-PIVSUPF2.js.map → chunk-IIUEHIQ2.js.map} +0 -0
- /package/dist/{chunk-JFRO5HJY.js.map → chunk-IPN67KVR.js.map} +0 -0
- /package/dist/{chunk-ZXEPLZUQ.js.map → chunk-JGSWWD33.js.map} +0 -0
- /package/dist/{chunk-A3UFV4K3.js.map → chunk-JIYJIH5N.js.map} +0 -0
- /package/dist/{chunk-M7KAJBO2.js.map → chunk-JKUVPVKR.js.map} +0 -0
- /package/dist/{chunk-QWURVT5Z.js.map → chunk-L2HSSVVD.js.map} +0 -0
- /package/dist/{chunk-VQ6H4DL6.js.map → chunk-L334PSLW.js.map} +0 -0
- /package/dist/{chunk-UY67YP6Q.js.map → chunk-LIUI46BX.js.map} +0 -0
- /package/dist/{chunk-2HVCTFKG.js.map → chunk-MPJ7VHHA.js.map} +0 -0
- /package/dist/{chunk-RSYFSCKL.js.map → chunk-NSUGAIIB.js.map} +0 -0
- /package/dist/{chunk-Z4EH5TSO.js.map → chunk-NXHBQC2O.js.map} +0 -0
- /package/dist/{chunk-JEDS2QYV.js.map → chunk-OH55F76C.js.map} +0 -0
- /package/dist/{chunk-GGHX4YHM.js.map → chunk-OUJ4DVR5.js.map} +0 -0
- /package/dist/{chunk-2NLLXCJG.js.map → chunk-OWHERGF2.js.map} +0 -0
- /package/dist/{chunk-4O4VAEWH.js.map → chunk-P5F7ISLV.js.map} +0 -0
- /package/dist/{chunk-5XY46Z2W.js.map → chunk-PNVQNAJM.js.map} +0 -0
- /package/dist/{chunk-HL643H2F.js.map → chunk-PRYDNBCO.js.map} +0 -0
- /package/dist/{chunk-F3GX76LV.js.map → chunk-PUTH5REB.js.map} +0 -0
- /package/dist/{chunk-IJFX4JRI.js.map → chunk-RBUR6USI.js.map} +0 -0
- /package/dist/{chunk-JM2WJBP7.js.map → chunk-RZSHIJYY.js.map} +0 -0
- /package/dist/{chunk-6BKSUA6P.js.map → chunk-SVTIWBSA.js.map} +0 -0
- /package/dist/{chunk-M3GOWG2P.js.map → chunk-TBFAQHQZ.js.map} +0 -0
- /package/dist/{chunk-ZRDEOC4X.js.map → chunk-TKCJI7WA.js.map} +0 -0
- /package/dist/{chunk-NJZY5LOC.js.map → chunk-TLOAAOT3.js.map} +0 -0
- /package/dist/{chunk-X7Y7WX73.js.map → chunk-UVYI6VIX.js.map} +0 -0
- /package/dist/{chunk-GJF337YM.js.map → chunk-VCYH2XUY.js.map} +0 -0
- /package/dist/{chunk-UP2Q7U4G.js.map → chunk-WD2QH3JM.js.map} +0 -0
- /package/dist/{chunk-MHSUEA32.js.map → chunk-WWSJQ7MP.js.map} +0 -0
- /package/dist/{chunk-UIX4JLVV.js.map → chunk-XAFSZ4DP.js.map} +0 -0
- /package/dist/{chunk-PJLJN23N.js.map → chunk-XICJL56Z.js.map} +0 -0
- /package/dist/{chunk-C5GTIRIO.js.map → chunk-XJDSZFBZ.js.map} +0 -0
|
@@ -20,10 +20,13 @@ import {
|
|
|
20
20
|
migrateLegacyEntityCanonicalIds,
|
|
21
21
|
validateRoots
|
|
22
22
|
} from "./chunk-WVEEVYMH.js";
|
|
23
|
+
import {
|
|
24
|
+
BufferSessionFiles
|
|
25
|
+
} from "./chunk-JCL7RO2G.js";
|
|
23
26
|
import {
|
|
24
27
|
normalizeQmdResultPath,
|
|
25
28
|
resolveNamespaceResultPath
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-OH55F76C.js";
|
|
27
30
|
import {
|
|
28
31
|
withholdToolScopedFromSharedNamespace
|
|
29
32
|
} from "./chunk-S2V7RUCL.js";
|
|
@@ -289,19 +292,19 @@ import {
|
|
|
289
292
|
|
|
290
293
|
// src/storage.ts
|
|
291
294
|
import {
|
|
292
|
-
lstat as
|
|
293
|
-
readdir as
|
|
295
|
+
lstat as lstat4,
|
|
296
|
+
readdir as readdir6,
|
|
294
297
|
readFile,
|
|
295
298
|
realpath as realpath2,
|
|
296
299
|
stat as stat3,
|
|
297
300
|
writeFile as writeFile2,
|
|
298
301
|
mkdir as mkdir2,
|
|
299
|
-
unlink as
|
|
302
|
+
unlink as unlink4,
|
|
300
303
|
appendFile,
|
|
301
304
|
open
|
|
302
305
|
} from "fs/promises";
|
|
303
306
|
import { appendFileSync, createReadStream, mkdirSync, statSync as statSync2 } from "fs";
|
|
304
|
-
import { createHash as
|
|
307
|
+
import { createHash as createHash5 } from "crypto";
|
|
305
308
|
|
|
306
309
|
// src/preferences/drift-types.ts
|
|
307
310
|
function serializeDriftProvenance(fm) {
|
|
@@ -325,7 +328,7 @@ function parseDriftProvenance(fm) {
|
|
|
325
328
|
}
|
|
326
329
|
|
|
327
330
|
// src/storage.ts
|
|
328
|
-
import
|
|
331
|
+
import path15 from "path";
|
|
329
332
|
|
|
330
333
|
// src/storage/tombstone-migration-sources.ts
|
|
331
334
|
import { statSync } from "fs";
|
|
@@ -4957,209 +4960,13 @@ var MeetingRecordStore = class {
|
|
|
4957
4960
|
};
|
|
4958
4961
|
var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
4959
4962
|
|
|
4960
|
-
// src/storage/buffer-session-files.ts
|
|
4961
|
-
import { createHash as createHash4 } from "crypto";
|
|
4962
|
-
import { lstat as lstat4, readdir as readdir5, unlink as unlink4 } from "fs/promises";
|
|
4963
|
-
import path13 from "path";
|
|
4964
|
-
function isMissing(err) {
|
|
4965
|
-
return err?.code === "ENOENT";
|
|
4966
|
-
}
|
|
4967
|
-
function asFsError(err) {
|
|
4968
|
-
return err;
|
|
4969
|
-
}
|
|
4970
|
-
function bufferSessionFileName(key) {
|
|
4971
|
-
return `s-${createHash4("sha256").update(key).digest("hex")}.json`;
|
|
4972
|
-
}
|
|
4973
|
-
function legacyStateToEntries(state) {
|
|
4974
|
-
const entries = /* @__PURE__ */ new Map();
|
|
4975
|
-
for (const [key, value] of Object.entries(state.entries ?? {})) {
|
|
4976
|
-
if (value && Array.isArray(value.turns)) entries.set(key, value);
|
|
4977
|
-
}
|
|
4978
|
-
if (!entries.has("default")) {
|
|
4979
|
-
entries.set("default", {
|
|
4980
|
-
turns: Array.isArray(state.turns) ? state.turns : [],
|
|
4981
|
-
lastExtractionAt: state.lastExtractionAt ?? null,
|
|
4982
|
-
extractionCount: Number.isFinite(state.extractionCount) ? state.extractionCount : 0
|
|
4983
|
-
});
|
|
4984
|
-
}
|
|
4985
|
-
return entries;
|
|
4986
|
-
}
|
|
4987
|
-
function entryFromBody(body) {
|
|
4988
|
-
if (!body || !Array.isArray(body.turns) || (body.key?.length ?? 0) === 0) return null;
|
|
4989
|
-
const entry = {
|
|
4990
|
-
turns: body.turns,
|
|
4991
|
-
lastExtractionAt: body.lastExtractionAt ?? null,
|
|
4992
|
-
extractionCount: Number.isFinite(body.extractionCount) ? Number(body.extractionCount) : 0
|
|
4993
|
-
};
|
|
4994
|
-
if (Array.isArray(body.retainedTurns)) entry.retainedTurns = body.retainedTurns;
|
|
4995
|
-
return { key: String(body.key), entry };
|
|
4996
|
-
}
|
|
4997
|
-
var BufferSessionFiles = class {
|
|
4998
|
-
constructor(stateDir, io) {
|
|
4999
|
-
this.stateDir = stateDir;
|
|
5000
|
-
this.io = io;
|
|
5001
|
-
}
|
|
5002
|
-
stateDir;
|
|
5003
|
-
io;
|
|
5004
|
-
dirVerified = false;
|
|
5005
|
-
get dir() {
|
|
5006
|
-
return path13.join(this.stateDir, "buffer");
|
|
5007
|
-
}
|
|
5008
|
-
fileFor(key) {
|
|
5009
|
-
return path13.join(this.dir, bufferSessionFileName(key));
|
|
5010
|
-
}
|
|
5011
|
-
/**
|
|
5012
|
-
* Refuse a symlinked buffer directory: following it would send buffered
|
|
5013
|
-
* conversation data (and deletions) outside the memory root. One lstat of
|
|
5014
|
-
* one directory, cached after it passes, so the observe path pays nothing
|
|
5015
|
-
* per write; the cache is dropped on any failure.
|
|
5016
|
-
*/
|
|
5017
|
-
async assertDirSafe() {
|
|
5018
|
-
if (this.dirVerified) return;
|
|
5019
|
-
let stat4 = null;
|
|
5020
|
-
try {
|
|
5021
|
-
stat4 = await lstat4(this.dir);
|
|
5022
|
-
} catch (err) {
|
|
5023
|
-
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5024
|
-
}
|
|
5025
|
-
if (stat4 && (stat4.isSymbolicLink() || !stat4.isDirectory())) {
|
|
5026
|
-
throw new Error(`buffer session directory must be a real directory, not a symlink or file: ${this.dir}`);
|
|
5027
|
-
}
|
|
5028
|
-
this.dirVerified = stat4 !== null;
|
|
5029
|
-
}
|
|
5030
|
-
/** Persist ONE session atomically. Compact JSON: machine-read state, and
|
|
5031
|
-
* pretty-printing a large buffer costs CPU and bytes on every observe. */
|
|
5032
|
-
async save(key, entry) {
|
|
5033
|
-
await this.assertDirSafe();
|
|
5034
|
-
await this.io.write(this.fileFor(key), JSON.stringify({ key, ...entry }));
|
|
5035
|
-
}
|
|
5036
|
-
/** Remove one session's file. Idempotent: an absent file is fine. */
|
|
5037
|
-
async remove(key) {
|
|
5038
|
-
await this.assertDirSafe();
|
|
5039
|
-
try {
|
|
5040
|
-
await unlink4(this.fileFor(key));
|
|
5041
|
-
} catch (err) {
|
|
5042
|
-
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5043
|
-
}
|
|
5044
|
-
}
|
|
5045
|
-
async listFiles() {
|
|
5046
|
-
await this.assertDirSafe();
|
|
5047
|
-
try {
|
|
5048
|
-
const dirents = await readdir5(this.dir, { withFileTypes: true });
|
|
5049
|
-
return dirents.filter((d) => d.isFile() && d.name.endsWith(".json")).map((d) => d.name);
|
|
5050
|
-
} catch (err) {
|
|
5051
|
-
if (err instanceof Error && isMissing(asFsError(err))) return [];
|
|
5052
|
-
throw err;
|
|
5053
|
-
}
|
|
5054
|
-
}
|
|
5055
|
-
/** Read every per-session file. Corrupt files are skipped (and logged) so
|
|
5056
|
-
* one bad file cannot nuke the other sessions' buffered turns. */
|
|
5057
|
-
async readAll() {
|
|
5058
|
-
const names = await this.listFiles();
|
|
5059
|
-
const entries = /* @__PURE__ */ new Map();
|
|
5060
|
-
for (const name of names) {
|
|
5061
|
-
try {
|
|
5062
|
-
const body = JSON.parse(await this.io.read(path13.join(this.dir, name)));
|
|
5063
|
-
const parsed = entryFromBody(body);
|
|
5064
|
-
if (!parsed) throw new Error("invalid buffer session file shape");
|
|
5065
|
-
if (entries.has(parsed.key)) {
|
|
5066
|
-
log.warn(`buffer: duplicate session file for key ${parsed.key} (${name}); keeping the first`);
|
|
5067
|
-
continue;
|
|
5068
|
-
}
|
|
5069
|
-
entries.set(parsed.key, parsed.entry);
|
|
5070
|
-
} catch (err) {
|
|
5071
|
-
if (err instanceof SecureStoreLockedError || err instanceof SecureStoreDecryptError) throw err;
|
|
5072
|
-
log.warn(`buffer: skipping unreadable per-session buffer file ${name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
5073
|
-
}
|
|
5074
|
-
}
|
|
5075
|
-
return { entries, fileCount: names.length };
|
|
5076
|
-
}
|
|
5077
|
-
/**
|
|
5078
|
-
* Read the legacy single-file buffer.json for migration. Null when absent,
|
|
5079
|
-
* or unreadable while session files exist (they are authoritative; a
|
|
5080
|
-
* corrupt leftover must not block startup). With no session files a corrupt
|
|
5081
|
-
* legacy file THROWS, preserving the old contract so callers can reset it.
|
|
5082
|
-
*/
|
|
5083
|
-
async readLegacy(hasSessionFiles) {
|
|
5084
|
-
let raw;
|
|
5085
|
-
try {
|
|
5086
|
-
raw = await this.io.read(path13.join(this.stateDir, "buffer.json"));
|
|
5087
|
-
} catch (err) {
|
|
5088
|
-
if (err instanceof SecureStoreLockedError) throw err;
|
|
5089
|
-
if (err instanceof Error && isMissing(asFsError(err))) return null;
|
|
5090
|
-
throw err;
|
|
5091
|
-
}
|
|
5092
|
-
try {
|
|
5093
|
-
const legacy = JSON.parse(raw);
|
|
5094
|
-
return legacy;
|
|
5095
|
-
} catch (err) {
|
|
5096
|
-
if (!hasSessionFiles) throw err;
|
|
5097
|
-
log.warn(
|
|
5098
|
-
`buffer: legacy buffer.json is unreadable but per-session buffer files exist; ignoring the legacy file (${err instanceof Error ? err.message : String(err)})`
|
|
5099
|
-
);
|
|
5100
|
-
return null;
|
|
5101
|
-
}
|
|
5102
|
-
}
|
|
5103
|
-
/**
|
|
5104
|
-
* Load the whole buffer, migrating a legacy buffer.json once. A per-session
|
|
5105
|
-
* file that parsed wins over the legacy snapshot (a crash mid-migration
|
|
5106
|
-
* leaves exactly that pair); legacy entries without a usable file are
|
|
5107
|
-
* written out, then the legacy file is retired. Both steps are idempotent.
|
|
5108
|
-
*/
|
|
5109
|
-
async load() {
|
|
5110
|
-
const { entries, fileCount } = await this.readAll();
|
|
5111
|
-
const legacy = await this.readLegacy(fileCount > 0);
|
|
5112
|
-
if (legacy !== null) {
|
|
5113
|
-
for (const [key, entry] of legacyStateToEntries(legacy)) {
|
|
5114
|
-
if (entries.has(key)) continue;
|
|
5115
|
-
entries.set(key, entry);
|
|
5116
|
-
await this.save(key, entry);
|
|
5117
|
-
}
|
|
5118
|
-
try {
|
|
5119
|
-
await unlink4(path13.join(this.stateDir, "buffer.json"));
|
|
5120
|
-
} catch (err) {
|
|
5121
|
-
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5122
|
-
}
|
|
5123
|
-
}
|
|
5124
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
5125
|
-
for (const [key, entry] of entries) out[key] = entry;
|
|
5126
|
-
const def = entries.get("default");
|
|
5127
|
-
return {
|
|
5128
|
-
turns: def?.turns ?? [],
|
|
5129
|
-
lastExtractionAt: def?.lastExtractionAt ?? null,
|
|
5130
|
-
extractionCount: def?.extractionCount ?? 0,
|
|
5131
|
-
entries: out
|
|
5132
|
-
};
|
|
5133
|
-
}
|
|
5134
|
-
/**
|
|
5135
|
-
* Reconcile the files with a WHOLE buffer state: write every entry, then
|
|
5136
|
-
* delete files for keys no longer present. Writes first, deletes last: a
|
|
5137
|
-
* crash leaves stale extra files (removed by the next reconcile) but never
|
|
5138
|
-
* loses sessions the state says exist. Not on the observe hot path.
|
|
5139
|
-
*/
|
|
5140
|
-
async reconcile(state) {
|
|
5141
|
-
const entries = legacyStateToEntries(state);
|
|
5142
|
-
const existing = await this.listFiles();
|
|
5143
|
-
for (const [key, entry] of entries) await this.save(key, entry);
|
|
5144
|
-
const live = new Set([...entries.keys()].map((key) => bufferSessionFileName(key)));
|
|
5145
|
-
for (const name of existing) {
|
|
5146
|
-
if (live.has(name)) continue;
|
|
5147
|
-
try {
|
|
5148
|
-
await unlink4(path13.join(this.dir, name));
|
|
5149
|
-
} catch (err) {
|
|
5150
|
-
if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
|
|
5151
|
-
}
|
|
5152
|
-
}
|
|
5153
|
-
}
|
|
5154
|
-
};
|
|
5155
|
-
|
|
5156
4963
|
// src/storage/supersession-audit.ts
|
|
5157
|
-
import { readdir as
|
|
5158
|
-
import
|
|
4964
|
+
import { readdir as readdir5 } from "fs/promises";
|
|
4965
|
+
import path13 from "path";
|
|
5159
4966
|
async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
|
|
5160
4967
|
let entries;
|
|
5161
4968
|
try {
|
|
5162
|
-
entries = await
|
|
4969
|
+
entries = await readdir5(lookup.correctionsDir, { withFileTypes: true });
|
|
5163
4970
|
} catch (error) {
|
|
5164
4971
|
if (isErrnoCode(error, "ENOENT")) return false;
|
|
5165
4972
|
throw error;
|
|
@@ -5167,7 +4974,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
|
|
|
5167
4974
|
for (const entry of entries) {
|
|
5168
4975
|
if (isMacOsReplicationJunkBasename(entry.name)) continue;
|
|
5169
4976
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
5170
|
-
const memory = await lookup.readMemoryByPath(
|
|
4977
|
+
const memory = await lookup.readMemoryByPath(path13.join(lookup.correctionsDir, entry.name));
|
|
5171
4978
|
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(
|
|
5172
4979
|
([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
|
|
5173
4980
|
))) {
|
|
@@ -5259,19 +5066,19 @@ Reason: ${reason}`;
|
|
|
5259
5066
|
// src/storage/dropped-extraction-chunk.ts
|
|
5260
5067
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5261
5068
|
import { mkdir } from "fs/promises";
|
|
5262
|
-
import
|
|
5069
|
+
import path14 from "path";
|
|
5263
5070
|
async function saveDroppedExtractionChunk(stateDir, writeSecureFile, bufferKey, reason, turns) {
|
|
5264
|
-
const droppedDir =
|
|
5071
|
+
const droppedDir = path14.join(stateDir, "dropped");
|
|
5265
5072
|
await mkdir(droppedDir, { recursive: true });
|
|
5266
5073
|
const safeKey = bufferKey.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 80) || "default";
|
|
5267
|
-
const filePath =
|
|
5074
|
+
const filePath = path14.join(droppedDir, `${Date.now()}-${randomUUID2().slice(0, 8)}-${safeKey}.json`);
|
|
5268
5075
|
const payload = { bufferKey, reason, droppedAt: (/* @__PURE__ */ new Date()).toISOString(), turns };
|
|
5269
5076
|
await writeSecureFile(filePath, JSON.stringify(payload, null, 2));
|
|
5270
5077
|
return filePath;
|
|
5271
5078
|
}
|
|
5272
5079
|
|
|
5273
5080
|
// src/storage/entity-timeline.ts
|
|
5274
|
-
import { createHash as
|
|
5081
|
+
import { createHash as createHash4 } from "crypto";
|
|
5275
5082
|
var ENTITY_TIMELINE_METADATA_MARKER = "remnic-meta-v1";
|
|
5276
5083
|
function parseEntityTimelineBullet(bullet, fallbackTimestamp) {
|
|
5277
5084
|
const trimmed = bullet.trim();
|
|
@@ -5713,7 +5520,7 @@ function fingerprintEntityStructuredFacts(entity) {
|
|
|
5713
5520
|
(left, right) => left.key.localeCompare(right.key) || left.title.localeCompare(right.title) || left.facts.join("\n").localeCompare(right.facts.join("\n"))
|
|
5714
5521
|
);
|
|
5715
5522
|
if (normalizedSections.length === 0) return void 0;
|
|
5716
|
-
return
|
|
5523
|
+
return createHash4("sha256").update(JSON.stringify(normalizedSections)).digest("hex");
|
|
5717
5524
|
}
|
|
5718
5525
|
function isEntitySynthesisStale(entity) {
|
|
5719
5526
|
const structuredFactCount = countEntityStructuredFacts(entity);
|
|
@@ -6270,17 +6077,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
6270
6077
|
}
|
|
6271
6078
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
6272
6079
|
function inferEntityTypeFromFilename(pathRel) {
|
|
6273
|
-
const basename =
|
|
6080
|
+
const basename = path15.basename(pathRel, ".md").toLowerCase();
|
|
6274
6081
|
const separator = basename.indexOf("-");
|
|
6275
6082
|
if (separator <= 0) return void 0;
|
|
6276
6083
|
const candidate = basename.slice(0, separator);
|
|
6277
6084
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
6278
6085
|
}
|
|
6279
6086
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
6280
|
-
const normalizedPath = pathRel.split(
|
|
6087
|
+
const normalizedPath = pathRel.split(path15.sep).join("/");
|
|
6281
6088
|
let normalizedFrontmatter = frontmatter;
|
|
6282
6089
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
6283
|
-
const basename =
|
|
6090
|
+
const basename = path15.basename(pathRel, ".md");
|
|
6284
6091
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
6285
6092
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
6286
6093
|
normalizedFrontmatter = {
|
|
@@ -6753,9 +6560,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6753
6560
|
this.entitySchemas = entitySchemas;
|
|
6754
6561
|
this.deletionRevisionStore = new DeletionRevisionStore({
|
|
6755
6562
|
baseDir,
|
|
6756
|
-
deletionRevisionMetadataPath:
|
|
6757
|
-
invalidationCommitMetadataPath:
|
|
6758
|
-
deletionRevisionLockPath:
|
|
6563
|
+
deletionRevisionMetadataPath: path15.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
|
|
6564
|
+
invalidationCommitMetadataPath: path15.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
|
|
6565
|
+
deletionRevisionLockPath: path15.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
|
|
6759
6566
|
assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
|
|
6760
6567
|
});
|
|
6761
6568
|
this.casRevisions = new CasRevisionHost(baseDir);
|
|
@@ -6943,8 +6750,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6943
6750
|
}
|
|
6944
6751
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
6945
6752
|
isStateFilePath(filePath) {
|
|
6946
|
-
const rel =
|
|
6947
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
6753
|
+
const rel = path15.relative(this.stateDir, path15.resolve(filePath));
|
|
6754
|
+
return rel === "" || !rel.startsWith("..") && !path15.isAbsolute(rel);
|
|
6948
6755
|
}
|
|
6949
6756
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
6950
6757
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -7059,8 +6866,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7059
6866
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
7060
6867
|
*/
|
|
7061
6868
|
isColdOrArchiveTierPath(p) {
|
|
7062
|
-
const rel =
|
|
7063
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
6869
|
+
const rel = path15.relative(this.baseDir, p);
|
|
6870
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path15.sep}`) || rel.startsWith(`archive${path15.sep}`);
|
|
7064
6871
|
}
|
|
7065
6872
|
/**
|
|
7066
6873
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -7147,7 +6954,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7147
6954
|
void 0,
|
|
7148
6955
|
this.baseDir
|
|
7149
6956
|
);
|
|
7150
|
-
const rel =
|
|
6957
|
+
const rel = path15.relative(this.baseDir, filePath).split(path15.sep).join("/");
|
|
7151
6958
|
return `${rel}:${version.versionId}`;
|
|
7152
6959
|
} catch (err) {
|
|
7153
6960
|
log.warn(
|
|
@@ -7192,10 +6999,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7192
6999
|
_StorageManager.okfConformanceByDir.set(memoryDir, enabled !== false);
|
|
7193
7000
|
}
|
|
7194
7001
|
okfConformanceEnabled() {
|
|
7195
|
-
for (let dir = this.baseDir; ; dir =
|
|
7002
|
+
for (let dir = this.baseDir; ; dir = path15.dirname(dir)) {
|
|
7196
7003
|
const registered = _StorageManager.okfConformanceByDir.get(dir);
|
|
7197
7004
|
if (registered !== void 0) return registered;
|
|
7198
|
-
if (dir ===
|
|
7005
|
+
if (dir === path15.dirname(dir)) return true;
|
|
7199
7006
|
}
|
|
7200
7007
|
}
|
|
7201
7008
|
/**
|
|
@@ -7239,12 +7046,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7239
7046
|
}
|
|
7240
7047
|
identityFilePath(workspaceDir, namespace) {
|
|
7241
7048
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
7242
|
-
if (!rawNamespace) return
|
|
7049
|
+
if (!rawNamespace) return path15.join(workspaceDir, "IDENTITY.md");
|
|
7243
7050
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7244
|
-
return
|
|
7051
|
+
return path15.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
7245
7052
|
}
|
|
7246
7053
|
versionFilePath(kind) {
|
|
7247
|
-
return
|
|
7054
|
+
return path15.join(this.stateDir, `.${kind}-version.log`);
|
|
7248
7055
|
}
|
|
7249
7056
|
bumpSharedVersion(kind, fallbackMap) {
|
|
7250
7057
|
const filePath = this.versionFilePath(kind);
|
|
@@ -7351,7 +7158,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7351
7158
|
// memories.
|
|
7352
7159
|
// -------------------------------------------------------------------------
|
|
7353
7160
|
get wearablesDir() {
|
|
7354
|
-
return
|
|
7161
|
+
return path15.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
7355
7162
|
}
|
|
7356
7163
|
/**
|
|
7357
7164
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -7367,7 +7174,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7367
7174
|
if (!isValidTranscriptDate(date)) {
|
|
7368
7175
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
7369
7176
|
}
|
|
7370
|
-
return
|
|
7177
|
+
return path15.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
7371
7178
|
}
|
|
7372
7179
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
7373
7180
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -7393,10 +7200,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7393
7200
|
return this._fusionStore = new FusionArtifactStore(this.wearablesDir, this.baseDir, {
|
|
7394
7201
|
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
7395
7202
|
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
7396
|
-
readDir: (d) =>
|
|
7397
|
-
deleteFile: (p) =>
|
|
7203
|
+
readDir: (d) => readdir6(d),
|
|
7204
|
+
deleteFile: (p) => unlink4(p),
|
|
7398
7205
|
realpath: (p) => realpath2(p),
|
|
7399
|
-
lstat: (p) =>
|
|
7206
|
+
lstat: (p) => lstat4(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7400
7207
|
});
|
|
7401
7208
|
}
|
|
7402
7209
|
_meetingRecordStore;
|
|
@@ -7411,10 +7218,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7411
7218
|
return this._meetingRecordStore = new MeetingRecordStore(this.baseDir, {
|
|
7412
7219
|
writeFile: (p, c) => this.writeStorageSecureFile(p, c),
|
|
7413
7220
|
readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
|
|
7414
|
-
readDir: (d) =>
|
|
7415
|
-
deleteFile: (p) =>
|
|
7221
|
+
readDir: (d) => readdir6(d),
|
|
7222
|
+
deleteFile: (p) => unlink4(p),
|
|
7416
7223
|
realpath: (p) => realpath2(p),
|
|
7417
|
-
lstat: (p) =>
|
|
7224
|
+
lstat: (p) => lstat4(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
|
|
7418
7225
|
});
|
|
7419
7226
|
}
|
|
7420
7227
|
/**
|
|
@@ -7481,25 +7288,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7481
7288
|
});
|
|
7482
7289
|
}
|
|
7483
7290
|
get factsDir() {
|
|
7484
|
-
return
|
|
7291
|
+
return path15.join(this.baseDir, "facts");
|
|
7485
7292
|
}
|
|
7486
7293
|
get correctionsDir() {
|
|
7487
|
-
return
|
|
7294
|
+
return path15.join(this.baseDir, "corrections");
|
|
7488
7295
|
}
|
|
7489
7296
|
get proceduresDir() {
|
|
7490
|
-
return
|
|
7297
|
+
return path15.join(this.baseDir, "procedures");
|
|
7491
7298
|
}
|
|
7492
7299
|
get reasoningTracesDir() {
|
|
7493
|
-
return
|
|
7300
|
+
return path15.join(this.baseDir, "reasoning-traces");
|
|
7494
7301
|
}
|
|
7495
7302
|
get entitiesDir() {
|
|
7496
|
-
return
|
|
7303
|
+
return path15.join(this.baseDir, "entities");
|
|
7497
7304
|
}
|
|
7498
7305
|
resolveEntityFilePath(name) {
|
|
7499
7306
|
if (typeof name !== "string") return null;
|
|
7500
|
-
const filePath =
|
|
7501
|
-
const relative2 =
|
|
7502
|
-
if (relative2 === "" || relative2.startsWith("..") ||
|
|
7307
|
+
const filePath = path15.resolve(this.entitiesDir, `${name}.md`);
|
|
7308
|
+
const relative2 = path15.relative(this.entitiesDir, filePath);
|
|
7309
|
+
if (relative2 === "" || relative2.startsWith("..") || path15.isAbsolute(relative2)) {
|
|
7503
7310
|
return null;
|
|
7504
7311
|
}
|
|
7505
7312
|
return filePath;
|
|
@@ -7510,7 +7317,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7510
7317
|
async readDependencyPropagationQueueFile(filePath) {
|
|
7511
7318
|
const target = await resolveSafeStoragePath(
|
|
7512
7319
|
this.baseDir,
|
|
7513
|
-
|
|
7320
|
+
path15.relative(
|
|
7514
7321
|
this.baseDir,
|
|
7515
7322
|
this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
|
|
7516
7323
|
)
|
|
@@ -7520,7 +7327,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7520
7327
|
async writeDependencyPropagationQueueFile(filePath, content) {
|
|
7521
7328
|
const target = await resolveSafeStoragePath(
|
|
7522
7329
|
this.baseDir,
|
|
7523
|
-
|
|
7330
|
+
path15.relative(
|
|
7524
7331
|
this.baseDir,
|
|
7525
7332
|
this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
|
|
7526
7333
|
)
|
|
@@ -7535,10 +7342,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7535
7342
|
});
|
|
7536
7343
|
}
|
|
7537
7344
|
assertManagedStoragePath(filePath, method) {
|
|
7538
|
-
const resolved =
|
|
7539
|
-
const base =
|
|
7540
|
-
const rel =
|
|
7541
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7345
|
+
const resolved = path15.resolve(filePath);
|
|
7346
|
+
const base = path15.resolve(this.baseDir);
|
|
7347
|
+
const rel = path15.relative(base, resolved);
|
|
7348
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path15.sep}`) || path15.isAbsolute(rel)) {
|
|
7542
7349
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
7543
7350
|
}
|
|
7544
7351
|
return resolved;
|
|
@@ -7575,7 +7382,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7575
7382
|
async digestOfflineSyncFile(filePath) {
|
|
7576
7383
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
7577
7384
|
const st = await stat3(target);
|
|
7578
|
-
const relPath =
|
|
7385
|
+
const relPath = path15.relative(this.baseDir, target).split(path15.sep).join("/");
|
|
7579
7386
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
7580
7387
|
const cached = cache.get(relPath);
|
|
7581
7388
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -7589,11 +7396,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7589
7396
|
if (encrypted) {
|
|
7590
7397
|
const content = await readMaybeEncryptedFileBuffer(target, this._secureStoreKey, this.baseDir);
|
|
7591
7398
|
digest = {
|
|
7592
|
-
sha256:
|
|
7399
|
+
sha256: createHash5("sha256").update(content).digest("hex"),
|
|
7593
7400
|
bytes: content.byteLength
|
|
7594
7401
|
};
|
|
7595
7402
|
} else {
|
|
7596
|
-
const hash =
|
|
7403
|
+
const hash = createHash5("sha256");
|
|
7597
7404
|
let bytes = 0;
|
|
7598
7405
|
for await (const rawChunk of createReadStream(target)) {
|
|
7599
7406
|
const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(rawChunk);
|
|
@@ -7660,7 +7467,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7660
7467
|
const cache = this.offlineSyncDigestCache;
|
|
7661
7468
|
if (!cache) return;
|
|
7662
7469
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
7663
|
-
await mkdir2(
|
|
7470
|
+
await mkdir2(path15.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
7664
7471
|
await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
7665
7472
|
`, "utf-8");
|
|
7666
7473
|
}).catch((err) => {
|
|
@@ -7761,7 +7568,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7761
7568
|
}
|
|
7762
7569
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
7763
7570
|
const writeKey = this.resolveWriteKey();
|
|
7764
|
-
await mkdir2(
|
|
7571
|
+
await mkdir2(path15.dirname(filePath), { recursive: true });
|
|
7765
7572
|
if (writeKey === null) {
|
|
7766
7573
|
try {
|
|
7767
7574
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -7787,13 +7594,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7787
7594
|
this.notifyCatalogWriteForPath(filePath);
|
|
7788
7595
|
}
|
|
7789
7596
|
get stateDir() {
|
|
7790
|
-
return
|
|
7597
|
+
return path15.join(this.baseDir, "state");
|
|
7791
7598
|
}
|
|
7792
7599
|
get offlineSyncDigestCachePath() {
|
|
7793
|
-
return
|
|
7600
|
+
return path15.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
7794
7601
|
}
|
|
7795
7602
|
get entitySynthesisQueuePath() {
|
|
7796
|
-
return
|
|
7603
|
+
return path15.join(this.stateDir, "entity-synthesis-queue.json");
|
|
7797
7604
|
}
|
|
7798
7605
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
7799
7606
|
/**
|
|
@@ -7803,7 +7610,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7803
7610
|
* helpers are injected into the store).
|
|
7804
7611
|
*/
|
|
7805
7612
|
get tombstonesPath() {
|
|
7806
|
-
return
|
|
7613
|
+
return path15.join(this.stateDir, "tombstones.jsonl");
|
|
7807
7614
|
}
|
|
7808
7615
|
/**
|
|
7809
7616
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -8116,55 +7923,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8116
7923
|
return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
|
|
8117
7924
|
}
|
|
8118
7925
|
get questionsDir() {
|
|
8119
|
-
return
|
|
7926
|
+
return path15.join(this.baseDir, "questions");
|
|
8120
7927
|
}
|
|
8121
7928
|
get artifactsDir() {
|
|
8122
|
-
return
|
|
7929
|
+
return path15.join(this.baseDir, "artifacts");
|
|
8123
7930
|
}
|
|
8124
7931
|
get identityDir() {
|
|
8125
|
-
return
|
|
7932
|
+
return path15.join(this.baseDir, "identity");
|
|
8126
7933
|
}
|
|
8127
7934
|
get identityAnchorPath() {
|
|
8128
|
-
return
|
|
7935
|
+
return path15.join(this.identityDir, "identity-anchor.md");
|
|
8129
7936
|
}
|
|
8130
7937
|
get identityIncidentsDir() {
|
|
8131
|
-
return
|
|
7938
|
+
return path15.join(this.identityDir, "incidents");
|
|
8132
7939
|
}
|
|
8133
7940
|
get identityAuditsWeeklyDir() {
|
|
8134
|
-
return
|
|
7941
|
+
return path15.join(this.identityDir, "audits", "weekly");
|
|
8135
7942
|
}
|
|
8136
7943
|
get identityAuditsMonthlyDir() {
|
|
8137
|
-
return
|
|
7944
|
+
return path15.join(this.identityDir, "audits", "monthly");
|
|
8138
7945
|
}
|
|
8139
7946
|
get identityImprovementLoopsPath() {
|
|
8140
|
-
return
|
|
7947
|
+
return path15.join(this.identityDir, "improvement-loops.md");
|
|
8141
7948
|
}
|
|
8142
7949
|
get identityReflectionsPath() {
|
|
8143
|
-
return
|
|
7950
|
+
return path15.join(this.identityDir, "reflections.md");
|
|
8144
7951
|
}
|
|
8145
7952
|
get profilePath() {
|
|
8146
|
-
return
|
|
7953
|
+
return path15.join(this.baseDir, "profile.md");
|
|
8147
7954
|
}
|
|
8148
7955
|
get memoryActionsPath() {
|
|
8149
|
-
return
|
|
7956
|
+
return path15.join(this.stateDir, "memory-actions.jsonl");
|
|
8150
7957
|
}
|
|
8151
7958
|
get memoryLifecycleLedgerPath() {
|
|
8152
|
-
return
|
|
7959
|
+
return path15.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
8153
7960
|
}
|
|
8154
7961
|
get compressionGuidelinesPath() {
|
|
8155
|
-
return
|
|
7962
|
+
return path15.join(this.stateDir, "compression-guidelines.md");
|
|
8156
7963
|
}
|
|
8157
7964
|
get compressionGuidelineDraftPath() {
|
|
8158
|
-
return
|
|
7965
|
+
return path15.join(this.stateDir, "compression-guidelines.draft.md");
|
|
8159
7966
|
}
|
|
8160
7967
|
get compressionGuidelineStatePath() {
|
|
8161
|
-
return
|
|
7968
|
+
return path15.join(this.stateDir, "compression-guideline-state.json");
|
|
8162
7969
|
}
|
|
8163
7970
|
get compressionGuidelineDraftStatePath() {
|
|
8164
|
-
return
|
|
7971
|
+
return path15.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
8165
7972
|
}
|
|
8166
7973
|
get behaviorSignalsPath() {
|
|
8167
|
-
return
|
|
7974
|
+
return path15.join(this.stateDir, "behavior-signals.jsonl");
|
|
8168
7975
|
}
|
|
8169
7976
|
/**
|
|
8170
7977
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -8196,7 +8003,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8196
8003
|
* governance sweeps can treat it uniformly.
|
|
8197
8004
|
*/
|
|
8198
8005
|
get bufferSurpriseLedgerPath() {
|
|
8199
|
-
return
|
|
8006
|
+
return path15.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
8200
8007
|
}
|
|
8201
8008
|
/**
|
|
8202
8009
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -8259,7 +8066,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8259
8066
|
this.loadAliasesSync();
|
|
8260
8067
|
}
|
|
8261
8068
|
loadAliasesSync() {
|
|
8262
|
-
const aliasPath =
|
|
8069
|
+
const aliasPath = path15.join(this.baseDir, "config", "aliases.json");
|
|
8263
8070
|
this.userAliases = {};
|
|
8264
8071
|
const raw = readEntityAliasConfigSync(this.baseDir);
|
|
8265
8072
|
if (raw === void 0) return;
|
|
@@ -8297,9 +8104,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8297
8104
|
await mkdir2(this.baseDir, { recursive: true });
|
|
8298
8105
|
await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
8299
8106
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8300
|
-
await mkdir2(
|
|
8301
|
-
await mkdir2(
|
|
8302
|
-
await mkdir2(
|
|
8107
|
+
await mkdir2(path15.join(this.factsDir, today), { recursive: true });
|
|
8108
|
+
await mkdir2(path15.join(this.proceduresDir, today), { recursive: true });
|
|
8109
|
+
await mkdir2(path15.join(this.reasoningTracesDir, today), { recursive: true });
|
|
8303
8110
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
8304
8111
|
await mkdir2(this.entitiesDir, { recursive: true });
|
|
8305
8112
|
await mkdir2(this.stateDir, { recursive: true });
|
|
@@ -8309,7 +8116,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8309
8116
|
await mkdir2(this.identityIncidentsDir, { recursive: true });
|
|
8310
8117
|
await mkdir2(this.identityAuditsWeeklyDir, { recursive: true });
|
|
8311
8118
|
await mkdir2(this.identityAuditsMonthlyDir, { recursive: true });
|
|
8312
|
-
await mkdir2(
|
|
8119
|
+
await mkdir2(path15.join(this.baseDir, "config"), { recursive: true });
|
|
8313
8120
|
await this.entityCanonicalIdMigration.begin(options.waitForEntityMigration !== false, this.entitiesDir);
|
|
8314
8121
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
8315
8122
|
this.bumpMemoryCorpusVersion();
|
|
@@ -8332,11 +8139,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8332
8139
|
async resolveCategoryWritePath(category, id, today) {
|
|
8333
8140
|
if (category === "correction") {
|
|
8334
8141
|
await mkdir2(this.correctionsDir, { recursive: true });
|
|
8335
|
-
return
|
|
8142
|
+
return path15.join(this.correctionsDir, `${id}.md`);
|
|
8336
8143
|
}
|
|
8337
|
-
const datedDir =
|
|
8144
|
+
const datedDir = path15.join(getCategoryDir(this.baseDir, category), today);
|
|
8338
8145
|
await mkdir2(datedDir, { recursive: true });
|
|
8339
|
-
return
|
|
8146
|
+
return path15.join(datedDir, `${id}.md`);
|
|
8340
8147
|
}
|
|
8341
8148
|
async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
|
|
8342
8149
|
const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
|
|
@@ -8507,7 +8314,7 @@ ${sanitized.text}
|
|
|
8507
8314
|
}
|
|
8508
8315
|
});
|
|
8509
8316
|
} catch (err) {
|
|
8510
|
-
await
|
|
8317
|
+
await unlink4(filePath).catch(() => void 0);
|
|
8511
8318
|
this.invalidateAllMemoriesCache();
|
|
8512
8319
|
await this.rebuildTombstoneBlockedCaptureAfterInvalidationForPath(filePath);
|
|
8513
8320
|
throw err;
|
|
@@ -8715,7 +8522,7 @@ ${sanitized.text}
|
|
|
8715
8522
|
await this.ensureDirectories();
|
|
8716
8523
|
const now = /* @__PURE__ */ new Date();
|
|
8717
8524
|
const day = now.toISOString().slice(0, 10);
|
|
8718
|
-
const dir =
|
|
8525
|
+
const dir = path15.join(this.artifactsDir, day);
|
|
8719
8526
|
await mkdir2(dir, { recursive: true });
|
|
8720
8527
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
8721
8528
|
const fm = {
|
|
@@ -8742,7 +8549,7 @@ ${sanitized.text}
|
|
|
8742
8549
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
8743
8550
|
return "";
|
|
8744
8551
|
}
|
|
8745
|
-
const filePath =
|
|
8552
|
+
const filePath = path15.join(dir, `${id}.md`);
|
|
8746
8553
|
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(this.withOkfType(fm))}
|
|
8747
8554
|
|
|
8748
8555
|
${sanitized.text}
|
|
@@ -9036,7 +8843,7 @@ ${sanitized.text}
|
|
|
9036
8843
|
* per-process in-memory cache safe across process boundaries.
|
|
9037
8844
|
*/
|
|
9038
8845
|
invalidateColdMemoriesCache() {
|
|
9039
|
-
const coldRoot =
|
|
8846
|
+
const coldRoot = path15.join(this.baseDir, "cold");
|
|
9040
8847
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
9041
8848
|
this.bumpColdWriteVersion();
|
|
9042
8849
|
invalidateAllForDir(this.baseDir);
|
|
@@ -9154,7 +8961,7 @@ ${sanitized.text}
|
|
|
9154
8961
|
const correctionPaths = [];
|
|
9155
8962
|
const factPaths = [];
|
|
9156
8963
|
for (const filePath of filePaths) {
|
|
9157
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
8964
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path15.sep}`)) {
|
|
9158
8965
|
correctionPaths.push(filePath);
|
|
9159
8966
|
} else {
|
|
9160
8967
|
factPaths.push(filePath);
|
|
@@ -9218,10 +9025,10 @@ ${sanitized.text}
|
|
|
9218
9025
|
const root = this.archiveDir;
|
|
9219
9026
|
const readDir = async (dir) => {
|
|
9220
9027
|
try {
|
|
9221
|
-
const entries = (await
|
|
9028
|
+
const entries = (await readdir6(dir, { withFileTypes: true })).filter((e) => !isMacOsReplicationJunkBasename(e.name));
|
|
9222
9029
|
for (const entry of entries) {
|
|
9223
9030
|
checkCorpusReadAbort(options);
|
|
9224
|
-
const fullPath =
|
|
9031
|
+
const fullPath = path15.join(dir, entry.name);
|
|
9225
9032
|
if (entry.isDirectory()) {
|
|
9226
9033
|
await readDir(fullPath);
|
|
9227
9034
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -9261,7 +9068,7 @@ ${sanitized.text}
|
|
|
9261
9068
|
return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
|
|
9262
9069
|
}
|
|
9263
9070
|
resolveTierRootDir(tier) {
|
|
9264
|
-
return tier === "cold" ?
|
|
9071
|
+
return tier === "cold" ? path15.join(this.baseDir, "cold") : this.baseDir;
|
|
9265
9072
|
}
|
|
9266
9073
|
resolveMemoryDateDir(memory) {
|
|
9267
9074
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -9276,13 +9083,13 @@ ${sanitized.text}
|
|
|
9276
9083
|
buildTierMemoryPath(memory, tier) {
|
|
9277
9084
|
const root = this.resolveTierRootDir(tier);
|
|
9278
9085
|
if (this.isArtifactMemory(memory)) {
|
|
9279
|
-
return
|
|
9086
|
+
return path15.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9280
9087
|
}
|
|
9281
9088
|
if (memory.frontmatter.category === "correction") {
|
|
9282
|
-
return
|
|
9089
|
+
return path15.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
9283
9090
|
}
|
|
9284
9091
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
9285
|
-
return
|
|
9092
|
+
return path15.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9286
9093
|
}
|
|
9287
9094
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
9288
9095
|
assertNotOkfReservedBasename(targetPath);
|
|
@@ -9314,7 +9121,7 @@ ${memory.content}
|
|
|
9314
9121
|
});
|
|
9315
9122
|
} catch (err) {
|
|
9316
9123
|
if (priorDest === null) {
|
|
9317
|
-
await
|
|
9124
|
+
await unlink4(targetPath).catch(() => void 0);
|
|
9318
9125
|
} else {
|
|
9319
9126
|
await writeFile2(targetPath, priorDest).catch(() => void 0);
|
|
9320
9127
|
}
|
|
@@ -9361,8 +9168,8 @@ ${memory.content}
|
|
|
9361
9168
|
memory.frontmatter.entityRef = current.frontmatter.entityRef;
|
|
9362
9169
|
}
|
|
9363
9170
|
durable = true;
|
|
9364
|
-
const sourcePath =
|
|
9365
|
-
const destPath =
|
|
9171
|
+
const sourcePath = path15.resolve(current.path);
|
|
9172
|
+
const destPath = path15.resolve(targetPath);
|
|
9366
9173
|
if (sourcePath !== destPath) {
|
|
9367
9174
|
await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
|
|
9368
9175
|
this.invalidateAllMemoriesCache();
|
|
@@ -9386,8 +9193,8 @@ ${memory.content}
|
|
|
9386
9193
|
}
|
|
9387
9194
|
async migrateMemoryToTier(memory, targetTier) {
|
|
9388
9195
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
9389
|
-
const sourcePath =
|
|
9390
|
-
const destPath =
|
|
9196
|
+
const sourcePath = path15.resolve(memory.path);
|
|
9197
|
+
const destPath = path15.resolve(targetPath);
|
|
9391
9198
|
if (sourcePath === destPath) {
|
|
9392
9199
|
return { changed: false, targetPath };
|
|
9393
9200
|
}
|
|
@@ -9397,7 +9204,7 @@ ${memory.content}
|
|
|
9397
9204
|
return { changed, targetPath };
|
|
9398
9205
|
}
|
|
9399
9206
|
get archiveDir() {
|
|
9400
|
-
return
|
|
9207
|
+
return path15.join(this.baseDir, "archive");
|
|
9401
9208
|
}
|
|
9402
9209
|
/**
|
|
9403
9210
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -9410,7 +9217,7 @@ ${memory.content}
|
|
|
9410
9217
|
try {
|
|
9411
9218
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
9412
9219
|
const today = now.toISOString().slice(0, 10);
|
|
9413
|
-
const destDir =
|
|
9220
|
+
const destDir = path15.join(this.archiveDir, today);
|
|
9414
9221
|
await mkdir2(destDir, { recursive: true });
|
|
9415
9222
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9416
9223
|
const updatedFm = canonicalizeEntityRefOption(
|
|
@@ -9426,7 +9233,7 @@ ${memory.content}
|
|
|
9426
9233
|
|
|
9427
9234
|
${current.content}
|
|
9428
9235
|
`;
|
|
9429
|
-
const destPath =
|
|
9236
|
+
const destPath = path15.join(destDir, path15.basename(current.path));
|
|
9430
9237
|
const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
|
|
9431
9238
|
await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
|
|
9432
9239
|
if (typeof current.frontmatter.entityRef === "string") {
|
|
@@ -9440,22 +9247,12 @@ ${current.content}
|
|
|
9440
9247
|
);
|
|
9441
9248
|
} catch (err) {
|
|
9442
9249
|
if (priorDest === null) {
|
|
9443
|
-
await recordArchiveDelete2(
|
|
9444
|
-
this.baseDir,
|
|
9445
|
-
destPath,
|
|
9446
|
-
() => unlink5(destPath).then(
|
|
9447
|
-
() => true,
|
|
9448
|
-
() => false
|
|
9449
|
-
)
|
|
9450
|
-
);
|
|
9250
|
+
await recordArchiveDelete2(this.baseDir, destPath, () => unlink4(destPath).then(() => true, () => false));
|
|
9451
9251
|
} else {
|
|
9452
9252
|
await recordArchiveDelete2(
|
|
9453
9253
|
this.baseDir,
|
|
9454
9254
|
destPath,
|
|
9455
|
-
() => this.writeStorageSecureFile(destPath, priorDest).then(
|
|
9456
|
-
() => true,
|
|
9457
|
-
() => false
|
|
9458
|
-
)
|
|
9255
|
+
() => this.writeStorageSecureFile(destPath, priorDest).then(() => true, () => false)
|
|
9459
9256
|
);
|
|
9460
9257
|
}
|
|
9461
9258
|
throw err;
|
|
@@ -9660,7 +9457,7 @@ ${memory.content}
|
|
|
9660
9457
|
`;
|
|
9661
9458
|
await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
|
|
9662
9459
|
this.invalidateAllMemoriesCache();
|
|
9663
|
-
if (memory.path.includes(`${
|
|
9460
|
+
if (memory.path.includes(`${path15.sep}cold${path15.sep}`)) {
|
|
9664
9461
|
this.invalidateColdMemoriesCache();
|
|
9665
9462
|
}
|
|
9666
9463
|
});
|
|
@@ -9672,7 +9469,7 @@ ${memory.content}
|
|
|
9672
9469
|
}
|
|
9673
9470
|
if (mentionReentry && !entityMentionEpoch.neutral(memory.frontmatter, updated)) entityMentionEpoch.bump(this.baseDir);
|
|
9674
9471
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
9675
|
-
if (memory.path.includes(`${
|
|
9472
|
+
if (memory.path.includes(`${path15.sep}cold${path15.sep}`)) {
|
|
9676
9473
|
this.invalidateColdMemoriesCache();
|
|
9677
9474
|
}
|
|
9678
9475
|
try {
|
|
@@ -9765,16 +9562,24 @@ ${memory.content}
|
|
|
9765
9562
|
await this.bufferSessionFiles().reconcile(state);
|
|
9766
9563
|
}
|
|
9767
9564
|
async saveBufferSession(key, entry) {
|
|
9768
|
-
await this.bufferSessionFiles().save(key, entry);
|
|
9565
|
+
return await this.bufferSessionFiles().save(key, entry);
|
|
9769
9566
|
}
|
|
9770
9567
|
async deleteBufferSession(key) {
|
|
9771
9568
|
await this.bufferSessionFiles().remove(key);
|
|
9772
9569
|
}
|
|
9570
|
+
/** Sync gate check for the extraction queue: is this session claimed by a buffer drain? */
|
|
9571
|
+
isBufferSessionClaimed(key) {
|
|
9572
|
+
return this.bufferSessionFiles().isClaimed(key);
|
|
9573
|
+
}
|
|
9574
|
+
/** The drain-claim store for this memory root (CLI drain + worker). */
|
|
9575
|
+
bufferDrainClaims() {
|
|
9576
|
+
return this.bufferSessionFiles().claims;
|
|
9577
|
+
}
|
|
9773
9578
|
saveDroppedExtractionChunk(bufferKey, reason, turns) {
|
|
9774
9579
|
return saveDroppedExtractionChunk(this.stateDir, (file, content) => this.writeStorageSecureFile(file, content), bufferKey, reason, turns);
|
|
9775
9580
|
}
|
|
9776
9581
|
async loadMeta() {
|
|
9777
|
-
const metaPath =
|
|
9582
|
+
const metaPath = path15.join(this.stateDir, "meta.json");
|
|
9778
9583
|
try {
|
|
9779
9584
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
9780
9585
|
const parsed = JSON.parse(raw);
|
|
@@ -9807,7 +9612,7 @@ ${memory.content}
|
|
|
9807
9612
|
}
|
|
9808
9613
|
async saveMeta(state) {
|
|
9809
9614
|
await this.ensureDirectories();
|
|
9810
|
-
await this.writeStorageSecureFile(
|
|
9615
|
+
await this.writeStorageSecureFile(path15.join(this.stateDir, "meta.json"), JSON.stringify(state, null, 2));
|
|
9811
9616
|
}
|
|
9812
9617
|
async appendMemoryActionEvents(events) {
|
|
9813
9618
|
if (events.length === 0) return 0;
|
|
@@ -9876,7 +9681,7 @@ ${memory.content}
|
|
|
9876
9681
|
},
|
|
9877
9682
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
9878
9683
|
async () => {
|
|
9879
|
-
await mkdir2(
|
|
9684
|
+
await mkdir2(path15.dirname(target), { recursive: true });
|
|
9880
9685
|
}
|
|
9881
9686
|
);
|
|
9882
9687
|
}
|
|
@@ -9974,7 +9779,7 @@ ${memory.content}
|
|
|
9974
9779
|
async appendReextractJobs(events) {
|
|
9975
9780
|
if (events.length === 0) return 0;
|
|
9976
9781
|
await this.ensureDirectories();
|
|
9977
|
-
const filePath =
|
|
9782
|
+
const filePath = path15.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9978
9783
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
9979
9784
|
try {
|
|
9980
9785
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -9987,7 +9792,7 @@ ${memory.content}
|
|
|
9987
9792
|
}
|
|
9988
9793
|
async readReextractJobs(limit = 200) {
|
|
9989
9794
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
9990
|
-
const filePath =
|
|
9795
|
+
const filePath = path15.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9991
9796
|
try {
|
|
9992
9797
|
const raw = await this.readStorageSecureFile(filePath);
|
|
9993
9798
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -10143,7 +9948,7 @@ ${memory.content}
|
|
|
10143
9948
|
return false;
|
|
10144
9949
|
}
|
|
10145
9950
|
if (draftState.contentHash) {
|
|
10146
|
-
const contentHash =
|
|
9951
|
+
const contentHash = createHash5("sha256").update(draftContent).digest("hex");
|
|
10147
9952
|
if (contentHash !== draftState.contentHash) return false;
|
|
10148
9953
|
}
|
|
10149
9954
|
await this.writeCompressionGuidelines(draftContent);
|
|
@@ -10152,8 +9957,8 @@ ${memory.content}
|
|
|
10152
9957
|
activationState: "active"
|
|
10153
9958
|
});
|
|
10154
9959
|
await Promise.all([
|
|
10155
|
-
|
|
10156
|
-
|
|
9960
|
+
unlink4(this.compressionGuidelineDraftPath).catch(() => void 0),
|
|
9961
|
+
unlink4(this.compressionGuidelineDraftStatePath).catch(() => void 0)
|
|
10157
9962
|
]);
|
|
10158
9963
|
return true;
|
|
10159
9964
|
}
|
|
@@ -10222,7 +10027,7 @@ ${question}
|
|
|
10222
10027
|
|
|
10223
10028
|
**Context:** ${context}
|
|
10224
10029
|
`;
|
|
10225
|
-
const filePath =
|
|
10030
|
+
const filePath = path15.join(this.questionsDir, `${id}.md`);
|
|
10226
10031
|
await this.writeStorageSecureFile(filePath, content);
|
|
10227
10032
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
10228
10033
|
this.invalidateQuestionsCache();
|
|
@@ -10281,11 +10086,11 @@ ${question}
|
|
|
10281
10086
|
} catch {
|
|
10282
10087
|
}
|
|
10283
10088
|
const hygiene = opts?.hygiene;
|
|
10284
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
10089
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path15.basename(identityPath));
|
|
10285
10090
|
if (rotateEnabled) {
|
|
10286
10091
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
10287
10092
|
if (existing.length > maxBytes) {
|
|
10288
|
-
const archiveDir =
|
|
10093
|
+
const archiveDir = path15.join(workspaceDir, hygiene.archiveDir);
|
|
10289
10094
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
10290
10095
|
filePath: identityPath,
|
|
10291
10096
|
archiveDir,
|
|
@@ -10545,7 +10350,7 @@ ${reflection}
|
|
|
10545
10350
|
if (entries.length === 0) return 0;
|
|
10546
10351
|
const memories = await this.readAllMemories();
|
|
10547
10352
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
10548
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
10353
|
+
const memoryPathMap = new Map(memories.map((m) => [path15.resolve(m.path), m]));
|
|
10549
10354
|
let updated = 0;
|
|
10550
10355
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
10551
10356
|
let entityRefMoved = false;
|
|
@@ -10553,7 +10358,7 @@ ${reflection}
|
|
|
10553
10358
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
10554
10359
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
10555
10360
|
for (const entry of entries) {
|
|
10556
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
10361
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path15.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
10557
10362
|
if (!memory) continue;
|
|
10558
10363
|
try {
|
|
10559
10364
|
const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
|
|
@@ -10585,7 +10390,7 @@ ${current.content}
|
|
|
10585
10390
|
if (warm) {
|
|
10586
10391
|
updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
|
|
10587
10392
|
}
|
|
10588
|
-
appliedPatches.set(
|
|
10393
|
+
appliedPatches.set(path15.resolve(memory.path), {
|
|
10589
10394
|
accessCount: entry.newCount,
|
|
10590
10395
|
lastAccessed: entry.lastAccessed
|
|
10591
10396
|
});
|
|
@@ -10603,7 +10408,7 @@ ${current.content}
|
|
|
10603
10408
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
10604
10409
|
if (cur) {
|
|
10605
10410
|
const reapplied = cur.map((m) => {
|
|
10606
|
-
const patch = appliedPatches.get(
|
|
10411
|
+
const patch = appliedPatches.get(path15.resolve(m.path));
|
|
10607
10412
|
return patch ? {
|
|
10608
10413
|
...m,
|
|
10609
10414
|
frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
|
|
@@ -10633,7 +10438,7 @@ ${current.content}
|
|
|
10633
10438
|
const pathsById = /* @__PURE__ */ new Map();
|
|
10634
10439
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
10635
10440
|
for (const filePath of filePaths) {
|
|
10636
|
-
const memoryId =
|
|
10441
|
+
const memoryId = path15.basename(filePath, ".md");
|
|
10637
10442
|
if (!wantedIds.has(memoryId)) continue;
|
|
10638
10443
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
10639
10444
|
paths.push(filePath);
|
|
@@ -10645,7 +10450,7 @@ ${current.content}
|
|
|
10645
10450
|
const preferredMatches = [];
|
|
10646
10451
|
for (const preferredPath of preferred) {
|
|
10647
10452
|
const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
|
|
10648
|
-
const directMatch = existingPaths.find((filePath) => directCandidates.has(
|
|
10453
|
+
const directMatch = existingPaths.find((filePath) => directCandidates.has(path15.resolve(filePath)));
|
|
10649
10454
|
if (directMatch) {
|
|
10650
10455
|
preferredMatches.push(directMatch);
|
|
10651
10456
|
continue;
|
|
@@ -10657,7 +10462,7 @@ ${current.content}
|
|
|
10657
10462
|
candidates.add(candidate);
|
|
10658
10463
|
}
|
|
10659
10464
|
}
|
|
10660
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
10465
|
+
const match = existingPaths.find((filePath) => candidates.has(path15.resolve(filePath)));
|
|
10661
10466
|
if (match) preferredMatches.push(match);
|
|
10662
10467
|
}
|
|
10663
10468
|
if (preferredMatches.length > 0) {
|
|
@@ -10848,7 +10653,7 @@ ${sanitized.text}
|
|
|
10848
10653
|
}
|
|
10849
10654
|
if (!oldMemory) return false;
|
|
10850
10655
|
const requireActiveAtWrite = options.requireActive === true || inferMemoryStatus(oldMemory.frontmatter, toMemoryPathRel(this.baseDir, oldMemory.path)) === "active";
|
|
10851
|
-
const operationId =
|
|
10656
|
+
const operationId = createHash5("sha256").update(
|
|
10852
10657
|
JSON.stringify({
|
|
10853
10658
|
oldMemoryId,
|
|
10854
10659
|
newMemoryId,
|
|
@@ -10979,21 +10784,21 @@ ${current.content}
|
|
|
10979
10784
|
}
|
|
10980
10785
|
}
|
|
10981
10786
|
get summariesDir() {
|
|
10982
|
-
return
|
|
10787
|
+
return path15.join(this.baseDir, "summaries");
|
|
10983
10788
|
}
|
|
10984
10789
|
async writeSummary(summary) {
|
|
10985
10790
|
await mkdir2(this.summariesDir, { recursive: true });
|
|
10986
|
-
const filePath =
|
|
10791
|
+
const filePath = path15.join(this.summariesDir, `${summary.id}.json`);
|
|
10987
10792
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
10988
10793
|
log.debug(`wrote summary ${summary.id}`);
|
|
10989
10794
|
}
|
|
10990
10795
|
async readSummaries() {
|
|
10991
10796
|
try {
|
|
10992
|
-
const files = await
|
|
10797
|
+
const files = await readdir6(this.summariesDir);
|
|
10993
10798
|
const summaries = [];
|
|
10994
10799
|
for (const file of files) {
|
|
10995
10800
|
if (isMacOsReplicationJunkBasename(file) || !file.endsWith(".json")) continue;
|
|
10996
|
-
const filePath =
|
|
10801
|
+
const filePath = path15.join(this.summariesDir, file);
|
|
10997
10802
|
const raw = await this.readStorageSecureFile(filePath);
|
|
10998
10803
|
summaries.push(JSON.parse(raw));
|
|
10999
10804
|
}
|
|
@@ -11063,13 +10868,13 @@ ${current.content}
|
|
|
11063
10868
|
return archived;
|
|
11064
10869
|
}
|
|
11065
10870
|
async saveTopics(topics) {
|
|
11066
|
-
const metaPath =
|
|
10871
|
+
const metaPath = path15.join(this.stateDir, "topics.json");
|
|
11067
10872
|
await mkdir2(this.stateDir, { recursive: true });
|
|
11068
10873
|
await this.writeStorageSecureFile(metaPath, JSON.stringify({ topics, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
11069
10874
|
log.debug(`saved ${topics.length} topic scores`);
|
|
11070
10875
|
}
|
|
11071
10876
|
async loadTopics() {
|
|
11072
|
-
const metaPath =
|
|
10877
|
+
const metaPath = path15.join(this.stateDir, "topics.json");
|
|
11073
10878
|
try {
|
|
11074
10879
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
11075
10880
|
return JSON.parse(raw);
|
|
@@ -11189,4 +10994,4 @@ export {
|
|
|
11189
10994
|
isValidBufferSurpriseEvent,
|
|
11190
10995
|
StorageManager3 as StorageManager
|
|
11191
10996
|
};
|
|
11192
|
-
//# sourceMappingURL=chunk-
|
|
10997
|
+
//# sourceMappingURL=chunk-N7RAABFM.js.map
|