@remnic/core 10.0.165 → 10.0.167
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 +129 -128
- package/dist/access-authorization-probe.js +4 -4
- package/dist/access-boundary.js +3 -3
- package/dist/access-cli.d.ts.map +1 -1
- package/dist/access-cli.js +145 -138
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +37 -0
- package/dist/access-coding-context-resolution.d.ts.map +1 -1
- package/dist/access-coding-context-resolution.js +48 -4
- package/dist/access-errors.d.ts +5 -0
- package/dist/access-errors.d.ts.map +1 -1
- package/dist/access-errors.js +3 -1
- package/dist/access-extraction-force-flush-preempt.js +129 -128
- package/dist/access-extraction-force-flush.js +129 -128
- package/dist/access-http-briefing.js +129 -128
- package/dist/access-http-query.js +129 -128
- package/dist/access-http.d.ts.map +1 -1
- package/dist/access-http.js +129 -128
- package/dist/access-identity-continuity-surface.js +129 -128
- package/dist/access-lcm-surface.js +129 -128
- package/dist/access-mcp.js +129 -128
- package/dist/access-memory-search-fanout.js +2 -2
- package/dist/access-namespace-preflight.js +4 -4
- package/dist/access-observe-transcript.js +3 -2
- package/dist/access-observe-write-category.js +9 -9
- package/dist/access-observe-write-surface.d.ts +1 -0
- package/dist/access-observe-write-surface.d.ts.map +1 -1
- package/dist/access-observe-write-surface.js +129 -128
- package/dist/access-offline-manifest.js +9 -8
- package/dist/access-operations-batch.js +129 -128
- package/dist/access-operations.d.ts +1 -1
- package/dist/access-operations.js +129 -128
- package/dist/access-recall-concurrency.d.ts +3 -16
- package/dist/access-recall-concurrency.d.ts.map +1 -1
- package/dist/access-recall-concurrency.js +129 -128
- package/dist/access-recall-corpus-versions.d.ts +4 -1
- package/dist/access-recall-corpus-versions.d.ts.map +1 -1
- package/dist/access-recall-corpus-versions.js +4 -1
- package/dist/access-recall-diagnostics.js +3 -3
- package/dist/access-recall-response.d.ts.map +1 -1
- package/dist/access-recall-response.js +129 -128
- package/dist/access-recall-surface.d.ts +1 -0
- package/dist/access-recall-surface.d.ts.map +1 -1
- package/dist/access-recall-surface.js +129 -128
- package/dist/access-schema.d.ts +1 -0
- package/dist/access-schema.d.ts.map +1 -1
- package/dist/access-schema.js +2 -2
- package/dist/access-service.d.ts +3 -15
- package/dist/access-service.d.ts.map +1 -1
- package/dist/access-service.js +131 -128
- package/dist/access-surface-catalog.js +5 -5
- package/dist/access-token-capabilities.js +2 -2
- package/dist/active-recall.js +21 -21
- package/dist/artifact-search.js +2 -2
- package/dist/auto-sync-L3M4RKJD.js +1 -1
- package/dist/briefing.js +19 -19
- package/dist/buffer-add-turns-bounded.js +2 -2
- package/dist/buffer-turn-helpers.d.ts.map +1 -1
- package/dist/buffer-turn-helpers.js +1 -1
- package/dist/buffer.js +11 -10
- package/dist/calibration.js +2 -2
- package/dist/capsule-import-gate.js +2 -2
- package/dist/causal-consolidation.js +20 -20
- package/dist/{chunk-5V3IBSVB.js → chunk-22V3CMIW.js} +4 -4
- package/dist/{chunk-7IWRLYFJ.js → chunk-2TJSGIKT.js} +2 -2
- package/dist/{chunk-V6M6N3EE.js → chunk-333SBFXB.js} +2 -2
- package/dist/{chunk-XBW7U7GM.js → chunk-3PNJZTDV.js} +5 -2
- package/dist/chunk-3PNJZTDV.js.map +1 -0
- package/dist/{chunk-XE4UYWW3.js → chunk-3YOX2BQD.js} +3 -3
- package/dist/{chunk-XEBNSY7N.js → chunk-4D2EY4WM.js} +2 -2
- package/dist/{chunk-5HFCXTGY.js → chunk-4D77BI3J.js} +29 -189
- package/dist/chunk-4D77BI3J.js.map +1 -0
- package/dist/{chunk-LPV72KRQ.js → chunk-4IMOGAFF.js} +3 -3
- package/dist/{chunk-QBREZ4QL.js → chunk-4L25GAYL.js} +2 -2
- package/dist/{chunk-HADD45AR.js → chunk-4WCLZBM2.js} +2 -2
- package/dist/{chunk-B3GKQ6DU.js → chunk-5MA6ZQ4Z.js} +2 -2
- package/dist/{chunk-V4ASAWRP.js → chunk-5PUZV73Z.js} +3 -3
- package/dist/{chunk-3QLAOYBL.js → chunk-5QDTZIGH.js} +3 -3
- package/dist/{chunk-WXDTOE6F.js → chunk-5VMRM2X3.js} +2 -2
- package/dist/{chunk-VE23DIBH.js → chunk-6QWFZ3X5.js} +2 -2
- package/dist/{chunk-SDGD6MYV.js → chunk-7F7HRJI2.js} +2 -2
- package/dist/{chunk-QFPNWSVH.js → chunk-7OCKK5M5.js} +6 -6
- package/dist/{chunk-WAJL65KW.js → chunk-7VIJUZYW.js} +3 -3
- package/dist/{chunk-EI2M2CFJ.js → chunk-A5UOREWD.js} +3 -3
- package/dist/{chunk-32CA7B6L.js → chunk-AQZL7JBZ.js} +2 -2
- package/dist/{chunk-EDA6CDBT.js → chunk-AVWOULJH.js} +2 -2
- package/dist/{chunk-4HKK5HUI.js → chunk-B3M56D2A.js} +2 -2
- package/dist/{chunk-YAVIBVCU.js → chunk-BFPQJNFZ.js} +5 -5
- package/dist/{chunk-YAVIBVCU.js.map → chunk-BFPQJNFZ.js.map} +1 -1
- package/dist/{chunk-SRN5M4LQ.js → chunk-BKTCVXMK.js} +4 -4
- package/dist/{chunk-TXVTNDQT.js → chunk-BPCR5DZP.js} +2 -2
- package/dist/{chunk-6S4DM53Y.js → chunk-C5QYWM6F.js} +6 -6
- package/dist/chunk-CKELO7Q6.js +113 -0
- package/dist/chunk-CKELO7Q6.js.map +1 -0
- package/dist/{chunk-IEB6XYW6.js → chunk-CKZWLAHN.js} +2 -2
- package/dist/{chunk-JVIWVJ2A.js → chunk-CUPILBIP.js} +3 -3
- package/dist/{chunk-274UY54Z.js → chunk-DFZYZOLH.js} +3 -3
- package/dist/{chunk-FSI45NUK.js → chunk-EZG54YDS.js} +2 -2
- package/dist/{chunk-7ZFB4VZS.js → chunk-FFWFFAP3.js} +2 -2
- package/dist/{chunk-22VXXA67.js → chunk-FGT7CUYZ.js} +2 -2
- package/dist/{chunk-Z3SXC3MP.js → chunk-FOTFLHBN.js} +2 -2
- package/dist/{chunk-RH6XWXMA.js → chunk-FRYCXXTB.js} +3 -3
- package/dist/{chunk-B377OKUP.js → chunk-G64WYD2S.js} +4 -4
- package/dist/{chunk-JJEQRSYU.js → chunk-GBSXTTLP.js} +2 -2
- package/dist/{chunk-2YODOG2O.js → chunk-GIL2M2OI.js} +3 -3
- package/dist/{chunk-YVRQ5JRA.js → chunk-GYOKVJPB.js} +14 -8
- package/dist/chunk-GYOKVJPB.js.map +1 -0
- package/dist/{chunk-ARJ3KCX4.js → chunk-HDLNSDLK.js} +2 -2
- package/dist/{chunk-VXUO5JZC.js → chunk-HDWISXFH.js} +6 -6
- package/dist/{chunk-RNFMFC37.js → chunk-IDYYGOOQ.js} +28 -1
- package/dist/chunk-IDYYGOOQ.js.map +1 -0
- package/dist/{chunk-IHOKB3L3.js → chunk-IE2ZLO3R.js} +785 -515
- package/dist/chunk-IE2ZLO3R.js.map +1 -0
- package/dist/{chunk-EZ47HOJ6.js → chunk-IXI6S2VJ.js} +4 -4
- package/dist/{chunk-VXMWTRQX.js → chunk-J74YOBB3.js} +4 -4
- package/dist/{chunk-AMW3IDCO.js → chunk-JFMMEHVG.js} +2 -2
- package/dist/{chunk-XKZBZOKV.js → chunk-JIF22AXI.js} +18 -1
- package/dist/chunk-JIF22AXI.js.map +1 -0
- package/dist/{chunk-JTSSSR4L.js → chunk-KIUFT2WZ.js} +3 -3
- package/dist/{chunk-L6BLTV4D.js → chunk-L7SEYUHS.js} +2 -2
- package/dist/{chunk-WRAK5LLB.js → chunk-LPUEBFX2.js} +3 -3
- package/dist/{chunk-DBVSU3HE.js → chunk-LVGTH6IQ.js} +9 -9
- package/dist/{chunk-33VVVP57.js → chunk-MEVBSF6T.js} +4 -1
- package/dist/chunk-MEVBSF6T.js.map +1 -0
- package/dist/{chunk-CJCTKL6Y.js → chunk-MGKCKY7X.js} +4 -1
- package/dist/chunk-MGKCKY7X.js.map +1 -0
- package/dist/{chunk-SOGOHLWN.js → chunk-N7AIFTSH.js} +1 -1
- package/dist/chunk-N7AIFTSH.js.map +1 -0
- package/dist/chunk-O3XGASU5.js +197 -0
- package/dist/chunk-O3XGASU5.js.map +1 -0
- package/dist/{chunk-OGBQMY46.js → chunk-O544TUJO.js} +2 -2
- package/dist/{chunk-TFNZXOXK.js → chunk-OAQRZ4SV.js} +2 -2
- package/dist/{chunk-IEEV27BC.js → chunk-OO2HEUZ4.js} +2 -2
- package/dist/{chunk-YMC4AYJK.js → chunk-OWM2VWNX.js} +10 -10
- package/dist/{chunk-4LPTSB5V.js → chunk-PFLN6TTW.js} +2 -2
- package/dist/{chunk-YOR5QBEU.js → chunk-QFTK6EDM.js} +4 -4
- package/dist/{chunk-A2WFUMUN.js → chunk-QKDXO4FD.js} +4 -4
- package/dist/{chunk-Y7HLGKKU.js → chunk-QLQUAVVP.js} +4 -4
- package/dist/{chunk-MUMQWCE2.js → chunk-QPFM6DHY.js} +2 -2
- package/dist/{chunk-YWPCDR3I.js → chunk-QVXEXGIM.js} +3 -3
- package/dist/{chunk-UPE7TJWN.js → chunk-QWWHYBPT.js} +2 -2
- package/dist/{chunk-NZHZQGLB.js → chunk-QXTKN25V.js} +2 -2
- package/dist/{chunk-OAGTKS73.js → chunk-RFLC6PKQ.js} +2 -2
- package/dist/{chunk-ZRLTQ2Y7.js → chunk-RO5EGRAI.js} +2 -2
- package/dist/{chunk-5D4NBANY.js → chunk-SIONKXLU.js} +2 -2
- package/dist/{chunk-6XTUZKCZ.js → chunk-SMDZTJ2D.js} +2 -2
- package/dist/{chunk-OFSAKEZB.js → chunk-T4BT4FQN.js} +2 -2
- package/dist/{chunk-IC35ZYLM.js → chunk-TAD6QMMD.js} +4 -4
- package/dist/{chunk-EAHNSQ7H.js → chunk-TB6VFEHQ.js} +2 -2
- package/dist/{chunk-6ARSFTLD.js → chunk-TNRGWJYT.js} +2 -2
- package/dist/{chunk-6TPWIPE3.js → chunk-U3BCW7GX.js} +3 -3
- package/dist/{chunk-JCAMHTS2.js → chunk-UBG65KEY.js} +7 -5
- package/dist/{chunk-JCAMHTS2.js.map → chunk-UBG65KEY.js.map} +1 -1
- package/dist/{chunk-CGOPDXLK.js → chunk-UMEUU66X.js} +2 -2
- package/dist/{chunk-5LTXYM7D.js → chunk-UYIBNDQE.js} +2 -2
- package/dist/{chunk-UGQEJWR3.js → chunk-VHXRLD6S.js} +2 -2
- package/dist/{chunk-WJ6S54ES.js → chunk-VOLTQNAP.js} +2 -2
- package/dist/{chunk-SBU5GDOT.js → chunk-VRHY7Y5A.js} +7 -7
- package/dist/{chunk-E5RJPLNL.js → chunk-W7N7NWG5.js} +3 -3
- package/dist/{chunk-UPWOMMVU.js → chunk-WECKZ3KT.js} +7 -7
- package/dist/{chunk-PCUDFWX5.js → chunk-WEFFO2MJ.js} +2 -2
- package/dist/{chunk-QCP75JGO.js → chunk-WQUGCOKF.js} +5 -5
- package/dist/{chunk-FKBGK3NC.js → chunk-WWUQ6CP3.js} +2 -2
- package/dist/{chunk-KR6PEAM4.js → chunk-X67XNZ64.js} +8 -8
- package/dist/{chunk-UYHDMCY2.js → chunk-XUVCQ4YZ.js} +2 -2
- package/dist/{chunk-7IJ2H43M.js → chunk-YY57TRKN.js} +2 -2
- package/dist/{chunk-AU6AEUFD.js → chunk-YYXYZM2I.js} +2 -2
- package/dist/{chunk-3FBAEPCU.js → chunk-ZDUE44CC.js} +2 -2
- package/dist/{chunk-PRE7R3RQ.js → chunk-ZQUOUPP3.js} +12 -3
- package/dist/chunk-ZQUOUPP3.js.map +1 -0
- package/dist/{chunk-RDO6AMDL.js → chunk-ZWDDY4WF.js} +2 -2
- package/dist/{chunk-QASTQVGK.js → chunk-ZX546Y3Y.js} +2 -2
- package/dist/chunk-ZX546Y3Y.js.map +1 -0
- package/dist/cli.js +129 -128
- package/dist/coding/architecture-surfaces.d.ts +0 -24
- package/dist/coding/architecture-surfaces.d.ts.map +1 -1
- package/dist/coding/codegraph-surfaces.d.ts.map +1 -1
- package/dist/coding/export-okf-codegraph.js +51 -24
- package/dist/coding/export-okf-codegraph.js.map +1 -1
- package/dist/coding/git-context.d.ts +23 -0
- package/dist/coding/git-context.d.ts.map +1 -1
- package/dist/coding/git-context.js +31 -0
- package/dist/coding/git-context.js.map +1 -0
- package/dist/coding/session-delta-surfaces.d.ts +0 -23
- package/dist/coding/session-delta-surfaces.d.ts.map +1 -1
- package/dist/compounding/engine.js +20 -20
- package/dist/config.js +21 -21
- package/dist/connectors/codex-materialize-runner.js +19 -19
- package/dist/connectors/droid-mcp.d.ts +4 -3
- package/dist/connectors/droid-mcp.d.ts.map +1 -1
- package/dist/connectors/index.js +23 -23
- package/dist/convergence-refresh.js +21 -21
- package/dist/conversation-index/backend.js +2 -2
- package/dist/corpus-watermark.js +23 -23
- package/dist/deep-recall-config.js +2 -2
- package/dist/deep-recall-http-glue.js +4 -4
- package/dist/entity-recall-cancellation.js +2 -2
- package/dist/entity-recall-reads.js +3 -3
- package/dist/entity-retrieval.js +21 -21
- package/dist/explicit-capture.js +129 -128
- package/dist/external-wiki-access.js +4 -4
- package/dist/extraction-judge.js +1 -1
- package/dist/extraction.js +31 -30
- package/dist/harmonic-retrieval.js +19 -19
- package/dist/index.js +208 -206
- package/dist/local-llm.js +2 -2
- package/dist/location/index.js +21 -21
- 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-http-glue.js +2 -2
- package/dist/memory-browse-operations.js +4 -4
- package/dist/memory-browse.js +6 -6
- package/dist/memory-controller.d.ts +8 -0
- package/dist/memory-controller.d.ts.map +1 -1
- package/dist/memory-controller.js +1 -1
- package/dist/namespaces/migrate.js +20 -20
- package/dist/namespaces/search.js +8 -8
- package/dist/namespaces/storage.js +19 -19
- package/dist/offline-sync-impression-drain.js +8 -7
- package/dist/operator-doctor-corpus.js +26 -26
- package/dist/operator-doctor-replica.js +4 -4
- package/dist/operator-toolkit.js +35 -34
- package/dist/orchestration/backlog-scheduler.js +130 -129
- package/dist/orchestration/backlog-scheduler.js.map +1 -1
- package/dist/orchestration/buffer-drain-runner.js +130 -129
- package/dist/orchestration/episodic-context-section.d.ts +3 -2
- package/dist/orchestration/episodic-context-section.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +34 -33
- package/dist/orchestration/orchestrator-helpers.d.ts +10 -0
- package/dist/orchestration/orchestrator-helpers.d.ts.map +1 -1
- package/dist/orchestration/orchestrator-init.d.ts +12 -13
- package/dist/orchestration/orchestrator-init.d.ts.map +1 -1
- package/dist/orchestration/recall-entry.d.ts.map +1 -1
- package/dist/orchestration/recall-internal.d.ts.map +1 -1
- package/dist/orchestration/session-context.d.ts +5 -1
- package/dist/orchestration/session-context.d.ts.map +1 -1
- package/dist/orchestration/startup-search-sync.d.ts +73 -0
- package/dist/orchestration/startup-search-sync.d.ts.map +1 -0
- package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
- package/dist/orchestrator.d.ts +4 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +129 -128
- package/dist/qmd-daemon-session.js +2 -2
- package/dist/qmd.js +3 -3
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation-http-glue.js +2 -2
- package/dist/recall-navigation-operations.js +4 -4
- package/dist/recall-navigation.js +129 -128
- package/dist/recall-qos.d.ts +26 -0
- package/dist/recall-qos.d.ts.map +1 -1
- package/dist/recall-qos.js +9 -1
- package/dist/recall-state-view-admission.js +6 -6
- package/dist/recall-why-service.js +6 -6
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.js +2 -2
- package/dist/relay/mission.d.ts +3 -3
- package/dist/replica-divergence.js +3 -3
- package/dist/resume-bundles.js +23 -23
- package/dist/search/factory.js +7 -7
- package/dist/search/index.js +9 -9
- package/dist/semantic-consolidation.js +20 -20
- package/dist/semantic-rule-promotion.js +19 -19
- package/dist/semantic-rule-verifier.js +19 -19
- package/dist/source-agent-qualifier.js +29 -28
- package/dist/standup/build.js +20 -20
- package/dist/storage/buffer-drain-claims.js +2 -2
- package/dist/storage/buffer-session-files.js +2 -2
- package/dist/storage.js +18 -18
- package/dist/summarizer.js +3 -3
- package/dist/support-passport/index.js +7 -7
- package/dist/tokens.js +3 -3
- package/dist/transfer/export-okf.js +19 -19
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +19 -19
- package/dist/who-knows-cli.js +21 -21
- package/dist/who-knows.js +20 -20
- package/package.json +12 -2
- package/src/access-cli.ts +18 -9
- package/src/access-coding-context-resolution.ts +138 -0
- package/src/access-errors.ts +5 -0
- package/src/access-http-admission.test.ts +76 -0
- package/src/access-http.test.ts +2 -0
- package/src/access-http.ts +4 -0
- package/src/access-observe-write-surface.ts +2 -1
- package/src/access-operations-batch.ts +2 -2
- package/src/access-recall-concurrency.ts +179 -22
- package/src/access-recall-corpus-versions.ts +12 -7
- package/src/access-recall-response.ts +25 -2
- package/src/access-recall-surface.ts +6 -4
- package/src/access-schema.ts +9 -0
- package/src/access-service-raw-excerpt-read-gate.test.ts +7 -2
- package/src/access-service-recall-concurrency.test.ts +242 -0
- package/src/access-service-set-coding-context.test.ts +210 -0
- package/src/access-service.ts +43 -58
- package/src/buffer-turn-helpers.ts +3 -0
- package/src/capsule-import-gate.test.ts +106 -0
- package/src/coding/access-coding-context.test.ts +3 -0
- package/src/coding/architecture-surfaces.ts +2 -1
- package/src/coding/codegraph-surfaces.test.ts +34 -0
- package/src/coding/codegraph-surfaces.ts +3 -2
- package/src/coding/git-context.test.ts +29 -0
- package/src/coding/git-context.ts +63 -2
- package/src/coding/session-delta-surfaces.ts +2 -1
- package/src/connectors/droid-mcp.test.ts +46 -0
- package/src/connectors/droid-mcp.ts +5 -5
- package/src/harmonic-graph-version.test.ts +63 -0
- package/src/memory-controller.test.ts +38 -0
- package/src/memory-controller.ts +25 -2
- package/src/orchestration/episodic-context-section.ts +6 -7
- package/src/orchestration/orchestrator-helpers.ts +10 -0
- package/src/orchestration/orchestrator-init.ts +57 -303
- package/src/orchestration/recall-entry.ts +59 -4
- package/src/orchestration/recall-internal.ts +10 -10
- package/src/orchestration/session-context.ts +11 -1
- package/src/orchestration/startup-search-sync.ts +492 -0
- package/src/orchestration/task-exit.test.ts +45 -0
- package/src/orchestration/turn-ingestion-buffered.test.ts +224 -0
- package/src/orchestration/turn-ingestion.ts +28 -35
- package/src/orchestrator-flush.test.ts +7 -7
- package/src/orchestrator-init.test.ts +364 -12
- package/src/orchestrator-source-attribution.test.ts +100 -0
- package/src/orchestrator-startup-ready-path.test.ts +133 -10
- package/src/orchestrator.ts +16 -1
- package/src/recall-qos.test.ts +62 -0
- package/src/recall-qos.ts +75 -0
- package/src/recall-retrieval-failure.test.ts +282 -18
- package/src/recall-search-options.test.ts +13 -1
- package/src/storage/buffer-drain-handin-memo.test.ts +140 -0
- package/src/types.ts +1 -1
- package/dist/chunk-33VVVP57.js.map +0 -1
- package/dist/chunk-3QNFHI6T.js +0 -38
- package/dist/chunk-3QNFHI6T.js.map +0 -1
- package/dist/chunk-5HFCXTGY.js.map +0 -1
- package/dist/chunk-CJCTKL6Y.js.map +0 -1
- package/dist/chunk-IHOKB3L3.js.map +0 -1
- package/dist/chunk-PRE7R3RQ.js.map +0 -1
- package/dist/chunk-QASTQVGK.js.map +0 -1
- package/dist/chunk-RNFMFC37.js.map +0 -1
- package/dist/chunk-SOGOHLWN.js.map +0 -1
- package/dist/chunk-XBW7U7GM.js.map +0 -1
- package/dist/chunk-XKZBZOKV.js.map +0 -1
- package/dist/chunk-YVRQ5JRA.js.map +0 -1
- /package/dist/{chunk-5V3IBSVB.js.map → chunk-22V3CMIW.js.map} +0 -0
- /package/dist/{chunk-7IWRLYFJ.js.map → chunk-2TJSGIKT.js.map} +0 -0
- /package/dist/{chunk-V6M6N3EE.js.map → chunk-333SBFXB.js.map} +0 -0
- /package/dist/{chunk-XE4UYWW3.js.map → chunk-3YOX2BQD.js.map} +0 -0
- /package/dist/{chunk-XEBNSY7N.js.map → chunk-4D2EY4WM.js.map} +0 -0
- /package/dist/{chunk-LPV72KRQ.js.map → chunk-4IMOGAFF.js.map} +0 -0
- /package/dist/{chunk-QBREZ4QL.js.map → chunk-4L25GAYL.js.map} +0 -0
- /package/dist/{chunk-HADD45AR.js.map → chunk-4WCLZBM2.js.map} +0 -0
- /package/dist/{chunk-B3GKQ6DU.js.map → chunk-5MA6ZQ4Z.js.map} +0 -0
- /package/dist/{chunk-V4ASAWRP.js.map → chunk-5PUZV73Z.js.map} +0 -0
- /package/dist/{chunk-3QLAOYBL.js.map → chunk-5QDTZIGH.js.map} +0 -0
- /package/dist/{chunk-WXDTOE6F.js.map → chunk-5VMRM2X3.js.map} +0 -0
- /package/dist/{chunk-VE23DIBH.js.map → chunk-6QWFZ3X5.js.map} +0 -0
- /package/dist/{chunk-SDGD6MYV.js.map → chunk-7F7HRJI2.js.map} +0 -0
- /package/dist/{chunk-QFPNWSVH.js.map → chunk-7OCKK5M5.js.map} +0 -0
- /package/dist/{chunk-WAJL65KW.js.map → chunk-7VIJUZYW.js.map} +0 -0
- /package/dist/{chunk-EI2M2CFJ.js.map → chunk-A5UOREWD.js.map} +0 -0
- /package/dist/{chunk-32CA7B6L.js.map → chunk-AQZL7JBZ.js.map} +0 -0
- /package/dist/{chunk-EDA6CDBT.js.map → chunk-AVWOULJH.js.map} +0 -0
- /package/dist/{chunk-4HKK5HUI.js.map → chunk-B3M56D2A.js.map} +0 -0
- /package/dist/{chunk-SRN5M4LQ.js.map → chunk-BKTCVXMK.js.map} +0 -0
- /package/dist/{chunk-TXVTNDQT.js.map → chunk-BPCR5DZP.js.map} +0 -0
- /package/dist/{chunk-6S4DM53Y.js.map → chunk-C5QYWM6F.js.map} +0 -0
- /package/dist/{chunk-IEB6XYW6.js.map → chunk-CKZWLAHN.js.map} +0 -0
- /package/dist/{chunk-JVIWVJ2A.js.map → chunk-CUPILBIP.js.map} +0 -0
- /package/dist/{chunk-274UY54Z.js.map → chunk-DFZYZOLH.js.map} +0 -0
- /package/dist/{chunk-FSI45NUK.js.map → chunk-EZG54YDS.js.map} +0 -0
- /package/dist/{chunk-7ZFB4VZS.js.map → chunk-FFWFFAP3.js.map} +0 -0
- /package/dist/{chunk-22VXXA67.js.map → chunk-FGT7CUYZ.js.map} +0 -0
- /package/dist/{chunk-Z3SXC3MP.js.map → chunk-FOTFLHBN.js.map} +0 -0
- /package/dist/{chunk-RH6XWXMA.js.map → chunk-FRYCXXTB.js.map} +0 -0
- /package/dist/{chunk-B377OKUP.js.map → chunk-G64WYD2S.js.map} +0 -0
- /package/dist/{chunk-JJEQRSYU.js.map → chunk-GBSXTTLP.js.map} +0 -0
- /package/dist/{chunk-2YODOG2O.js.map → chunk-GIL2M2OI.js.map} +0 -0
- /package/dist/{chunk-ARJ3KCX4.js.map → chunk-HDLNSDLK.js.map} +0 -0
- /package/dist/{chunk-VXUO5JZC.js.map → chunk-HDWISXFH.js.map} +0 -0
- /package/dist/{chunk-EZ47HOJ6.js.map → chunk-IXI6S2VJ.js.map} +0 -0
- /package/dist/{chunk-VXMWTRQX.js.map → chunk-J74YOBB3.js.map} +0 -0
- /package/dist/{chunk-AMW3IDCO.js.map → chunk-JFMMEHVG.js.map} +0 -0
- /package/dist/{chunk-JTSSSR4L.js.map → chunk-KIUFT2WZ.js.map} +0 -0
- /package/dist/{chunk-L6BLTV4D.js.map → chunk-L7SEYUHS.js.map} +0 -0
- /package/dist/{chunk-WRAK5LLB.js.map → chunk-LPUEBFX2.js.map} +0 -0
- /package/dist/{chunk-DBVSU3HE.js.map → chunk-LVGTH6IQ.js.map} +0 -0
- /package/dist/{chunk-OGBQMY46.js.map → chunk-O544TUJO.js.map} +0 -0
- /package/dist/{chunk-TFNZXOXK.js.map → chunk-OAQRZ4SV.js.map} +0 -0
- /package/dist/{chunk-IEEV27BC.js.map → chunk-OO2HEUZ4.js.map} +0 -0
- /package/dist/{chunk-YMC4AYJK.js.map → chunk-OWM2VWNX.js.map} +0 -0
- /package/dist/{chunk-4LPTSB5V.js.map → chunk-PFLN6TTW.js.map} +0 -0
- /package/dist/{chunk-YOR5QBEU.js.map → chunk-QFTK6EDM.js.map} +0 -0
- /package/dist/{chunk-A2WFUMUN.js.map → chunk-QKDXO4FD.js.map} +0 -0
- /package/dist/{chunk-Y7HLGKKU.js.map → chunk-QLQUAVVP.js.map} +0 -0
- /package/dist/{chunk-MUMQWCE2.js.map → chunk-QPFM6DHY.js.map} +0 -0
- /package/dist/{chunk-YWPCDR3I.js.map → chunk-QVXEXGIM.js.map} +0 -0
- /package/dist/{chunk-UPE7TJWN.js.map → chunk-QWWHYBPT.js.map} +0 -0
- /package/dist/{chunk-NZHZQGLB.js.map → chunk-QXTKN25V.js.map} +0 -0
- /package/dist/{chunk-OAGTKS73.js.map → chunk-RFLC6PKQ.js.map} +0 -0
- /package/dist/{chunk-ZRLTQ2Y7.js.map → chunk-RO5EGRAI.js.map} +0 -0
- /package/dist/{chunk-5D4NBANY.js.map → chunk-SIONKXLU.js.map} +0 -0
- /package/dist/{chunk-6XTUZKCZ.js.map → chunk-SMDZTJ2D.js.map} +0 -0
- /package/dist/{chunk-OFSAKEZB.js.map → chunk-T4BT4FQN.js.map} +0 -0
- /package/dist/{chunk-IC35ZYLM.js.map → chunk-TAD6QMMD.js.map} +0 -0
- /package/dist/{chunk-EAHNSQ7H.js.map → chunk-TB6VFEHQ.js.map} +0 -0
- /package/dist/{chunk-6ARSFTLD.js.map → chunk-TNRGWJYT.js.map} +0 -0
- /package/dist/{chunk-6TPWIPE3.js.map → chunk-U3BCW7GX.js.map} +0 -0
- /package/dist/{chunk-CGOPDXLK.js.map → chunk-UMEUU66X.js.map} +0 -0
- /package/dist/{chunk-5LTXYM7D.js.map → chunk-UYIBNDQE.js.map} +0 -0
- /package/dist/{chunk-UGQEJWR3.js.map → chunk-VHXRLD6S.js.map} +0 -0
- /package/dist/{chunk-WJ6S54ES.js.map → chunk-VOLTQNAP.js.map} +0 -0
- /package/dist/{chunk-SBU5GDOT.js.map → chunk-VRHY7Y5A.js.map} +0 -0
- /package/dist/{chunk-E5RJPLNL.js.map → chunk-W7N7NWG5.js.map} +0 -0
- /package/dist/{chunk-UPWOMMVU.js.map → chunk-WECKZ3KT.js.map} +0 -0
- /package/dist/{chunk-PCUDFWX5.js.map → chunk-WEFFO2MJ.js.map} +0 -0
- /package/dist/{chunk-QCP75JGO.js.map → chunk-WQUGCOKF.js.map} +0 -0
- /package/dist/{chunk-FKBGK3NC.js.map → chunk-WWUQ6CP3.js.map} +0 -0
- /package/dist/{chunk-KR6PEAM4.js.map → chunk-X67XNZ64.js.map} +0 -0
- /package/dist/{chunk-UYHDMCY2.js.map → chunk-XUVCQ4YZ.js.map} +0 -0
- /package/dist/{chunk-7IJ2H43M.js.map → chunk-YY57TRKN.js.map} +0 -0
- /package/dist/{chunk-AU6AEUFD.js.map → chunk-YYXYZM2I.js.map} +0 -0
- /package/dist/{chunk-3FBAEPCU.js.map → chunk-ZDUE44CC.js.map} +0 -0
- /package/dist/{chunk-RDO6AMDL.js.map → chunk-ZWDDY4WF.js.map} +0 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-ready startup search sync (#3518, #3525): probe, catalog-union
|
|
3
|
+
* namespace discovery, collection ensure, the missing-collection noop swap,
|
|
4
|
+
* and the corpus-wide `qmd update` plus warm-up search. Extracted from
|
|
5
|
+
* orchestrator-init.ts so the coordinator stays under the structural-ratchet
|
|
6
|
+
* ceiling; every collaborator arrives through the host interface so the
|
|
7
|
+
* runner holds no orchestrator internals.
|
|
8
|
+
*
|
|
9
|
+
* Two shared-flight contracts live here:
|
|
10
|
+
* - `ensureStartupSearchBackend`: concurrent callers join one backend
|
|
11
|
+
* bring-up so nobody observes the mid-run half-finished state (#3518).
|
|
12
|
+
* - `startupSearchSync` / `joinStartupSearchSync`: post-ready fire, CLI
|
|
13
|
+
* one-shots and the server retry loop join one corpus update (#3525).
|
|
14
|
+
* The flight is owned by its own controller — never the initiating
|
|
15
|
+
* caller's signal — and cancels when the epoch retires or the last live
|
|
16
|
+
* caller aborts (#3527 review).
|
|
17
|
+
*/
|
|
18
|
+
import { resolveNamespaceCapabilities, resolveQmdCapabilities } from "../capabilities.js";
|
|
19
|
+
import { log } from "../logger.js";
|
|
20
|
+
import { NoopSearchBackend } from "../search/noop-backend.js";
|
|
21
|
+
import type { OrchestratorInitDeps } from "./orchestrator-init.js";
|
|
22
|
+
|
|
23
|
+
/** Outcome of one backend bring-up: probe, catalog-union discovery, per-namespace
|
|
24
|
+
* collection ensure, and the missing-collection noop swap. "ready" carries the
|
|
25
|
+
* epoch and discovery the full sync needs for its corpus update. "degraded" is
|
|
26
|
+
* the probed-available backend whose collection check answered "unknown" — the
|
|
27
|
+
* ensure is unverified, so neither sync may claim success. */
|
|
28
|
+
type StartupBackendEnsure =
|
|
29
|
+
| { state: "ready"; epoch: number; discovery: { namespaces: string[]; complete: boolean } }
|
|
30
|
+
| { state: "unavailable" | "missing" | "degraded" | "retired" };
|
|
31
|
+
|
|
32
|
+
type StartupBackendEnsureFlight = {
|
|
33
|
+
epoch: number;
|
|
34
|
+
promise: Promise<StartupBackendEnsure>;
|
|
35
|
+
controller: AbortController;
|
|
36
|
+
liveCallers: number;
|
|
37
|
+
cleanup: Array<() => void>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type StartupSyncFlight = {
|
|
41
|
+
epoch: number;
|
|
42
|
+
promise: Promise<boolean>;
|
|
43
|
+
controller: AbortController;
|
|
44
|
+
liveCallers: number;
|
|
45
|
+
cleanup: Array<() => void>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** The epoch and namespace primitives the runner borrows from the
|
|
49
|
+
* orchestrator lifecycle — injected as bound functions so no private
|
|
50
|
+
* coordinator member is exposed. */
|
|
51
|
+
export interface StartupSearchSyncHost {
|
|
52
|
+
deps: OrchestratorInitDeps;
|
|
53
|
+
currentOrNewStartupEpoch(): number | null;
|
|
54
|
+
isCurrentStartupEpoch(epoch: number): boolean;
|
|
55
|
+
linkedEpochAbortController(
|
|
56
|
+
epoch: number,
|
|
57
|
+
externalSignal?: AbortSignal,
|
|
58
|
+
): { controller: AbortController; dispose(): void };
|
|
59
|
+
probeForStartupEpoch(epoch: number, externalSignal?: AbortSignal): Promise<boolean>;
|
|
60
|
+
startupNamespaces(epoch: number): Promise<{ namespaces: string[]; complete: boolean }>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class StartupSearchSyncRunner {
|
|
64
|
+
private startupBackendEnsureFlight: StartupBackendEnsureFlight | undefined;
|
|
65
|
+
private startupSyncInFlight: StartupSyncFlight | undefined;
|
|
66
|
+
|
|
67
|
+
constructor(private readonly host: StartupSearchSyncHost) {}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Readiness level of startupSearchSync (#3518): probe, catalog-union
|
|
71
|
+
* collection ensure, and the missing-collection noop swap — WITHOUT the
|
|
72
|
+
* corpus-wide index update. The awaited ready path and the warm-up gate use
|
|
73
|
+
* this so readiness waits only on the probe, the collection and the model
|
|
74
|
+
* warm-up; the corpus update runs after ready under the server retry loop
|
|
75
|
+
* via startupSearchSync. Returns true when the backend is usable for
|
|
76
|
+
* warm-up search, false while unavailable, retired, or noop-disposed.
|
|
77
|
+
*/
|
|
78
|
+
async startupSearchReadySync(signal?: AbortSignal): Promise<boolean> {
|
|
79
|
+
const ensured = await this.ensureStartupSearchBackend(signal);
|
|
80
|
+
return ensured.state === "ready";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Freshness-dependent one-shot entry point (#3525): joins the shared
|
|
85
|
+
* startupSearchSync when this lifecycle still owes a corpus sync, so a
|
|
86
|
+
* caller that needs a fresh index — the `remnic` one-shot diagnostic
|
|
87
|
+
* commands, an OpenClaw boot — waits for the same update the post-ready
|
|
88
|
+
* fire started instead of querying a stale index and aborting the run in
|
|
89
|
+
* flight. Resolves true when the index is already synced or no sync is
|
|
90
|
+
* owed (maintenance disabled); false when the joined sync failed.
|
|
91
|
+
*/
|
|
92
|
+
async joinStartupSearchSync(signal?: AbortSignal): Promise<boolean> {
|
|
93
|
+
if (
|
|
94
|
+
!resolveQmdCapabilities(this.host.deps.config).qmdMaintenance
|
|
95
|
+
|| this.host.deps.deferredSyncSucceeded
|
|
96
|
+
) return true;
|
|
97
|
+
return this.startupSearchSync(signal);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Namespace-aware startup search sync. Re-probes QMD, ensures collections
|
|
102
|
+
* (namespace-aware when namespacesEnabled), runs update, and warms up search.
|
|
103
|
+
* Designed for server retry paths that run after the deferred init completes
|
|
104
|
+
* when QMD was not available during initial startup — and, since #3518, for
|
|
105
|
+
* the post-ready corpus update the deferred path no longer awaits.
|
|
106
|
+
*
|
|
107
|
+
* Accepts an optional AbortSignal so callers can interrupt the sync during
|
|
108
|
+
* shutdown. The signal is checked between phases and forwarded into the QMD
|
|
109
|
+
* update and warmup search calls so a long-running `qmd update` subprocess
|
|
110
|
+
* is killed promptly rather than left in flight after `httpServer.stop()`.
|
|
111
|
+
*
|
|
112
|
+
* Returns true if the sync succeeded (QMD now available), false otherwise.
|
|
113
|
+
*/
|
|
114
|
+
async startupSearchSync(signal?: AbortSignal): Promise<boolean> {
|
|
115
|
+
if (signal?.aborted) return false;
|
|
116
|
+
const epoch = this.host.currentOrNewStartupEpoch();
|
|
117
|
+
if (epoch === null) return false;
|
|
118
|
+
// The post-ready fire (#3525), a freshness-dependent CLI joiner and the
|
|
119
|
+
// server retry loop can all arrive while a call is in flight: join it
|
|
120
|
+
// rather than spawn a second `qmd update` over the same index. Only the
|
|
121
|
+
// current epoch's flight joins — a retired cycle's dying call would hand
|
|
122
|
+
// the joiner its false. The shared run is owned by the flight's
|
|
123
|
+
// controller, never the initiating caller's signal (#3527): it cancels
|
|
124
|
+
// when the epoch retires or every live caller's signal has aborted, and
|
|
125
|
+
// each caller's own signal decides its own wait.
|
|
126
|
+
let flight = this.startupSyncInFlight;
|
|
127
|
+
if (
|
|
128
|
+
!flight ||
|
|
129
|
+
flight.epoch !== epoch ||
|
|
130
|
+
flight.controller.signal.aborted
|
|
131
|
+
) {
|
|
132
|
+
const controller = new AbortController();
|
|
133
|
+
// Normalize an operational failure on the shared run before any caller
|
|
134
|
+
// joins it: a caller without a signal (the local CLI) must get false and
|
|
135
|
+
// keep its stale-index warning and cleanup, not a rejection (#3527).
|
|
136
|
+
const run = this.runStartupSearchSync(controller.signal).catch((err) => {
|
|
137
|
+
log.warn(`startupSearchSync: shared sync failed: ${err}`);
|
|
138
|
+
return false;
|
|
139
|
+
});
|
|
140
|
+
const next: StartupSyncFlight = {
|
|
141
|
+
epoch,
|
|
142
|
+
promise: run,
|
|
143
|
+
controller,
|
|
144
|
+
liveCallers: 0,
|
|
145
|
+
cleanup: [],
|
|
146
|
+
};
|
|
147
|
+
this.startupSyncInFlight = next;
|
|
148
|
+
const settle = () => {
|
|
149
|
+
if (this.startupSyncInFlight === next) this.startupSyncInFlight = undefined;
|
|
150
|
+
for (const remove of next.cleanup) remove();
|
|
151
|
+
};
|
|
152
|
+
void run.then(settle);
|
|
153
|
+
// A completed sync publishes success for its epoch directly — not only
|
|
154
|
+
// through the post-ready .then() — so a joiner, a server retry or an
|
|
155
|
+
// abortDeferredInit() that lands first never re-runs `qmd update`.
|
|
156
|
+
void run.then((synced) => {
|
|
157
|
+
if (synced && !controller.signal.aborted && this.host.isCurrentStartupEpoch(epoch)) {
|
|
158
|
+
this.host.deps.deferredSyncSucceeded = true;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
flight = next;
|
|
162
|
+
}
|
|
163
|
+
// Each caller holds the shared run open until its own signal aborts; the
|
|
164
|
+
// last live caller's abort cancels the run for everyone.
|
|
165
|
+
flight.liveCallers += 1;
|
|
166
|
+
if (signal) {
|
|
167
|
+
const held = flight;
|
|
168
|
+
return new Promise<boolean>((resolve) => {
|
|
169
|
+
const onCallerAbort = () => {
|
|
170
|
+
held.liveCallers -= 1;
|
|
171
|
+
if (held.liveCallers <= 0) held.controller.abort();
|
|
172
|
+
resolve(false);
|
|
173
|
+
};
|
|
174
|
+
signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
175
|
+
held.cleanup.push(() => signal.removeEventListener("abort", onCallerAbort));
|
|
176
|
+
void held.promise.then((result) => {
|
|
177
|
+
signal.removeEventListener("abort", onCallerAbort);
|
|
178
|
+
resolve(result);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return flight.promise;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private async runStartupSearchSync(signal?: AbortSignal): Promise<boolean> {
|
|
186
|
+
const ensured = await this.ensureStartupSearchBackend(signal);
|
|
187
|
+
if (ensured.state !== "ready") return false;
|
|
188
|
+
const { epoch, discovery } = ensured;
|
|
189
|
+
// A caller whose own signal aborted must not dispatch update work even
|
|
190
|
+
// when joined callers kept the shared ensure alive to a ready result.
|
|
191
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
192
|
+
log.debug("startupSearchSync: aborted or retired after the shared backend ensure");
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
const namespaces = discovery.namespaces;
|
|
196
|
+
|
|
197
|
+
// Run index update — namespace-aware when enabled.
|
|
198
|
+
// qmd.update() swallows errors internally, so we: (1) snapshot fail/run
|
|
199
|
+
// timestamps, (2) reset throttles so the update isn't skipped by stale
|
|
200
|
+
// backoff, and (3) verify timestamps after update to confirm it executed
|
|
201
|
+
// and didn't fail silently.
|
|
202
|
+
// The abort signal is forwarded into the QMD subprocess call so the
|
|
203
|
+
// long-running `qmd update` process is killed promptly on shutdown.
|
|
204
|
+
if (resolveQmdCapabilities(this.host.deps.config).qmdMaintenance) {
|
|
205
|
+
try {
|
|
206
|
+
// SAFETY: guarded by the `in` check — the concrete QMD backend's fail
|
|
207
|
+
// timestamp is an internal the SearchBackend interface does not declare.
|
|
208
|
+
const failTsBefore = "lastUpdateFailedAtMs" in this.host.deps.qmd
|
|
209
|
+
? (this.host.deps.qmd as any).lastUpdateFailedAtMs as number | null
|
|
210
|
+
: null;
|
|
211
|
+
const hasRunTs = "lastUpdateRanAtMs" in this.host.deps.qmd;
|
|
212
|
+
if ("resetUpdateThrottles" in this.host.deps.qmd) {
|
|
213
|
+
// SAFETY: guarded by the `in` check — the concrete backend's throttle
|
|
214
|
+
// reset is an internal the SearchBackend interface does not declare.
|
|
215
|
+
(this.host.deps.qmd as any).resetUpdateThrottles();
|
|
216
|
+
}
|
|
217
|
+
log.info("startupSearchSync: updating index to match current disk state");
|
|
218
|
+
const updateAbort = this.host.linkedEpochAbortController(epoch, signal);
|
|
219
|
+
let namespaceUpdate: { backendCount: number; eligibleNamespaces: string[] } | null = null;
|
|
220
|
+
try {
|
|
221
|
+
if (resolveNamespaceCapabilities(this.host.deps.config).namespaces) {
|
|
222
|
+
namespaceUpdate = await this.host.deps.namespaceSearchRouter.updateNamespacesDetailed(
|
|
223
|
+
namespaces,
|
|
224
|
+
{ signal: updateAbort.controller.signal },
|
|
225
|
+
);
|
|
226
|
+
} else {
|
|
227
|
+
await this.host.deps.qmd.update({ signal: updateAbort.controller.signal });
|
|
228
|
+
}
|
|
229
|
+
} finally {
|
|
230
|
+
updateAbort.dispose();
|
|
231
|
+
}
|
|
232
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
233
|
+
log.debug("startupSearchSync: aborted or retired after update");
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
// SAFETY: both casts read the concrete backend's update timestamps,
|
|
237
|
+
// guarded by their `in` checks; SearchBackend does not declare them.
|
|
238
|
+
const failTsAfter = "lastUpdateFailedAtMs" in this.host.deps.qmd
|
|
239
|
+
? (this.host.deps.qmd as any).lastUpdateFailedAtMs as number | null
|
|
240
|
+
: null;
|
|
241
|
+
// SAFETY: guarded by hasRunTs (the `in` check before the update) — the
|
|
242
|
+
// run timestamp is a concrete-backend internal not on SearchBackend.
|
|
243
|
+
const runTsAfter = hasRunTs
|
|
244
|
+
? (this.host.deps.qmd as any).lastUpdateRanAtMs as number | null
|
|
245
|
+
: null;
|
|
246
|
+
if (failTsAfter !== null && failTsAfter !== failTsBefore) {
|
|
247
|
+
log.warn("startupSearchSync: update silently failed (detected via fail timestamp)");
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
if (namespaceUpdate !== null) {
|
|
251
|
+
if (namespaceUpdate.backendCount === 0) {
|
|
252
|
+
log.warn("startupSearchSync: no namespace backends were eligible for update (all unavailable or collections missing)");
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
// The router skips a namespace whose backend is unavailable or whose
|
|
256
|
+
// collection is missing. Name each one so a partial update is never
|
|
257
|
+
// reported as full coverage (#3527). It does not fail the sync: a
|
|
258
|
+
// missing collection has no index to refresh, and a false here would
|
|
259
|
+
// re-run the corpus update on every server retry.
|
|
260
|
+
const eligible = new Set(namespaceUpdate.eligibleNamespaces);
|
|
261
|
+
const skipped = namespaces.filter((namespace) => !eligible.has(namespace));
|
|
262
|
+
if (skipped.length > 0) {
|
|
263
|
+
log.warn(`startupSearchSync: skipped namespaces with no available backend or collection: ${skipped.join(", ")}`);
|
|
264
|
+
}
|
|
265
|
+
log.info(`startupSearchSync: namespace updates succeeded (${eligible.size}/${namespaces.length} namespaces updated)`);
|
|
266
|
+
} else if (hasRunTs && runTsAfter === null) {
|
|
267
|
+
log.warn("startupSearchSync: update was throttled/skipped (run timestamp is null after reset + update)");
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
log.info("startupSearchSync: sync complete");
|
|
271
|
+
} catch (err) {
|
|
272
|
+
log.warn(`startupSearchSync: update failed: ${err}`);
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Warmup search to pre-load embedding models
|
|
278
|
+
if (!signal?.aborted && this.host.isCurrentStartupEpoch(epoch)) {
|
|
279
|
+
const warmupAbort = this.host.linkedEpochAbortController(epoch, signal);
|
|
280
|
+
try {
|
|
281
|
+
await this.host.deps.qmd.search(
|
|
282
|
+
"warmup",
|
|
283
|
+
this.host.deps.config.defaultNamespace,
|
|
284
|
+
1,
|
|
285
|
+
undefined,
|
|
286
|
+
{ signal: warmupAbort.controller.signal },
|
|
287
|
+
);
|
|
288
|
+
log.info("startupSearchSync: warmup complete");
|
|
289
|
+
} catch (err) {
|
|
290
|
+
log.debug(`startupSearchSync: warmup search failed (non-fatal): ${err}`);
|
|
291
|
+
} finally {
|
|
292
|
+
warmupAbort.dispose();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// A retired epoch's warmup settles without throwing: re-check before
|
|
297
|
+
// publishing success, so a stale run cannot mark a replacement
|
|
298
|
+
// lifecycle as synced (#3527 review).
|
|
299
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) return false;
|
|
300
|
+
return discovery.complete;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* The shared readiness half of the startup sync: probe, catalog-union
|
|
305
|
+
* namespace discovery, per-namespace collection ensure, and the
|
|
306
|
+
* missing-collection noop swap. `startupSearchReadySync` exposes this for
|
|
307
|
+
* the awaited ready path; `startupSearchSync` layers the corpus update and
|
|
308
|
+
* warm-up search on top for the post-ready retry loop (#3518). Concurrent
|
|
309
|
+
* callers join one in-flight `runStartupSearchBackend` so nobody observes
|
|
310
|
+
* the mid-run state where probe() has already flipped isAvailable() (#3518
|
|
311
|
+
* second read).
|
|
312
|
+
*/
|
|
313
|
+
private ensureStartupSearchBackend(
|
|
314
|
+
signal?: AbortSignal,
|
|
315
|
+
): Promise<StartupBackendEnsure> {
|
|
316
|
+
if (signal?.aborted) return Promise.resolve({ state: "retired" });
|
|
317
|
+
// Share one backend bring-up across concurrent callers (#3518 second
|
|
318
|
+
// read): probe() flips isAvailable() before the collection ensure and the
|
|
319
|
+
// missing-collection noop swap finish, so a readiness caller arriving
|
|
320
|
+
// mid-run must await the SAME run — never observe the half-finished state
|
|
321
|
+
// or start a second probe/ensure. Three boundaries keep the sharing safe
|
|
322
|
+
// (#3518 third read): the flight is joined only while its epoch is still
|
|
323
|
+
// current and it has not been abandoned, so a caller after a lifecycle
|
|
324
|
+
// restart runs its own ensure instead of inheriting "retired"; and the
|
|
325
|
+
// shared run aborts only when its epoch retires or every participating
|
|
326
|
+
// caller's signal has aborted — never because one caller's per-attempt
|
|
327
|
+
// timeout fired while other callers still hold it.
|
|
328
|
+
let flight = this.startupBackendEnsureFlight;
|
|
329
|
+
if (
|
|
330
|
+
!flight ||
|
|
331
|
+
!this.host.isCurrentStartupEpoch(flight.epoch) ||
|
|
332
|
+
flight.controller.signal.aborted
|
|
333
|
+
) {
|
|
334
|
+
const epoch = this.host.currentOrNewStartupEpoch();
|
|
335
|
+
if (epoch === null) return Promise.resolve({ state: "retired" });
|
|
336
|
+
const controller = new AbortController();
|
|
337
|
+
const run = this.runStartupSearchBackend(epoch, controller.signal);
|
|
338
|
+
const next: StartupBackendEnsureFlight = {
|
|
339
|
+
epoch,
|
|
340
|
+
promise: run,
|
|
341
|
+
controller,
|
|
342
|
+
liveCallers: 0,
|
|
343
|
+
cleanup: [],
|
|
344
|
+
};
|
|
345
|
+
this.startupBackendEnsureFlight = next;
|
|
346
|
+
// run.then(clear, clear) clears the flight on settle in both directions
|
|
347
|
+
// without creating a second derived promise that could reject
|
|
348
|
+
// unhandled; settle also removes every registered caller listener.
|
|
349
|
+
const settle = () => {
|
|
350
|
+
if (this.startupBackendEnsureFlight === next) {
|
|
351
|
+
this.startupBackendEnsureFlight = undefined;
|
|
352
|
+
}
|
|
353
|
+
for (const remove of next.cleanup) remove();
|
|
354
|
+
};
|
|
355
|
+
run.then(settle, settle);
|
|
356
|
+
flight = next;
|
|
357
|
+
}
|
|
358
|
+
// Each caller holds the shared run open until its own signal aborts; the
|
|
359
|
+
// last live caller's abort cancels the run for everyone.
|
|
360
|
+
flight.liveCallers += 1;
|
|
361
|
+
if (signal) {
|
|
362
|
+
const held = flight;
|
|
363
|
+
// An aborted caller releases its slot and settles its own wait as
|
|
364
|
+
// "retired" — it must not stay parked on the shared run while live
|
|
365
|
+
// callers keep it going.
|
|
366
|
+
return new Promise<StartupBackendEnsure>((resolve, reject) => {
|
|
367
|
+
const onCallerAbort = () => {
|
|
368
|
+
held.liveCallers -= 1;
|
|
369
|
+
if (held.liveCallers <= 0) held.controller.abort();
|
|
370
|
+
resolve({ state: "retired" });
|
|
371
|
+
};
|
|
372
|
+
signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
373
|
+
held.cleanup.push(() => signal.removeEventListener("abort", onCallerAbort));
|
|
374
|
+
held.promise.then(
|
|
375
|
+
(result) => {
|
|
376
|
+
signal.removeEventListener("abort", onCallerAbort);
|
|
377
|
+
resolve(result);
|
|
378
|
+
},
|
|
379
|
+
(err) => {
|
|
380
|
+
signal.removeEventListener("abort", onCallerAbort);
|
|
381
|
+
reject(err);
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
return flight.promise;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
private async runStartupSearchBackend(
|
|
390
|
+
epoch: number,
|
|
391
|
+
signal?: AbortSignal,
|
|
392
|
+
): Promise<StartupBackendEnsure> {
|
|
393
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
394
|
+
return { state: "retired" };
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const available = await this.host.probeForStartupEpoch(epoch, signal);
|
|
398
|
+
if (!available) return { state: "unavailable" };
|
|
399
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
400
|
+
log.debug("startupSearchSync: aborted or retired after probe");
|
|
401
|
+
return { state: "retired" };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
log.info(`startupSearchSync: backend now available ${this.host.deps.qmd.debugStatus()}`);
|
|
405
|
+
|
|
406
|
+
// Clear namespace router cache so re-probe picks up newly available backends
|
|
407
|
+
if (resolveNamespaceCapabilities(this.host.deps.config).namespaces) {
|
|
408
|
+
this.host.deps.namespaceSearchRouter.clearCache();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Ensure collections — namespace-aware when enabled.
|
|
412
|
+
// Use the catalog-union namespace set (issue #1499 sweep, same class as
|
|
413
|
+
// NHZEV): this is the QMD startup-recovery sync that ensures collections AND
|
|
414
|
+
// lets `startupSearchSync` run `updateNamespaces(...)` over the SAME
|
|
415
|
+
// `namespaces` set. A dynamic namespace that exists only in the persisted
|
|
416
|
+
// catalog must be ensured and re-synced here too, otherwise after a
|
|
417
|
+
// backend-was-unavailable-at-boot recovery its collection stays stale.
|
|
418
|
+
// Falls back to the configured set on any catalog read failure.
|
|
419
|
+
const discovery = await this.host.startupNamespaces(epoch);
|
|
420
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
421
|
+
log.debug("startupSearchSync: aborted or retired after namespace discovery");
|
|
422
|
+
return { state: "retired" };
|
|
423
|
+
}
|
|
424
|
+
const namespaces = discovery.namespaces;
|
|
425
|
+
|
|
426
|
+
const states = await Promise.all(
|
|
427
|
+
namespaces.map(async (namespace) => {
|
|
428
|
+
const epochAbort = this.host.linkedEpochAbortController(epoch, signal);
|
|
429
|
+
try {
|
|
430
|
+
return {
|
|
431
|
+
namespace,
|
|
432
|
+
state: resolveNamespaceCapabilities(this.host.deps.config).namespaces
|
|
433
|
+
? await this.host.deps.namespaceSearchRouter.ensureNamespaceCollection(
|
|
434
|
+
namespace,
|
|
435
|
+
{ signal: epochAbort.controller.signal },
|
|
436
|
+
)
|
|
437
|
+
: await this.host.deps.qmd.ensureCollection(
|
|
438
|
+
this.host.deps.config.memoryDir,
|
|
439
|
+
this.host.deps.config.qmdCollection,
|
|
440
|
+
{ signal: epochAbort.controller.signal },
|
|
441
|
+
),
|
|
442
|
+
};
|
|
443
|
+
} finally {
|
|
444
|
+
epochAbort.dispose();
|
|
445
|
+
}
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
450
|
+
log.debug("startupSearchSync: aborted or retired after ensureCollection");
|
|
451
|
+
return { state: "retired" };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const defaultState =
|
|
455
|
+
states.find((e) => e.namespace === this.host.deps.config.defaultNamespace)?.state ?? "unknown";
|
|
456
|
+
if (defaultState === "missing") {
|
|
457
|
+
await this.host.deps.disposeSearchBackendIfNeeded();
|
|
458
|
+
if (signal?.aborted || !this.host.isCurrentStartupEpoch(epoch)) {
|
|
459
|
+
log.debug("startupSearchSync: aborted or retired while disposing a missing backend");
|
|
460
|
+
return { state: "retired" };
|
|
461
|
+
}
|
|
462
|
+
// Reset the real backend's available flag before replacing it with noop.
|
|
463
|
+
// probe() set available=true earlier in this call; without this reset,
|
|
464
|
+
// any code that captured a reference to the old backend (e.g. a concurrent
|
|
465
|
+
// recall() that read this.host.deps.qmd before the reassignment) would observe
|
|
466
|
+
// isAvailable()===true against a backend with a missing collection.
|
|
467
|
+
if ("available" in this.host.deps.qmd) {
|
|
468
|
+
// SAFETY: the concrete backend owns `available`; the SearchBackend interface does not declare it.
|
|
469
|
+
(this.host.deps.qmd as any).available = false;
|
|
470
|
+
}
|
|
471
|
+
this.host.deps.qmd = new NoopSearchBackend();
|
|
472
|
+
log.warn("startupSearchSync: search collection missing; disabling search (fallback retrieval remains enabled)");
|
|
473
|
+
return { state: "missing" };
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// "unknown" means the collection check could not determine the state
|
|
477
|
+
// (timeout, cancelled auto-create, failed recheck). Retrieval stays
|
|
478
|
+
// fail-open on the probed backend, but the ensure is unverified: neither
|
|
479
|
+
// the readiness sync nor the full sync may claim success — the next
|
|
480
|
+
// attempt re-checks, and the warm-up gate counts this as degraded
|
|
481
|
+
// rather than warmed (#3518 third read). Explicit "skipped" (remote or
|
|
482
|
+
// daemon-only modes that run no local check) still counts as ready.
|
|
483
|
+
if (defaultState === "unknown") {
|
|
484
|
+
log.warn(
|
|
485
|
+
"startupSearchSync: collection check could not verify the default collection; the sync stays unready until a retry verifies it",
|
|
486
|
+
);
|
|
487
|
+
return { state: "degraded" };
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return { state: "ready", epoch, discovery };
|
|
491
|
+
}
|
|
492
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { createTaskExit } from "./task-exit.js";
|
|
5
|
+
|
|
6
|
+
test("task-exit: a task settled before it started reports exit immediately", () => {
|
|
7
|
+
let exited = 0;
|
|
8
|
+
const task = createTaskExit(() => exited++);
|
|
9
|
+
|
|
10
|
+
task.settled();
|
|
11
|
+
|
|
12
|
+
assert.equal(exited, 1);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("task-exit: a started task reports exit only when it finishes", () => {
|
|
16
|
+
let exited = 0;
|
|
17
|
+
const task = createTaskExit(() => exited++);
|
|
18
|
+
|
|
19
|
+
task.start();
|
|
20
|
+
task.settled();
|
|
21
|
+
assert.equal(exited, 0, "settled() is a no-op once the closure is running");
|
|
22
|
+
|
|
23
|
+
task.report();
|
|
24
|
+
assert.equal(exited, 1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("task-exit: the callback fires exactly once no matter the order", () => {
|
|
28
|
+
let exited = 0;
|
|
29
|
+
const task = createTaskExit(() => exited++);
|
|
30
|
+
|
|
31
|
+
task.settled();
|
|
32
|
+
task.report();
|
|
33
|
+
task.report();
|
|
34
|
+
|
|
35
|
+
assert.equal(exited, 1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("task-exit: no callback means no crash", () => {
|
|
39
|
+
const task = createTaskExit();
|
|
40
|
+
assert.doesNotThrow(() => {
|
|
41
|
+
task.start();
|
|
42
|
+
task.settled();
|
|
43
|
+
task.report();
|
|
44
|
+
});
|
|
45
|
+
});
|