@remnic/core 10.0.161 → 10.0.163
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 +68 -68
- package/dist/access-cli.js +68 -68
- package/dist/access-extraction-force-flush-preempt.js +68 -68
- package/dist/access-extraction-force-flush.js +68 -68
- package/dist/access-http-briefing.js +68 -68
- package/dist/access-http-query.js +68 -68
- package/dist/access-http.js +68 -68
- package/dist/access-identity-continuity-surface.js +68 -68
- package/dist/access-lcm-surface.js +68 -68
- package/dist/access-mcp.js +68 -68
- package/dist/access-observe-write-category.js +5 -5
- package/dist/access-observe-write-surface.js +68 -68
- package/dist/access-operations-batch.js +68 -68
- package/dist/access-operations.js +68 -68
- package/dist/access-recall-concurrency.js +68 -68
- package/dist/access-recall-diagnostics.js +2 -2
- package/dist/access-recall-response.js +68 -68
- package/dist/access-recall-surface.js +68 -68
- package/dist/access-schema.js +4 -4
- package/dist/access-service.js +68 -68
- package/dist/active-recall.js +10 -10
- package/dist/briefing.js +9 -9
- package/dist/buffer.js +2 -2
- package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-GWVG7LGC.js} +2 -2
- package/dist/causal-consolidation.js +10 -10
- package/dist/{chunk-HIPHLFIQ.js → chunk-22VXXA67.js} +2 -2
- package/dist/{chunk-IFFCHE3O.js → chunk-2S3M2GLC.js} +8 -2
- package/dist/{chunk-IFFCHE3O.js.map → chunk-2S3M2GLC.js.map} +1 -1
- package/dist/{chunk-VGCK2RV3.js → chunk-3QLAOYBL.js} +2 -2
- package/dist/{chunk-6NPLVV6M.js → chunk-4HKK5HUI.js} +2 -2
- package/dist/{chunk-XTAGZXOM.js → chunk-4LPTSB5V.js} +2 -2
- package/dist/{chunk-HKOGDSNS.js → chunk-4NBUHYUV.js} +2 -2
- package/dist/{chunk-VVVFT435.js → chunk-5D4NBANY.js} +5 -5
- package/dist/{chunk-VVVFT435.js.map → chunk-5D4NBANY.js.map} +1 -1
- package/dist/{chunk-K3KSTSGM.js → chunk-5LTXYM7D.js} +2 -2
- package/dist/{chunk-M7BCA43N.js → chunk-5MXKS25U.js} +5 -5
- package/dist/{chunk-KTZNXQWL.js → chunk-6ARSFTLD.js} +2 -2
- package/dist/{chunk-773QSFFN.js → chunk-6TPWIPE3.js} +2 -2
- package/dist/{chunk-L2DACC2T.js → chunk-ARJ3KCX4.js} +2 -2
- package/dist/{chunk-6PVS6JET.js → chunk-AU6AEUFD.js} +2 -2
- package/dist/{chunk-R45L4TV6.js → chunk-BUKK5SWA.js} +6 -6
- package/dist/{chunk-JUYTXFDV.js → chunk-CGOPDXLK.js} +2 -2
- package/dist/{chunk-TGH7AU5U.js → chunk-DBVSU3HE.js} +8 -8
- package/dist/{chunk-3UKPFFMS.js → chunk-E5RJPLNL.js} +2 -2
- package/dist/{chunk-TLJV42SZ.js → chunk-EDA6CDBT.js} +2 -2
- package/dist/{chunk-ZWSSUWKO.js → chunk-EI2M2CFJ.js} +2 -2
- package/dist/{chunk-V24YLFJW.js → chunk-FNV6ZPCY.js} +6 -4
- package/dist/chunk-FNV6ZPCY.js.map +1 -0
- package/dist/{chunk-BDFOBNLX.js → chunk-FSI45NUK.js} +2 -2
- package/dist/{chunk-BFJQBCDL.js → chunk-GDAFI6HH.js} +239 -156
- package/dist/chunk-GDAFI6HH.js.map +1 -0
- package/dist/{chunk-DFK6AQWM.js → chunk-IC35ZYLM.js} +2 -2
- package/dist/{chunk-PJFSSXXY.js → chunk-JJEQRSYU.js} +2 -2
- package/dist/{chunk-5UE45DLK.js → chunk-JVIWVJ2A.js} +2 -2
- package/dist/{chunk-BNQJKWWZ.js → chunk-K3FH3LAQ.js} +4 -4
- package/dist/{chunk-UADAXWUJ.js → chunk-KR6PEAM4.js} +7 -7
- package/dist/{chunk-YKAQKIPR.js → chunk-L6BLTV4D.js} +2 -2
- package/dist/{chunk-2YJYBAR3.js → chunk-OAGTKS73.js} +2 -2
- package/dist/{chunk-BXLOS5AJ.js → chunk-OWHERGF2.js} +2 -2
- package/dist/{chunk-CA7XVRHZ.js → chunk-PCUDFWX5.js} +2 -2
- package/dist/{chunk-I6IKSDUO.js → chunk-PRE7R3RQ.js} +2 -2
- package/dist/{chunk-MWEJL436.js → chunk-QBREZ4QL.js} +2 -2
- package/dist/{chunk-TFA6HPOA.js → chunk-QCP75JGO.js} +5 -5
- package/dist/{chunk-MZETCZJF.js → chunk-QFPNWSVH.js} +5 -5
- package/dist/{chunk-52EM4UQU.js → chunk-QUC4S2D2.js} +10 -9
- package/dist/chunk-QUC4S2D2.js.map +1 -0
- package/dist/{chunk-7PCWJZXG.js → chunk-RDO6AMDL.js} +2 -2
- package/dist/{chunk-QDY4TSKK.js → chunk-RH6XWXMA.js} +3 -3
- package/dist/{chunk-BT5TAOXG.js → chunk-SBU5GDOT.js} +3 -3
- package/dist/{chunk-KJ3Z7JHF.js → chunk-SOGOHLWN.js} +1 -1
- package/dist/chunk-SOGOHLWN.js.map +1 -0
- package/dist/{chunk-TBOCVPXL.js → chunk-SRN5M4LQ.js} +3 -3
- package/dist/{chunk-NBHMEYM4.js → chunk-TFNZXOXK.js} +2 -2
- package/dist/{chunk-O7CHKXSF.js → chunk-UGQEJWR3.js} +2 -2
- package/dist/{chunk-DQEMWVMT.js → chunk-UVYI6VIX.js} +1 -1
- package/dist/{chunk-H6OTEBPK.js → chunk-V6M6N3EE.js} +2 -2
- package/dist/{chunk-AQ6GV5MU.js → chunk-VXMWTRQX.js} +2 -2
- package/dist/{chunk-PCCNK3RX.js → chunk-VXUO5JZC.js} +11 -13
- package/dist/chunk-VXUO5JZC.js.map +1 -0
- package/dist/{chunk-UR6COSJN.js → chunk-WAJL65KW.js} +3 -3
- package/dist/{chunk-V3D2OOVE.js → chunk-WRAK5LLB.js} +2 -2
- package/dist/{chunk-BTCZVBV3.js → chunk-XE4UYWW3.js} +3 -3
- package/dist/{chunk-VXKPZ6BO.js → chunk-Y7HLGKKU.js} +2 -2
- package/dist/{chunk-YAFMWQRL.js → chunk-YMC4AYJK.js} +4 -4
- package/dist/chunk-YMC4AYJK.js.map +1 -0
- package/dist/{chunk-B7F2G57I.js → chunk-YWPCDR3I.js} +2 -2
- package/dist/{chunk-NFTFMMKT.js → chunk-Z3SXC3MP.js} +2 -2
- package/dist/{chunk-DS24H6M4.js → chunk-ZRLTQ2Y7.js} +2 -2
- package/dist/cli.js +68 -68
- package/dist/coding/export-okf-codegraph.js +8 -8
- package/dist/compounding/engine.js +10 -10
- package/dist/config.js +10 -10
- package/dist/connectors/codex-materialize-runner.js +9 -9
- package/dist/connectors/index.js +9 -9
- package/dist/convergence-refresh.js +11 -11
- package/dist/conversation-index/backend.js +2 -2
- package/dist/corpus-watermark.js +11 -11
- package/dist/deep-recall-http-glue.js +5 -5
- package/dist/entity-retrieval.js +9 -9
- package/dist/explicit-capture.js +68 -68
- package/dist/extraction-error-classification.d.ts +11 -2
- package/dist/extraction-error-classification.d.ts.map +1 -1
- package/dist/extraction-error-classification.js +3 -1
- package/dist/extraction-reply-diagnostic.d.ts +4 -2
- package/dist/extraction-reply-diagnostic.d.ts.map +1 -1
- package/dist/extraction-reply-diagnostic.js +1 -1
- package/dist/extraction.js +14 -14
- package/dist/harmonic-retrieval.js +9 -9
- package/dist/index.js +74 -74
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.js +2 -2
- package/dist/location/index.js +10 -10
- package/dist/maintenance/memory-governance.js +9 -9
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +9 -9
- package/dist/maintenance/rebuild-memory-projection-runner.js +11 -11
- package/dist/maintenance/rebuild-memory-projection.js +10 -10
- package/dist/namespaces/migrate.js +10 -10
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.js +9 -9
- package/dist/operator-doctor-corpus.js +12 -12
- package/dist/operator-toolkit.js +17 -17
- package/dist/orchestration/backlog-scheduler.js +69 -69
- package/dist/orchestration/buffer-drain-runner.js +69 -69
- package/dist/orchestration/extraction-drain.d.ts.map +1 -1
- package/dist/orchestration/extraction-run-helpers.d.ts +7 -0
- package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
- package/dist/orchestration/extraction-run.d.ts.map +1 -1
- package/dist/orchestration/maintenance.js +17 -17
- package/dist/orchestration/orchestrator-init.d.ts +28 -1
- package/dist/orchestration/orchestrator-init.d.ts.map +1 -1
- package/dist/orchestrator.d.ts +13 -9
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +68 -68
- 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.js +68 -68
- 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/resume-bundles.js +11 -11
- package/dist/search/factory.js +5 -5
- package/dist/search/index.js +9 -9
- package/dist/semantic-consolidation.js +10 -10
- package/dist/semantic-rule-promotion.js +9 -9
- package/dist/semantic-rule-verifier.js +9 -9
- package/dist/source-agent-qualifier.js +11 -11
- package/dist/standup/build.js +9 -9
- package/dist/storage.js +8 -8
- package/dist/transfer/autodetect.js +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +3 -3
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/export-okf.js +9 -9
- package/dist/types-extraction-failure.d.ts +12 -0
- package/dist/types-extraction-failure.d.ts.map +1 -0
- package/dist/types-extraction-failure.js +1 -0
- package/dist/types-extraction-failure.js.map +1 -0
- package/dist/types.d.ts +3 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +9 -9
- package/dist/who-knows-cli.js +10 -10
- package/dist/who-knows.js +9 -9
- package/package.json +2 -2
- package/src/access-observe-replay-durability.test.ts +23 -3
- package/src/buffer-admission-idempotency.test.ts +1 -1
- package/src/buffer-ingress-invariant.test.ts +1 -1
- package/src/config.test.ts +3 -2
- package/src/config.ts +1 -1
- package/src/extraction-error-classification.ts +13 -2
- package/src/extraction-queue-concurrency-default.test.ts +107 -0
- package/src/extraction-reply-diagnostic-wiring.test.ts +4 -4
- package/src/extraction-reply-diagnostic.test.ts +3 -1
- package/src/extraction-reply-diagnostic.ts +9 -1
- package/src/extraction.ts +6 -6
- package/src/orchestration/extraction-drain-parts.test.ts +33 -0
- package/src/orchestration/extraction-drain.ts +7 -1
- package/src/orchestration/extraction-queue-coordinator.ts +1 -1
- package/src/orchestration/extraction-run-helpers.ts +14 -0
- package/src/orchestration/extraction-run.test.ts +28 -5
- package/src/orchestration/extraction-run.ts +11 -13
- package/src/orchestration/orchestrator-init.ts +259 -111
- package/src/orchestrator-extraction-queue.test.ts +3 -3
- package/src/orchestrator-flush.test.ts +43 -34
- package/src/orchestrator-init.test.ts +66 -3
- package/src/orchestrator-startup-ready-path.test.ts +506 -0
- package/src/orchestrator.ts +18 -9
- package/src/storage.ts +1 -1
- package/src/types-extraction-failure.ts +11 -0
- package/src/types.ts +3 -9
- package/dist/chunk-52EM4UQU.js.map +0 -1
- package/dist/chunk-BFJQBCDL.js.map +0 -1
- package/dist/chunk-KJ3Z7JHF.js.map +0 -1
- package/dist/chunk-PCCNK3RX.js.map +0 -1
- package/dist/chunk-V24YLFJW.js.map +0 -1
- package/dist/chunk-YAFMWQRL.js.map +0 -1
- /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
- /package/dist/{chunk-HIPHLFIQ.js.map → chunk-22VXXA67.js.map} +0 -0
- /package/dist/{chunk-VGCK2RV3.js.map → chunk-3QLAOYBL.js.map} +0 -0
- /package/dist/{chunk-6NPLVV6M.js.map → chunk-4HKK5HUI.js.map} +0 -0
- /package/dist/{chunk-XTAGZXOM.js.map → chunk-4LPTSB5V.js.map} +0 -0
- /package/dist/{chunk-HKOGDSNS.js.map → chunk-4NBUHYUV.js.map} +0 -0
- /package/dist/{chunk-K3KSTSGM.js.map → chunk-5LTXYM7D.js.map} +0 -0
- /package/dist/{chunk-M7BCA43N.js.map → chunk-5MXKS25U.js.map} +0 -0
- /package/dist/{chunk-KTZNXQWL.js.map → chunk-6ARSFTLD.js.map} +0 -0
- /package/dist/{chunk-773QSFFN.js.map → chunk-6TPWIPE3.js.map} +0 -0
- /package/dist/{chunk-L2DACC2T.js.map → chunk-ARJ3KCX4.js.map} +0 -0
- /package/dist/{chunk-6PVS6JET.js.map → chunk-AU6AEUFD.js.map} +0 -0
- /package/dist/{chunk-R45L4TV6.js.map → chunk-BUKK5SWA.js.map} +0 -0
- /package/dist/{chunk-JUYTXFDV.js.map → chunk-CGOPDXLK.js.map} +0 -0
- /package/dist/{chunk-TGH7AU5U.js.map → chunk-DBVSU3HE.js.map} +0 -0
- /package/dist/{chunk-3UKPFFMS.js.map → chunk-E5RJPLNL.js.map} +0 -0
- /package/dist/{chunk-TLJV42SZ.js.map → chunk-EDA6CDBT.js.map} +0 -0
- /package/dist/{chunk-ZWSSUWKO.js.map → chunk-EI2M2CFJ.js.map} +0 -0
- /package/dist/{chunk-BDFOBNLX.js.map → chunk-FSI45NUK.js.map} +0 -0
- /package/dist/{chunk-DFK6AQWM.js.map → chunk-IC35ZYLM.js.map} +0 -0
- /package/dist/{chunk-PJFSSXXY.js.map → chunk-JJEQRSYU.js.map} +0 -0
- /package/dist/{chunk-5UE45DLK.js.map → chunk-JVIWVJ2A.js.map} +0 -0
- /package/dist/{chunk-BNQJKWWZ.js.map → chunk-K3FH3LAQ.js.map} +0 -0
- /package/dist/{chunk-UADAXWUJ.js.map → chunk-KR6PEAM4.js.map} +0 -0
- /package/dist/{chunk-YKAQKIPR.js.map → chunk-L6BLTV4D.js.map} +0 -0
- /package/dist/{chunk-2YJYBAR3.js.map → chunk-OAGTKS73.js.map} +0 -0
- /package/dist/{chunk-BXLOS5AJ.js.map → chunk-OWHERGF2.js.map} +0 -0
- /package/dist/{chunk-CA7XVRHZ.js.map → chunk-PCUDFWX5.js.map} +0 -0
- /package/dist/{chunk-I6IKSDUO.js.map → chunk-PRE7R3RQ.js.map} +0 -0
- /package/dist/{chunk-MWEJL436.js.map → chunk-QBREZ4QL.js.map} +0 -0
- /package/dist/{chunk-TFA6HPOA.js.map → chunk-QCP75JGO.js.map} +0 -0
- /package/dist/{chunk-MZETCZJF.js.map → chunk-QFPNWSVH.js.map} +0 -0
- /package/dist/{chunk-7PCWJZXG.js.map → chunk-RDO6AMDL.js.map} +0 -0
- /package/dist/{chunk-QDY4TSKK.js.map → chunk-RH6XWXMA.js.map} +0 -0
- /package/dist/{chunk-BT5TAOXG.js.map → chunk-SBU5GDOT.js.map} +0 -0
- /package/dist/{chunk-TBOCVPXL.js.map → chunk-SRN5M4LQ.js.map} +0 -0
- /package/dist/{chunk-NBHMEYM4.js.map → chunk-TFNZXOXK.js.map} +0 -0
- /package/dist/{chunk-O7CHKXSF.js.map → chunk-UGQEJWR3.js.map} +0 -0
- /package/dist/{chunk-DQEMWVMT.js.map → chunk-UVYI6VIX.js.map} +0 -0
- /package/dist/{chunk-H6OTEBPK.js.map → chunk-V6M6N3EE.js.map} +0 -0
- /package/dist/{chunk-AQ6GV5MU.js.map → chunk-VXMWTRQX.js.map} +0 -0
- /package/dist/{chunk-UR6COSJN.js.map → chunk-WAJL65KW.js.map} +0 -0
- /package/dist/{chunk-V3D2OOVE.js.map → chunk-WRAK5LLB.js.map} +0 -0
- /package/dist/{chunk-BTCZVBV3.js.map → chunk-XE4UYWW3.js.map} +0 -0
- /package/dist/{chunk-VXKPZ6BO.js.map → chunk-Y7HLGKKU.js.map} +0 -0
- /package/dist/{chunk-B7F2G57I.js.map → chunk-YWPCDR3I.js.map} +0 -0
- /package/dist/{chunk-NFTFMMKT.js.map → chunk-Z3SXC3MP.js.map} +0 -0
- /package/dist/{chunk-DS24H6M4.js.map → chunk-ZRLTQ2Y7.js.map} +0 -0
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
|
|
7
|
+
import { parseConfig } from "./config.js";
|
|
8
|
+
import { namespaceIdentityToken } from "./namespaces/identity.js";
|
|
9
|
+
import { Orchestrator } from "./orchestrator.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Issue #3518: the corpus-wide QMD update must not sit in the awaited ready
|
|
13
|
+
* path. `deferredReady` settles after the probe, collection ensure and model
|
|
14
|
+
* warm-up; the update runs afterward under the server retry loop, which sees
|
|
15
|
+
* `deferredSyncSucceeded === false` and calls `startupSearchSync`. The
|
|
16
|
+
* readiness-level entry point (`startupSearchReadySync`) repeats only the
|
|
17
|
+
* probe + collection ensure so warm-up attempts never block on a reindex.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
|
|
21
|
+
|
|
22
|
+
// SAFETY: tests stub private orchestrator deps through the self-deps seam, as the neighbouring init tests do.
|
|
23
|
+
const asDeps = (orchestrator: Orchestrator) => orchestrator as any;
|
|
24
|
+
|
|
25
|
+
function readyPathConfig(memoryDir: string) {
|
|
26
|
+
return parseConfig({
|
|
27
|
+
memoryDir,
|
|
28
|
+
workspaceDir: path.join(memoryDir, "workspace"),
|
|
29
|
+
qmdEnabled: true,
|
|
30
|
+
qmdMaintenanceEnabled: true,
|
|
31
|
+
namespacesEnabled: true,
|
|
32
|
+
namespaceCatalogEnabled: true,
|
|
33
|
+
defaultNamespace: "default",
|
|
34
|
+
sharedNamespace: "shared",
|
|
35
|
+
namespacePolicies: [],
|
|
36
|
+
embeddingFallbackEnabled: false,
|
|
37
|
+
identityContinuityEnabled: false,
|
|
38
|
+
transcriptEnabled: false,
|
|
39
|
+
hourlySummariesEnabled: false,
|
|
40
|
+
compoundingEnabled: false,
|
|
41
|
+
knowledgeIndexEnabled: false,
|
|
42
|
+
wearables: { enabled: false, sources: {} },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function blockingUpdateQmd(updateCalls: number[]) {
|
|
47
|
+
return {
|
|
48
|
+
probe: async () => true,
|
|
49
|
+
debugStatus: () => "synthetic-qmd",
|
|
50
|
+
isAvailable: () => true,
|
|
51
|
+
search: async () => [],
|
|
52
|
+
async update() {
|
|
53
|
+
updateCalls.push(1);
|
|
54
|
+
await new Promise<void>(() => {});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function stubWarmupDeps(orchestrator: any) {
|
|
60
|
+
orchestrator.storage.readAllMemories = async () => [];
|
|
61
|
+
orchestrator.storage.readAllEntityFiles = async () => [];
|
|
62
|
+
orchestrator.storage.buildKnowledgeIndex = async () => [];
|
|
63
|
+
orchestrator.maintenanceScheduler.autoRegisterCrons = async () => {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
test("deferredInitialize resolves without the corpus update and leaves the retry flag armed", async () => {
|
|
67
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
68
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
69
|
+
const updateCalls: number[] = [];
|
|
70
|
+
const deps = asDeps(orchestrator);
|
|
71
|
+
try {
|
|
72
|
+
deps.qmd = blockingUpdateQmd(updateCalls);
|
|
73
|
+
deps.namespaceSearchRouter.updateNamespaces = async () => {
|
|
74
|
+
updateCalls.push(1);
|
|
75
|
+
await new Promise<void>(() => {});
|
|
76
|
+
return 0;
|
|
77
|
+
};
|
|
78
|
+
stubWarmupDeps(deps);
|
|
79
|
+
|
|
80
|
+
const outcome = await Promise.race([
|
|
81
|
+
deps.deferredInitialize(new AbortController().signal).then(() => "settled" as const),
|
|
82
|
+
sleep(2_000).then(() => "hung" as const),
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
assert.equal(outcome, "settled", "deferred init must not wait on the corpus update");
|
|
86
|
+
assert.equal(updateCalls.length, 0, "the corpus update must not run in the deferred path");
|
|
87
|
+
assert.equal(
|
|
88
|
+
deps.deferredSyncSucceeded,
|
|
89
|
+
false,
|
|
90
|
+
"the owed update must leave the retry flag armed",
|
|
91
|
+
);
|
|
92
|
+
} finally {
|
|
93
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
94
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("startupSearchReadySync probes and ensures collections without running the corpus update", async () => {
|
|
99
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
100
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
101
|
+
const updateCalls: number[] = [];
|
|
102
|
+
const ensured: string[] = [];
|
|
103
|
+
const deps = asDeps(orchestrator);
|
|
104
|
+
try {
|
|
105
|
+
deps.qmd = blockingUpdateQmd(updateCalls);
|
|
106
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
107
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async (ns: string) => {
|
|
108
|
+
ensured.push(ns);
|
|
109
|
+
return "present";
|
|
110
|
+
};
|
|
111
|
+
deps.namespaceSearchRouter.updateNamespaces = async () => {
|
|
112
|
+
updateCalls.push(1);
|
|
113
|
+
await new Promise<void>(() => {});
|
|
114
|
+
return 0;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const ready = await Promise.race([
|
|
118
|
+
orchestrator.startupSearchReadySync(new AbortController().signal),
|
|
119
|
+
sleep(2_000).then(() => "hung" as const),
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
assert.equal(ready, true, "a probed backend with ensured collections reports ready");
|
|
123
|
+
assert.ok(ensured.length > 0, "the readiness sync still ensures collections");
|
|
124
|
+
assert.equal(updateCalls.length, 0, "the readiness sync must not run the corpus update");
|
|
125
|
+
} finally {
|
|
126
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
127
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("startupSearchSync still runs the corpus update over the catalog union for the post-ready retry loop", async () => {
|
|
132
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
133
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
134
|
+
const updates: string[][] = [];
|
|
135
|
+
const dynamicNamespace = "ready-path-dynamic";
|
|
136
|
+
const dynamicStorageDir = path.join(
|
|
137
|
+
memoryDir,
|
|
138
|
+
"namespaces",
|
|
139
|
+
namespaceIdentityToken(dynamicNamespace),
|
|
140
|
+
);
|
|
141
|
+
await mkdir(path.join(dynamicStorageDir, "state"), { recursive: true });
|
|
142
|
+
const deps = asDeps(orchestrator);
|
|
143
|
+
try {
|
|
144
|
+
deps.qmd = {
|
|
145
|
+
probe: async () => true,
|
|
146
|
+
debugStatus: () => "synthetic-qmd",
|
|
147
|
+
isAvailable: () => true,
|
|
148
|
+
search: async () => [],
|
|
149
|
+
update: async () => {},
|
|
150
|
+
lastUpdateRanAtMs: 1,
|
|
151
|
+
lastUpdateFailedAtMs: null,
|
|
152
|
+
};
|
|
153
|
+
deps.namespaceCatalog.listNamespaces = async () => [
|
|
154
|
+
{ namespace: "default" },
|
|
155
|
+
{
|
|
156
|
+
namespace: dynamicNamespace,
|
|
157
|
+
identityToken: namespaceIdentityToken(dynamicNamespace),
|
|
158
|
+
kind: "project",
|
|
159
|
+
createdAt: new Date(0).toISOString(),
|
|
160
|
+
storageDir: dynamicStorageDir,
|
|
161
|
+
discoveredBy: "write",
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
165
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async () => "present";
|
|
166
|
+
deps.namespaceSearchRouter.updateNamespaces = async (ns: string[]) => {
|
|
167
|
+
updates.push([...ns]);
|
|
168
|
+
return ns.length;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const synced = await orchestrator.startupSearchSync(new AbortController().signal);
|
|
172
|
+
|
|
173
|
+
assert.equal(synced, true);
|
|
174
|
+
assert.equal(updates.length, 1, "the retry entry point must run the corpus update");
|
|
175
|
+
for (const expected of ["default", "shared", dynamicNamespace]) {
|
|
176
|
+
assert.ok(updates[0].includes(expected), `update must cover ${expected}`);
|
|
177
|
+
}
|
|
178
|
+
} finally {
|
|
179
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
180
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("startupSearchReadySync joins an in-flight full sync's backend phase and resolves before its corpus update (#3518 second read)", async () => {
|
|
185
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
186
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
187
|
+
const probeCalls: number[] = [];
|
|
188
|
+
const ensureEntries: string[] = [];
|
|
189
|
+
const updateCalls: number[] = [];
|
|
190
|
+
const ensureGate = Promise.withResolvers<void>();
|
|
191
|
+
const updateGate = Promise.withResolvers<void>();
|
|
192
|
+
const deps = asDeps(orchestrator);
|
|
193
|
+
try {
|
|
194
|
+
deps.qmd = {
|
|
195
|
+
probe: async () => {
|
|
196
|
+
probeCalls.push(1);
|
|
197
|
+
return true;
|
|
198
|
+
},
|
|
199
|
+
debugStatus: () => "synthetic-qmd",
|
|
200
|
+
// The real backend flips isAvailable() inside probe(), before ensure
|
|
201
|
+
// finishes (qmd.ts recordProbeSuccess) — the window the warm-up gate
|
|
202
|
+
// used to trust.
|
|
203
|
+
isAvailable: () => probeCalls.length > 0,
|
|
204
|
+
search: async () => [],
|
|
205
|
+
update: async () => {},
|
|
206
|
+
lastUpdateRanAtMs: 1,
|
|
207
|
+
lastUpdateFailedAtMs: null,
|
|
208
|
+
};
|
|
209
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
210
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async (ns: string) => {
|
|
211
|
+
ensureEntries.push(ns);
|
|
212
|
+
await ensureGate.promise;
|
|
213
|
+
return "present";
|
|
214
|
+
};
|
|
215
|
+
deps.namespaceSearchRouter.updateNamespaces = async (ns: string[]) => {
|
|
216
|
+
updateCalls.push(1);
|
|
217
|
+
await updateGate.promise;
|
|
218
|
+
return ns.length;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const signal = new AbortController().signal;
|
|
222
|
+
const full = orchestrator.startupSearchSync(signal);
|
|
223
|
+
for (let i = 0; i < 200 && ensureEntries.length === 0; i += 1) await sleep(5);
|
|
224
|
+
assert.ok(ensureEntries.length > 0, "the full sync reaches its collection ensure");
|
|
225
|
+
|
|
226
|
+
const ready = orchestrator.startupSearchReadySync(signal);
|
|
227
|
+
await sleep(50);
|
|
228
|
+
assert.equal(
|
|
229
|
+
probeCalls.length,
|
|
230
|
+
1,
|
|
231
|
+
"the ready sync must join the in-flight backend run, not start a second probe",
|
|
232
|
+
);
|
|
233
|
+
assert.equal(
|
|
234
|
+
new Set(ensureEntries).size,
|
|
235
|
+
ensureEntries.length,
|
|
236
|
+
"each namespace is ensured once across joined callers",
|
|
237
|
+
);
|
|
238
|
+
assert.equal(
|
|
239
|
+
await Promise.race([ready.then(() => "settled" as const), sleep(50).then(() => "pending" as const)]),
|
|
240
|
+
"pending",
|
|
241
|
+
"the joined ready sync must wait for the shared ensure to finish",
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
ensureGate.resolve();
|
|
245
|
+
assert.equal(
|
|
246
|
+
await Promise.race([ready, sleep(2_000).then(() => "hung" as const)]),
|
|
247
|
+
true,
|
|
248
|
+
"the joined ready sync resolves once the shared ensure completes",
|
|
249
|
+
);
|
|
250
|
+
assert.equal(
|
|
251
|
+
await Promise.race([full.then(() => "synced" as const), sleep(50).then(() => "pending" as const)]),
|
|
252
|
+
"pending",
|
|
253
|
+
"the full sync keeps running its corpus update after the ready sync resolves",
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
updateGate.resolve();
|
|
257
|
+
assert.equal(await full, true);
|
|
258
|
+
assert.equal(updateCalls.length, 1);
|
|
259
|
+
} finally {
|
|
260
|
+
ensureGate.resolve();
|
|
261
|
+
updateGate.resolve();
|
|
262
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
263
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test("an unknown collection state keeps the readiness and full syncs unready (wAQ third read)", async () => {
|
|
268
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
269
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
270
|
+
const updateCalls: number[] = [];
|
|
271
|
+
const deps = asDeps(orchestrator);
|
|
272
|
+
try {
|
|
273
|
+
deps.qmd = {
|
|
274
|
+
probe: async () => true,
|
|
275
|
+
debugStatus: () => "synthetic-qmd",
|
|
276
|
+
isAvailable: () => true,
|
|
277
|
+
search: async () => [],
|
|
278
|
+
update: async () => {
|
|
279
|
+
updateCalls.push(1);
|
|
280
|
+
},
|
|
281
|
+
lastUpdateRanAtMs: 1,
|
|
282
|
+
lastUpdateFailedAtMs: null,
|
|
283
|
+
};
|
|
284
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
285
|
+
// The collection check could not determine the state (timeout, cancelled
|
|
286
|
+
// auto-create, recheck failure): retrieval stays fail-open, but the
|
|
287
|
+
// startup syncs must not claim readiness off an unverified ensure. A
|
|
288
|
+
// zero-result healthy warm-up on top must not open the gate as warmed.
|
|
289
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async () => "unknown";
|
|
290
|
+
deps.namespaceSearchRouter.updateNamespaces = async (ns: string[]) => {
|
|
291
|
+
updateCalls.push(1);
|
|
292
|
+
return ns.length;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const signal = new AbortController().signal;
|
|
296
|
+
assert.equal(
|
|
297
|
+
await orchestrator.startupSearchReadySync(signal),
|
|
298
|
+
false,
|
|
299
|
+
"an unverified collection state must not open strict readiness",
|
|
300
|
+
);
|
|
301
|
+
assert.equal(
|
|
302
|
+
await orchestrator.startupSearchSync(signal),
|
|
303
|
+
false,
|
|
304
|
+
"the full sync must not claim success off an unverified ensure",
|
|
305
|
+
);
|
|
306
|
+
assert.equal(updateCalls.length, 0, "the corpus update does not run while the ensure is unverified");
|
|
307
|
+
} finally {
|
|
308
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
309
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
test("an explicitly skipped collection ensure still counts as ready (wAQ third read)", async () => {
|
|
314
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
315
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
316
|
+
const deps = asDeps(orchestrator);
|
|
317
|
+
try {
|
|
318
|
+
deps.qmd = {
|
|
319
|
+
probe: async () => true,
|
|
320
|
+
debugStatus: () => "synthetic-qmd",
|
|
321
|
+
isAvailable: () => true,
|
|
322
|
+
search: async () => [],
|
|
323
|
+
update: async () => {},
|
|
324
|
+
lastUpdateRanAtMs: 1,
|
|
325
|
+
lastUpdateFailedAtMs: null,
|
|
326
|
+
};
|
|
327
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
328
|
+
// Remote or daemon-only modes intentionally run no local collection check;
|
|
329
|
+
// "skipped" is a supported explicit answer, unlike "unknown".
|
|
330
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async () => "skipped";
|
|
331
|
+
|
|
332
|
+
assert.equal(
|
|
333
|
+
await orchestrator.startupSearchReadySync(new AbortController().signal),
|
|
334
|
+
true,
|
|
335
|
+
"explicit skipped support must be preserved",
|
|
336
|
+
);
|
|
337
|
+
} finally {
|
|
338
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
339
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("a caller after an epoch transition runs its own backend ensure instead of joining the retired flight", async () => {
|
|
344
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
345
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
346
|
+
const probeCalls: number[] = [];
|
|
347
|
+
const ensureGate = Promise.withResolvers<void>();
|
|
348
|
+
let gateFirstEnsure = true;
|
|
349
|
+
const deps = asDeps(orchestrator);
|
|
350
|
+
try {
|
|
351
|
+
deps.qmd = {
|
|
352
|
+
probe: async () => {
|
|
353
|
+
probeCalls.push(1);
|
|
354
|
+
return true;
|
|
355
|
+
},
|
|
356
|
+
debugStatus: () => "synthetic-qmd",
|
|
357
|
+
isAvailable: () => true,
|
|
358
|
+
search: async () => [],
|
|
359
|
+
update: async () => {},
|
|
360
|
+
lastUpdateRanAtMs: 1,
|
|
361
|
+
lastUpdateFailedAtMs: null,
|
|
362
|
+
};
|
|
363
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
364
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async () => {
|
|
365
|
+
if (gateFirstEnsure) {
|
|
366
|
+
gateFirstEnsure = false;
|
|
367
|
+
await ensureGate.promise;
|
|
368
|
+
}
|
|
369
|
+
return "present";
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const signal = new AbortController().signal;
|
|
373
|
+
const first = orchestrator.startupSearchReadySync(signal);
|
|
374
|
+
for (let i = 0; i < 200 && gateFirstEnsure; i += 1) await sleep(5);
|
|
375
|
+
assert.equal(probeCalls.length, 1, "epoch A's readiness run reached its ensure");
|
|
376
|
+
|
|
377
|
+
// A same-instance lifecycle restart retires epoch A and opens epoch B
|
|
378
|
+
// while A's shared ensure is still in flight.
|
|
379
|
+
deps.orchestratorInitCoordinator.beginStartupEpoch();
|
|
380
|
+
|
|
381
|
+
const second = orchestrator.startupSearchReadySync(signal);
|
|
382
|
+
ensureGate.resolve();
|
|
383
|
+
assert.equal(
|
|
384
|
+
await second,
|
|
385
|
+
true,
|
|
386
|
+
"the epoch-B caller must run its own ensure, not inherit epoch A's retired flight",
|
|
387
|
+
);
|
|
388
|
+
assert.equal(
|
|
389
|
+
probeCalls.length,
|
|
390
|
+
2,
|
|
391
|
+
"the epoch-B caller re-probes instead of joining the retired run",
|
|
392
|
+
);
|
|
393
|
+
assert.equal(
|
|
394
|
+
await first,
|
|
395
|
+
false,
|
|
396
|
+
"epoch A's joined run reports retired once its epoch is replaced",
|
|
397
|
+
);
|
|
398
|
+
} finally {
|
|
399
|
+
ensureGate.resolve();
|
|
400
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
401
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test("a caller abort does not cancel the shared backend ensure for joined callers", async () => {
|
|
406
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
407
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
408
|
+
const ensureGate = Promise.withResolvers<void>();
|
|
409
|
+
let firstEnsureSeen = false;
|
|
410
|
+
const deps = asDeps(orchestrator);
|
|
411
|
+
try {
|
|
412
|
+
deps.qmd = {
|
|
413
|
+
probe: async () => true,
|
|
414
|
+
debugStatus: () => "synthetic-qmd",
|
|
415
|
+
isAvailable: () => true,
|
|
416
|
+
search: async () => [],
|
|
417
|
+
update: async () => {},
|
|
418
|
+
lastUpdateRanAtMs: 1,
|
|
419
|
+
lastUpdateFailedAtMs: null,
|
|
420
|
+
};
|
|
421
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
422
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async () => {
|
|
423
|
+
if (!firstEnsureSeen) {
|
|
424
|
+
firstEnsureSeen = true;
|
|
425
|
+
await ensureGate.promise;
|
|
426
|
+
}
|
|
427
|
+
return "present";
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
// The first caller aborts mid-ensure — the readiness gate's per-attempt
|
|
431
|
+
// timeout. The shared backend run is epoch-owned, so the abort must not
|
|
432
|
+
// kill it for the full-sync caller that joined it.
|
|
433
|
+
const firstController = new AbortController();
|
|
434
|
+
const first = orchestrator.startupSearchReadySync(firstController.signal);
|
|
435
|
+
for (let i = 0; i < 200 && !firstEnsureSeen; i += 1) await sleep(5);
|
|
436
|
+
assert.ok(firstEnsureSeen, "the shared run reached its ensure");
|
|
437
|
+
|
|
438
|
+
const second = orchestrator.startupSearchReadySync(new AbortController().signal);
|
|
439
|
+
firstController.abort();
|
|
440
|
+
ensureGate.resolve();
|
|
441
|
+
|
|
442
|
+
assert.equal(
|
|
443
|
+
await Promise.race([second, sleep(2_000).then(() => "hung" as const)]),
|
|
444
|
+
true,
|
|
445
|
+
"the joined caller keeps the shared run's result after the first caller's abort",
|
|
446
|
+
);
|
|
447
|
+
await first;
|
|
448
|
+
} finally {
|
|
449
|
+
ensureGate.resolve();
|
|
450
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
451
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
test("an aborted caller settles instead of waiting on the shared run", async () => {
|
|
456
|
+
const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-ready-path-"));
|
|
457
|
+
const orchestrator = new Orchestrator(readyPathConfig(memoryDir));
|
|
458
|
+
const ensureGate = Promise.withResolvers<void>();
|
|
459
|
+
let firstEnsureSeen = false;
|
|
460
|
+
const deps = asDeps(orchestrator);
|
|
461
|
+
try {
|
|
462
|
+
deps.qmd = {
|
|
463
|
+
probe: async () => true,
|
|
464
|
+
debugStatus: () => "synthetic-qmd",
|
|
465
|
+
isAvailable: () => true,
|
|
466
|
+
search: async () => [],
|
|
467
|
+
update: async () => {},
|
|
468
|
+
lastUpdateRanAtMs: 1,
|
|
469
|
+
lastUpdateFailedAtMs: null,
|
|
470
|
+
};
|
|
471
|
+
deps.namespaceSearchRouter.clearCache = () => undefined;
|
|
472
|
+
deps.namespaceSearchRouter.ensureNamespaceCollection = async () => {
|
|
473
|
+
if (!firstEnsureSeen) {
|
|
474
|
+
firstEnsureSeen = true;
|
|
475
|
+
await ensureGate.promise;
|
|
476
|
+
}
|
|
477
|
+
return "present";
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
const firstController = new AbortController();
|
|
481
|
+
const first = orchestrator.startupSearchReadySync(firstController.signal);
|
|
482
|
+
for (let i = 0; i < 200 && !firstEnsureSeen; i += 1) await sleep(5);
|
|
483
|
+
assert.ok(firstEnsureSeen, "the shared run reached its ensure");
|
|
484
|
+
|
|
485
|
+
const second = orchestrator.startupSearchReadySync(new AbortController().signal);
|
|
486
|
+
firstController.abort();
|
|
487
|
+
|
|
488
|
+
// The aborted caller must not stay parked on the shared run: it settles
|
|
489
|
+
// now while the joiner's live participation keeps the run alive.
|
|
490
|
+
assert.equal(
|
|
491
|
+
await Promise.race([first, sleep(2_000).then(() => "hung" as const)]),
|
|
492
|
+
false,
|
|
493
|
+
"the aborted caller settles as not-ready without waiting on the held ensure",
|
|
494
|
+
);
|
|
495
|
+
ensureGate.resolve();
|
|
496
|
+
assert.equal(
|
|
497
|
+
await Promise.race([second, sleep(2_000).then(() => "hung" as const)]),
|
|
498
|
+
true,
|
|
499
|
+
"the joined caller still resolves with the shared run's verified result",
|
|
500
|
+
);
|
|
501
|
+
} finally {
|
|
502
|
+
ensureGate.resolve();
|
|
503
|
+
await orchestrator.destroy().catch(() => undefined);
|
|
504
|
+
await rm(memoryDir, { recursive: true, force: true });
|
|
505
|
+
}
|
|
506
|
+
});
|
package/src/orchestrator.ts
CHANGED
|
@@ -958,11 +958,13 @@ export class Orchestrator {
|
|
|
958
958
|
private resolveInit: (() => void) | null = null;
|
|
959
959
|
|
|
960
960
|
/**
|
|
961
|
-
* Resolves when deferred initialization (
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*
|
|
961
|
+
* Resolves when deferred initialization (warmup, caches, cron) completes.
|
|
962
|
+
* CLI and http-serve callers that need `qmd.isAvailable()` to reflect
|
|
963
|
+
* reality should `await orchestrator.deferredReady` after `initialize()`.
|
|
964
|
+
* The corpus-wide QMD update is deliberately NOT part of this gate (#3518):
|
|
965
|
+
* it runs after ready under the server retry loop, so `deferredReady` no
|
|
966
|
+
* longer implies a synced index. Gateway callers can ignore it — recall()
|
|
967
|
+
* degrades gracefully when QMD isn't ready yet.
|
|
966
968
|
*
|
|
967
969
|
* Also resolves (without error) when `initialize()` throws before reaching
|
|
968
970
|
* the deferred-init phase, so callers never hang on a permanently-pending
|
|
@@ -977,10 +979,11 @@ export class Orchestrator {
|
|
|
977
979
|
private deferredInitAbort: AbortController | null = null;
|
|
978
980
|
|
|
979
981
|
/**
|
|
980
|
-
* Whether the
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
982
|
+
* Whether the startup corpus update completed successfully. The deferred
|
|
983
|
+
* init no longer runs it (#3518), so this stays false until the server
|
|
984
|
+
* retry loop's startupSearchSync() lands — including when
|
|
985
|
+
* `qmd.isAvailable()` is true, because availability only means the probe
|
|
986
|
+
* and collection ensure succeeded, not that the index is current.
|
|
984
987
|
*/
|
|
985
988
|
deferredSyncSucceeded = false;
|
|
986
989
|
|
|
@@ -2033,6 +2036,12 @@ export class Orchestrator {
|
|
|
2033
2036
|
);
|
|
2034
2037
|
}
|
|
2035
2038
|
|
|
2039
|
+
async startupSearchReadySync(signal?: AbortSignal): Promise<boolean> {
|
|
2040
|
+
return this.orchestratorInitCoordinator.startupSearchReadySync(
|
|
2041
|
+
signal,
|
|
2042
|
+
);
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2036
2045
|
async runPatternReinforcement(options: {
|
|
2037
2046
|
force?: boolean;
|
|
2038
2047
|
namespace?: string;
|
package/src/storage.ts
CHANGED
|
@@ -1648,7 +1648,7 @@ function parseExtractionRetryStateEntries(raw: unknown): NonNullable<MetaState["
|
|
|
1648
1648
|
if (!("firstFailedAt" in entry) || typeof entry.firstFailedAt !== "string") continue;
|
|
1649
1649
|
if (!("lastFailureClass" in entry)) continue;
|
|
1650
1650
|
const cls = entry.lastFailureClass;
|
|
1651
|
-
if (cls !== "provider_retryable" && cls !== "parse_empty" && cls !== "auth_config") continue;
|
|
1651
|
+
if (cls !== "provider_retryable" && cls !== "parse_empty" && cls !== "output_truncated" && cls !== "auth_config") continue;
|
|
1652
1652
|
const lastFailureClass: ExtractionFailureClass = cls;
|
|
1653
1653
|
valid.push({
|
|
1654
1654
|
fingerprint: entry.fingerprint,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coarse failure class consumed by the extraction retry/backoff + circuit
|
|
3
|
+
* breaker layer (extraction hot-loop hardening). Kept deliberately small:
|
|
4
|
+
* - `provider_retryable`: transient provider failure (429/5xx/network) — back off and retry.
|
|
5
|
+
* - `parse_empty`: provider responded but produced no parseable output — retry with a low attempt cap.
|
|
6
|
+
* - `output_truncated`: provider stopped at its output ceiling (`finish_reason=length`) — a retry
|
|
7
|
+
* at the same `maxOutputTokens` can never complete, so the fingerprint long-parks immediately;
|
|
8
|
+
* the window survives for a run under a raised ceiling (#3521).
|
|
9
|
+
* - `auth_config`: auth/config failure (401/403/"no models configured") — open the breaker immediately.
|
|
10
|
+
*/
|
|
11
|
+
export type ExtractionFailureClass = "provider_retryable" | "parse_empty" | "output_truncated" | "auth_config";
|
package/src/types.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { ActivityConfig } from "./activity/types.js";
|
|
|
7
7
|
import type { WearablesConfig } from "./wearables/types.js";
|
|
8
8
|
import type { ExtractionSpanConfig, ExtractedFactSpanRef } from "./extraction-span-config.js";
|
|
9
9
|
import type { ExtractionLivenessConfig } from "./extraction-liveness.js";
|
|
10
|
+
import type { ExtractionFailureClass } from "./types-extraction-failure.js";
|
|
10
11
|
import type { ReplicaPeersConfig } from "./replica-peers-config.js";
|
|
11
12
|
import type { ExternalWikiRoot } from "./external-wiki-config.js";
|
|
12
13
|
import type { StateViewResult } from "./recall-state-view.js";
|
|
@@ -724,7 +725,7 @@ export interface PluginConfig
|
|
|
724
725
|
/** Retained turns admitted per session before live backpressure (#3415 bound). */
|
|
725
726
|
bufferMaxTurnsPerSession: number;
|
|
726
727
|
bufferMaxMinutes: number;
|
|
727
|
-
/**
|
|
728
|
+
/** Background extraction concurrency; defaults to 2. Same-buffer tasks never overlap. Applies at daemon start. */
|
|
728
729
|
extractionQueueConcurrency: number;
|
|
729
730
|
/**
|
|
730
731
|
* Debounce window (ms) for persisting the smart buffer to `state/buffer.json`
|
|
@@ -3334,14 +3335,7 @@ export interface QuestionEntry {
|
|
|
3334
3335
|
resolvedAt?: string;
|
|
3335
3336
|
}
|
|
3336
3337
|
|
|
3337
|
-
|
|
3338
|
-
* Coarse failure class consumed by the extraction retry/backoff + circuit
|
|
3339
|
-
* breaker layer (extraction hot-loop hardening). Kept deliberately small:
|
|
3340
|
-
* - `provider_retryable`: transient provider failure (429/5xx/network) — back off and retry.
|
|
3341
|
-
* - `parse_empty`: provider responded but produced no parseable output — retry with a low attempt cap.
|
|
3342
|
-
* - `auth_config`: auth/config failure (401/403/"no models configured") — open the breaker immediately.
|
|
3343
|
-
*/
|
|
3344
|
-
export type ExtractionFailureClass = "provider_retryable" | "parse_empty" | "auth_config";
|
|
3338
|
+
export type { ExtractionFailureClass };
|
|
3345
3339
|
|
|
3346
3340
|
export interface ExtractionResult {
|
|
3347
3341
|
facts: ExtractedFact[];
|