@evomap/evolver-proxy 2.0.46 → 2.0.48
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/bin/evolver-proxy.d.ts +4 -0
- package/dist/bin/evolver-proxy.js +49 -5
- package/dist/bin/proxyStopSignal.d.ts +8 -0
- package/dist/bin/proxyStopSignal.js +13 -0
- package/dist/bin/triggerFeedbackStartup.d.ts +8 -0
- package/dist/bin/triggerFeedbackStartup.js +23 -0
- package/dist/daemon/localRecall.d.ts +37 -0
- package/dist/daemon/localRecall.js +112 -0
- package/dist/daemon/proxyDaemon.d.ts +33 -1
- package/dist/daemon/proxyDaemon.js +263 -18
- package/dist/daemon/publishBindingLedger.d.ts +38 -0
- package/dist/daemon/publishBindingLedger.js +171 -1
- package/dist/daemon/recallContext.d.ts +3 -0
- package/dist/daemon/recallContext.js +10 -0
- package/dist/lifecycle/claimNudge.js +1 -1
- package/dist/lifecycle/deployGuard.js +1 -1
- package/dist/lifecycle/legacyNodeId.js +1 -1
- package/dist/lifecycle/manager.js +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/server.js +1 -1
- package/dist/llm/traceBackfill.js +1 -1
- package/dist/llm/traceConfig.js +1 -1
- package/dist/llm/traceControl.js +1 -1
- package/dist/llm/traceEnvelope.js +1 -1
- package/dist/llm/traceSink.js +1 -1
- package/dist/llm/traceUploadPayload.js +1 -1
- package/dist/llm/upstream.js +1 -1
- package/dist/router/cachePassthrough.js +1 -1
- package/dist/router/features.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/router/messagesRoute.js +1 -1
- package/dist/router/modelRouter.js +1 -1
- package/dist/router/providerRoutes.js +1 -1
- package/dist/router/sseScan.js +1 -1
- package/dist/selfUpdate/bootstrap.js +29 -23
- package/dist/selfUpdate/bootstrapReadiness.js +4 -1
- package/dist/selfUpdate/fileMetadata.d.ts +2 -0
- package/dist/selfUpdate/fileMetadata.js +25 -0
- package/dist/selfUpdate/migration.js +19 -13
- package/dist/selfUpdate/recoveryChildStartGate.js +4 -2
- package/dist/selfUpdate/transaction.js +278 -64
- package/dist/selfUpdate/windowsUpdater.js +2 -1
- package/dist/sync/engine.js +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --
|
|
2
2
|
import { mailbox } from '@evomap/evolver-core';
|
|
3
3
|
import { PrivateNodeCredentialStore } from '../private/nodeCredentialStore.js';
|
|
4
|
+
import { type ProxyStopSignalSource } from './proxyStopSignal.js';
|
|
4
5
|
import { loadEnvFileFromEnv } from './envFile.js';
|
|
5
6
|
import { type DegradedStartupBootstrapResult } from '../selfUpdate/bootstrap.js';
|
|
6
7
|
import { type SelfUpdatePolicy } from '../selfUpdate/policy.js';
|
|
@@ -129,6 +130,7 @@ interface ProxyLoopLogger {
|
|
|
129
130
|
write: (chunk: string) => unknown;
|
|
130
131
|
}
|
|
131
132
|
export interface ProxyLoopOptions {
|
|
133
|
+
signal?: AbortSignal;
|
|
132
134
|
minDelayMs?: number;
|
|
133
135
|
errorDelayMs?: number;
|
|
134
136
|
maxIterations?: number;
|
|
@@ -147,6 +149,7 @@ export declare function runManagedProxyLoop(options: {
|
|
|
147
149
|
};
|
|
148
150
|
runLoop?: (daemon: ProxyLoopDaemon, options?: ProxyLoopOptions) => Promise<void>;
|
|
149
151
|
logger?: ProxyLoopLogger;
|
|
152
|
+
signals?: ProxyStopSignalSource;
|
|
150
153
|
}): Promise<void>;
|
|
151
154
|
interface CreateProxyDaemonDepsOptions {
|
|
152
155
|
runtime: HubRuntime;
|
|
@@ -158,6 +161,7 @@ interface CreateProxyDaemonDepsOptions {
|
|
|
158
161
|
selfUpdatePolicy: SelfUpdatePolicy;
|
|
159
162
|
env?: NodeJS.ProcessEnv;
|
|
160
163
|
selfUpdateOverrides?: SelfUpdateRuntimeOverrides;
|
|
164
|
+
triggerFeedback?: ProxyDaemonDeps['triggerFeedback'];
|
|
161
165
|
}
|
|
162
166
|
interface SelfUpdateRuntimeOverrides extends ReleaseBinaryOptions {
|
|
163
167
|
restart?: () => void;
|
|
@@ -4,7 +4,7 @@ import { readFileSync, realpathSync, rmSync } from 'node:fs';
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { bootstrap as coreBootstrap, daemon, hub as hubNs, mailbox, util, verify } from '@evomap/evolver-core';
|
|
7
|
+
import { bootstrap as coreBootstrap, daemon, events, exec as execCore, hub as hubNs, mailbox, util, verify } from '@evomap/evolver-core';
|
|
8
8
|
import { AtpHubClient, connectPublicHub, globalFetchLike, isNodeSecret, parseNodeSecretVersion } from '@evomap/evolver-adapter-public';
|
|
9
9
|
import { ProxyDaemon } from '../daemon/proxyDaemon.js';
|
|
10
10
|
import { resolveHubMode, resolveHubUrl } from '../daemon/selectHub.js';
|
|
@@ -16,6 +16,8 @@ import { createAtpOrderConsentGate } from '../daemon/atpConsent.js';
|
|
|
16
16
|
import { SystemdNotifier } from '../daemon/systemdNotifier.js';
|
|
17
17
|
import { resolveProxyStorePath } from './proxyStorePath.js';
|
|
18
18
|
import { publishProxySettings } from './proxySettings.js';
|
|
19
|
+
import { recoverTriggerFeedbackBeforeHub } from './triggerFeedbackStartup.js';
|
|
20
|
+
import { proxyStopSignal } from './proxyStopSignal.js';
|
|
19
21
|
import { expandHomePath, loadEnvFileFromEnv } from './envFile.js';
|
|
20
22
|
import { readLegacyNodeId, resolveProxyNodeId } from '../lifecycle/legacyNodeId.js';
|
|
21
23
|
import { createClaimNudge, wrapHelloWithClaimNudge } from '../lifecycle/claimNudge.js';
|
|
@@ -82,6 +84,8 @@ export async function runProxyMain(options = {}) {
|
|
|
82
84
|
finally {
|
|
83
85
|
clearRecoveryControllerLifecycleOwnerCapability(process.env);
|
|
84
86
|
}
|
|
87
|
+
const triggerFeedback = execCore.createTriggerFeedbackLocalFacade(process.env);
|
|
88
|
+
await recoverTriggerFeedbackBeforeHub(triggerFeedback);
|
|
85
89
|
let storePath;
|
|
86
90
|
let store;
|
|
87
91
|
let proxyDaemon;
|
|
@@ -162,6 +166,7 @@ export async function runProxyMain(options = {}) {
|
|
|
162
166
|
evolverVersion,
|
|
163
167
|
selfUpdatePolicy,
|
|
164
168
|
env: process.env,
|
|
169
|
+
triggerFeedback,
|
|
165
170
|
}),
|
|
166
171
|
onIpcListen: (listeningPort) => {
|
|
167
172
|
proxySettingsState.url = `http://127.0.0.1:${listeningPort}`;
|
|
@@ -580,12 +585,16 @@ export async function runProxyLoop(daemon, options = {}) {
|
|
|
580
585
|
let consecutiveTickFailures = 0;
|
|
581
586
|
try {
|
|
582
587
|
for (let iteration = 0; iteration < maxIterations; iteration += 1) {
|
|
588
|
+
if (options.signal?.aborted)
|
|
589
|
+
break;
|
|
583
590
|
daemon.setExpectedNextTick?.(undefined);
|
|
584
591
|
let delayMs = errorDelayMs;
|
|
585
592
|
let tickHealthy = false;
|
|
586
593
|
let exitForResolvedFailure;
|
|
587
594
|
try {
|
|
588
595
|
const rep = await daemon.tick();
|
|
596
|
+
if (options.signal?.aborted)
|
|
597
|
+
break;
|
|
589
598
|
const resolvedFailure = resolvedTickFailureMessage(rep);
|
|
590
599
|
if (resolvedFailure) {
|
|
591
600
|
logLoopResolvedFailure(options.logger, resolvedFailure);
|
|
@@ -640,18 +649,49 @@ export async function runProxyLoop(daemon, options = {}) {
|
|
|
640
649
|
}
|
|
641
650
|
}
|
|
642
651
|
export async function runManagedProxyLoop(options) {
|
|
652
|
+
const scope = proxyStopSignal(options.signals);
|
|
653
|
+
let stopping;
|
|
654
|
+
const stop = () => {
|
|
655
|
+
stopping ??= Promise.resolve().then(() => options.daemon.stop());
|
|
656
|
+
void stopping.catch(() => { });
|
|
657
|
+
};
|
|
658
|
+
scope.signal.addEventListener('abort', stop, { once: true });
|
|
659
|
+
let failure;
|
|
643
660
|
try {
|
|
644
661
|
await options.notifier.readyOrThrow();
|
|
645
|
-
|
|
662
|
+
if (!scope.signal.aborted)
|
|
663
|
+
await (options.runLoop ?? runProxyLoop)(options.daemon, { ...(options.logger ? { logger: options.logger } : {}), signal: scope.signal });
|
|
646
664
|
}
|
|
647
|
-
|
|
665
|
+
catch (error) {
|
|
666
|
+
failure = { error };
|
|
667
|
+
}
|
|
668
|
+
try {
|
|
648
669
|
try {
|
|
649
670
|
options.notifier.stop();
|
|
650
671
|
}
|
|
651
|
-
|
|
652
|
-
|
|
672
|
+
catch (error) {
|
|
673
|
+
failure ??= { error };
|
|
653
674
|
}
|
|
675
|
+
stop();
|
|
676
|
+
try {
|
|
677
|
+
await stopping;
|
|
678
|
+
}
|
|
679
|
+
catch (error) {
|
|
680
|
+
failure ??= { error };
|
|
681
|
+
try {
|
|
682
|
+
await closeStartupResources({ store: options.store });
|
|
683
|
+
}
|
|
684
|
+
catch (closeError) {
|
|
685
|
+
failure ??= { error: closeError };
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
finally {
|
|
690
|
+
scope.signal.removeEventListener('abort', stop);
|
|
691
|
+
scope.close();
|
|
654
692
|
}
|
|
693
|
+
if (failure)
|
|
694
|
+
throw failure.error;
|
|
655
695
|
}
|
|
656
696
|
export function createProxyDaemonDeps(options) {
|
|
657
697
|
const selfUpdate = createSelfUpdateDeps(options.selfUpdatePolicy, options.evolverVersion, options.env ?? process.env, options.selfUpdateOverrides);
|
|
@@ -660,13 +700,17 @@ export function createProxyDaemonDeps(options) {
|
|
|
660
700
|
const heartbeatIntervalMs = positiveIntegerEnv(env['HEARTBEAT_INTERVAL_MS']);
|
|
661
701
|
const publishExecutionVerifier = resolveNativePublishExecutionVerifier(env);
|
|
662
702
|
const hubAuthFailurePolicy = resolveHubAuthFailurePolicy(env);
|
|
703
|
+
const triggerFeedback = options.triggerFeedback ?? execCore.createTriggerFeedbackLocalFacade(env);
|
|
663
704
|
return {
|
|
705
|
+
...(triggerFeedback ? { triggerFeedback } : {}),
|
|
664
706
|
hub: options.runtime.hub,
|
|
665
707
|
...(options.runtime.currentNodeId ? { currentNodeId: options.runtime.currentNodeId } : {}),
|
|
666
708
|
...(options.hubMode === 'private' && options.runtime.boundReuseFeedback
|
|
667
709
|
? { boundReuseFeedback: options.runtime.boundReuseFeedback } : {}),
|
|
668
710
|
...(options.hubMode ? { hubMode: options.hubMode } : {}),
|
|
669
711
|
store: options.store,
|
|
712
|
+
// The node's one local asset pool, shared with the CLI: distillations persist into it and every recall reads it.
|
|
713
|
+
assetStoreDir: events.assetsDir(env),
|
|
670
714
|
ipcToken: options.ipcToken,
|
|
671
715
|
...(options.ipcPort !== undefined ? { ipcPort: options.ipcPort } : {}),
|
|
672
716
|
...(options.runtime.atp ? {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ProxyStopSignalSource {
|
|
2
|
+
on(signal: 'SIGINT' | 'SIGTERM', listener: () => void): unknown;
|
|
3
|
+
off(signal: 'SIGINT' | 'SIGTERM', listener: () => void): unknown;
|
|
4
|
+
}
|
|
5
|
+
export declare function proxyStopSignal(source?: ProxyStopSignalSource): {
|
|
6
|
+
signal: AbortSignal;
|
|
7
|
+
close(): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function proxyStopSignal(source = process) {
|
|
2
|
+
const controller = new AbortController();
|
|
3
|
+
const stop = () => controller.abort();
|
|
4
|
+
source.on('SIGINT', stop);
|
|
5
|
+
source.on('SIGTERM', stop);
|
|
6
|
+
return {
|
|
7
|
+
signal: controller.signal,
|
|
8
|
+
close() {
|
|
9
|
+
source.off('SIGINT', stop);
|
|
10
|
+
source.off('SIGTERM', stop);
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { exec as execCore } from '@evomap/evolver-core';
|
|
2
|
+
import { type ProxyStopSignalSource } from './proxyStopSignal.js';
|
|
3
|
+
export declare function recoverTriggerFeedbackBeforeHub(feedback: execCore.TriggerFeedbackLocalFacade | undefined, options?: {
|
|
4
|
+
signals?: ProxyStopSignalSource;
|
|
5
|
+
logger?: {
|
|
6
|
+
write(message: string): unknown;
|
|
7
|
+
};
|
|
8
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { exec as execCore } from '@evomap/evolver-core';
|
|
2
|
+
import { proxyStopSignal } from './proxyStopSignal.js';
|
|
3
|
+
export async function recoverTriggerFeedbackBeforeHub(feedback, options = {}) {
|
|
4
|
+
if (!feedback?.recover)
|
|
5
|
+
return;
|
|
6
|
+
const stop = proxyStopSignal(options.signals);
|
|
7
|
+
const logger = options.logger ?? process.stderr;
|
|
8
|
+
try {
|
|
9
|
+
const result = await feedback.recover(stop.signal);
|
|
10
|
+
if (stop.signal.aborted)
|
|
11
|
+
throw new Error('trigger_feedback_startup_cancelled');
|
|
12
|
+
if (result['ok'] !== true)
|
|
13
|
+
logger.write('[evolver-proxy] trigger feedback startup recovery is pending or unavailable\n');
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
if (stop.signal.aborted)
|
|
17
|
+
throw new Error('trigger_feedback_startup_cancelled');
|
|
18
|
+
logger.write('[evolver-proxy] trigger feedback startup recovery is pending or unavailable\n');
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
stop.close();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { assetstore } from '@evomap/evolver-core';
|
|
2
|
+
export type ReuseTallies = (options?: {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
deadlineAt?: number;
|
|
5
|
+
}) => ReadonlyMap<string, assetstore.ReuseTally> | Promise<ReadonlyMap<string, assetstore.ReuseTally>>;
|
|
6
|
+
export declare const LOCAL_RECALL_TIMEOUT_MS = 1500;
|
|
7
|
+
export declare const LOCAL_RECALL_STALE_MS = 30000;
|
|
8
|
+
export declare const MAX_OUTSTANDING_LOCAL_READS = 2;
|
|
9
|
+
export interface LocalRecallDiagnostics {
|
|
10
|
+
considered: number;
|
|
11
|
+
injected: number;
|
|
12
|
+
refusal?: assetstore.LocalRecallRefusal;
|
|
13
|
+
closest?: {
|
|
14
|
+
asset_id: string;
|
|
15
|
+
relevance: number;
|
|
16
|
+
prompt_similarity: number;
|
|
17
|
+
signal_hits: string[];
|
|
18
|
+
};
|
|
19
|
+
error?: string;
|
|
20
|
+
/** The store held more records of a kind than one recall reads; the rest were not considered. */
|
|
21
|
+
truncated?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface LocalRecallOutcome {
|
|
24
|
+
assets: assetstore.AssetRecord[];
|
|
25
|
+
/** Exact server-created response objects mapped to the raw records their eligibility binds. */
|
|
26
|
+
rawAssets?: ReadonlyMap<assetstore.AssetRecord, assetstore.AssetRecord>;
|
|
27
|
+
diagnostics: LocalRecallDiagnostics;
|
|
28
|
+
}
|
|
29
|
+
interface LocalRecallRead {
|
|
30
|
+
finish: (eligibility: assetstore.GeneContextEligibility, reuse: ReadonlyMap<string, assetstore.ReuseTally>) => LocalRecallOutcome;
|
|
31
|
+
}
|
|
32
|
+
/** Per-asset reuse counts the hosts recorded in root_events, active log and rotated archive alike, re-read only
|
|
33
|
+
* when that history changed. */
|
|
34
|
+
export declare function rootEventReuseTallies(path?: string): ReuseTallies;
|
|
35
|
+
/** The local Gene, with its project's notes, that this prompt should get from the local store, or none. */
|
|
36
|
+
export declare function recallFromLocalStore(store: assetstore.AssetStoreProvider, text: string, projectDir: unknown): Promise<LocalRecallRead>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { assetstore, events, ops } from '@evomap/evolver-core';
|
|
2
|
+
const MAX_LOCAL_RECALL_RECORDS = 20_000;
|
|
3
|
+
// Passing the local strength gate is already the evidence; the floor keeps a local hit above the host's own
|
|
4
|
+
// similarity cut (0.3) and comparable with the Hub's scores, which the host ranks the merged candidates by.
|
|
5
|
+
const LOCAL_SIMILARITY_FLOOR = 0.5;
|
|
6
|
+
// Recall sits on the critical path of the host's step; a store this slow to read is left out of this turn.
|
|
7
|
+
export const LOCAL_RECALL_TIMEOUT_MS = 1_500;
|
|
8
|
+
// A read still running this long after it started is taken for hung; recall may then start a fresh one.
|
|
9
|
+
export const LOCAL_RECALL_STALE_MS = 30_000;
|
|
10
|
+
// Hung reads cannot be reclaimed; past this many still outstanding, recall waits for one to end instead of adding more.
|
|
11
|
+
export const MAX_OUTSTANDING_LOCAL_READS = 2;
|
|
12
|
+
/** Per-asset reuse counts the hosts recorded in root_events, active log and rotated archive alike, re-read only
|
|
13
|
+
* when that history changed. */
|
|
14
|
+
export function rootEventReuseTallies(path = events.rootEventsPath()) {
|
|
15
|
+
let generation = 0;
|
|
16
|
+
let cached;
|
|
17
|
+
// Keep the last verified counts when history is unreadable; without a snapshot, negative evidence is unknown.
|
|
18
|
+
return async (options = {}) => {
|
|
19
|
+
const attempt = ++generation;
|
|
20
|
+
const check = () => {
|
|
21
|
+
options.signal?.throwIfAborted();
|
|
22
|
+
if (options.deadlineAt !== undefined && (!Number.isFinite(options.deadlineAt) || Date.now() >= options.deadlineAt)) {
|
|
23
|
+
throw new Error('local_recall_timeout');
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
check();
|
|
28
|
+
const version = await events.rootEventHistoryVersion(path);
|
|
29
|
+
check();
|
|
30
|
+
if (cached?.version === version) {
|
|
31
|
+
cached.generation = Math.max(cached.generation, attempt);
|
|
32
|
+
return cached.tallies;
|
|
33
|
+
}
|
|
34
|
+
const history = await events.readRootEventHistoryAsync(path, options);
|
|
35
|
+
const summary = await ops.summarizeReuseOutcomesAsync(history, options);
|
|
36
|
+
check();
|
|
37
|
+
const tallies = new Map(summary.perGene.map((gene) => [gene.assetId, { success: gene.success, negative: gene.negative }]));
|
|
38
|
+
if (!cached || attempt > cached.generation)
|
|
39
|
+
cached = { generation: attempt, version, tallies };
|
|
40
|
+
return tallies;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error instanceof events.AuditCleanupError)
|
|
44
|
+
throw error;
|
|
45
|
+
check();
|
|
46
|
+
if (!cached)
|
|
47
|
+
throw error;
|
|
48
|
+
return cached.tallies;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function recalledAsset(hit) {
|
|
53
|
+
// Only notes recall matched to this project leave the store; a record's own fields cannot carry any.
|
|
54
|
+
const { project_notes: _unvouched, recall: _claimed, ...gene } = hit.gene;
|
|
55
|
+
return {
|
|
56
|
+
...gene,
|
|
57
|
+
similarity: LOCAL_SIMILARITY_FLOOR + (1 - LOCAL_SIMILARITY_FLOOR) * hit.relevance,
|
|
58
|
+
...(hit.projectNotes.length > 0 ? { project_notes: hit.projectNotes } : {}),
|
|
59
|
+
recall: {
|
|
60
|
+
source: 'local',
|
|
61
|
+
relevance: hit.relevance,
|
|
62
|
+
signal_hits: hit.signalHits,
|
|
63
|
+
prompt_similarity: hit.promptSimilarity,
|
|
64
|
+
project_match: hit.projectMatch,
|
|
65
|
+
reuse: hit.reuse,
|
|
66
|
+
merged_asset_ids: hit.mergedAssetIds,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function diagnosticsOf(result) {
|
|
71
|
+
return {
|
|
72
|
+
considered: result.considered,
|
|
73
|
+
injected: result.hits.length,
|
|
74
|
+
...(result.refusal ? { refusal: result.refusal } : {}),
|
|
75
|
+
...(result.closest ? { closest: { asset_id: result.closest.assetId, relevance: result.closest.relevance,
|
|
76
|
+
prompt_similarity: result.closest.promptSimilarity, signal_hits: result.closest.signalHits } } : {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The local Gene, with its project's notes, that this prompt should get from the local store, or none. */
|
|
80
|
+
export async function recallFromLocalStore(store, text, projectDir) {
|
|
81
|
+
const [geneRead, capsuleRead] = await Promise.allSettled([
|
|
82
|
+
Promise.resolve().then(() => store.list('Gene', MAX_LOCAL_RECALL_RECORDS + 1)),
|
|
83
|
+
Promise.resolve().then(() => store.list('Capsule', MAX_LOCAL_RECALL_RECORDS + 1)),
|
|
84
|
+
]);
|
|
85
|
+
if (geneRead.status === 'rejected' && capsuleRead.status === 'rejected') {
|
|
86
|
+
const causes = [geneRead.reason, capsuleRead.reason];
|
|
87
|
+
const cleanupFailures = causes.filter((cause) => cause instanceof events.AuditCleanupError && !cause.cleanupComplete);
|
|
88
|
+
if (cleanupFailures.length > 0) {
|
|
89
|
+
throw new events.AuditCleanupError({ status: 'failed', error: new AggregateError(causes, 'local_recall_reads_failed') }, new AggregateError(cleanupFailures, 'local_recall_cleanup_pending'), events.auditCleanupSequence(cleanupFailures.map((failure) => ({
|
|
90
|
+
run: () => failure.retryCleanup(), retryFailedOperation: true,
|
|
91
|
+
}))));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (geneRead.status === 'rejected')
|
|
95
|
+
throw geneRead.reason;
|
|
96
|
+
if (capsuleRead.status === 'rejected')
|
|
97
|
+
throw capsuleRead.reason;
|
|
98
|
+
const allGenes = geneRead.value;
|
|
99
|
+
const allCapsules = capsuleRead.value;
|
|
100
|
+
const truncated = allGenes.length > MAX_LOCAL_RECALL_RECORDS || allCapsules.length > MAX_LOCAL_RECALL_RECORDS;
|
|
101
|
+
const genes = allGenes.slice(0, MAX_LOCAL_RECALL_RECORDS);
|
|
102
|
+
const capsules = allCapsules.slice(0, MAX_LOCAL_RECALL_RECORDS);
|
|
103
|
+
const contexts = typeof store.readLocalContextsV1 === 'function' && capsules.length > 0
|
|
104
|
+
? await store.readLocalContextsV1(capsules.map((capsule) => capsule.asset_id)) : [];
|
|
105
|
+
const query = { text, projectFingerprint: await assetstore.projectFingerprint(projectDir) };
|
|
106
|
+
return { finish: (eligibility, reuse) => {
|
|
107
|
+
const qualified = [...genes, ...capsules].filter((asset) => assetstore.assetContextEligibilityReason(asset, eligibility) === undefined);
|
|
108
|
+
const result = assetstore.recallLocalAssets(qualified, query, reuse, contexts);
|
|
109
|
+
const rawAssets = new Map(result.hits.map((hit) => [recalledAsset(hit), hit.gene]));
|
|
110
|
+
return { assets: [...rawAssets.keys()], rawAssets, diagnostics: { ...diagnosticsOf(result), ...(truncated ? { truncated } : {}) } };
|
|
111
|
+
} };
|
|
112
|
+
}
|
|
@@ -4,6 +4,7 @@ import { LifecycleManager, type HelloLifecycleMode, type HelloResult, type Heart
|
|
|
4
4
|
import { type SelfUpdateDeps } from '../selfUpdate/executor.js';
|
|
5
5
|
import type { AtpOrderConsentGate } from './atpConsent.js';
|
|
6
6
|
import type { PrivateBoundReuseFeedback } from '../private/adapterLoader.js';
|
|
7
|
+
import { type ReuseTallies } from './localRecall.js';
|
|
7
8
|
import { type PublishRecallVerifierPort } from './publishRecallVerifier.js';
|
|
8
9
|
type HubCapability = hubNs.HubCapability;
|
|
9
10
|
type AssetStoreProvider = assetstore.AssetStoreProvider;
|
|
@@ -12,11 +13,12 @@ export declare const DEFAULT_IPC_PORT = 19820;
|
|
|
12
13
|
export type HubAuthFailurePolicy = 'deny' | 'warn';
|
|
13
14
|
export declare function resolveHubAuthFailurePolicy(env?: Record<string, string | undefined>): HubAuthFailurePolicy;
|
|
14
15
|
export interface ProxyDaemonDeps {
|
|
16
|
+
triggerFeedback?: import('@evomap/evolver-core').exec.TriggerFeedbackLocalFacade;
|
|
15
17
|
recipeExecutionDirectory?: string;
|
|
16
18
|
/** operator配置,不能由单次搜索请求关闭。 */
|
|
17
19
|
benchmarkId?: string;
|
|
18
20
|
sourceProvenance?: assetstore.ProvenanceStore;
|
|
19
|
-
/**
|
|
21
|
+
/** 自定义provider须显式提供本pool的资格账本;缺账本不等于没有审核记录。 */
|
|
20
22
|
sourceReview?: assetstore.ReviewLedger;
|
|
21
23
|
hub: HubCapability;
|
|
22
24
|
/** Identity actually presented by the connected Hub runtime; terminal lifecycle state is scoped to it. */
|
|
@@ -63,6 +65,10 @@ export interface ProxyDaemonDeps {
|
|
|
63
65
|
assetStore?: AssetStoreProvider;
|
|
64
66
|
/** 未显式传 assetStore 时, 用该目录创建 LocalJsonlProvider; 缺省跟随 storePath 同目录. */
|
|
65
67
|
assetStoreDir?: string;
|
|
68
|
+
/** Reuse counts that rank local recall; defaults to the hosts' records in root_events. */
|
|
69
|
+
localReuseTallies?: ReuseTallies;
|
|
70
|
+
/** How long a text recall waits for the local store before leaving it out of this turn. */
|
|
71
|
+
localRecallTimeoutMs?: number;
|
|
66
72
|
/** 可选 ATP 兼容路由实现. ProxyDaemon 只依赖窄接口; public/private adapter 在 bin 层装配. */
|
|
67
73
|
atp?: AtpProxyClient;
|
|
68
74
|
/** Consent gate for local /atp/order spend attempts. Missing gate fails closed. */
|
|
@@ -162,6 +168,11 @@ export declare class ProxyDaemon {
|
|
|
162
168
|
readonly sync: SyncEngine;
|
|
163
169
|
readonly lifecycle: LifecycleManager;
|
|
164
170
|
private readonly assetStore;
|
|
171
|
+
private readonly localReuseTallies;
|
|
172
|
+
private readonly localRecallTimeoutMs;
|
|
173
|
+
private localRecallStartedAt;
|
|
174
|
+
private localReadsOutstanding;
|
|
175
|
+
private readonly localRecallCleanup;
|
|
165
176
|
private readonly benchmark;
|
|
166
177
|
private readonly sourceProvenance;
|
|
167
178
|
private readonly sourceReview;
|
|
@@ -199,6 +210,7 @@ export declare class ProxyDaemon {
|
|
|
199
210
|
/** A poke that arrived between ticks (no sleep in flight) parks the wake here so it is not lost. */
|
|
200
211
|
private wakeRunnerPending;
|
|
201
212
|
private started;
|
|
213
|
+
private feedbackRecovery;
|
|
202
214
|
private lifecycleArmed;
|
|
203
215
|
private lastTickAt;
|
|
204
216
|
private readonly runtimeProcessIdentity;
|
|
@@ -226,6 +238,7 @@ export declare class ProxyDaemon {
|
|
|
226
238
|
/** 启动: 锁 + IPC 监听 + 初次 hello. 返回 IPC 端口. */
|
|
227
239
|
start(): Promise<number>;
|
|
228
240
|
private listenIpc;
|
|
241
|
+
private drainTriggerFeedbackRecovery;
|
|
229
242
|
/** 单轮: core pump/TTL/wake + proxy 出站 + hub 入站 + 到点心跳. */
|
|
230
243
|
tick(): Promise<ProxyTickReport>;
|
|
231
244
|
/** 下一轮建议延时: inbound 背压/idle 与 outbound pending cadence 取更快者. */
|
|
@@ -270,6 +283,8 @@ export declare class ProxyDaemon {
|
|
|
270
283
|
private respondAssetSearch;
|
|
271
284
|
private qualifyFetch;
|
|
272
285
|
private recallAssets;
|
|
286
|
+
private retryLocalRecallCleanup;
|
|
287
|
+
private localRecall;
|
|
273
288
|
private localFetchAssets;
|
|
274
289
|
private feedbackNodeId;
|
|
275
290
|
private handleProxyRoute;
|
|
@@ -279,6 +294,23 @@ export declare class ProxyDaemon {
|
|
|
279
294
|
private publishAssetSubmitSynchronously;
|
|
280
295
|
private createSynchronousAssetSubmitEnvelope;
|
|
281
296
|
private composeRecipeAfterAcceptedSubmit;
|
|
297
|
+
/**
|
|
298
|
+
* 记住本节点已发布的 Gene:之后单独发布引用它的 Capsule 时,parent 有本机发布事实可查。
|
|
299
|
+
* 只在 Hub 接受发布后登记;本机记账失败不得让已接受的发布变成失败。
|
|
300
|
+
*/
|
|
301
|
+
private recordPublishedParents;
|
|
302
|
+
/**
|
|
303
|
+
* 记下本节点正在为这些 Gene 提交发布。
|
|
304
|
+
* 单独发布的 Gene 从来不需要 binding,也就不会在 ledger 里登记任何 parent 事实;
|
|
305
|
+
* 没有这条事实,之后单独发布引用它的 Capsule 必然被 publish_binding_missing 拒绝。
|
|
306
|
+
*/
|
|
307
|
+
private recordPublishingParents;
|
|
308
|
+
/**
|
|
309
|
+
* parent 发布终态失败:这份 parent 不再授权单独发布的 Capsule。
|
|
310
|
+
* 可重试的失败不算终态,发布仍会继续。
|
|
311
|
+
*/
|
|
312
|
+
private recordFailedParents;
|
|
313
|
+
private submitEnvelopeAssets;
|
|
282
314
|
private currentHubMode;
|
|
283
315
|
private handleHubModeBoundOutbound;
|
|
284
316
|
private publishSynchronousBundle;
|