@evomap/evolver-proxy 2.0.49 → 2.0.51

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.
Files changed (37) hide show
  1. package/dist/bin/evolver-proxy.d.ts +3 -1
  2. package/dist/bin/evolver-proxy.js +6 -0
  3. package/dist/daemon/backgroundCuration.d.ts +7 -3
  4. package/dist/daemon/backgroundCuration.js +9 -3
  5. package/dist/daemon/distillMeasures.d.ts +59 -0
  6. package/dist/daemon/distillMeasures.js +139 -0
  7. package/dist/daemon/localRecall.d.ts +6 -1
  8. package/dist/daemon/localRecall.js +23 -5
  9. package/dist/daemon/proxyDaemon.d.ts +9 -0
  10. package/dist/daemon/proxyDaemon.js +68 -11
  11. package/dist/lifecycle/claimNudge.js +1 -1
  12. package/dist/lifecycle/deployGuard.js +1 -1
  13. package/dist/lifecycle/legacyNodeId.js +1 -1
  14. package/dist/lifecycle/manager.js +1 -1
  15. package/dist/llm/index.js +1 -1
  16. package/dist/llm/server.js +1 -1
  17. package/dist/llm/traceBackfill.js +1 -1
  18. package/dist/llm/traceConfig.js +1 -1
  19. package/dist/llm/traceControl.js +1 -1
  20. package/dist/llm/traceEnvelope.js +1 -1
  21. package/dist/llm/traceSink.js +1 -1
  22. package/dist/llm/traceUploadPayload.js +1 -1
  23. package/dist/llm/upstream.js +1 -1
  24. package/dist/router/cachePassthrough.js +1 -1
  25. package/dist/router/features.js +1 -1
  26. package/dist/router/index.js +1 -1
  27. package/dist/router/messagesRoute.js +1 -1
  28. package/dist/router/modelRouter.js +1 -1
  29. package/dist/router/providerRoutes.js +1 -1
  30. package/dist/router/sseScan.js +1 -1
  31. package/dist/selfUpdate/bootstrap.js +40 -46
  32. package/dist/selfUpdate/bootstrapReadiness.js +15 -3
  33. package/dist/selfUpdate/migration.js +37 -22
  34. package/dist/selfUpdate/transaction.js +158 -59
  35. package/dist/selfUpdate/windowsUpdater.js +70 -10
  36. package/dist/sync/engine.js +1 -1
  37. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env -S node --
2
- import { mailbox } from '@evomap/evolver-core';
2
+ import { hub as hubNs, mailbox } from '@evomap/evolver-core';
3
3
  import { PrivateNodeCredentialStore } from '../private/nodeCredentialStore.js';
4
4
  import { type ProxyStopSignalSource } from './proxyStopSignal.js';
5
5
  import { loadEnvFileFromEnv } from './envFile.js';
@@ -90,6 +90,7 @@ export interface RuntimeDeps {
90
90
  now?: () => number;
91
91
  privateImporter?: PrivateAdapterImporter;
92
92
  privateNodeCredentialStore?: Pick<PrivateNodeCredentialStore, 'read' | 'write'>;
93
+ recentClients?: hubNs.RecentClients;
93
94
  }
94
95
  export type PublicNodeSecretSource = 'env' | 'store' | 'hub_rotate' | 'legacy_file';
