@remnic/core 10.0.92 → 10.0.93
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 +331 -58
- package/dist/access-authorization-probe.js +2 -283
- package/dist/access-boundary.d.ts +1 -1
- package/dist/access-boundary.d.ts.map +1 -1
- package/dist/access-boundary.js +1 -282
- package/dist/access-cli.js +286 -302
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.js +3 -3
- package/dist/access-extraction-force-flush.js +331 -58
- package/dist/access-http-briefing.js +331 -59
- package/dist/access-http-query.js +331 -60
- package/dist/access-http.js +329 -111
- package/dist/access-identity-continuity-surface.js +331 -58
- package/dist/access-lcm-surface.js +331 -58
- package/dist/access-mcp-frames.d.ts +20 -6
- package/dist/access-mcp-frames.d.ts.map +1 -1
- package/dist/access-mcp-frames.js +1 -1
- package/dist/access-mcp.d.ts +5 -0
- package/dist/access-mcp.d.ts.map +1 -1
- package/dist/access-mcp.js +329 -86
- package/dist/access-namespace-preflight.js +2 -282
- package/dist/access-observe-transcript.js +3 -3
- package/dist/access-observe-write-category.js +6 -6
- package/dist/access-observe-write-surface.js +331 -58
- package/dist/access-offline-manifest.js +12 -11
- package/dist/access-operations-batch.js +329 -63
- package/dist/access-operations.js +329 -72
- package/dist/access-recall-concurrency.js +331 -58
- package/dist/access-recall-diagnostics.js +5 -4
- package/dist/access-recall-response.js +331 -58
- package/dist/access-recall-surface.js +331 -58
- package/dist/access-schema.js +2 -2
- package/dist/access-service.js +334 -61
- package/dist/access-surface-catalog.js +6 -283
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/active-context-transform.js +1 -1
- package/dist/active-memory-bridge.js +3 -2
- package/dist/active-recall.js +35 -36
- package/dist/active-recall.js.map +1 -1
- package/dist/activity/journal-extract.d.ts +13 -1
- package/dist/activity/journal-extract.d.ts.map +1 -1
- package/dist/{auto-sync-3AZW7MXI.js → auto-sync-BO5YZKM6.js} +13 -15
- package/dist/{auto-sync-3AZW7MXI.js.map → auto-sync-BO5YZKM6.js.map} +1 -1
- package/dist/briefing.js +19 -19
- package/dist/buffer.js +16 -16
- package/dist/calibration.js +10 -10
- package/dist/{capsule-merge-2IIXFXN5.js → capsule-merge-6IDAYTKG.js} +6 -6
- package/dist/causal-consolidation.js +22 -22
- package/dist/{chunk-ATPWZ4F7.js → chunk-2LMA22UU.js} +5 -5
- package/dist/{chunk-RGUUBAT5.js → chunk-2WCLTWV2.js} +3 -3
- package/dist/{chunk-BQZEGOZ4.js → chunk-2YODOG2O.js} +2 -2
- package/dist/{chunk-WYG5UNDY.js → chunk-3AUDELZL.js} +2 -2
- package/dist/{chunk-N4KAE2NB.js → chunk-3CYOCE6U.js} +3 -3
- package/dist/{chunk-MB6ZJDN6.js → chunk-3FBAEPCU.js} +2 -2
- package/dist/{chunk-PIITB2YZ.js → chunk-3ZS3NUEI.js} +4 -4
- package/dist/{chunk-ANZZLRUX.js → chunk-4IVRQMZW.js} +2 -2
- package/dist/{chunk-63E37JCN.js → chunk-4RAJT5L2.js} +4 -4
- package/dist/{chunk-45VUHDV2.js → chunk-5CO5G4MN.js} +2 -2
- package/dist/{chunk-BRLXOZLM.js → chunk-5YT2IIFX.js} +729 -17
- package/dist/chunk-5YT2IIFX.js.map +1 -0
- package/dist/{chunk-E4IRW2FG.js → chunk-622V2AZA.js} +233 -40
- package/dist/chunk-622V2AZA.js.map +1 -0
- package/dist/{chunk-LUJCQQ3L.js → chunk-65HWAQ4F.js} +2 -2
- package/dist/{chunk-T67LUYCR.js → chunk-77NTFICT.js} +5 -5
- package/dist/chunk-A2WFUMUN.js +86 -0
- package/dist/chunk-A2WFUMUN.js.map +1 -0
- package/dist/{chunk-UE6RRXMF.js → chunk-A4F7OIC5.js} +2 -2
- package/dist/chunk-AHA5VQGP.js +117 -0
- package/dist/chunk-AHA5VQGP.js.map +1 -0
- package/dist/{chunk-SUSW74WU.js → chunk-ATG2PQ4V.js} +56 -5
- package/dist/chunk-ATG2PQ4V.js.map +1 -0
- package/dist/{chunk-U6UNF5ZS.js → chunk-B33YWUJV.js} +3 -3
- package/dist/{chunk-RRJBDXAQ.js → chunk-B377OKUP.js} +2 -2
- package/dist/{chunk-IUKYFTGW.js → chunk-B3DR2JBZ.js} +140 -125
- package/dist/chunk-B3DR2JBZ.js.map +1 -0
- package/dist/{chunk-ETZLQOUR.js → chunk-BGHCSLE5.js} +2 -2
- package/dist/{chunk-YYOMGOHB.js → chunk-BOK6BN5M.js} +2 -2
- package/dist/{chunk-OH7QLI6W.js → chunk-BPPUH5JM.js} +5 -5
- package/dist/{chunk-4J363OAA.js → chunk-BTI4C4MA.js} +2 -2
- package/dist/{chunk-O6ZSWHVR.js → chunk-C2KE5DMD.js} +4 -4
- package/dist/{chunk-47F6WWLQ.js → chunk-C73N66PR.js} +2 -2
- package/dist/{chunk-E3A7ELSG.js → chunk-CGJYL633.js} +2 -2
- package/dist/{chunk-WRT7GJ2D.js → chunk-CIWMTNHW.js} +4 -4
- package/dist/{chunk-O55EKIEC.js → chunk-D3ZKHLN2.js} +2 -2
- package/dist/{chunk-CD4BCCNP.js → chunk-DJ7WVEWX.js} +2 -2
- package/dist/{chunk-PWXPRVLK.js → chunk-EFL24KOI.js} +2 -2
- package/dist/{chunk-4CJTQHEG.js → chunk-ESLOLCD4.js} +3 -3
- package/dist/{chunk-6F42QONS.js → chunk-ETBVCRVL.js} +4 -4
- package/dist/{chunk-VILPVT4S.js → chunk-EZ47HOJ6.js} +4 -4
- package/dist/{chunk-EFYN5I7Z.js → chunk-F4QFU5IZ.js} +2 -2
- package/dist/{chunk-T6OZW2WR.js → chunk-FA7SLQ5X.js} +7 -1
- package/dist/chunk-FA7SLQ5X.js.map +1 -0
- package/dist/{chunk-7W3RXOIG.js → chunk-FMKILENU.js} +14 -14
- package/dist/{chunk-YLXETSAH.js → chunk-GCZJ7XRI.js} +2 -2
- package/dist/{chunk-5HFXGXE5.js → chunk-GQXOBKPL.js} +7 -9
- package/dist/{chunk-5HFXGXE5.js.map → chunk-GQXOBKPL.js.map} +1 -1
- package/dist/{chunk-UDKWFDV2.js → chunk-HLUHEMN4.js} +27 -3
- package/dist/chunk-HLUHEMN4.js.map +1 -0
- package/dist/{chunk-QFEDITXM.js → chunk-JNDMIAJ4.js} +2 -2
- package/dist/chunk-JTSSSR4L.js +359 -0
- package/dist/chunk-JTSSSR4L.js.map +1 -0
- package/dist/{chunk-5KBIOI4G.js → chunk-JVBAPAWZ.js} +217 -13
- package/dist/chunk-JVBAPAWZ.js.map +1 -0
- package/dist/{chunk-E5PPE4VA.js → chunk-K2VRKCPA.js} +2 -2
- package/dist/{chunk-MKRYQROF.js → chunk-LGEHAQHK.js} +4 -4
- package/dist/{chunk-7HTUYFR3.js → chunk-LLPMMMWG.js} +27 -10
- package/dist/chunk-LLPMMMWG.js.map +1 -0
- package/dist/{chunk-XYTQJD7F.js → chunk-LMJVP5CM.js} +2 -2
- package/dist/{chunk-FQKBJJYB.js → chunk-LPV72KRQ.js} +2 -2
- package/dist/{chunk-2LCRG2YV.js → chunk-M2XR6B6V.js} +2 -2
- package/dist/{chunk-P4WNBSTW.js → chunk-MH632KPO.js} +2 -2
- package/dist/{chunk-EQ4U73UH.js → chunk-MLAMXQAW.js} +14 -2
- package/dist/chunk-MLAMXQAW.js.map +1 -0
- package/dist/{chunk-ZU5JDLOH.js → chunk-MMRTPH3J.js} +2 -2
- package/dist/{chunk-PMJFRDJI.js → chunk-MUX7IL77.js} +2 -2
- package/dist/{chunk-HF3BKUVV.js → chunk-NAQ4A5IX.js} +7 -7
- package/dist/{chunk-TVIVY7KU.js → chunk-NED7IR7B.js} +4 -4
- package/dist/{chunk-6F5MJFXY.js → chunk-NHVAX7MH.js} +2 -2
- package/dist/{chunk-TG3R2SID.js → chunk-NMGHGTVR.js} +5 -5
- package/dist/{chunk-YCNIGRRF.js → chunk-NS7U4ZYU.js} +13 -117
- package/dist/chunk-NS7U4ZYU.js.map +1 -0
- package/dist/{chunk-NGHDW6UU.js → chunk-NUQEREIP.js} +2 -2
- package/dist/{chunk-5IIQU4JZ.js → chunk-OB72KNMF.js} +4 -4
- package/dist/{chunk-JV4S6VDH.js → chunk-OJXJWNFY.js} +2 -2
- package/dist/{chunk-QJPJXCS4.js → chunk-P3WRNWWM.js} +157 -4
- package/dist/chunk-P3WRNWWM.js.map +1 -0
- package/dist/{chunk-E6M225BJ.js → chunk-PC5DRBGD.js} +18 -8
- package/dist/chunk-PC5DRBGD.js.map +1 -0
- package/dist/{chunk-Z7JIZ42P.js → chunk-PRAUN6PN.js} +3 -3
- package/dist/{chunk-RWGRSKN5.js → chunk-PT4DZDJA.js} +2 -2
- package/dist/{chunk-7EPY3IQL.js → chunk-PZJQ46DH.js} +2 -2
- package/dist/{chunk-MXHMNKWG.js → chunk-QDESY76F.js} +3 -3
- package/dist/{chunk-I6QGI65T.js → chunk-QRMG4HK4.js} +3 -3
- package/dist/{chunk-ZU3NJNO7.js → chunk-QSF5SJAM.js} +4 -4
- package/dist/{chunk-5IYOKDM4.js → chunk-R23JWJD3.js} +5 -5
- package/dist/{chunk-RHQLIHMB.js → chunk-R4BBGPI2.js} +218 -218
- package/dist/chunk-R4BBGPI2.js.map +1 -0
- package/dist/{chunk-7GLJMDEQ.js → chunk-RM2YUFH6.js} +6 -6
- package/dist/{chunk-IPT2OY4B.js → chunk-RQFXZYTF.js} +35 -33
- package/dist/chunk-RQFXZYTF.js.map +1 -0
- package/dist/{chunk-AP6NCP3V.js → chunk-S3S72HRM.js} +8 -6
- package/dist/chunk-S3S72HRM.js.map +1 -0
- package/dist/{chunk-RIMK327Y.js → chunk-SGQPR5SX.js} +7 -7
- package/dist/{chunk-ZGFLIK5H.js → chunk-SPAKBUJY.js} +2 -2
- package/dist/{chunk-ER7XANP3.js → chunk-SQ3GEIEL.js} +4 -4
- package/dist/{chunk-BLJT6JP2.js → chunk-SVT5IA2H.js} +2 -2
- package/dist/{chunk-HVX4LPNY.js → chunk-T4KY6UYF.js} +5 -3
- package/dist/{chunk-HVX4LPNY.js.map → chunk-T4KY6UYF.js.map} +1 -1
- package/dist/{chunk-GVGAO3WV.js → chunk-TJ4F6H4H.js} +3 -3
- package/dist/{chunk-R6HMAIKM.js → chunk-TOSPNM4T.js} +2 -2
- package/dist/{chunk-HH5LY6RR.js → chunk-TRQE3RYR.js} +5 -5
- package/dist/{chunk-RMXS4I66.js → chunk-TVDJEUV5.js} +2 -2
- package/dist/{chunk-PLCYKAWH.js → chunk-TYRWSE4B.js} +2 -2
- package/dist/{chunk-B4QYQFGY.js → chunk-UBEKET2V.js} +383 -36
- package/dist/chunk-UBEKET2V.js.map +1 -0
- package/dist/{chunk-IQWUACVG.js → chunk-UHMHJX5G.js} +3 -3
- package/dist/{chunk-YODUDA6R.js → chunk-UN4RVUG2.js} +22 -22
- package/dist/{chunk-E6Z4FBX6.js → chunk-V2QSNFCT.js} +2 -2
- package/dist/{chunk-NBH6K6G5.js → chunk-V65H7MI6.js} +345 -16
- package/dist/chunk-V65H7MI6.js.map +1 -0
- package/dist/chunk-W54Z2MOP.js +4500 -0
- package/dist/chunk-W54Z2MOP.js.map +1 -0
- package/dist/{chunk-E7YZXWIS.js → chunk-WKSQTMU7.js} +2 -2
- package/dist/{chunk-RIZ5NUNN.js → chunk-WQ4XKIOX.js} +4 -4
- package/dist/{chunk-FSO3G4JJ.js → chunk-WQURALGV.js} +4995 -2747
- package/dist/chunk-WQURALGV.js.map +1 -0
- package/dist/{chunk-QEYTRFR3.js → chunk-X26YOFGS.js} +2 -2
- package/dist/{chunk-ITHZFHST.js → chunk-X2BVB74H.js} +2 -2
- package/dist/{chunk-XYKBWTWI.js → chunk-XIYLWEXC.js} +2 -2
- package/dist/{chunk-IBJ6U753.js → chunk-XKZBZOKV.js} +4 -4
- package/dist/{chunk-65AUYLU3.js → chunk-XPXHQI6N.js} +2 -2
- package/dist/{chunk-EXHXJETE.js → chunk-XRDYRWZI.js} +2 -2
- package/dist/chunk-XRWWCW4H.js +102 -0
- package/dist/chunk-XRWWCW4H.js.map +1 -0
- package/dist/chunk-YKJBSMMP.js +67137 -0
- package/dist/chunk-YKJBSMMP.js.map +1 -0
- package/dist/{chunk-2JSDPUKD.js → chunk-YMFPFXEX.js} +2 -2
- package/dist/{chunk-645WOU5I.js → chunk-ZDZJNXL6.js} +4 -4
- package/dist/{chunk-6TCXIRP5.js → chunk-ZKE4CO6B.js} +4 -4
- package/dist/{chunk-FNXQZGUS.js → chunk-ZSE774RV.js} +2 -2
- package/dist/cli.js +302 -184
- package/dist/coding/export-okf-codegraph.js +28 -28
- package/dist/compounding/engine.js +22 -23
- package/dist/config.js +35 -36
- package/dist/connectors/codex-materialize-runner.js +19 -19
- package/dist/connectors/index.js +20 -20
- package/dist/connectors/live/google-drive.d.ts +2 -0
- package/dist/connectors/live/google-drive.d.ts.map +1 -1
- package/dist/consolidation-provenance-check.js +4 -4
- package/dist/consolidation-undo.js +5 -5
- package/dist/contradiction/index.js +7 -6
- package/dist/{contradiction-scan-P2MHYFVG.js → contradiction-scan-IBPYGQZF.js} +4 -3
- package/dist/convergence-refresh.js +21 -21
- package/dist/corpus-watermark.js +22 -22
- package/dist/deep-recall-http-glue.js +2 -2
- package/dist/deep-recall-policy-llm.js +4 -4
- package/dist/direct-answer-wiring.js +2 -2
- package/dist/embedding-fallback.js +1 -1
- package/dist/entity-retrieval.js +20 -20
- package/dist/eval-trajectory-store.js +2 -2
- package/dist/eval-trajectory.js +2 -2
- package/dist/event-order-recall.js +2 -2
- package/dist/explicit-capture.d.ts +3 -2
- package/dist/explicit-capture.d.ts.map +1 -1
- package/dist/explicit-capture.js +530 -6
- package/dist/explicit-cue-recall.js +2 -2
- package/dist/external-wiki-access.js +2 -283
- package/dist/extraction-faithfulness.js +4 -4
- package/dist/extraction-judge.js +5 -5
- package/dist/extraction-normalization.js +1 -1
- package/dist/extraction-quote-grounding.d.ts.map +1 -1
- package/dist/extraction-quote-grounding.js +1 -1
- package/dist/extraction-source-grounding-rules.js +2 -2
- package/dist/extraction-source-grounding.js +3 -3
- package/dist/extraction.js +42 -43
- package/dist/fallback-llm-codex-subscription.js +2 -2
- package/dist/fallback-llm.js +3 -3
- package/dist/{first-start-migration-QFI7B5SH.js → first-start-migration-FILJH3RO.js} +6 -5
- package/dist/{first-start-migration-QFI7B5SH.js.map → first-start-migration-FILJH3RO.js.map} +1 -1
- package/dist/focused-list-recall.js +2 -2
- package/dist/harmonic-retrieval.js +19 -19
- package/dist/index.js +772 -793
- package/dist/lcm/index.js +2 -2
- package/dist/live-connectors-runner.js +2 -3
- package/dist/local-llm-config.js +2 -2
- package/dist/local-llm-helpers.d.ts +4 -0
- package/dist/local-llm-helpers.d.ts.map +1 -1
- package/dist/local-llm-helpers.js +3 -1
- package/dist/local-llm.d.ts +4 -1
- package/dist/local-llm.d.ts.map +1 -1
- package/dist/local-llm.js +4 -4
- package/dist/location/index.js +26 -28
- package/dist/maintenance/memory-governance.js +19 -19
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +19 -19
- package/dist/maintenance/rebuild-memory-projection-runner.js +21 -21
- package/dist/maintenance/rebuild-memory-projection.js +20 -20
- package/dist/memory-browse-operations.js +2 -283
- package/dist/memory-browse.js +8 -7
- package/dist/memory-controller.js +2 -2
- package/dist/memory-subject.js +2 -2
- package/dist/namespaces/migrate.js +20 -20
- package/dist/namespaces/search.js +5 -5
- package/dist/namespaces/storage.js +19 -19
- package/dist/offline-sync-changeset-generations.js +1 -1
- package/dist/offline-sync-embedding-generation.js +1 -1
- package/dist/offline-sync-impression-drain.js +6 -6
- package/dist/offline-sync-snapshot-stream.js +1 -1
- package/dist/offline-sync.js +1 -1
- package/dist/operator-doctor-corpus.js +23 -23
- package/dist/operator-toolkit.js +57 -60
- package/dist/orchestration/backlog-scheduler.js +277 -293
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +277 -293
- package/dist/orchestration/extraction-run.d.ts +4 -0
- package/dist/orchestration/extraction-run.d.ts.map +1 -1
- package/dist/orchestration/fact-dedup-window.d.ts +1 -1
- package/dist/orchestration/fact-dedup-window.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +38 -41
- package/dist/orchestrator.d.ts +9 -11
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +289 -306
- package/dist/page-versioning.js +3 -3
- package/dist/qmd-daemon-session.js +2 -2
- package/dist/qmd.js +3 -3
- package/dist/recall-explain-renderer.js +1 -1
- package/dist/recall-navigation-operations.js +2 -283
- package/dist/recall-navigation.js +331 -58
- package/dist/recall-planner-llm.js +3 -3
- package/dist/recall-state-view-admission.js +6 -6
- package/dist/recall-why-service.js +10 -9
- package/dist/recall-why.js +4 -3
- package/dist/recall-xray-cli.js +2 -2
- package/dist/recall-xray-renderer.js +1 -1
- package/dist/reconcile/manifest.js +3 -3
- package/dist/{resolution-N7H3F2E4.js → resolution-OVVIF7ZY.js} +8 -7
- package/dist/response-guidance-recall.js +2 -2
- package/dist/resume-bundles.js +39 -40
- package/dist/salvage-envelope.js +4 -4
- package/dist/search/factory.js +4 -4
- package/dist/search/index.js +4 -4
- package/dist/semantic-consolidation.js +22 -22
- package/dist/semantic-rule-promotion.js +19 -19
- package/dist/semantic-rule-verifier.js +19 -19
- package/dist/shared-context/manager.js +2 -3
- package/dist/source-agent-qualifier.js +31 -32
- package/dist/standup/build.js +19 -19
- package/dist/storage/content-hash-index.d.ts +10 -0
- package/dist/storage/content-hash-index.d.ts.map +1 -1
- package/dist/storage.js +18 -18
- package/dist/subject-config.js +3 -3
- package/dist/summarizer.d.ts +4 -1
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +6 -6
- package/dist/support-passport/index.js +53 -297
- package/dist/targeted-fact-recall.js +2 -2
- package/dist/tier-routing.js +3 -2
- package/dist/{tier-stats-FQGQSFET.js → tier-stats-FXEUJN73.js} +6 -5
- package/dist/{tier-stats-FQGQSFET.js.map → tier-stats-FXEUJN73.js.map} +1 -1
- package/dist/transcript.js +2 -2
- package/dist/transfer/capsule-import.js +4 -4
- package/dist/transfer/export-okf.js +19 -19
- package/dist/verified-recall.js +19 -19
- package/dist/wearables/memory-gen.d.ts +5 -1
- package/dist/wearables/memory-gen.d.ts.map +1 -1
- package/dist/wearables/service.d.ts.map +1 -1
- package/dist/who-knows-cli.js +20 -20
- package/dist/who-knows.js +19 -19
- package/dist/write-envelope.js +3 -3
- package/package.json +2 -2
- package/src/access-boundary.ts +5 -1
- package/src/access-category-alias.test.ts +5 -0
- package/src/access-mcp-frames.test.ts +60 -5
- package/src/access-mcp-frames.ts +72 -18
- package/src/access-mcp.test.ts +66 -2
- package/src/access-mcp.ts +19 -13
- package/src/access-service-coding-write.test.ts +7 -0
- package/src/activity/journal-extract-storage.test.ts +31 -0
- package/src/activity/journal-extract.test.ts +1 -0
- package/src/activity/journal-extract.ts +24 -3
- package/src/connectors/live/google-drive.test.ts +39 -0
- package/src/connectors/live/google-drive.ts +41 -12
- package/src/explicit-capture.test.ts +109 -17
- package/src/explicit-capture.ts +90 -37
- package/src/extraction-quote-grounding.test.ts +20 -0
- package/src/extraction-quote-grounding.ts +21 -11
- package/src/fact-dedup-window.test.ts +37 -0
- package/src/local-llm-helpers.ts +12 -0
- package/src/local-llm-shutdown.test.ts +194 -0
- package/src/local-llm.ts +32 -30
- package/src/orchestration/extraction-run.ts +12 -3
- package/src/orchestration/fact-dedup-window.ts +5 -1
- package/src/orchestrator-connector-dedup.test.ts +9 -5
- package/src/orchestrator.ts +47 -50
- package/src/storage/content-hash-index.ts +27 -2
- package/src/storage-fact-hash-publish-failure.test.ts +87 -0
- package/src/summarizer-shutdown.test.ts +195 -0
- package/src/summarizer.ts +15 -2
- package/src/wearables/memory-gen.test.ts +20 -0
- package/src/wearables/memory-gen.ts +14 -7
- package/src/wearables/service.ts +14 -1
- package/src/wearables/storage-io.test.ts +25 -0
- package/dist/chunk-2FGLEF7C.js +0 -61
- package/dist/chunk-2FGLEF7C.js.map +0 -1
- package/dist/chunk-3RLK65ZK.js +0 -203
- package/dist/chunk-3RLK65ZK.js.map +0 -1
- package/dist/chunk-4WR2OD7K.js +0 -43
- package/dist/chunk-4WR2OD7K.js.map +0 -1
- package/dist/chunk-5KBIOI4G.js.map +0 -1
- package/dist/chunk-5M5M22GW.js +0 -346
- package/dist/chunk-5M5M22GW.js.map +0 -1
- package/dist/chunk-7HTUYFR3.js.map +0 -1
- package/dist/chunk-AP6NCP3V.js.map +0 -1
- package/dist/chunk-B4QYQFGY.js.map +0 -1
- package/dist/chunk-BJRTMNCB.js +0 -1919
- package/dist/chunk-BJRTMNCB.js.map +0 -1
- package/dist/chunk-BRLXOZLM.js.map +0 -1
- package/dist/chunk-BSACVS6R.js +0 -621
- package/dist/chunk-BSACVS6R.js.map +0 -1
- package/dist/chunk-DKAA2IHQ.js +0 -3644
- package/dist/chunk-DKAA2IHQ.js.map +0 -1
- package/dist/chunk-E4IRW2FG.js.map +0 -1
- package/dist/chunk-E6M225BJ.js.map +0 -1
- package/dist/chunk-EQ4U73UH.js.map +0 -1
- package/dist/chunk-ETSJD5IV.js +0 -361
- package/dist/chunk-ETSJD5IV.js.map +0 -1
- package/dist/chunk-F55YQP7N.js +0 -336
- package/dist/chunk-F55YQP7N.js.map +0 -1
- package/dist/chunk-FHGWKODN.js +0 -2300
- package/dist/chunk-FHGWKODN.js.map +0 -1
- package/dist/chunk-FLRP63GU.js +0 -32219
- package/dist/chunk-FLRP63GU.js.map +0 -1
- package/dist/chunk-FSO3G4JJ.js.map +0 -1
- package/dist/chunk-ID6JGIMD.js +0 -25
- package/dist/chunk-ID6JGIMD.js.map +0 -1
- package/dist/chunk-IGLJNHOX.js +0 -62
- package/dist/chunk-IGLJNHOX.js.map +0 -1
- package/dist/chunk-IPT2OY4B.js.map +0 -1
- package/dist/chunk-IUKYFTGW.js.map +0 -1
- package/dist/chunk-NBH6K6G5.js.map +0 -1
- package/dist/chunk-NTRUKAAE.js +0 -223
- package/dist/chunk-NTRUKAAE.js.map +0 -1
- package/dist/chunk-OGXXGHW6.js +0 -223
- package/dist/chunk-OGXXGHW6.js.map +0 -1
- package/dist/chunk-PPCLZ4JU.js +0 -28
- package/dist/chunk-PPCLZ4JU.js.map +0 -1
- package/dist/chunk-QJPJXCS4.js.map +0 -1
- package/dist/chunk-R2LBF4HH.js +0 -729
- package/dist/chunk-R2LBF4HH.js.map +0 -1
- package/dist/chunk-RHQLIHMB.js.map +0 -1
- package/dist/chunk-RRTVGD3J.js +0 -792
- package/dist/chunk-RRTVGD3J.js.map +0 -1
- package/dist/chunk-SUSW74WU.js.map +0 -1
- package/dist/chunk-T6OZW2WR.js.map +0 -1
- package/dist/chunk-UDKWFDV2.js.map +0 -1
- package/dist/chunk-V7IZKJI3.js +0 -22
- package/dist/chunk-V7IZKJI3.js.map +0 -1
- package/dist/chunk-X562NQFA.js +0 -10144
- package/dist/chunk-X562NQFA.js.map +0 -1
- package/dist/chunk-XDSCJOH7.js +0 -3991
- package/dist/chunk-XDSCJOH7.js.map +0 -1
- package/dist/chunk-YCNIGRRF.js.map +0 -1
- package/dist/chunk-ZTTCDQ4I.js +0 -18796
- package/dist/chunk-ZTTCDQ4I.js.map +0 -1
- /package/dist/{capsule-merge-2IIXFXN5.js.map → capsule-merge-6IDAYTKG.js.map} +0 -0
- /package/dist/{chunk-ATPWZ4F7.js.map → chunk-2LMA22UU.js.map} +0 -0
- /package/dist/{chunk-RGUUBAT5.js.map → chunk-2WCLTWV2.js.map} +0 -0
- /package/dist/{chunk-BQZEGOZ4.js.map → chunk-2YODOG2O.js.map} +0 -0
- /package/dist/{chunk-WYG5UNDY.js.map → chunk-3AUDELZL.js.map} +0 -0
- /package/dist/{chunk-N4KAE2NB.js.map → chunk-3CYOCE6U.js.map} +0 -0
- /package/dist/{chunk-MB6ZJDN6.js.map → chunk-3FBAEPCU.js.map} +0 -0
- /package/dist/{chunk-PIITB2YZ.js.map → chunk-3ZS3NUEI.js.map} +0 -0
- /package/dist/{chunk-ANZZLRUX.js.map → chunk-4IVRQMZW.js.map} +0 -0
- /package/dist/{chunk-63E37JCN.js.map → chunk-4RAJT5L2.js.map} +0 -0
- /package/dist/{chunk-45VUHDV2.js.map → chunk-5CO5G4MN.js.map} +0 -0
- /package/dist/{chunk-LUJCQQ3L.js.map → chunk-65HWAQ4F.js.map} +0 -0
- /package/dist/{chunk-T67LUYCR.js.map → chunk-77NTFICT.js.map} +0 -0
- /package/dist/{chunk-UE6RRXMF.js.map → chunk-A4F7OIC5.js.map} +0 -0
- /package/dist/{chunk-U6UNF5ZS.js.map → chunk-B33YWUJV.js.map} +0 -0
- /package/dist/{chunk-RRJBDXAQ.js.map → chunk-B377OKUP.js.map} +0 -0
- /package/dist/{chunk-ETZLQOUR.js.map → chunk-BGHCSLE5.js.map} +0 -0
- /package/dist/{chunk-YYOMGOHB.js.map → chunk-BOK6BN5M.js.map} +0 -0
- /package/dist/{chunk-OH7QLI6W.js.map → chunk-BPPUH5JM.js.map} +0 -0
- /package/dist/{chunk-4J363OAA.js.map → chunk-BTI4C4MA.js.map} +0 -0
- /package/dist/{chunk-O6ZSWHVR.js.map → chunk-C2KE5DMD.js.map} +0 -0
- /package/dist/{chunk-47F6WWLQ.js.map → chunk-C73N66PR.js.map} +0 -0
- /package/dist/{chunk-E3A7ELSG.js.map → chunk-CGJYL633.js.map} +0 -0
- /package/dist/{chunk-WRT7GJ2D.js.map → chunk-CIWMTNHW.js.map} +0 -0
- /package/dist/{chunk-O55EKIEC.js.map → chunk-D3ZKHLN2.js.map} +0 -0
- /package/dist/{chunk-CD4BCCNP.js.map → chunk-DJ7WVEWX.js.map} +0 -0
- /package/dist/{chunk-PWXPRVLK.js.map → chunk-EFL24KOI.js.map} +0 -0
- /package/dist/{chunk-4CJTQHEG.js.map → chunk-ESLOLCD4.js.map} +0 -0
- /package/dist/{chunk-6F42QONS.js.map → chunk-ETBVCRVL.js.map} +0 -0
- /package/dist/{chunk-VILPVT4S.js.map → chunk-EZ47HOJ6.js.map} +0 -0
- /package/dist/{chunk-EFYN5I7Z.js.map → chunk-F4QFU5IZ.js.map} +0 -0
- /package/dist/{chunk-7W3RXOIG.js.map → chunk-FMKILENU.js.map} +0 -0
- /package/dist/{chunk-YLXETSAH.js.map → chunk-GCZJ7XRI.js.map} +0 -0
- /package/dist/{chunk-QFEDITXM.js.map → chunk-JNDMIAJ4.js.map} +0 -0
- /package/dist/{chunk-E5PPE4VA.js.map → chunk-K2VRKCPA.js.map} +0 -0
- /package/dist/{chunk-MKRYQROF.js.map → chunk-LGEHAQHK.js.map} +0 -0
- /package/dist/{chunk-XYTQJD7F.js.map → chunk-LMJVP5CM.js.map} +0 -0
- /package/dist/{chunk-FQKBJJYB.js.map → chunk-LPV72KRQ.js.map} +0 -0
- /package/dist/{chunk-2LCRG2YV.js.map → chunk-M2XR6B6V.js.map} +0 -0
- /package/dist/{chunk-P4WNBSTW.js.map → chunk-MH632KPO.js.map} +0 -0
- /package/dist/{chunk-ZU5JDLOH.js.map → chunk-MMRTPH3J.js.map} +0 -0
- /package/dist/{chunk-PMJFRDJI.js.map → chunk-MUX7IL77.js.map} +0 -0
- /package/dist/{chunk-HF3BKUVV.js.map → chunk-NAQ4A5IX.js.map} +0 -0
- /package/dist/{chunk-TVIVY7KU.js.map → chunk-NED7IR7B.js.map} +0 -0
- /package/dist/{chunk-6F5MJFXY.js.map → chunk-NHVAX7MH.js.map} +0 -0
- /package/dist/{chunk-TG3R2SID.js.map → chunk-NMGHGTVR.js.map} +0 -0
- /package/dist/{chunk-NGHDW6UU.js.map → chunk-NUQEREIP.js.map} +0 -0
- /package/dist/{chunk-5IIQU4JZ.js.map → chunk-OB72KNMF.js.map} +0 -0
- /package/dist/{chunk-JV4S6VDH.js.map → chunk-OJXJWNFY.js.map} +0 -0
- /package/dist/{chunk-Z7JIZ42P.js.map → chunk-PRAUN6PN.js.map} +0 -0
- /package/dist/{chunk-RWGRSKN5.js.map → chunk-PT4DZDJA.js.map} +0 -0
- /package/dist/{chunk-7EPY3IQL.js.map → chunk-PZJQ46DH.js.map} +0 -0
- /package/dist/{chunk-MXHMNKWG.js.map → chunk-QDESY76F.js.map} +0 -0
- /package/dist/{chunk-I6QGI65T.js.map → chunk-QRMG4HK4.js.map} +0 -0
- /package/dist/{chunk-ZU3NJNO7.js.map → chunk-QSF5SJAM.js.map} +0 -0
- /package/dist/{chunk-5IYOKDM4.js.map → chunk-R23JWJD3.js.map} +0 -0
- /package/dist/{chunk-7GLJMDEQ.js.map → chunk-RM2YUFH6.js.map} +0 -0
- /package/dist/{chunk-RIMK327Y.js.map → chunk-SGQPR5SX.js.map} +0 -0
- /package/dist/{chunk-ZGFLIK5H.js.map → chunk-SPAKBUJY.js.map} +0 -0
- /package/dist/{chunk-ER7XANP3.js.map → chunk-SQ3GEIEL.js.map} +0 -0
- /package/dist/{chunk-BLJT6JP2.js.map → chunk-SVT5IA2H.js.map} +0 -0
- /package/dist/{chunk-GVGAO3WV.js.map → chunk-TJ4F6H4H.js.map} +0 -0
- /package/dist/{chunk-R6HMAIKM.js.map → chunk-TOSPNM4T.js.map} +0 -0
- /package/dist/{chunk-HH5LY6RR.js.map → chunk-TRQE3RYR.js.map} +0 -0
- /package/dist/{chunk-RMXS4I66.js.map → chunk-TVDJEUV5.js.map} +0 -0
- /package/dist/{chunk-PLCYKAWH.js.map → chunk-TYRWSE4B.js.map} +0 -0
- /package/dist/{chunk-IQWUACVG.js.map → chunk-UHMHJX5G.js.map} +0 -0
- /package/dist/{chunk-YODUDA6R.js.map → chunk-UN4RVUG2.js.map} +0 -0
- /package/dist/{chunk-E6Z4FBX6.js.map → chunk-V2QSNFCT.js.map} +0 -0
- /package/dist/{chunk-E7YZXWIS.js.map → chunk-WKSQTMU7.js.map} +0 -0
- /package/dist/{chunk-RIZ5NUNN.js.map → chunk-WQ4XKIOX.js.map} +0 -0
- /package/dist/{chunk-QEYTRFR3.js.map → chunk-X26YOFGS.js.map} +0 -0
- /package/dist/{chunk-ITHZFHST.js.map → chunk-X2BVB74H.js.map} +0 -0
- /package/dist/{chunk-XYKBWTWI.js.map → chunk-XIYLWEXC.js.map} +0 -0
- /package/dist/{chunk-IBJ6U753.js.map → chunk-XKZBZOKV.js.map} +0 -0
- /package/dist/{chunk-65AUYLU3.js.map → chunk-XPXHQI6N.js.map} +0 -0
- /package/dist/{chunk-EXHXJETE.js.map → chunk-XRDYRWZI.js.map} +0 -0
- /package/dist/{chunk-2JSDPUKD.js.map → chunk-YMFPFXEX.js.map} +0 -0
- /package/dist/{chunk-645WOU5I.js.map → chunk-ZDZJNXL6.js.map} +0 -0
- /package/dist/{chunk-6TCXIRP5.js.map → chunk-ZKE4CO6B.js.map} +0 -0
- /package/dist/{chunk-FNXQZGUS.js.map → chunk-ZSE774RV.js.map} +0 -0
- /package/dist/{contradiction-scan-P2MHYFVG.js.map → contradiction-scan-IBPYGQZF.js.map} +0 -0
- /package/dist/{resolution-N7H3F2E4.js.map → resolution-OVVIF7ZY.js.map} +0 -0
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDefaultNamespaceRoot,
|
|
3
3
|
resolveNamespaceStorageRoot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CGJYL633.js";
|
|
5
|
+
import {
|
|
6
|
+
getConfiguredNamespaces
|
|
7
|
+
} from "./chunk-QRMG4HK4.js";
|
|
8
|
+
import {
|
|
9
|
+
displayErrorDetail
|
|
10
|
+
} from "./chunk-RL6NEVXT.js";
|
|
5
11
|
import {
|
|
6
12
|
isSafeRouteNamespace
|
|
7
13
|
} from "./chunk-PCXDUHQH.js";
|
|
@@ -12,6 +18,7 @@ import {
|
|
|
12
18
|
normalizeNamespaceIdentity
|
|
13
19
|
} from "./chunk-VUFL7X3H.js";
|
|
14
20
|
import {
|
|
21
|
+
resolveConversationContextCapabilities,
|
|
15
22
|
resolveNamespaceCapabilities
|
|
16
23
|
} from "./chunk-C5LWPYS3.js";
|
|
17
24
|
import {
|
|
@@ -701,9 +708,9 @@ var NamespaceCatalog = class {
|
|
|
701
708
|
}
|
|
702
709
|
if (await this.hasSymlinkedAncestor(candidate)) return false;
|
|
703
710
|
try {
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
706
|
-
if (!
|
|
711
|
+
const stat3 = await lstat(candidate);
|
|
712
|
+
if (stat3.isSymbolicLink()) return false;
|
|
713
|
+
if (!stat3.isDirectory()) return false;
|
|
707
714
|
} catch {
|
|
708
715
|
return this.isNearestExistingAncestorContained(candidate, memoryReal);
|
|
709
716
|
}
|
|
@@ -764,8 +771,8 @@ var NamespaceCatalog = class {
|
|
|
764
771
|
}
|
|
765
772
|
if (!(isPathInside(memoryReal, real) || real === memoryReal)) return false;
|
|
766
773
|
try {
|
|
767
|
-
const
|
|
768
|
-
return
|
|
774
|
+
const stat3 = await lstat(real);
|
|
775
|
+
return stat3.isDirectory();
|
|
769
776
|
} catch {
|
|
770
777
|
return false;
|
|
771
778
|
}
|
|
@@ -929,14 +936,14 @@ var NamespaceCatalog = class {
|
|
|
929
936
|
if (normalizeNamespaceIdentity(namespace) !== this.defaultNamespaceIdentity && path2.resolve(root) === path2.resolve(this.memoryDir)) {
|
|
930
937
|
return false;
|
|
931
938
|
}
|
|
932
|
-
let
|
|
939
|
+
let stat3;
|
|
933
940
|
try {
|
|
934
|
-
|
|
941
|
+
stat3 = await lstat(root);
|
|
935
942
|
} catch {
|
|
936
943
|
return false;
|
|
937
944
|
}
|
|
938
|
-
if (
|
|
939
|
-
if (!
|
|
945
|
+
if (stat3.isSymbolicLink()) return false;
|
|
946
|
+
if (!stat3.isDirectory()) return false;
|
|
940
947
|
try {
|
|
941
948
|
const real = await realpath(root);
|
|
942
949
|
if (memoryReal && !isPathInside(memoryReal, real)) return false;
|
|
@@ -1166,18 +1173,18 @@ var NamespaceCatalog = class {
|
|
|
1166
1173
|
for (const entry of entries) {
|
|
1167
1174
|
const token = entry.name;
|
|
1168
1175
|
const fullPath = path2.join(namespacesDir, token);
|
|
1169
|
-
let
|
|
1176
|
+
let stat3;
|
|
1170
1177
|
try {
|
|
1171
|
-
|
|
1178
|
+
stat3 = await lstat(fullPath);
|
|
1172
1179
|
} catch (err) {
|
|
1173
1180
|
skipped.push({ token, reason: "error", detail: err instanceof Error ? err.message : String(err) });
|
|
1174
1181
|
continue;
|
|
1175
1182
|
}
|
|
1176
|
-
if (
|
|
1183
|
+
if (stat3.isSymbolicLink()) {
|
|
1177
1184
|
skipped.push({ token, reason: "symlink", detail: fullPath });
|
|
1178
1185
|
continue;
|
|
1179
1186
|
}
|
|
1180
|
-
if (!
|
|
1187
|
+
if (!stat3.isDirectory()) continue;
|
|
1181
1188
|
try {
|
|
1182
1189
|
const real = await realpath(fullPath);
|
|
1183
1190
|
if (memoryReal && !isPathInside(memoryReal, real)) {
|
|
@@ -1591,9 +1598,714 @@ function isPathInside(root, child) {
|
|
|
1591
1598
|
return relative === "" || !relative.startsWith("..") && !path2.isAbsolute(relative);
|
|
1592
1599
|
}
|
|
1593
1600
|
|
|
1601
|
+
// src/maintenance/namespace-planner.ts
|
|
1602
|
+
import { createHash as createHash2, randomUUID } from "crypto";
|
|
1603
|
+
import { lstat as lstat2, mkdir as mkdir2, open as open2, readFile, readdir as readdir2, rename as rename2, rm as rm2, rmdir, utimes, writeFile as writeFile2 } from "fs/promises";
|
|
1604
|
+
import path3 from "path";
|
|
1605
|
+
var DEFAULT_MAX_NAMESPACES_PER_CYCLE = 20;
|
|
1606
|
+
var DEFAULT_LOCK_STALE_MS = 10 * 6e4;
|
|
1607
|
+
var LOCK_BASE = "maintenance-locks";
|
|
1608
|
+
var STATUS_BASE = "namespace-maintenance-status";
|
|
1609
|
+
var namespaceMaintenanceFs = { open: open2, rm: rm2 };
|
|
1610
|
+
function inferConfiguredKind(config, namespace) {
|
|
1611
|
+
if (namespace === config.defaultNamespace.trim()) return "default";
|
|
1612
|
+
if (namespace === config.sharedNamespace.trim()) return "shared";
|
|
1613
|
+
return "explicit";
|
|
1614
|
+
}
|
|
1615
|
+
function maxNamespacesPerCycle(config) {
|
|
1616
|
+
return Math.max(
|
|
1617
|
+
1,
|
|
1618
|
+
Math.floor(
|
|
1619
|
+
typeof config.maintenanceMaxNamespacesPerCycle === "number" && Number.isFinite(config.maintenanceMaxNamespacesPerCycle) ? config.maintenanceMaxNamespacesPerCycle : DEFAULT_MAX_NAMESPACES_PER_CYCLE
|
|
1620
|
+
)
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
function namespaceKindAllowed(config, kind) {
|
|
1624
|
+
switch (kind) {
|
|
1625
|
+
case "branch":
|
|
1626
|
+
return config.maintenanceIncludeBranchNamespaces === true;
|
|
1627
|
+
case "project":
|
|
1628
|
+
return config.maintenanceIncludeProjectNamespaces !== false;
|
|
1629
|
+
case "team-project":
|
|
1630
|
+
return config.maintenanceIncludeTeamProjectNamespaces !== false;
|
|
1631
|
+
default:
|
|
1632
|
+
return true;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
function disabledReasonForKind(kind) {
|
|
1636
|
+
if (kind === "branch") return "branch_disabled";
|
|
1637
|
+
if (kind === "project") return "project_disabled";
|
|
1638
|
+
if (kind === "team-project") return "team_project_disabled";
|
|
1639
|
+
return "fanout_disabled";
|
|
1640
|
+
}
|
|
1641
|
+
async function catalogRootIsLive(config, record) {
|
|
1642
|
+
if (typeof record.storageDir !== "string" || record.storageDir.length === 0) {
|
|
1643
|
+
return false;
|
|
1644
|
+
}
|
|
1645
|
+
try {
|
|
1646
|
+
const liveRoot = await resolveNamespaceStorageRoot(config, record.namespace);
|
|
1647
|
+
if (path3.resolve(liveRoot) !== path3.resolve(record.storageDir)) return false;
|
|
1648
|
+
return hasMemoryData(liveRoot);
|
|
1649
|
+
} catch {
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
function candidateSortKey(candidate) {
|
|
1654
|
+
const write = candidate.lastWriteAt ?? "";
|
|
1655
|
+
return `${write}\0${candidate.namespace}`;
|
|
1656
|
+
}
|
|
1657
|
+
function candidatePriority(candidate) {
|
|
1658
|
+
if (candidate.kind === "default") return 0;
|
|
1659
|
+
if (candidate.kind === "shared") return 1;
|
|
1660
|
+
if (candidate.source === "configured") return 2;
|
|
1661
|
+
if (candidate.kind === "team-project") return 3;
|
|
1662
|
+
if (candidate.kind === "project") return 4;
|
|
1663
|
+
if (candidate.kind === "branch") return 8;
|
|
1664
|
+
return 7;
|
|
1665
|
+
}
|
|
1666
|
+
function sortCandidates(a, b) {
|
|
1667
|
+
const priority = candidatePriority(a) - candidatePriority(b);
|
|
1668
|
+
if (priority !== 0) return priority;
|
|
1669
|
+
const am = Date.parse(a.lastMaintenanceAt ?? "");
|
|
1670
|
+
const bm = Date.parse(b.lastMaintenanceAt ?? "");
|
|
1671
|
+
const aMaintained = Number.isFinite(am);
|
|
1672
|
+
const bMaintained = Number.isFinite(bm);
|
|
1673
|
+
if (aMaintained && bMaintained && am !== bm) return am - bm;
|
|
1674
|
+
if (aMaintained !== bMaintained) return aMaintained ? 1 : -1;
|
|
1675
|
+
const aw = Date.parse(a.lastWriteAt ?? "");
|
|
1676
|
+
const bw = Date.parse(b.lastWriteAt ?? "");
|
|
1677
|
+
const aValid = Number.isFinite(aw);
|
|
1678
|
+
const bValid = Number.isFinite(bw);
|
|
1679
|
+
if (aValid && bValid && aw !== bw) return bw - aw;
|
|
1680
|
+
if (aValid !== bValid) return aValid ? -1 : 1;
|
|
1681
|
+
const byKey = candidateSortKey(a).localeCompare(candidateSortKey(b));
|
|
1682
|
+
if (byKey !== 0) return byKey;
|
|
1683
|
+
return a.namespace.localeCompare(b.namespace);
|
|
1684
|
+
}
|
|
1685
|
+
async function planNamespaceMaintenance(config, options) {
|
|
1686
|
+
const generatedAt = (options.now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
1687
|
+
const configured = resolveNamespaceCapabilities(config).namespaces ? getConfiguredNamespaces(config) : [config.defaultNamespace.trim()].filter(Boolean);
|
|
1688
|
+
const byNamespace = /* @__PURE__ */ new Map();
|
|
1689
|
+
const skipped = [];
|
|
1690
|
+
for (const namespace of configured) {
|
|
1691
|
+
const kind = inferConfiguredKind(config, namespace);
|
|
1692
|
+
byNamespace.set(namespace, {
|
|
1693
|
+
namespace,
|
|
1694
|
+
kind,
|
|
1695
|
+
source: "configured"
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
if (resolveNamespaceCapabilities(config).namespaces && resolveConversationContextCapabilities(config).maintenanceNamespaceFanout !== false) {
|
|
1699
|
+
const configuredSet = new Set(configured);
|
|
1700
|
+
try {
|
|
1701
|
+
const records = options.catalog?.enabled ? await options.catalog.listNamespaces(void 0, {
|
|
1702
|
+
onIncomplete: (reason) => skipped.push({ namespace: "*", reason: "catalog_read_failed", detail: reason })
|
|
1703
|
+
}) : [];
|
|
1704
|
+
for (const record of records) {
|
|
1705
|
+
const namespace = record.namespace.trim();
|
|
1706
|
+
if (!namespace) continue;
|
|
1707
|
+
const isConfigured = configuredSet.has(namespace);
|
|
1708
|
+
const kind = isConfigured ? inferConfiguredKind(config, namespace) : record.kind;
|
|
1709
|
+
if (!namespaceKindAllowed(config, kind)) {
|
|
1710
|
+
skipped.push({
|
|
1711
|
+
namespace,
|
|
1712
|
+
kind,
|
|
1713
|
+
reason: disabledReasonForKind(kind)
|
|
1714
|
+
});
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
if (!isConfigured && !await catalogRootIsLive(config, record)) {
|
|
1718
|
+
skipped.push({
|
|
1719
|
+
namespace,
|
|
1720
|
+
kind,
|
|
1721
|
+
reason: "unsafe_or_stale_root"
|
|
1722
|
+
});
|
|
1723
|
+
continue;
|
|
1724
|
+
}
|
|
1725
|
+
byNamespace.set(namespace, {
|
|
1726
|
+
namespace,
|
|
1727
|
+
kind,
|
|
1728
|
+
storageDir: record.storageDir,
|
|
1729
|
+
source: isConfigured ? "configured" : "catalog",
|
|
1730
|
+
lastWriteAt: record.lastWriteAt,
|
|
1731
|
+
lastMaintenanceAt: record.lastMaintenanceAt?.[options.jobName]
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
} catch (error) {
|
|
1735
|
+
skipped.push({
|
|
1736
|
+
namespace: "*",
|
|
1737
|
+
reason: "catalog_read_failed",
|
|
1738
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
} else if (resolveNamespaceCapabilities(config).namespaces) {
|
|
1742
|
+
skipped.push({
|
|
1743
|
+
namespace: "*",
|
|
1744
|
+
reason: "fanout_disabled"
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
if (options.budgetMode !== "unbounded") {
|
|
1748
|
+
const latestStatusAtByNamespace = await readLatestStatusAtByNamespace(config, options.jobName);
|
|
1749
|
+
for (const candidate of byNamespace.values()) {
|
|
1750
|
+
if (!candidate.lastMaintenanceAt) {
|
|
1751
|
+
candidate.lastMaintenanceAt = latestStatusAtByNamespace.get(candidate.namespace);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
const candidates = [...byNamespace.values()].filter((candidate) => namespaceKindAllowed(config, candidate.kind)).sort(sortCandidates);
|
|
1756
|
+
const max = maxNamespacesPerCycle(config);
|
|
1757
|
+
const applyCycleBudget = options.budgetMode !== "unbounded";
|
|
1758
|
+
const selected = applyCycleBudget ? candidates.slice(0, max) : candidates;
|
|
1759
|
+
if (applyCycleBudget) {
|
|
1760
|
+
for (const candidate of candidates.slice(max)) {
|
|
1761
|
+
skipped.push({
|
|
1762
|
+
namespace: candidate.namespace,
|
|
1763
|
+
kind: candidate.kind,
|
|
1764
|
+
reason: "budget_exhausted"
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return {
|
|
1769
|
+
jobName: options.jobName,
|
|
1770
|
+
generatedAt,
|
|
1771
|
+
namespaces: selected,
|
|
1772
|
+
skipped,
|
|
1773
|
+
budget: {
|
|
1774
|
+
maxNamespacesPerCycle: max,
|
|
1775
|
+
selected: selected.length
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
function stablePathSegment(value) {
|
|
1780
|
+
const sanitized = value.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 128) || "unnamed";
|
|
1781
|
+
if (sanitized.length <= 128 && sanitized === value) return sanitized;
|
|
1782
|
+
return `${sanitized.slice(0, 80)}-${createHash2("sha256").update(value).digest("hex").slice(0, 16)}`;
|
|
1783
|
+
}
|
|
1784
|
+
function namespacePathSegment(namespace) {
|
|
1785
|
+
const token = namespaceIdentityToken(namespace);
|
|
1786
|
+
if (token.length <= 160) return token;
|
|
1787
|
+
return `ns-${createHash2("sha256").update(namespace).digest("hex")}`;
|
|
1788
|
+
}
|
|
1789
|
+
function lockPath(config, jobName, namespace) {
|
|
1790
|
+
return path3.join(
|
|
1791
|
+
config.memoryDir,
|
|
1792
|
+
"state",
|
|
1793
|
+
LOCK_BASE,
|
|
1794
|
+
stablePathSegment(jobName),
|
|
1795
|
+
`${namespacePathSegment(namespace)}.lock`
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
function namespaceMaintenanceLockStaleMs(config) {
|
|
1799
|
+
if (typeof config.maintenanceNamespaceLockStaleMs === "number" && Number.isFinite(config.maintenanceNamespaceLockStaleMs) && config.maintenanceNamespaceLockStaleMs > 0) {
|
|
1800
|
+
return Math.floor(config.maintenanceNamespaceLockStaleMs);
|
|
1801
|
+
}
|
|
1802
|
+
return DEFAULT_LOCK_STALE_MS;
|
|
1803
|
+
}
|
|
1804
|
+
function namespaceMaintenanceLockHeartbeatMs(config) {
|
|
1805
|
+
const staleMs = namespaceMaintenanceLockStaleMs(config);
|
|
1806
|
+
return Math.max(1, Math.min(3e4, Math.floor(staleMs / 3) || 1));
|
|
1807
|
+
}
|
|
1808
|
+
function errorCode(error) {
|
|
1809
|
+
return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
1810
|
+
}
|
|
1811
|
+
async function withNamespaceMaintenanceLockHeartbeat(config, locks, task) {
|
|
1812
|
+
const activeLocks = Array.isArray(locks) ? locks : [locks];
|
|
1813
|
+
const interval = setInterval(() => {
|
|
1814
|
+
for (const lock of activeLocks) {
|
|
1815
|
+
void lock.touch().catch(() => void 0);
|
|
1816
|
+
}
|
|
1817
|
+
}, namespaceMaintenanceLockHeartbeatMs(config));
|
|
1818
|
+
interval.unref?.();
|
|
1819
|
+
try {
|
|
1820
|
+
return await task();
|
|
1821
|
+
} finally {
|
|
1822
|
+
clearInterval(interval);
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
async function removeStaleLockDirectory(filePath) {
|
|
1826
|
+
let entries;
|
|
1827
|
+
try {
|
|
1828
|
+
entries = await readdir2(filePath, { withFileTypes: true });
|
|
1829
|
+
} catch (error) {
|
|
1830
|
+
if (errorCode(error) === "ENOENT") return;
|
|
1831
|
+
throw error;
|
|
1832
|
+
}
|
|
1833
|
+
for (const entry of entries) {
|
|
1834
|
+
if (!entry.isFile()) continue;
|
|
1835
|
+
await namespaceMaintenanceFs.rm(path3.join(filePath, entry.name), { force: true });
|
|
1836
|
+
}
|
|
1837
|
+
try {
|
|
1838
|
+
await rmdir(filePath);
|
|
1839
|
+
} catch (error) {
|
|
1840
|
+
if (errorCode(error) === "ENOENT") return;
|
|
1841
|
+
throw error;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
async function tryAcquireNamespaceMaintenanceLock(config, jobName, namespace) {
|
|
1845
|
+
const filePath = lockPath(config, jobName, namespace);
|
|
1846
|
+
await mkdir2(path3.dirname(filePath), { recursive: true });
|
|
1847
|
+
try {
|
|
1848
|
+
const lockId = randomUUID();
|
|
1849
|
+
await mkdir2(filePath);
|
|
1850
|
+
const ownerPath = path3.join(filePath, `${lockId}.json`);
|
|
1851
|
+
let handle;
|
|
1852
|
+
try {
|
|
1853
|
+
handle = await namespaceMaintenanceFs.open(ownerPath, "wx");
|
|
1854
|
+
await handle.writeFile(
|
|
1855
|
+
`${JSON.stringify({
|
|
1856
|
+
lockId,
|
|
1857
|
+
pid: process.pid,
|
|
1858
|
+
jobName,
|
|
1859
|
+
namespace,
|
|
1860
|
+
acquiredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1861
|
+
})}
|
|
1862
|
+
`,
|
|
1863
|
+
"utf8"
|
|
1864
|
+
);
|
|
1865
|
+
await handle.close();
|
|
1866
|
+
} catch (setupError) {
|
|
1867
|
+
await handle?.close().catch(() => void 0);
|
|
1868
|
+
await namespaceMaintenanceFs.rm(ownerPath, { force: true }).catch(() => void 0);
|
|
1869
|
+
await rmdir(filePath).catch(() => void 0);
|
|
1870
|
+
throw setupError;
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
path: filePath,
|
|
1874
|
+
async touch() {
|
|
1875
|
+
try {
|
|
1876
|
+
const parsed = JSON.parse(await readFile(ownerPath, "utf8"));
|
|
1877
|
+
if (parsed.lockId === lockId) {
|
|
1878
|
+
const now = /* @__PURE__ */ new Date();
|
|
1879
|
+
await utimes(ownerPath, now, now);
|
|
1880
|
+
await utimes(filePath, now, now);
|
|
1881
|
+
}
|
|
1882
|
+
} catch {
|
|
1883
|
+
}
|
|
1884
|
+
},
|
|
1885
|
+
async release() {
|
|
1886
|
+
try {
|
|
1887
|
+
const parsed = JSON.parse(await readFile(ownerPath, "utf8"));
|
|
1888
|
+
if (parsed.lockId === lockId) {
|
|
1889
|
+
await namespaceMaintenanceFs.rm(ownerPath, { force: true });
|
|
1890
|
+
await rmdir(filePath).catch(() => void 0);
|
|
1891
|
+
}
|
|
1892
|
+
} catch {
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
if (errorCode(error) === "EEXIST") {
|
|
1898
|
+
const staleMs = namespaceMaintenanceLockStaleMs(config);
|
|
1899
|
+
try {
|
|
1900
|
+
const s = await lstat2(filePath);
|
|
1901
|
+
if (s.isSymbolicLink()) {
|
|
1902
|
+
return null;
|
|
1903
|
+
}
|
|
1904
|
+
if ((s.isFile() || s.isDirectory()) && Date.now() - s.mtimeMs > staleMs) {
|
|
1905
|
+
try {
|
|
1906
|
+
if (s.isDirectory()) {
|
|
1907
|
+
await removeStaleLockDirectory(filePath);
|
|
1908
|
+
} else {
|
|
1909
|
+
await namespaceMaintenanceFs.rm(filePath, { force: true });
|
|
1910
|
+
}
|
|
1911
|
+
} catch (removeError) {
|
|
1912
|
+
if (errorCode(removeError) === "ENOENT") {
|
|
1913
|
+
return tryAcquireNamespaceMaintenanceLock(config, jobName, namespace);
|
|
1914
|
+
}
|
|
1915
|
+
if (errorCode(removeError) === "ENOTEMPTY") {
|
|
1916
|
+
return null;
|
|
1917
|
+
}
|
|
1918
|
+
throw removeError;
|
|
1919
|
+
}
|
|
1920
|
+
return tryAcquireNamespaceMaintenanceLock(config, jobName, namespace);
|
|
1921
|
+
}
|
|
1922
|
+
} catch (statError) {
|
|
1923
|
+
if (errorCode(statError) === "ENOENT") {
|
|
1924
|
+
return tryAcquireNamespaceMaintenanceLock(config, jobName, namespace);
|
|
1925
|
+
}
|
|
1926
|
+
throw statError;
|
|
1927
|
+
}
|
|
1928
|
+
return null;
|
|
1929
|
+
}
|
|
1930
|
+
throw error;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
function statusBasePath(config) {
|
|
1934
|
+
return path3.join(config.memoryDir, "state", STATUS_BASE);
|
|
1935
|
+
}
|
|
1936
|
+
function statusPath(config, jobName, namespace) {
|
|
1937
|
+
return path3.join(statusBasePath(config), stablePathSegment(jobName), `${namespacePathSegment(namespace)}.json`);
|
|
1938
|
+
}
|
|
1939
|
+
function lastRanStatusPath(config, jobName, namespace) {
|
|
1940
|
+
return path3.join(statusBasePath(config), stablePathSegment(jobName), `${namespacePathSegment(namespace)}.last-ran.json`);
|
|
1941
|
+
}
|
|
1942
|
+
function parseStatus(value) {
|
|
1943
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1944
|
+
const v = value;
|
|
1945
|
+
if (typeof v.namespace === "string" && typeof v.jobName === "string" && (v.state === "ran" || v.state === "skipped" || v.state === "failed") && typeof v.startedAt === "string" && typeof v.completedAt === "string") {
|
|
1946
|
+
return v;
|
|
1947
|
+
}
|
|
1948
|
+
return null;
|
|
1949
|
+
}
|
|
1950
|
+
async function readLatestStatusAtByNamespace(config, jobName) {
|
|
1951
|
+
const latest = /* @__PURE__ */ new Map();
|
|
1952
|
+
const latestMs = /* @__PURE__ */ new Map();
|
|
1953
|
+
for (const status of [...await readStatusFiles(config), ...await readLastRanStatusFiles(config)]) {
|
|
1954
|
+
if (status.state !== "ran") continue;
|
|
1955
|
+
if (status.jobName !== jobName) continue;
|
|
1956
|
+
const completedAtMs = Date.parse(status.completedAt);
|
|
1957
|
+
if (!Number.isFinite(completedAtMs)) continue;
|
|
1958
|
+
const previousMs = latestMs.get(status.namespace);
|
|
1959
|
+
if (previousMs !== void 0 && previousMs >= completedAtMs) continue;
|
|
1960
|
+
latestMs.set(status.namespace, completedAtMs);
|
|
1961
|
+
latest.set(status.namespace, status.completedAt);
|
|
1962
|
+
}
|
|
1963
|
+
return latest;
|
|
1964
|
+
}
|
|
1965
|
+
async function readStatusFile(filePath) {
|
|
1966
|
+
try {
|
|
1967
|
+
const parsed = JSON.parse(await readFile(filePath, "utf8"));
|
|
1968
|
+
return parseStatus(parsed);
|
|
1969
|
+
} catch {
|
|
1970
|
+
return null;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
async function readStatusFiles(config) {
|
|
1974
|
+
if (typeof config.memoryDir !== "string" || config.memoryDir.length === 0) {
|
|
1975
|
+
return [];
|
|
1976
|
+
}
|
|
1977
|
+
const root = statusBasePath(config);
|
|
1978
|
+
const statuses = [];
|
|
1979
|
+
let jobDirs;
|
|
1980
|
+
try {
|
|
1981
|
+
jobDirs = await readdir2(root, { withFileTypes: true });
|
|
1982
|
+
} catch {
|
|
1983
|
+
return statuses;
|
|
1984
|
+
}
|
|
1985
|
+
for (const jobDir of jobDirs) {
|
|
1986
|
+
if (!jobDir.isDirectory()) continue;
|
|
1987
|
+
let files;
|
|
1988
|
+
try {
|
|
1989
|
+
files = await readdir2(path3.join(root, jobDir.name), { withFileTypes: true });
|
|
1990
|
+
} catch {
|
|
1991
|
+
continue;
|
|
1992
|
+
}
|
|
1993
|
+
for (const file of files) {
|
|
1994
|
+
if (!file.isFile() || !file.name.endsWith(".json")) continue;
|
|
1995
|
+
if (file.name.endsWith(".last-ran.json")) continue;
|
|
1996
|
+
const status = await readStatusFile(path3.join(root, jobDir.name, file.name));
|
|
1997
|
+
if (status) statuses.push(status);
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
return statuses;
|
|
2001
|
+
}
|
|
2002
|
+
async function readLastRanStatusFiles(config) {
|
|
2003
|
+
if (typeof config.memoryDir !== "string" || config.memoryDir.length === 0) {
|
|
2004
|
+
return [];
|
|
2005
|
+
}
|
|
2006
|
+
const root = statusBasePath(config);
|
|
2007
|
+
const statuses = [];
|
|
2008
|
+
let jobDirs;
|
|
2009
|
+
try {
|
|
2010
|
+
jobDirs = await readdir2(root, { withFileTypes: true });
|
|
2011
|
+
} catch {
|
|
2012
|
+
return statuses;
|
|
2013
|
+
}
|
|
2014
|
+
for (const jobDir of jobDirs) {
|
|
2015
|
+
if (!jobDir.isDirectory()) continue;
|
|
2016
|
+
let files;
|
|
2017
|
+
try {
|
|
2018
|
+
files = await readdir2(path3.join(root, jobDir.name), { withFileTypes: true });
|
|
2019
|
+
} catch {
|
|
2020
|
+
continue;
|
|
2021
|
+
}
|
|
2022
|
+
for (const file of files) {
|
|
2023
|
+
if (!file.isFile() || !file.name.endsWith(".last-ran.json")) continue;
|
|
2024
|
+
const status = await readStatusFile(path3.join(root, jobDir.name, file.name));
|
|
2025
|
+
if (status) statuses.push(status);
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
return statuses;
|
|
2029
|
+
}
|
|
2030
|
+
async function writeStatusPayload(target, status) {
|
|
2031
|
+
const dir = path3.dirname(target);
|
|
2032
|
+
await mkdir2(dir, { recursive: true });
|
|
2033
|
+
const temp = `${target}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
2034
|
+
const payload = {
|
|
2035
|
+
version: 1,
|
|
2036
|
+
...status
|
|
2037
|
+
};
|
|
2038
|
+
await writeFile2(temp, `${JSON.stringify(payload, null, 2)}
|
|
2039
|
+
`, "utf8");
|
|
2040
|
+
await rename2(temp, target);
|
|
2041
|
+
}
|
|
2042
|
+
async function writeStatusFile(config, status) {
|
|
2043
|
+
await writeStatusPayload(statusPath(config, status.jobName, status.namespace), status);
|
|
2044
|
+
if (status.state === "ran") {
|
|
2045
|
+
await writeStatusPayload(lastRanStatusPath(config, status.jobName, status.namespace), status);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
async function recordNamespaceMaintenanceStatusSafely(config, status) {
|
|
2049
|
+
try {
|
|
2050
|
+
await writeStatusFile(config, status);
|
|
2051
|
+
} catch {
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
function maintenanceErrorDetail(error) {
|
|
2055
|
+
return displayErrorDetail(error) || "Error";
|
|
2056
|
+
}
|
|
2057
|
+
async function readNamespaceMaintenanceStatuses(config) {
|
|
2058
|
+
return (await readStatusFiles(config)).sort((a, b) => {
|
|
2059
|
+
const byJob = a.jobName.localeCompare(b.jobName);
|
|
2060
|
+
if (byJob !== 0) return byJob;
|
|
2061
|
+
return a.namespace.localeCompare(b.namespace);
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
async function readNamespaceMaintenanceLastRanStatuses(config) {
|
|
2065
|
+
return (await readLastRanStatusFiles(config)).sort((a, b) => {
|
|
2066
|
+
const byJob = a.jobName.localeCompare(b.jobName);
|
|
2067
|
+
if (byJob !== 0) return byJob;
|
|
2068
|
+
return a.namespace.localeCompare(b.namespace);
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
async function runNamespaceMaintenancePlan(config, plan, runner, catalog) {
|
|
2072
|
+
const statuses = [];
|
|
2073
|
+
for (const skipped of plan.skipped) {
|
|
2074
|
+
if (skipped.namespace === "*") continue;
|
|
2075
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2076
|
+
const status = {
|
|
2077
|
+
namespace: skipped.namespace,
|
|
2078
|
+
jobName: plan.jobName,
|
|
2079
|
+
state: "skipped",
|
|
2080
|
+
reason: skipped.reason,
|
|
2081
|
+
startedAt: now,
|
|
2082
|
+
completedAt: now
|
|
2083
|
+
};
|
|
2084
|
+
statuses.push(status);
|
|
2085
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2086
|
+
}
|
|
2087
|
+
for (const candidate of plan.namespaces) {
|
|
2088
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2089
|
+
const lock = await tryAcquireNamespaceMaintenanceLock(config, plan.jobName, candidate.namespace);
|
|
2090
|
+
if (!lock) {
|
|
2091
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2092
|
+
const status = {
|
|
2093
|
+
namespace: candidate.namespace,
|
|
2094
|
+
jobName: plan.jobName,
|
|
2095
|
+
state: "skipped",
|
|
2096
|
+
reason: "lock_held",
|
|
2097
|
+
startedAt,
|
|
2098
|
+
completedAt
|
|
2099
|
+
};
|
|
2100
|
+
statuses.push(status);
|
|
2101
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2102
|
+
continue;
|
|
2103
|
+
}
|
|
2104
|
+
try {
|
|
2105
|
+
const result = await withNamespaceMaintenanceLockHeartbeat(config, lock, () => runner(candidate));
|
|
2106
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2107
|
+
if (result?.skipped) {
|
|
2108
|
+
const status = {
|
|
2109
|
+
namespace: candidate.namespace,
|
|
2110
|
+
jobName: plan.jobName,
|
|
2111
|
+
state: "skipped",
|
|
2112
|
+
reason: result.skipReason ?? "throttled",
|
|
2113
|
+
startedAt,
|
|
2114
|
+
completedAt
|
|
2115
|
+
};
|
|
2116
|
+
statuses.push(status);
|
|
2117
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2118
|
+
} else {
|
|
2119
|
+
const status = {
|
|
2120
|
+
namespace: candidate.namespace,
|
|
2121
|
+
jobName: plan.jobName,
|
|
2122
|
+
state: "ran",
|
|
2123
|
+
startedAt,
|
|
2124
|
+
completedAt,
|
|
2125
|
+
itemCount: result?.itemCount
|
|
2126
|
+
};
|
|
2127
|
+
statuses.push(status);
|
|
2128
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2129
|
+
try {
|
|
2130
|
+
await catalog?.markMaintenance(candidate.namespace, plan.jobName, new Date(completedAt));
|
|
2131
|
+
} catch {
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
} catch (error) {
|
|
2135
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2136
|
+
const status = {
|
|
2137
|
+
namespace: candidate.namespace,
|
|
2138
|
+
jobName: plan.jobName,
|
|
2139
|
+
state: "failed",
|
|
2140
|
+
reason: "job_failed",
|
|
2141
|
+
startedAt,
|
|
2142
|
+
completedAt,
|
|
2143
|
+
error: maintenanceErrorDetail(error)
|
|
2144
|
+
};
|
|
2145
|
+
statuses.push(status);
|
|
2146
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2147
|
+
} finally {
|
|
2148
|
+
await lock.release().catch(() => void 0);
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
return {
|
|
2152
|
+
jobName: plan.jobName,
|
|
2153
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2154
|
+
ran: statuses.filter((s) => s.state === "ran").length,
|
|
2155
|
+
skipped: statuses.filter((s) => s.state === "skipped").length,
|
|
2156
|
+
failed: statuses.filter((s) => s.state === "failed").length,
|
|
2157
|
+
statuses
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
async function runNamespaceMaintenanceBatchPlan(config, plan, runner, catalog, options = {}) {
|
|
2161
|
+
const statuses = [];
|
|
2162
|
+
for (const skipped of plan.skipped) {
|
|
2163
|
+
if (skipped.namespace === "*") continue;
|
|
2164
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2165
|
+
const status = {
|
|
2166
|
+
namespace: skipped.namespace,
|
|
2167
|
+
jobName: plan.jobName,
|
|
2168
|
+
state: "skipped",
|
|
2169
|
+
reason: skipped.reason,
|
|
2170
|
+
startedAt: now,
|
|
2171
|
+
completedAt: now
|
|
2172
|
+
};
|
|
2173
|
+
statuses.push(status);
|
|
2174
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2175
|
+
}
|
|
2176
|
+
const acquired = [];
|
|
2177
|
+
try {
|
|
2178
|
+
for (const candidate of plan.namespaces) {
|
|
2179
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2180
|
+
const lock = await tryAcquireNamespaceMaintenanceLock(config, plan.jobName, candidate.namespace);
|
|
2181
|
+
if (!lock) {
|
|
2182
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2183
|
+
const status = {
|
|
2184
|
+
namespace: candidate.namespace,
|
|
2185
|
+
jobName: plan.jobName,
|
|
2186
|
+
state: "skipped",
|
|
2187
|
+
reason: "lock_held",
|
|
2188
|
+
startedAt,
|
|
2189
|
+
completedAt
|
|
2190
|
+
};
|
|
2191
|
+
statuses.push(status);
|
|
2192
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2193
|
+
continue;
|
|
2194
|
+
}
|
|
2195
|
+
acquired.push({ candidate, lock, startedAt });
|
|
2196
|
+
}
|
|
2197
|
+
} catch (error) {
|
|
2198
|
+
await Promise.all(acquired.map(({ lock }) => lock.release().catch(() => void 0)));
|
|
2199
|
+
throw error;
|
|
2200
|
+
}
|
|
2201
|
+
if (options.requireAllLocks && acquired.length > 0 && acquired.length < plan.namespaces.length) {
|
|
2202
|
+
for (const { candidate, startedAt } of acquired) {
|
|
2203
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2204
|
+
const status = {
|
|
2205
|
+
namespace: candidate.namespace,
|
|
2206
|
+
jobName: plan.jobName,
|
|
2207
|
+
state: "skipped",
|
|
2208
|
+
reason: "batch_lock_incomplete",
|
|
2209
|
+
startedAt,
|
|
2210
|
+
completedAt
|
|
2211
|
+
};
|
|
2212
|
+
statuses.push(status);
|
|
2213
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2214
|
+
}
|
|
2215
|
+
await Promise.all(acquired.map(({ lock }) => lock.release().catch(() => void 0)));
|
|
2216
|
+
return {
|
|
2217
|
+
jobName: plan.jobName,
|
|
2218
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2219
|
+
ran: statuses.filter((s) => s.state === "ran").length,
|
|
2220
|
+
skipped: statuses.filter((s) => s.state === "skipped").length,
|
|
2221
|
+
failed: statuses.filter((s) => s.state === "failed").length,
|
|
2222
|
+
statuses
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
if (acquired.length === 0) {
|
|
2226
|
+
return {
|
|
2227
|
+
jobName: plan.jobName,
|
|
2228
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2229
|
+
ran: statuses.filter((s) => s.state === "ran").length,
|
|
2230
|
+
skipped: statuses.filter((s) => s.state === "skipped").length,
|
|
2231
|
+
failed: statuses.filter((s) => s.state === "failed").length,
|
|
2232
|
+
statuses
|
|
2233
|
+
};
|
|
2234
|
+
}
|
|
2235
|
+
try {
|
|
2236
|
+
const result = await withNamespaceMaintenanceLockHeartbeat(
|
|
2237
|
+
config,
|
|
2238
|
+
acquired.map(({ lock }) => lock),
|
|
2239
|
+
() => runner(acquired.map(({ candidate }) => candidate))
|
|
2240
|
+
);
|
|
2241
|
+
for (const { candidate, startedAt } of acquired) {
|
|
2242
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2243
|
+
const status = {
|
|
2244
|
+
namespace: candidate.namespace,
|
|
2245
|
+
jobName: plan.jobName,
|
|
2246
|
+
state: "ran",
|
|
2247
|
+
startedAt,
|
|
2248
|
+
completedAt,
|
|
2249
|
+
itemCount: itemCountForNamespace(result, candidate.namespace)
|
|
2250
|
+
};
|
|
2251
|
+
statuses.push(status);
|
|
2252
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2253
|
+
try {
|
|
2254
|
+
await catalog?.markMaintenance(candidate.namespace, plan.jobName, new Date(completedAt));
|
|
2255
|
+
} catch {
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
} catch (error) {
|
|
2259
|
+
const skipReason = options.skipReasonForError?.(error);
|
|
2260
|
+
for (const { candidate, startedAt } of acquired) {
|
|
2261
|
+
const completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2262
|
+
const status = skipReason ? {
|
|
2263
|
+
namespace: candidate.namespace,
|
|
2264
|
+
jobName: plan.jobName,
|
|
2265
|
+
state: "skipped",
|
|
2266
|
+
reason: skipReason,
|
|
2267
|
+
startedAt,
|
|
2268
|
+
completedAt
|
|
2269
|
+
} : {
|
|
2270
|
+
namespace: candidate.namespace,
|
|
2271
|
+
jobName: plan.jobName,
|
|
2272
|
+
state: "failed",
|
|
2273
|
+
reason: "job_failed",
|
|
2274
|
+
startedAt,
|
|
2275
|
+
completedAt,
|
|
2276
|
+
error: maintenanceErrorDetail(error)
|
|
2277
|
+
};
|
|
2278
|
+
statuses.push(status);
|
|
2279
|
+
await recordNamespaceMaintenanceStatusSafely(config, status);
|
|
2280
|
+
}
|
|
2281
|
+
} finally {
|
|
2282
|
+
await Promise.all(acquired.map(({ lock }) => lock.release().catch(() => void 0)));
|
|
2283
|
+
}
|
|
2284
|
+
return {
|
|
2285
|
+
jobName: plan.jobName,
|
|
2286
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2287
|
+
ran: statuses.filter((s) => s.state === "ran").length,
|
|
2288
|
+
skipped: statuses.filter((s) => s.state === "skipped").length,
|
|
2289
|
+
failed: statuses.filter((s) => s.state === "failed").length,
|
|
2290
|
+
statuses
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
function itemCountForNamespace(result, namespace) {
|
|
2294
|
+
const itemCounts = result?.itemCounts;
|
|
2295
|
+
if (itemCounts instanceof Map) return itemCounts.get(namespace);
|
|
2296
|
+
if (itemCounts && Object.prototype.hasOwnProperty.call(itemCounts, namespace)) {
|
|
2297
|
+
return itemCounts[namespace];
|
|
2298
|
+
}
|
|
2299
|
+
return result?.itemCount;
|
|
2300
|
+
}
|
|
2301
|
+
|
|
1594
2302
|
export {
|
|
1595
|
-
hasMemoryData,
|
|
1596
2303
|
isNamespaceKind,
|
|
1597
|
-
NamespaceCatalog
|
|
2304
|
+
NamespaceCatalog,
|
|
2305
|
+
planNamespaceMaintenance,
|
|
2306
|
+
readNamespaceMaintenanceStatuses,
|
|
2307
|
+
readNamespaceMaintenanceLastRanStatuses,
|
|
2308
|
+
runNamespaceMaintenancePlan,
|
|
2309
|
+
runNamespaceMaintenanceBatchPlan
|
|
1598
2310
|
};
|
|
1599
|
-
//# sourceMappingURL=chunk-
|
|
2311
|
+
//# sourceMappingURL=chunk-5YT2IIFX.js.map
|