@remnic/core 10.0.52 → 10.0.54
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-UM3ZLT2X.js → chunk-2GU6XS4L.js} +31 -28
- package/dist/chunk-2GU6XS4L.js.map +1 -0
- 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-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-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-EC2KVA27.js → chunk-PVG7TCUG.js} +186 -105
- package/dist/chunk-PVG7TCUG.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 +25 -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 +582 -1
- package/src/orchestration/maintenance.ts +82 -95
- package/src/orchestration/qmd-maintenance-completion.ts +44 -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
|
@@ -9,26 +9,26 @@ import {
|
|
|
9
9
|
} from "./chunk-666A3MOW.js";
|
|
10
10
|
import {
|
|
11
11
|
PROJECTION_REBUILD_RUNNER_FLAG
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-B43P3DTC.js";
|
|
13
13
|
import {
|
|
14
14
|
startLocationAutoSync
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6CDNOREO.js";
|
|
16
16
|
import {
|
|
17
17
|
CompoundingEngine,
|
|
18
18
|
isIsoWeekId,
|
|
19
19
|
msUntilNextIsoWeek,
|
|
20
20
|
previousIsoWeekId
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-53OFDW3P.js";
|
|
22
22
|
import {
|
|
23
23
|
rebuildMemoryLifecycleLedger
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-IFOCK3OJ.js";
|
|
25
25
|
import {
|
|
26
26
|
planNamespaceMaintenance,
|
|
27
27
|
runNamespaceMaintenanceBatchPlan
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-R3WZ74B2.js";
|
|
29
29
|
import {
|
|
30
30
|
rebuildMemoryProjection
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-QAHP5SBG.js";
|
|
32
32
|
import {
|
|
33
33
|
DEFAULT_TIMELINE_CATEGORIES,
|
|
34
34
|
TIMELINE_RESERVED_IDLE,
|
|
@@ -108,8 +108,8 @@ import {
|
|
|
108
108
|
|
|
109
109
|
// src/orchestration/maintenance.ts
|
|
110
110
|
import { existsSync as existsSync2 } from "fs";
|
|
111
|
-
import {
|
|
112
|
-
import
|
|
111
|
+
import { lstat as lstat2, readdir, realpath, stat } from "fs/promises";
|
|
112
|
+
import path8 from "path";
|
|
113
113
|
|
|
114
114
|
// src/maintenance/day-summary-cron.ts
|
|
115
115
|
function resolveDaySummaryCronModel(config) {
|
|
@@ -373,14 +373,96 @@ async function maybeRebuildMemoryProjectionScheduled(opts) {
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
// src/orchestration/lifecycle-pending-fallback-drain.ts
|
|
377
|
+
import { appendFile, mkdir, readFile, writeFile } from "fs/promises";
|
|
378
|
+
import path2 from "path";
|
|
379
|
+
async function drainPendingLifecycleAppendsForPath(memoryDir) {
|
|
380
|
+
const ledgerPath = path2.join(memoryDir, "state", "memory-lifecycle-ledger.jsonl");
|
|
381
|
+
const spillDir = pendingLifecycleLedgerDir(ledgerPath);
|
|
382
|
+
let spillFiles;
|
|
383
|
+
let claimedOrphans;
|
|
384
|
+
try {
|
|
385
|
+
spillFiles = await listContainedSpillFiles(spillDir);
|
|
386
|
+
claimedOrphans = await listContainedSpillFiles(spillDir, ".jsonl.claimed");
|
|
387
|
+
} catch (err) {
|
|
388
|
+
log.debug(`fallback lifecycle pending scan failed (non-fatal) for ${memoryDir}: ${err}`);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (spillFiles.length === 0 && claimedOrphans.length === 0) return;
|
|
392
|
+
const io = {
|
|
393
|
+
writeSecure: async (filePath, payload) => {
|
|
394
|
+
await mkdir(path2.dirname(filePath), { recursive: true });
|
|
395
|
+
await writeFile(filePath, payload, "utf-8");
|
|
396
|
+
},
|
|
397
|
+
readSecure: async (filePath) => {
|
|
398
|
+
if (await probeEncryptedRegularFileHeader(filePath)) {
|
|
399
|
+
throw new Error(`fallback lifecycle drain deferred: encrypted spill at ${filePath}`);
|
|
400
|
+
}
|
|
401
|
+
return readFile(filePath, "utf-8");
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
try {
|
|
405
|
+
await drainPendingLifecycleLedgerIfAny(
|
|
406
|
+
ledgerPath,
|
|
407
|
+
io,
|
|
408
|
+
async (payload) => {
|
|
409
|
+
if (await probeEncryptedRegularFileHeader(ledgerPath)) {
|
|
410
|
+
throw new Error(`fallback lifecycle drain deferred: ledger became encrypted at ${ledgerPath}`);
|
|
411
|
+
}
|
|
412
|
+
await appendFile(ledgerPath, payload, "utf-8");
|
|
413
|
+
},
|
|
414
|
+
async () => {
|
|
415
|
+
await mkdir(path2.dirname(ledgerPath), { recursive: true });
|
|
416
|
+
}
|
|
417
|
+
);
|
|
418
|
+
} catch (err) {
|
|
419
|
+
log.debug(`fallback lifecycle pending drain failed (non-fatal) for ${memoryDir}: ${err}`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// src/orchestration/qmd-maintenance-completion.ts
|
|
424
|
+
var QmdMaintenanceCompletion = class {
|
|
425
|
+
waiters = [];
|
|
426
|
+
/**
|
|
427
|
+
* Resolves true when a pass that started after this call completed successfully. With a
|
|
428
|
+
* `namespace` the request is served as soon as a pass ran that namespace, whatever else it skipped.
|
|
429
|
+
*/
|
|
430
|
+
wait(namespace) {
|
|
431
|
+
return new Promise((resolve) => this.waiters.push({ resolve, namespace }));
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* A pass is starting: take every waiter it will serve and return their settle function.
|
|
435
|
+
* `ran` lists the namespaces a namespace-aware pass ran (absent when namespaces are disabled:
|
|
436
|
+
* one corpus is maintained and the pass outcome applies to every waiter); `defer` keeps the
|
|
437
|
+
* waiters it did not serve waiting for a later pass (a pass that covered only part of the selection).
|
|
438
|
+
*/
|
|
439
|
+
claim() {
|
|
440
|
+
const claimed = this.waiters.splice(0);
|
|
441
|
+
return (served, defer = false, ran) => {
|
|
442
|
+
const requeue = [];
|
|
443
|
+
for (const waiter of claimed) {
|
|
444
|
+
const own = waiter.namespace !== void 0 && ran !== void 0 ? ran.has(waiter.namespace) : served;
|
|
445
|
+
if (own) waiter.resolve(true);
|
|
446
|
+
else if (defer) requeue.push(waiter);
|
|
447
|
+
else waiter.resolve(false);
|
|
448
|
+
}
|
|
449
|
+
this.waiters.unshift(...requeue);
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
/** The scheduler stopped: nothing will serve the waiters. */
|
|
453
|
+
abandon() {
|
|
454
|
+
this.claim()(false);
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
|
|
376
458
|
// src/compounding/weekly-scheduler.ts
|
|
377
459
|
import { lstat } from "fs/promises";
|
|
378
|
-
import
|
|
460
|
+
import path3 from "path";
|
|
379
461
|
function compoundingWeeklyDoneMarkerPath(memoryDir, weekId) {
|
|
380
462
|
if (!isIsoWeekId(weekId)) {
|
|
381
463
|
throw new Error("compounding weekly cron: week id must be YYYY-Www");
|
|
382
464
|
}
|
|
383
|
-
return
|
|
465
|
+
return path3.join(memoryDir, "compounding", "weekly", ".scheduler", `${weekId}.done`);
|
|
384
466
|
}
|
|
385
467
|
async function defaultWeekDone(memoryDir, weekId) {
|
|
386
468
|
try {
|
|
@@ -517,18 +599,18 @@ async function refreshActivityIndex(qmd, collection, signal) {
|
|
|
517
599
|
|
|
518
600
|
// src/activity/store.ts
|
|
519
601
|
import { mkdirSync } from "fs";
|
|
520
|
-
import { mkdir } from "fs/promises";
|
|
521
|
-
import
|
|
602
|
+
import { mkdir as mkdir2 } from "fs/promises";
|
|
603
|
+
import path4 from "path";
|
|
522
604
|
var ACTIVITY_SCHEMA_VERSION = 1;
|
|
523
605
|
var MAX_SEARCH_RESULTS = 100;
|
|
524
606
|
function activityDatabasePath(memoryDir) {
|
|
525
|
-
return
|
|
607
|
+
return path4.join(memoryDir, "state", "activity.sqlite");
|
|
526
608
|
}
|
|
527
609
|
async function ensureActivityStateDir(memoryDir) {
|
|
528
|
-
await
|
|
610
|
+
await mkdir2(path4.join(memoryDir, "state"), { recursive: true });
|
|
529
611
|
}
|
|
530
612
|
function openActivityDatabase(memoryDir) {
|
|
531
|
-
mkdirSync(
|
|
613
|
+
mkdirSync(path4.join(memoryDir, "state"), { recursive: true });
|
|
532
614
|
const db = openBetterSqlite3(activityDatabasePath(memoryDir));
|
|
533
615
|
db.pragma("journal_mode = WAL");
|
|
534
616
|
db.pragma("busy_timeout = 5000");
|
|
@@ -775,9 +857,9 @@ var ActivityStore = class _ActivityStore {
|
|
|
775
857
|
};
|
|
776
858
|
|
|
777
859
|
// src/activity/pipeline.ts
|
|
778
|
-
import { mkdir as
|
|
860
|
+
import { mkdir as mkdir3, readFile as readFile2, rename, writeFile as writeFile2 } from "fs/promises";
|
|
779
861
|
import { randomUUID } from "crypto";
|
|
780
|
-
import
|
|
862
|
+
import path5 from "path";
|
|
781
863
|
var MAX_SYNC_PAGES = 1e4;
|
|
782
864
|
function activityCursorKey(machine, date) {
|
|
783
865
|
return `${machine}\0${date}`;
|
|
@@ -812,13 +894,13 @@ function snapshotForMachine(snapshot, machine) {
|
|
|
812
894
|
async function writeDigestIfChanged(memoryDir, date, serialized) {
|
|
813
895
|
const target = activityDigestPath(memoryDir, date);
|
|
814
896
|
try {
|
|
815
|
-
if (await
|
|
897
|
+
if (await readFile2(target, "utf8") === serialized) return false;
|
|
816
898
|
} catch (error) {
|
|
817
899
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT") throw error;
|
|
818
900
|
}
|
|
819
|
-
await
|
|
901
|
+
await mkdir3(path5.dirname(target), { recursive: true, mode: 448 });
|
|
820
902
|
const temporary = `${target}.${process.pid}.${randomUUID()}.tmp`;
|
|
821
|
-
await
|
|
903
|
+
await writeFile2(temporary, serialized, { encoding: "utf8", mode: 384 });
|
|
822
904
|
await rename(temporary, target);
|
|
823
905
|
return true;
|
|
824
906
|
}
|
|
@@ -963,8 +1045,8 @@ function responsePage(value, machine) {
|
|
|
963
1045
|
nextCursor
|
|
964
1046
|
};
|
|
965
1047
|
}
|
|
966
|
-
function requestUrl(baseUrl,
|
|
967
|
-
const url = new URL(
|
|
1048
|
+
function requestUrl(baseUrl, path9, query) {
|
|
1049
|
+
const url = new URL(path9, baseUrl);
|
|
968
1050
|
const parts = Object.entries(query).filter((entry) => entry[1] !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
|
969
1051
|
url.search = parts.join("&");
|
|
970
1052
|
return url.toString();
|
|
@@ -1019,13 +1101,13 @@ var ActivityHttpSourceClient = class {
|
|
|
1019
1101
|
// src/activity/timeline/regenerate.ts
|
|
1020
1102
|
import { randomBytes } from "crypto";
|
|
1021
1103
|
import { mkdirSync as mkdirSync3, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
1022
|
-
import
|
|
1104
|
+
import path7 from "path";
|
|
1023
1105
|
|
|
1024
1106
|
// src/activity/timeline/corrections.ts
|
|
1025
1107
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
1026
|
-
import
|
|
1108
|
+
import path6 from "path";
|
|
1027
1109
|
function timelineCorrectionDatabasePath(memoryDir) {
|
|
1028
|
-
return
|
|
1110
|
+
return path6.join(memoryDir, "state", "activity-timeline.sqlite");
|
|
1029
1111
|
}
|
|
1030
1112
|
function rowToCorrection(row) {
|
|
1031
1113
|
return {
|
|
@@ -1041,7 +1123,7 @@ var TimelineCorrectionStore = class _TimelineCorrectionStore {
|
|
|
1041
1123
|
this.db = db;
|
|
1042
1124
|
}
|
|
1043
1125
|
static open(memoryDir) {
|
|
1044
|
-
mkdirSync2(
|
|
1126
|
+
mkdirSync2(path6.join(memoryDir, "state"), { recursive: true });
|
|
1045
1127
|
const db = openBetterSqlite3(timelineCorrectionDatabasePath(memoryDir));
|
|
1046
1128
|
db.pragma("journal_mode = WAL");
|
|
1047
1129
|
db.pragma("busy_timeout = 5000");
|
|
@@ -1425,7 +1507,7 @@ async function runTimelineCardAnalysis(input) {
|
|
|
1425
1507
|
|
|
1426
1508
|
// src/activity/timeline/regenerate.ts
|
|
1427
1509
|
var TIMELINE_DAY_FORMAT_VERSION = 1;
|
|
1428
|
-
var TIMELINE_DAY_DIR =
|
|
1510
|
+
var TIMELINE_DAY_DIR = path7.join("activity", "timeline");
|
|
1429
1511
|
var inflight = /* @__PURE__ */ new Map();
|
|
1430
1512
|
function requireToken(value, name) {
|
|
1431
1513
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
@@ -1438,7 +1520,7 @@ function timelineDayPath(memoryDir, date) {
|
|
|
1438
1520
|
if (!isValidActivityDate(date)) {
|
|
1439
1521
|
throw new RangeError("date must be a real YYYY-MM-DD day");
|
|
1440
1522
|
}
|
|
1441
|
-
return
|
|
1523
|
+
return path7.join(path7.resolve(root), TIMELINE_DAY_DIR, `${date}.json`);
|
|
1442
1524
|
}
|
|
1443
1525
|
function snapshotToObservation(snapshot) {
|
|
1444
1526
|
if (typeof snapshot.id !== "number") return null;
|
|
@@ -1468,7 +1550,7 @@ function localDatesForUtcRange(fromMs, toMs, timezone) {
|
|
|
1468
1550
|
function listPersistedTimelineDates(memoryDir) {
|
|
1469
1551
|
let entries;
|
|
1470
1552
|
try {
|
|
1471
|
-
entries = readdirSync(
|
|
1553
|
+
entries = readdirSync(path7.join(path7.resolve(requireToken(memoryDir, "memoryDir")), TIMELINE_DAY_DIR));
|
|
1472
1554
|
} catch {
|
|
1473
1555
|
return [];
|
|
1474
1556
|
}
|
|
@@ -1562,7 +1644,7 @@ function persistDay(filePath, payload) {
|
|
|
1562
1644
|
throw error;
|
|
1563
1645
|
}
|
|
1564
1646
|
}
|
|
1565
|
-
mkdirSync3(
|
|
1647
|
+
mkdirSync3(path7.dirname(filePath), { recursive: true, mode: 448 });
|
|
1566
1648
|
const tmpPath = `${filePath}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
|
|
1567
1649
|
writeFileSync(tmpPath, text, { encoding: "utf8", mode: 384 });
|
|
1568
1650
|
try {
|
|
@@ -1657,7 +1739,7 @@ async function regenerateUncached(input) {
|
|
|
1657
1739
|
}
|
|
1658
1740
|
}
|
|
1659
1741
|
async function regenerateTimelineDay(input) {
|
|
1660
|
-
const key = `${
|
|
1742
|
+
const key = `${path7.resolve(requireToken(input.memoryDir, "memoryDir"))}\0${input.date}`;
|
|
1661
1743
|
const pending = inflight.get(key);
|
|
1662
1744
|
if (pending !== void 0) return pending;
|
|
1663
1745
|
const run = regenerateUncached(input).finally(() => {
|
|
@@ -1965,6 +2047,9 @@ var MaintenanceScheduler = class {
|
|
|
1965
2047
|
qmdMaintenanceTimer = null;
|
|
1966
2048
|
qmdMaintenancePending = false;
|
|
1967
2049
|
qmdMaintenanceInFlight = false;
|
|
2050
|
+
qmdCompletion = new QmdMaintenanceCompletion();
|
|
2051
|
+
/** Namespaces that ran in passes of the request still waiting for full coverage. */
|
|
2052
|
+
qmdCoveredNamespaces = /* @__PURE__ */ new Set();
|
|
1968
2053
|
lastQmdEmbedAtMs = 0;
|
|
1969
2054
|
lastQmdEmbedAtMsByNamespace = /* @__PURE__ */ new Map();
|
|
1970
2055
|
// ── Lifecycle-ledger auto-compaction state (issue #1910) ──
|
|
@@ -2055,7 +2140,7 @@ var MaintenanceScheduler = class {
|
|
|
2055
2140
|
}
|
|
2056
2141
|
async autoRegisterDaySummaryCron() {
|
|
2057
2142
|
const home = resolveHomeDir();
|
|
2058
|
-
const jobsPath =
|
|
2143
|
+
const jobsPath = path8.join(home, ".openclaw", "cron", "jobs.json");
|
|
2059
2144
|
try {
|
|
2060
2145
|
if (!existsSync2(jobsPath)) {
|
|
2061
2146
|
log.debug("day-summary cron: jobs.json not found, skipping auto-register");
|
|
@@ -2085,7 +2170,7 @@ var MaintenanceScheduler = class {
|
|
|
2085
2170
|
}
|
|
2086
2171
|
async autoRegisterNightlyGovernanceCron() {
|
|
2087
2172
|
const home = resolveHomeDir();
|
|
2088
|
-
const jobsPath =
|
|
2173
|
+
const jobsPath = path8.join(home, ".openclaw", "cron", "jobs.json");
|
|
2089
2174
|
try {
|
|
2090
2175
|
if (!existsSync2(jobsPath)) {
|
|
2091
2176
|
log.debug("nightly governance cron: jobs.json not found, skipping auto-register");
|
|
@@ -2107,7 +2192,7 @@ var MaintenanceScheduler = class {
|
|
|
2107
2192
|
}
|
|
2108
2193
|
async autoRegisterProceduralMiningCron() {
|
|
2109
2194
|
const home = resolveHomeDir();
|
|
2110
|
-
const jobsPath =
|
|
2195
|
+
const jobsPath = path8.join(home, ".openclaw", "cron", "jobs.json");
|
|
2111
2196
|
try {
|
|
2112
2197
|
if (!existsSync2(jobsPath)) {
|
|
2113
2198
|
log.debug("procedural mining cron: jobs.json not found, skipping auto-register");
|
|
@@ -2127,7 +2212,7 @@ var MaintenanceScheduler = class {
|
|
|
2127
2212
|
}
|
|
2128
2213
|
async autoRegisterContradictionScanCron() {
|
|
2129
2214
|
const home = resolveHomeDir();
|
|
2130
|
-
const jobsPath =
|
|
2215
|
+
const jobsPath = path8.join(home, ".openclaw", "cron", "jobs.json");
|
|
2131
2216
|
try {
|
|
2132
2217
|
if (!existsSync2(jobsPath)) {
|
|
2133
2218
|
log.debug("contradiction scan cron: jobs.json not found, skipping auto-register");
|
|
@@ -2147,7 +2232,7 @@ var MaintenanceScheduler = class {
|
|
|
2147
2232
|
}
|
|
2148
2233
|
async autoRegisterPatternReinforcementCron() {
|
|
2149
2234
|
const home = resolveHomeDir();
|
|
2150
|
-
const jobsPath =
|
|
2235
|
+
const jobsPath = path8.join(home, ".openclaw", "cron", "jobs.json");
|
|
2151
2236
|
try {
|
|
2152
2237
|
if (!existsSync2(jobsPath)) {
|
|
2153
2238
|
log.debug("pattern reinforcement cron: jobs.json not found, skipping auto-register");
|
|
@@ -2167,7 +2252,7 @@ var MaintenanceScheduler = class {
|
|
|
2167
2252
|
}
|
|
2168
2253
|
async autoRegisterGraphEdgeDecayCron() {
|
|
2169
2254
|
const home = resolveHomeDir();
|
|
2170
|
-
const jobsPath =
|
|
2255
|
+
const jobsPath = path8.join(home, ".openclaw", "cron", "jobs.json");
|
|
2171
2256
|
try {
|
|
2172
2257
|
if (!existsSync2(jobsPath)) {
|
|
2173
2258
|
log.debug("graph edge decay cron: jobs.json not found, skipping auto-register");
|
|
@@ -2241,18 +2326,29 @@ var MaintenanceScheduler = class {
|
|
|
2241
2326
|
// ───────────────────────────────────────────────────────────────────────
|
|
2242
2327
|
// QMD maintenance scheduling (debounced + singleflight)
|
|
2243
2328
|
// ───────────────────────────────────────────────────────────────────────
|
|
2244
|
-
/** Internal: queue a debounced QMD maintenance pass. */
|
|
2329
|
+
/** Internal: queue a debounced QMD maintenance pass; false when nothing could be armed. */
|
|
2245
2330
|
requestQmdMaintenance() {
|
|
2246
|
-
if (!this.deps.getQmd().isAvailable()) return;
|
|
2247
|
-
if (!resolveQmdCapabilities(this.deps.config).qmdMaintenance) return;
|
|
2331
|
+
if (!this.deps.getQmd().isAvailable()) return false;
|
|
2332
|
+
if (!resolveQmdCapabilities(this.deps.config).qmdMaintenance) return false;
|
|
2248
2333
|
this.qmdMaintenancePending = true;
|
|
2249
|
-
if (this.qmdMaintenanceTimer) return;
|
|
2334
|
+
if (this.qmdMaintenanceTimer) return true;
|
|
2250
2335
|
this.qmdMaintenanceTimer = setTimeout(() => {
|
|
2251
2336
|
this.qmdMaintenanceTimer = null;
|
|
2252
2337
|
this.runQmdMaintenance().catch(
|
|
2253
2338
|
(err) => log.debug(`background qmd maintenance failed: ${err}`)
|
|
2254
2339
|
);
|
|
2255
2340
|
}, this.deps.config.qmdMaintenanceDebounceMs);
|
|
2341
|
+
return true;
|
|
2342
|
+
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Like a maintenance request, but resolves true only once a pass that started
|
|
2345
|
+
* after it completed successfully. False when nothing could be armed (QMD
|
|
2346
|
+
* unavailable or maintenance off), the pass failed, or dispose() abandoned it,
|
|
2347
|
+
* so a caller that must not lose the re-index keeps owing it.
|
|
2348
|
+
*/
|
|
2349
|
+
requestQmdMaintenanceCompletion(namespace) {
|
|
2350
|
+
if (this.disposed || !this.requestQmdMaintenance()) return Promise.resolve(false);
|
|
2351
|
+
return this.qmdCompletion.wait(namespace);
|
|
2256
2352
|
}
|
|
2257
2353
|
/**
|
|
2258
2354
|
* Public entrypoint for tool-driven QMD maintenance requests.
|
|
@@ -2282,6 +2378,10 @@ var MaintenanceScheduler = class {
|
|
|
2282
2378
|
if (!this.qmdMaintenancePending) return;
|
|
2283
2379
|
this.qmdMaintenanceInFlight = true;
|
|
2284
2380
|
this.qmdMaintenancePending = false;
|
|
2381
|
+
const settle = this.qmdCompletion.claim();
|
|
2382
|
+
let served = false;
|
|
2383
|
+
let deferred = false;
|
|
2384
|
+
let ranNamespaces;
|
|
2285
2385
|
try {
|
|
2286
2386
|
if (resolveNamespaceCapabilities(this.deps.config).namespaces) {
|
|
2287
2387
|
const plan = await this.namespaceMaintenancePlan("qmd");
|
|
@@ -2300,7 +2400,7 @@ var MaintenanceScheduler = class {
|
|
|
2300
2400
|
}
|
|
2301
2401
|
this.lastQmdEmbedAtMs = now;
|
|
2302
2402
|
};
|
|
2303
|
-
await runNamespaceMaintenanceBatchPlan(
|
|
2403
|
+
const summary = await runNamespaceMaintenanceBatchPlan(
|
|
2304
2404
|
this.deps.config,
|
|
2305
2405
|
plan,
|
|
2306
2406
|
async (candidates) => {
|
|
@@ -2347,8 +2447,39 @@ var MaintenanceScheduler = class {
|
|
|
2347
2447
|
skipReasonForError: qmdMaintenanceSkipReasonForError
|
|
2348
2448
|
}
|
|
2349
2449
|
);
|
|
2450
|
+
const covered = this.qmdCoveredNamespaces;
|
|
2451
|
+
const ran = /* @__PURE__ */ new Set();
|
|
2452
|
+
ranNamespaces = ran;
|
|
2453
|
+
const before = covered.size;
|
|
2454
|
+
for (const status of summary.statuses) {
|
|
2455
|
+
if (status.state !== "ran") continue;
|
|
2456
|
+
covered.add(status.namespace);
|
|
2457
|
+
ran.add(status.namespace);
|
|
2458
|
+
}
|
|
2459
|
+
const uncovered = summary.statuses.some(
|
|
2460
|
+
(status) => status.state === "skipped" && (status.reason === "budget_exhausted" || status.reason === "lock_held") && !covered.has(status.namespace)
|
|
2461
|
+
);
|
|
2462
|
+
const catalogReadFailed = plan.skipped.some((skip) => skip.reason === "catalog_read_failed");
|
|
2463
|
+
served = summary.ran > 0 && summary.failed === 0 && !uncovered && !catalogReadFailed;
|
|
2464
|
+
deferred = !served && summary.failed === 0 && !catalogReadFailed && covered.size > before && !this.disposed;
|
|
2350
2465
|
} else {
|
|
2351
|
-
|
|
2466
|
+
const qmd = this.deps.getQmd();
|
|
2467
|
+
if (qmd.updateCompleted) {
|
|
2468
|
+
try {
|
|
2469
|
+
served = await qmd.updateCompleted();
|
|
2470
|
+
} catch (err) {
|
|
2471
|
+
log.debug(`qmd maintenance update did not run: ${err}`);
|
|
2472
|
+
}
|
|
2473
|
+
} else if (qmd.updateStrict) {
|
|
2474
|
+
try {
|
|
2475
|
+
await qmd.updateStrict();
|
|
2476
|
+
served = true;
|
|
2477
|
+
} catch (err) {
|
|
2478
|
+
log.debug(`qmd maintenance update did not run: ${err}`);
|
|
2479
|
+
}
|
|
2480
|
+
} else {
|
|
2481
|
+
await qmd.update();
|
|
2482
|
+
}
|
|
2352
2483
|
const now = Date.now();
|
|
2353
2484
|
if (resolveQmdCapabilities(this.deps.config).qmdAutoEmbed && now - this.lastQmdEmbedAtMs >= this.deps.config.qmdEmbedMinIntervalMs) {
|
|
2354
2485
|
await this.deps.getQmd().embed();
|
|
@@ -2356,7 +2487,10 @@ var MaintenanceScheduler = class {
|
|
|
2356
2487
|
}
|
|
2357
2488
|
}
|
|
2358
2489
|
} finally {
|
|
2490
|
+
settle(served, deferred, ranNamespaces);
|
|
2491
|
+
if (!deferred) this.qmdCoveredNamespaces.clear();
|
|
2359
2492
|
this.qmdMaintenanceInFlight = false;
|
|
2493
|
+
if (deferred) this.qmdMaintenancePending = true;
|
|
2360
2494
|
if (this.qmdMaintenancePending) {
|
|
2361
2495
|
this.requestQmdMaintenance();
|
|
2362
2496
|
}
|
|
@@ -2439,7 +2573,7 @@ var MaintenanceScheduler = class {
|
|
|
2439
2573
|
*/
|
|
2440
2574
|
async hasOverCapEncryptedLifecycleLedger(targets) {
|
|
2441
2575
|
for (const target of targets) {
|
|
2442
|
-
const ledgerPath =
|
|
2576
|
+
const ledgerPath = path8.join(target.memoryDir, "state", "memory-lifecycle-ledger.jsonl");
|
|
2443
2577
|
let size;
|
|
2444
2578
|
try {
|
|
2445
2579
|
size = (await stat(ledgerPath)).size;
|
|
@@ -2466,7 +2600,7 @@ var MaintenanceScheduler = class {
|
|
|
2466
2600
|
if (target.storage) {
|
|
2467
2601
|
await this.drainPendingLifecycleAppends(target.storage);
|
|
2468
2602
|
} else {
|
|
2469
|
-
await
|
|
2603
|
+
await drainPendingLifecycleAppendsForPath(target.memoryDir);
|
|
2470
2604
|
}
|
|
2471
2605
|
}
|
|
2472
2606
|
/** Drain a target's durable pending lifecycle-append spill into its ledger
|
|
@@ -2479,60 +2613,6 @@ var MaintenanceScheduler = class {
|
|
|
2479
2613
|
log.debug(`lifecycle pending drain failed (non-fatal): ${err}`);
|
|
2480
2614
|
}
|
|
2481
2615
|
}
|
|
2482
|
-
/**
|
|
2483
|
-
* Drain a filesystem-fallback target's pending lifecycle-append spill when no
|
|
2484
|
-
* secure StorageManager is available (catalog-disabled namespace; issue
|
|
2485
|
-
* #2033). Uses the safe path-scoped PLAINTEXT context this fallback already
|
|
2486
|
-
* operates in: a keyless drain can only fold plaintext spills into a plaintext
|
|
2487
|
-
* ledger, so it refuses when the ledger or ANY spill is encrypted at rest,
|
|
2488
|
-
* leaving those pending for a keyed (catalog-path) drain — exactly mirroring
|
|
2489
|
-
* the fallback compaction's encrypted-ledger deferral. Non-fatal; a fast
|
|
2490
|
-
* no-op when nothing is pending. The shared spill lister enforces the symlink/
|
|
2491
|
-
* containment guard on every spill file it reads or deletes.
|
|
2492
|
-
*/
|
|
2493
|
-
async drainPendingLifecycleAppendsForPath(memoryDir) {
|
|
2494
|
-
const ledgerPath = path7.join(memoryDir, "state", "memory-lifecycle-ledger.jsonl");
|
|
2495
|
-
const spillDir = pendingLifecycleLedgerDir(ledgerPath);
|
|
2496
|
-
let spillFiles;
|
|
2497
|
-
let claimedOrphans;
|
|
2498
|
-
try {
|
|
2499
|
-
spillFiles = await listContainedSpillFiles(spillDir);
|
|
2500
|
-
claimedOrphans = await listContainedSpillFiles(spillDir, ".jsonl.claimed");
|
|
2501
|
-
} catch (err) {
|
|
2502
|
-
log.debug(`fallback lifecycle pending scan failed (non-fatal) for ${memoryDir}: ${err}`);
|
|
2503
|
-
return;
|
|
2504
|
-
}
|
|
2505
|
-
if (spillFiles.length === 0 && claimedOrphans.length === 0) return;
|
|
2506
|
-
const io = {
|
|
2507
|
-
writeSecure: async (filePath, payload) => {
|
|
2508
|
-
await mkdir3(path7.dirname(filePath), { recursive: true });
|
|
2509
|
-
await writeFile2(filePath, payload, "utf-8");
|
|
2510
|
-
},
|
|
2511
|
-
readSecure: async (filePath) => {
|
|
2512
|
-
if (await probeEncryptedRegularFileHeader(filePath)) {
|
|
2513
|
-
throw new Error(`fallback lifecycle drain deferred: encrypted spill at ${filePath}`);
|
|
2514
|
-
}
|
|
2515
|
-
return readFile2(filePath, "utf-8");
|
|
2516
|
-
}
|
|
2517
|
-
};
|
|
2518
|
-
try {
|
|
2519
|
-
await drainPendingLifecycleLedgerIfAny(
|
|
2520
|
-
ledgerPath,
|
|
2521
|
-
io,
|
|
2522
|
-
async (payload) => {
|
|
2523
|
-
if (await probeEncryptedRegularFileHeader(ledgerPath)) {
|
|
2524
|
-
throw new Error(`fallback lifecycle drain deferred: ledger became encrypted at ${ledgerPath}`);
|
|
2525
|
-
}
|
|
2526
|
-
await appendFile(ledgerPath, payload, "utf-8");
|
|
2527
|
-
},
|
|
2528
|
-
async () => {
|
|
2529
|
-
await mkdir3(path7.dirname(ledgerPath), { recursive: true });
|
|
2530
|
-
}
|
|
2531
|
-
);
|
|
2532
|
-
} catch (err) {
|
|
2533
|
-
log.debug(`fallback lifecycle pending drain failed (non-fatal) for ${memoryDir}: ${err}`);
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
2616
|
/**
|
|
2537
2617
|
* Enumerate the lifecycle ledgers to consider for compaction: the root
|
|
2538
2618
|
* (through the secure-configured root storage when available) plus every
|
|
@@ -2544,7 +2624,7 @@ var MaintenanceScheduler = class {
|
|
|
2544
2624
|
const targets = [];
|
|
2545
2625
|
const seen = /* @__PURE__ */ new Set();
|
|
2546
2626
|
const addTarget = (memoryDir, storage) => {
|
|
2547
|
-
const key =
|
|
2627
|
+
const key = path8.resolve(memoryDir);
|
|
2548
2628
|
if (seen.has(key)) return;
|
|
2549
2629
|
seen.add(key);
|
|
2550
2630
|
targets.push({ memoryDir, storage });
|
|
@@ -2573,7 +2653,7 @@ var MaintenanceScheduler = class {
|
|
|
2573
2653
|
}
|
|
2574
2654
|
}
|
|
2575
2655
|
if (resolveNamespaceCapabilities(this.deps.config).namespaces) {
|
|
2576
|
-
const namespacesBase =
|
|
2656
|
+
const namespacesBase = path8.join(this.deps.config.memoryDir, "namespaces");
|
|
2577
2657
|
let memoryDirReal;
|
|
2578
2658
|
try {
|
|
2579
2659
|
memoryDirReal = await realpath(this.deps.config.memoryDir);
|
|
@@ -2598,7 +2678,7 @@ var MaintenanceScheduler = class {
|
|
|
2598
2678
|
}
|
|
2599
2679
|
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
2600
2680
|
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
|
|
2601
|
-
const childPath =
|
|
2681
|
+
const childPath = path8.join(namespacesBase, entry.name);
|
|
2602
2682
|
try {
|
|
2603
2683
|
assertPathInsideRoot(memoryDirReal, await realpath(childPath), childPath);
|
|
2604
2684
|
} catch (err) {
|
|
@@ -2610,7 +2690,7 @@ var MaintenanceScheduler = class {
|
|
|
2610
2690
|
if (resolveNamespaceStorage && routeNamespace !== null) {
|
|
2611
2691
|
try {
|
|
2612
2692
|
const storage = await resolveNamespaceStorage(routeNamespace);
|
|
2613
|
-
if (
|
|
2693
|
+
if (path8.resolve(storage.dir) === path8.resolve(childPath)) {
|
|
2614
2694
|
addTarget(storage.dir, storage);
|
|
2615
2695
|
continue;
|
|
2616
2696
|
}
|
|
@@ -2641,7 +2721,7 @@ var MaintenanceScheduler = class {
|
|
|
2641
2721
|
* an over-cap rewrite never arms the throttle.
|
|
2642
2722
|
*/
|
|
2643
2723
|
async compactLifecycleLedgerTarget(target, threshold) {
|
|
2644
|
-
const ledgerPath =
|
|
2724
|
+
const ledgerPath = path8.join(target.memoryDir, "state", "memory-lifecycle-ledger.jsonl");
|
|
2645
2725
|
let size = 0;
|
|
2646
2726
|
try {
|
|
2647
2727
|
size = (await stat(ledgerPath)).size;
|
|
@@ -2745,6 +2825,7 @@ var MaintenanceScheduler = class {
|
|
|
2745
2825
|
this.qmdMaintenanceTimer = null;
|
|
2746
2826
|
}
|
|
2747
2827
|
this.qmdMaintenancePending = false;
|
|
2828
|
+
this.qmdCompletion.abandon();
|
|
2748
2829
|
await activityDrain;
|
|
2749
2830
|
await locationDrain;
|
|
2750
2831
|
await weeklyDrain;
|
|
@@ -2793,4 +2874,4 @@ export {
|
|
|
2793
2874
|
ActivitySyncScheduler,
|
|
2794
2875
|
MaintenanceScheduler
|
|
2795
2876
|
};
|
|
2796
|
-
//# sourceMappingURL=chunk-
|
|
2877
|
+
//# sourceMappingURL=chunk-PVG7TCUG.js.map
|