95
96
  export interface PublicNodeSecretSelection {
@@ -154,6 +155,7 @@ export declare function runManagedProxyLoop(options: {
154
155
  interface CreateProxyDaemonDepsOptions {
155
156
  runtime: HubRuntime;
156
157
  store: mailbox.MailboxStore;
158
+ recentClients?: hubNs.RecentClients;
157
159
  hubMode?: 'public' | 'private';
158
160
  ipcToken: string;
159
161
  ipcPort?: number;
@@ -149,17 +149,21 @@ export async function runProxyMain(options = {}) {
149
149
  const privateNodeCredentialStore = mode === 'private'
150
150
  ? new PrivateNodeCredentialStore(storePath)
151
151
  : undefined;
152
+ const recentClients = new hubNs.RecentClients();
153
+ recentClients.record(hubNs.clientIdentityFromEnv(process.env));
152
154
  const runtime = await (options.connectRuntime ?? connectHubRuntime)({
153
155
  mode,
154
156
  hubUrl,
155
157
  senderId,
156
158
  store,
159
+ recentClients,
157
160
  ...(privateNodeCredentialStore ? { privateNodeCredentialStore } : {}),
158
161
  });
159
162
  proxyDaemon = new ProxyDaemon({
160
163
  ...createProxyDaemonDeps({
161
164
  runtime,
162
165
  store,
166
+ recentClients,
163
167
  hubMode: mode,
164
168
  ipcToken,
165
169
  ...(ipcPort !== undefined ? { ipcPort } : {}),
@@ -706,6 +710,7 @@ export function createProxyDaemonDeps(options) {
706
710
  ...(triggerFeedback ? { triggerFeedback } : {}),
707
711
  hub: options.runtime.hub,
708
712
  ...(options.runtime.currentNodeId ? { currentNodeId: options.runtime.currentNodeId } : {}),
713
+ ...(options.recentClients ? { recentClients: options.recentClients } : {}),
709
714
  ...(options.hubMode === 'private' && options.runtime.boundReuseFeedback
710
715
  ? { boundReuseFeedback: options.runtime.boundReuseFeedback } : {}),
711
716
  ...(options.hubMode ? { hubMode: options.hubMode } : {}),
@@ -1322,6 +1327,7 @@ export async function connectHubRuntime(deps) {
1322
1327
  ...(nodeSecretVersion !== undefined ? { nodeSecretVersion } : {}),
1323
1328
  senderId,
1324
1329
  antiAbuse: { source: 'evolver-proxy', proxyPortConfigured: true },
1330
+ ...(deps.recentClients ? { clients: () => deps.recentClients.list() } : {}),
1325
1331
  onNodeSecretRotated: (secret, version) => {
1326
1332
  persistRotatedPublicNodeCredentials(deps.store, selection, secret, version);
1327
1333
  },
@@ -2,6 +2,7 @@ import { assetstore, type hub as hubNs, type verify } from '@evomap/evolver-core
2
2
  import { type VerificationContextStore } from './observedEvidence.js';
3
3
  export declare const CURATION_INTERVAL_MS: number;
4
4
  export declare const CURATION_IDLE_MS: number;
5
+ export declare const CURATION_POLL_MS = 30000;
5
6
  export type ExecutionVerifier = (input: hubNs.ConversationDistillInput, signal: AbortSignal) => Promise<hubNs.ConversationDistillVerifiedExecution | null>;
6
7
  export interface CuratedPublication {
7
8
  queued: boolean;
@@ -9,7 +10,7 @@ export interface CuratedPublication {
9
10
  envelopeId?: string;
10
11
  assetIds?: string[];
11
12
  }
12
- export type CuratedMailboxCommit = (send: () => boolean) => 'stored' | 'not_stored' | 'review_not_approved' | 'verification_plan_changed';
13
+ export type CuratedMailboxCommit = (send: () => boolean) => 'stored' | 'not_stored' | 'review_not_approved' | 'verification_plan_changed' | 'publish_policy_manual';
13
14
  /** Where each check runs inside the copy, and which project lends the copy its installed dependencies. */
14
15
  export interface VerificationPlan {
15
16
  checks: readonly verify.ObservedCheck[];
@@ -22,9 +23,11 @@ export interface CurationDeps {
22
23
  /** Absent where read-only isolation is unavailable: genes then wait, never published unverified. */
23
24
  verifierForRoot: ((root: string, plan?: VerificationPlan) => ExecutionVerifier) | undefined;
24
25
  verify: (body: hubNs.ConversationDistillInput, verifier: ExecutionVerifier, planDigest: string) => Promise<hubNs.ConversationDistillVerifiedExecution | undefined>;
25
- enqueue: (body: hubNs.ConversationDistillInput, verified: hubNs.ConversationDistillVerifiedExecution, planDigest: string, commit: CuratedMailboxCommit) => Promise<CuratedPublication>;
26
+ enqueue: (body: hubNs.ConversationDistillInput, verified: hubNs.ConversationDistillVerifiedExecution, planDigest: string, commit: CuratedMailboxCommit, expectedGeneAssetId: string) => Promise<CuratedPublication>;
26
27
  now: () => Date;
27
28
  scratchDir?: string;
29
+ /** The node's publish policy, reread every pass; `manual` keeps promotion but never enqueues a publish. */
30
+ publishMode?: () => assetstore.PublishMode;
28
31
  }
29
32
  export interface CurationReport {
30
33
  promoted: string[];
@@ -39,6 +42,7 @@ export interface CurationReport {
39
42
  */
40
43
  export declare function runCurationTick(deps: CurationDeps): Promise<CurationReport>;
41
44
  export interface CurationStatus {
45
+ publish_policy: assetstore.PublishMode;
42
46
  publish_verifier: 'available' | 'unavailable';
43
47
  publish_verifier_reason?: 'read_only_isolation_unavailable';
44
48
  awaiting_verification: number;
@@ -50,4 +54,4 @@ export interface CurationStatus {
50
54
  };
51
55
  }
52
56
  /** Why promoted genes are or are not leaving this machine, for /proxy/status and the plugin's status command. */
53
- export declare function curationStatus(contexts: VerificationContextStore, review: assetstore.ReviewLedger, verifierAvailable: boolean): CurationStatus;
57
+ export declare function curationStatus(contexts: VerificationContextStore, review: assetstore.ReviewLedger, verifierAvailable: boolean, publishMode?: assetstore.PublishMode): CurationStatus;
@@ -6,6 +6,9 @@ import { createRecordedCheckout, RecordedTreeMismatch } from './curationGit.js';
6
6
  import { hasVerificationPlan } from './observedEvidence.js';
7
7
  export const CURATION_INTERVAL_MS = 10 * 60_000;
8
8
  export const CURATION_IDLE_MS = 2 * 60_000;
9
+ // Host relays reach the Proxy every minute or two; checking only at each interval boundary would almost always land
10
+ // inside their activity, so the quiet window is polled for and a run still starts at most once per interval.
11
+ export const CURATION_POLL_MS = 30_000;
9
12
  function geneDigest(gene) {
10
13
  return wire.canonicalize(gene);
11
14
  }
@@ -83,12 +86,14 @@ async function enqueueCurrentVerification(deps, context, body, verified, geneBef
83
86
  const commit = (send) => deps.review.withExplicitApproval(context.geneAssetId, () => {
84
87
  if (!isCurrent())
85
88
  return 'verification_plan_changed';
89
+ if (deps.publishMode?.() === 'manual')
90
+ return 'publish_policy_manual';
86
91
  if (!send())
87
92
  return 'not_stored';
88
93
  saveCurrentObservation(deps.contexts, context, { published: { at, envelopeId: '', assetIds: [] } });
89
94
  return 'stored';
90
95
  }) ?? 'review_not_approved';
91
- const publication = await deps.enqueue(body, verified, context.planDigest, commit);
96
+ const publication = await deps.enqueue(body, verified, context.planDigest, commit, context.geneAssetId);
92
97
  if (!publication.queued)
93
98
  return publication.reason ?? 'publish_blocked';
94
99
  const latest = deps.contexts.get(context.geneAssetId);
@@ -132,7 +137,7 @@ async function curateOne(deps, context, gene) {
132
137
  */
133
138
  export async function runCurationTick(deps) {
134
139
  const promoted = await algo.autoPromoteProbationGenes(deps.store, deps.review, { by: 'proxy-auto-promote' });
135
- if (!deps.verifierForRoot)
140
+ if (!deps.verifierForRoot || deps.publishMode?.() === 'manual')
136
141
  return { promoted };
137
142
  const candidate = await pendingCandidate(deps);
138
143
  if (!candidate)
@@ -142,11 +147,12 @@ export async function runCurationTick(deps) {
142
147
  return { promoted, attempted: { geneAssetId: candidate.context.geneAssetId, result } };
143
148
  }
144
149
  /** Why promoted genes are or are not leaving this machine, for /proxy/status and the plugin's status command. */
145
- export function curationStatus(contexts, review, verifierAvailable) {
150
+ export function curationStatus(contexts, review, verifierAvailable, publishMode = 'auto') {
146
151
  const all = contexts.list();
147
152
  const latest = all.filter((context) => context.lastAttempt)
148
153
  .sort((a, b) => (b.lastAttempt.at).localeCompare(a.lastAttempt.at))[0];
149
154
  return {
155
+ publish_policy: publishMode,
150
156
  publish_verifier: verifierAvailable ? 'available' : 'unavailable',
151
157
  ...(verifierAvailable ? {} : { publish_verifier_reason: 'read_only_isolation_unavailable' }),
152
158
  awaiting_verification: all.filter((context) => awaitsVerification(context) && review.get(context.geneAssetId)?.state === 'approved').length,
@@ -0,0 +1,59 @@
1
+ import type { assetstore, hub as hubNs } from '@evomap/evolver-core';
2
+ type DistillOutcomeStatus = 'stored' | 'draft' | 'rejected' | 'skipped';
3
+ export interface DistillOutcome {
4
+ at: string;
5
+ status: DistillOutcomeStatus;
6
+ reason?: string;
7
+ }
8
+ export interface DistillationStatus {
9
+ window_hours: number;
10
+ stored: number;
11
+ drafts: number;
12
+ /** Drafts the quality gate refused, by reason. */
13
+ rejected: Record<string, number>;
14
+ /** Requests that never became a draft (IR structure, references, contracts, repairs, too little to go on), by reason. */
15
+ skipped: Record<string, number>;
16
+ }
17
+ export interface TrialControl {
18
+ asset_id: string;
19
+ withheld_id: string;
20
+ task_id: string;
21
+ passed: boolean;
22
+ platform?: string;
23
+ at: string;
24
+ }
25
+ interface TrialArm {
26
+ runs: number;
27
+ passed: number;
28
+ }
29
+ export interface TrialEffect {
30
+ gene_asset_id: string;
31
+ title: string;
32
+ treated: TrialArm;
33
+ control: TrialArm;
34
+ }
35
+ export declare function distillOutcomeOf(result: hubNs.ConversationDistillResult, at: Date): DistillOutcome;
36
+ export declare class DistillOutcomeLog {
37
+ private readonly log;
38
+ constructor(assetStoreDir: string);
39
+ record(outcome: DistillOutcome): void;
40
+ summary(now: Date): DistillationStatus;
41
+ }
42
+ export declare class TrialControlLog {
43
+ private readonly log;
44
+ private readonly withholdings;
45
+ constructor(assetStoreDir: string);
46
+ /** Records one withholding and names it; the turn that went without the draft reports its control under this id. */
47
+ withheld(assetId: string, at: Date): string;
48
+ /** A control counts only against the withholding it names: of that draft, in the last day, and only once. */
49
+ record(entry: TrialControl): 'recorded' | 'duplicate' | 'not_withheld';
50
+ list(): TrialControl[];
51
+ }
52
+ /**
53
+ * Keyed by the Gene's own id, not its asset id: the asset id also hashes runtime metadata (model, `env_class`), so the
54
+ * same draft would land in another arm on another machine.
55
+ */
56
+ export declare function isTrialHoldout(geneId: string, recallText: string): boolean;
57
+ /** Each trial draft with a control arm: how often checks passed with it recalled, and without. */
58
+ export declare function trialEffect(store: assetstore.AssetStoreProvider, controls: TrialControlLog): Promise<TrialEffect[]>;
59
+ export {};
@@ -0,0 +1,139 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { dirname, join } from 'node:path';
4
+ const MAX_OUTCOMES = 1_000;
5
+ const MAX_CONTROLS = 5_000;
6
+ const WINDOW_HOURS = 24;
7
+ const WITHHOLDING_TTL_MS = 24 * 3_600_000;
8
+ // One trial recall in five is withheld, so a draft's pass rate can be compared with sessions that did without it.
9
+ const HOLDOUT_BUCKETS = 5;
10
+ const MAX_EFFECT_ROWS = 10;
11
+ const MAX_LISTED_CAPSULES = 20_000;
12
+ /** An append-only JSON-lines file that keeps its newest `max` entries. */
13
+ class BoundedJsonl {
14
+ path;
15
+ max;
16
+ constructor(path, max) {
17
+ this.path = path;
18
+ this.max = max;
19
+ }
20
+ read() {
21
+ if (!existsSync(this.path))
22
+ return [];
23
+ return readFileSync(this.path, 'utf8').split('\n').flatMap((line) => {
24
+ if (!line.trim())
25
+ return [];
26
+ try {
27
+ return [JSON.parse(line)];
28
+ }
29
+ catch {
30
+ return [];
31
+ }
32
+ });
33
+ }
34
+ append(entry) {
35
+ mkdirSync(dirname(this.path), { recursive: true });
36
+ appendFileSync(this.path, `${JSON.stringify(entry)}\n`, { mode: 0o600 });
37
+ const entries = this.read();
38
+ if (entries.length <= this.max)
39
+ return;
40
+ const temporary = `${this.path}.${process.pid}.tmp`;
41
+ writeFileSync(temporary, entries.slice(-this.max).map((item) => JSON.stringify(item)).join('\n') + '\n', { mode: 0o600 });
42
+ renameSync(temporary, this.path);
43
+ }
44
+ }
45
+ export function distillOutcomeOf(result, at) {
46
+ const stamp = at.toISOString();
47
+ if (!result.ok)
48
+ return { at: stamp, status: 'skipped', reason: result.quality?.reason ?? result.reason };
49
+ if (result.status === 'stored')
50
+ return { at: stamp, status: 'stored' };
51
+ return result.quality.ok ? { at: stamp, status: 'draft' } : { at: stamp, status: 'rejected', reason: result.quality.reason ?? 'quality_gate' };
52
+ }
53
+ export class DistillOutcomeLog {
54
+ log;
55
+ constructor(assetStoreDir) {
56
+ this.log = new BoundedJsonl(join(assetStoreDir, 'distill-outcomes.jsonl'), MAX_OUTCOMES);
57
+ }
58
+ record(outcome) {
59
+ this.log.append(outcome);
60
+ }
61
+ summary(now) {
62
+ const since = now.getTime() - WINDOW_HOURS * 3_600_000;
63
+ const status = { window_hours: WINDOW_HOURS, stored: 0, drafts: 0, rejected: {}, skipped: {} };
64
+ const count = (byReason, reason = 'unknown') => { byReason[reason] = (byReason[reason] ?? 0) + 1; };
65
+ for (const outcome of this.log.read()) {
66
+ if (Date.parse(outcome.at) < since)
67
+ continue;
68
+ if (outcome.status === 'stored')
69
+ status.stored += 1;
70
+ else if (outcome.status === 'draft')
71
+ status.drafts += 1;
72
+ else
73
+ count(outcome.status === 'skipped' ? status.skipped : status.rejected, outcome.reason);
74
+ }
75
+ return status;
76
+ }
77
+ }
78
+ export class TrialControlLog {
79
+ log;
80
+ withholdings;
81
+ constructor(assetStoreDir) {
82
+ this.log = new BoundedJsonl(join(assetStoreDir, 'trial-control.jsonl'), MAX_CONTROLS);
83
+ this.withholdings = new BoundedJsonl(join(assetStoreDir, 'trial-withheld.jsonl'), MAX_CONTROLS);
84
+ }
85
+ /** Records one withholding and names it; the turn that went without the draft reports its control under this id. */
86
+ withheld(assetId, at) {
87
+ const id = randomUUID();
88
+ this.withholdings.append({ id, asset_id: assetId, at: at.toISOString() });
89
+ return id;
90
+ }
91
+ /** A control counts only against the withholding it names: of that draft, in the last day, and only once. */
92
+ record(entry) {
93
+ const withholding = this.withholdings.read().find((known) => known.id === entry.withheld_id);
94
+ if (!withholding || withholding.asset_id !== entry.asset_id
95
+ || Date.parse(withholding.at) < Date.parse(entry.at) - WITHHOLDING_TTL_MS)
96
+ return 'not_withheld';
97
+ if (this.log.read().some((known) => known.withheld_id === entry.withheld_id))
98
+ return 'duplicate';
99
+ this.log.append(entry);
100
+ return 'recorded';
101
+ }
102
+ list() {
103
+ return this.log.read();
104
+ }
105
+ }
106
+ /**
107
+ * Keyed by the Gene's own id, not its asset id: the asset id also hashes runtime metadata (model, `env_class`), so the
108
+ * same draft would land in another arm on another machine.
109
+ */
110
+ export function isTrialHoldout(geneId, recallText) {
111
+ return createHash('sha256').update(`${geneId}\n${recallText}`).digest()[0] % HOLDOUT_BUCKETS === 0;
112
+ }
113
+ const arm = () => ({ runs: 0, passed: 0 });
114
+ /** Each trial draft with a control arm: how often checks passed with it recalled, and without. */
115
+ export async function trialEffect(store, controls) {
116
+ const rows = new Map();
117
+ for (const entry of controls.list()) {
118
+ const row = rows.get(entry.asset_id) ?? { treated: arm(), control: arm() };
119
+ row.control.runs += 1;
120
+ if (entry.passed)
121
+ row.control.passed += 1;
122
+ rows.set(entry.asset_id, row);
123
+ }
124
+ if (rows.size === 0)
125
+ return [];
126
+ for (const capsule of await store.list('Capsule', MAX_LISTED_CAPSULES)) {
127
+ const row = capsule['source_type'] === 'reused' ? rows.get(String(capsule['reused_asset_id'] ?? '')) : undefined;
128
+ if (!row)
129
+ continue;
130
+ row.treated.runs += 1;
131
+ if (capsule['outcome']?.status === 'success')
132
+ row.treated.passed += 1;
133
+ }
134
+ const ranked = [...rows].sort(([, a], [, b]) => (b.treated.runs + b.control.runs) - (a.treated.runs + a.control.runs)).slice(0, MAX_EFFECT_ROWS);
135
+ return Promise.all(ranked.map(async ([assetId, row]) => {
136
+ const gene = await store.get(assetId);
137
+ return { gene_asset_id: assetId, title: String(gene?.['summary'] ?? '').slice(0, 80), ...row };
138
+ }));
139
+ }
@@ -19,6 +19,11 @@ export interface LocalRecallDiagnostics {
19
19
  error?: string;
20
20
  /** The store held more records of a kind than one recall reads; the rest were not considered. */
21
21
  truncated?: boolean;
22
+ /** A trial draft this recall would have returned, held back so the turn can serve as its control. */
23
+ trial_withheld?: {
24
+ asset_id: string;
25
+ withheld_id?: string;
26
+ };
22
27
  }
23
28
  export interface LocalRecallOutcome {
24
29
  assets: assetstore.AssetRecord[];
@@ -33,5 +38,5 @@ interface LocalRecallRead {
33
38
  * when that history changed. */
34
39
  export declare function rootEventReuseTallies(path?: string): ReuseTallies;
35
40
  /** 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>;
41
+ export declare function recallFromLocalStore(store: assetstore.AssetStoreProvider, text: string, projectDir: unknown, onWithheld?: (assetId: string) => string | undefined): Promise<LocalRecallRead>;
37
42
  export {};
@@ -1,4 +1,5 @@
1
- import { assetstore, events, ops } from '@evomap/evolver-core';
1
+ import { assetstore, events, hub, ops } from '@evomap/evolver-core';
2
+ import { isTrialHoldout } from './distillMeasures.js';
2
3
  const MAX_LOCAL_RECALL_RECORDS = 20_000;
3
4
  // Passing the local strength gate is already the evidence; the floor keeps a local hit above the host's own
4
5
  // similarity cut (0.3) and comparable with the Hub's scores, which the host ranks the merged candidates by.
@@ -71,6 +72,14 @@ function recalledAsset(hit, trial) {
71
72
  },
72
73
  };
73
74
  }
75
+ /** A project-bound Gene is recalled only in the project one of its Capsules was distilled in. */
76
+ function isBoundHere(gene, capsules, fingerprint) {
77
+ if (!fingerprint)
78
+ return false;
79
+ const geneId = String(gene['id'] ?? gene.asset_id);
80
+ return capsules.some((capsule) => capsule['gene'] === geneId
81
+ && capsule['content']?.project_fingerprint === fingerprint);
82
+ }
74
83
  /** Quarantined drafts that may be tried once: every other gate still applies, and two failures end the trial. */
75
84
  function trialPool(genes, capsules, eligibility) {
76
85
  const onTrial = genes.filter((gene) => eligibility.review.get(gene.asset_id)?.state === 'quarantined');
@@ -103,7 +112,7 @@ function diagnosticsOf(result) {
103
112
  };
104
113
  }
105
114
  /** The local Gene, with its project's notes, that this prompt should get from the local store, or none. */
106
- export async function recallFromLocalStore(store, text, projectDir) {
115
+ export async function recallFromLocalStore(store, text, projectDir, onWithheld = () => undefined) {
107
116
  const [geneRead, capsuleRead] = await Promise.allSettled([
108
117
  Promise.resolve().then(() => store.list('Gene', MAX_LOCAL_RECALL_RECORDS + 1)),
109
118
  Promise.resolve().then(() => store.list('Capsule', MAX_LOCAL_RECALL_RECORDS + 1)),
@@ -133,15 +142,24 @@ export async function recallFromLocalStore(store, text, projectDir) {
133
142
  const rawAssets = new Map(result.hits.map((hit) => [recalledAsset(hit, trial), hit.gene]));
134
143
  return { assets: [...rawAssets.keys()], rawAssets, diagnostics: { ...diagnosticsOf(result), ...(truncated ? { truncated } : {}) } };
135
144
  };
145
+ const inScope = genes.filter((gene) => !hub.isProjectBoundGene(gene) || isBoundHere(gene, capsules, query.projectFingerprint));
136
146
  return { finish: (eligibility, reuse) => {
137
- const qualified = [...genes, ...capsules].filter((asset) => assetstore.assetContextEligibilityReason(asset, eligibility) === undefined);
147
+ const qualified = [...inScope, ...capsules].filter((asset) => assetstore.assetContextEligibilityReason(asset, eligibility) === undefined);
138
148
  const result = assetstore.recallLocalAssets(qualified, query, reuse, contexts);
139
149
  if (result.hits.length > 0)
140
150
  return outcomeOf(result, false);
141
- const trial = trialPool(genes, capsules, eligibility);
151
+ const trial = trialPool(inScope, capsules, eligibility);
142
152
  if (trial.length === 0)
143
153
  return outcomeOf(result, false);
144
154
  const trialResult = assetstore.recallLocalAssets(trial, { ...query, limit: 1 }, reuse, contexts);
145
- return trialResult.hits.length > 0 ? outcomeOf(trialResult, true) : outcomeOf(result, false);
155
+ const drafted = trialResult.hits[0]?.gene;
156
+ if (!drafted)
157
+ return outcomeOf(result, false);
158
+ if (!isTrialHoldout(String(drafted['id'] ?? drafted.asset_id), text))
159
+ return outcomeOf(trialResult, true);
160
+ const withheldId = onWithheld(drafted.asset_id);
161
+ const withheld = outcomeOf(result, false);
162
+ const named = { asset_id: drafted.asset_id, ...(withheldId ? { withheld_id: withheldId } : {}) };
163
+ return { ...withheld, diagnostics: { ...withheld.diagnostics, trial_withheld: named } };
146
164
  } };
147
165
  }
@@ -14,6 +14,8 @@ export declare const DEFAULT_IPC_PORT = 19820;
14
14
  export type HubAuthFailurePolicy = 'deny' | 'warn';
15
15
  export declare function resolveHubAuthFailurePolicy(env?: Record<string, string | undefined>): HubAuthFailurePolicy;
16
16
  export interface ProxyDaemonDeps {
17
+ /** The host agents and plugins served lately; each request's `x-evomap-client-*` headers update it. */
18
+ recentClients?: hubNs.RecentClients;
17
19
  triggerFeedback?: import('@evomap/evolver-core').exec.TriggerFeedbackLocalFacade;
18
20
  recipeExecutionDirectory?: string;
19
21
  /** operator配置,不能由单次搜索请求关闭。 */
@@ -214,8 +216,11 @@ export declare class ProxyDaemon {
214
216
  private wakeRunnerPending;
215
217
  private started;
216
218
  private readonly verificationContexts;
219
+ private readonly distillOutcomes;
220
+ private readonly trialControls;
217
221
  private lastRouteAt;
218
222
  private curationTimer;
223
+ private lastCurationAt;
219
224
  private curationRunning;
220
225
  private feedbackRecovery;
221
226
  private lifecycleArmed;
@@ -246,8 +251,11 @@ export declare class ProxyDaemon {
246
251
  start(): Promise<number>;
247
252
  private scheduleCuration;
248
253
  private curateWhenIdle;
254
+ private publishMode;
249
255
  private enqueueVerifiedDistillation;
250
256
  private trackStoredDraft;
257
+ /** The control arm of a trial draft: a turn that ran its checks with the draft withheld. */
258
+ private recordTrialControl;
251
259
  private enqueueDistillPublication;
252
260
  private registerDistillPublication;
253
261
  private distillPublicationEnvelope;
@@ -301,6 +309,7 @@ export declare class ProxyDaemon {
301
309
  private localRecall;
302
310
  private localFetchAssets;
303
311
  private feedbackNodeId;
312
+ private asRequestClient;
304
313
  private handleProxyRoute;
305
314
  private searchAssets;
306
315
  private searchRemoteAssets;