@evomap/evolver-cli 2.0.0-beta.8 → 2.0.0

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 (91) hide show
  1. package/dist/antiGeneBenchmark.js +2 -0
  2. package/dist/antiGeneRollout.js +9 -3
  3. package/dist/assetHealth.js +2 -0
  4. package/dist/assetTrust.js +14 -1
  5. package/dist/atp.d.ts +10 -5
  6. package/dist/atp.js +119 -26
  7. package/dist/atpAutoBuyer.d.ts +120 -0
  8. package/dist/atpAutoBuyer.js +814 -0
  9. package/dist/atpAutoDeliver.js +2 -2
  10. package/dist/autoDistillLlm.js +2 -1
  11. package/dist/autoDistillTranscript.js +3 -2
  12. package/dist/autoexec.d.ts +101 -13
  13. package/dist/autoexec.js +794 -91
  14. package/dist/cli.js +13 -0
  15. package/dist/cliContracts.d.ts +23 -2
  16. package/dist/cliContracts.js +504 -54
  17. package/dist/commands.d.ts +1 -0
  18. package/dist/commands.js +1 -0
  19. package/dist/curriculumCapabilityGaps.d.ts +6 -0
  20. package/dist/curriculumCapabilityGaps.js +24 -0
  21. package/dist/cycleConsumer.d.ts +13 -0
  22. package/dist/cycleConsumer.js +186 -20
  23. package/dist/dashboard.js +47 -9
  24. package/dist/dispatch.js +8 -2
  25. package/dist/distillAdmission.d.ts +13 -0
  26. package/dist/distillAdmission.js +35 -0
  27. package/dist/distillObserver.js +4 -6
  28. package/dist/distillPrimitives.d.ts +11 -12
  29. package/dist/distillPrimitives.js +115 -21
  30. package/dist/doctor.js +120 -11
  31. package/dist/identityHome.d.ts +9 -0
  32. package/dist/identityHome.js +47 -0
  33. package/dist/index.d.ts +70 -40
  34. package/dist/index.js +586 -200
  35. package/dist/learningTrace.d.ts +15 -0
  36. package/dist/learningTrace.js +73 -0
  37. package/dist/lifecycle.d.ts +67 -1
  38. package/dist/lifecycle.js +738 -44
  39. package/dist/localMemoryGraph.d.ts +90 -3
  40. package/dist/localMemoryGraph.js +2031 -231
  41. package/dist/login.d.ts +1 -1
  42. package/dist/login.js +3 -3
  43. package/dist/materialPackage.js +3 -6
  44. package/dist/materialSnapshot.d.ts +9 -1
  45. package/dist/materialSnapshot.js +23 -6
  46. package/dist/memoryGraphOps.d.ts +8 -0
  47. package/dist/memoryGraphOps.js +140 -0
  48. package/dist/migrate/assetFormatMap.d.ts +61 -0
  49. package/dist/migrate/assetFormatMap.js +53 -0
  50. package/dist/migrate/envTranslate.d.ts +26 -0
  51. package/dist/migrate/envTranslate.js +147 -0
  52. package/dist/migrate/fieldMap.d.ts +4 -2
  53. package/dist/migrate/fieldMap.js +9 -5
  54. package/dist/migrate/oauthImport.d.ts +66 -0
  55. package/dist/migrate/oauthImport.js +667 -0
  56. package/dist/migrate/v1Import.d.ts +92 -1
  57. package/dist/migrate/v1Import.js +1481 -141
  58. package/dist/promptRecallHook.d.ts +24 -0
  59. package/dist/promptRecallHook.js +425 -0
  60. package/dist/recallVerifyReport.d.ts +37 -0
  61. package/dist/recallVerifyReport.js +244 -0
  62. package/dist/recipe.d.ts +7 -1
  63. package/dist/recipe.js +426 -56
  64. package/dist/requiredSandboxValidation.d.ts +5 -0
  65. package/dist/requiredSandboxValidation.js +4 -0
  66. package/dist/reuse.d.ts +9 -0
  67. package/dist/reuse.js +159 -58
  68. package/dist/runtimeCapabilities.js +15 -15
  69. package/dist/runtimeSessionSource.d.ts +3 -2
  70. package/dist/runtimeSessionSource.js +63 -11
  71. package/dist/selectionPolicyConfig.d.ts +8 -0
  72. package/dist/selectionPolicyConfig.js +18 -0
  73. package/dist/semanticIdfConfig.d.ts +2 -0
  74. package/dist/semanticIdfConfig.js +4 -0
  75. package/dist/sessionIngest.d.ts +37 -0
  76. package/dist/sessionIngest.js +156 -0
  77. package/dist/setupHooks.js +95 -1
  78. package/dist/skill2gep.d.ts +13 -9
  79. package/dist/skill2gep.js +42 -30
  80. package/dist/skillDistill.d.ts +8 -4
  81. package/dist/skillDistill.js +38 -9
  82. package/dist/solo/mode.js +1 -0
  83. package/dist/sync.d.ts +12 -0
  84. package/dist/sync.js +1246 -151
  85. package/dist/thesis.d.ts +1 -1
  86. package/dist/thesis.js +20 -3
  87. package/dist/trajectoryExport.js +21 -3
  88. package/dist/v1Compat.d.ts +1 -0
  89. package/dist/v1Compat.js +9 -0
  90. package/dist/workflowRuntime.js +24 -18
  91. package/package.json +11 -8
@@ -1,9 +1,10 @@
1
1
  import { algo, type signals } from '@evomap/evolver-core';
2
2
  import type { NormalizedTurn } from '@evomap/evolver-runtime-adapters';
3
- /** Short matchable signal tokens from the STRONG signals only (toolName + a known error class). Every strong
4
- * signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
3
+ /** Short matchable signal tokens from STRONG signals (error classes) and SUCCESS signals (verified capabilities).
4
+ * Every strong signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
5
5
  * `Error: connection refused`), it falls back to its kind (`structured_error`/`error_result`) so a real strong
6
6
  * signal is never silently tokenless — keeping `signals_match.length === 0` an honest "no strong signal" gate.
7
+ * Success signals (#578) also produce tokens so a purely successful session can yield a matchable gene.
7
8
  * Deduped, ≤8. */
8
9
  export declare function signalTokens(sigs: readonly signals.ExtractedSignal[]): string[];
9
10
  /** Draft strategy steps = the agent's own substantive (non-meta) turns — boundary-trimmed (never chopped
@@ -30,11 +31,9 @@ export interface DraftAdmissionOptions {
30
31
  /** Reject a draft with fewer strategy steps than this (default 1, i.e. just non-empty like intakeGene; raise it
31
32
  * for a stricter substance floor). A real fix can be one concrete step, so the default does not over-filter. */
32
33
  minStrategy?: number;
33
- /** Reject a draft whose signal-set Jaccard similarity to ANY existing gene is >= this (default 0.6).
34
- * Signal sets are capped at 8 tokens, so two same-size sets differing by ONE token score 7/9 ≈ 0.78 —
35
- * the old 0.8 default could never fire on the dominant draft shape (#562: 118-draft flood, max pairwise
36
- * similarity exactly 0.78, zero rejections). 0.6 rejects shared-core near-dupes while genuinely
37
- * cross-domain drafts (less than half the tokens shared) still pass. */
34
+ /** Reject a draft whose discriminating-signal Jaccard similarity to ANY existing gene is >= this (default 0.6).
35
+ * Generated fallback markers and generic command runners are omitted from this SOFT comparison, while the
36
+ * exact-subset check still uses the complete signal sets. */
38
37
  maxSimilarity?: number;
39
38
  }
40
39
  export interface DraftAdmission {
@@ -43,10 +42,10 @@ export interface DraftAdmission {
43
42
  }
44
43
  /**
45
44
  * Value/novelty gate run BEFORE a draft is quarantined (#117 improvement 3). `intakeGene` already rejects
46
- * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps), but two kinds of noise still
47
- * reach the human review queue: drafts too thin to be worth reviewing (one weak signal, one vague step), and
48
- * near-duplicates that escape the subset check by carrying one extra signal. Unattended auto-distill turns that
49
- * trickle into a flood, and a review gate nobody reads is no gate. This adds a substance floor + a SOFT similarity
50
- * reject. Pure and deterministic; the caller decides what to do with a non-admit (skip, never an error).
45
+ * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps). Admission mirrors that subset
46
+ * check so a duplicate is a per-candidate skip instead of aborting a whole batch, then adds the two missing noise
47
+ * controls: a substance floor and a SOFT near-duplicate comparison. Unattended auto-distill turns that trickle
48
+ * into a flood, and a review gate nobody reads is no gate. Pure and deterministic; the caller decides what to do
49
+ * with a non-admit (skip, never an error).
51
50
  */
52
51
  export declare function assessDraftAdmission(candidate: algo.GeneCandidate, existing?: readonly ExistingGeneSignals[], opts?: DraftAdmissionOptions): DraftAdmission;
@@ -2,7 +2,7 @@
2
2
  // `evolver ingest --distill` and the live distillObserver reuse ONE copy (no forked distill logic). Zero behavior
3
3
  // change vs the inline version: same tokens, same step drafting, same candidate shape. No I/O — the caller parses
4
4
  // the session into turns + extracts signals; this turns them into a draft GeneCandidate (or null when too thin).
5
- import { algo } from '@evomap/evolver-core';
5
+ import { algo, hub } from '@evomap/evolver-core';
6
6
  // Map a strong signal's free-text to a SHORT, matchable token (so a gene's signals_match stays a few
7
7
  // keywords, not a dumped error blob). Deterministic + testable; unknown errors fall back to the tool name only.
8
8
  const SIGNAL_ERROR_CLASSES = [
@@ -14,10 +14,11 @@ const SIGNAL_ERROR_CLASSES = [
14
14
  [/permission denied/i, 'permission-denied'],
15
15
  [/timed?\s?out/i, 'timeout'],
16
16
  ];
17
- /** Short matchable signal tokens from the STRONG signals only (toolName + a known error class). Every strong
18
- * signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
17
+ /** Short matchable signal tokens from STRONG signals (error classes) and SUCCESS signals (verified capabilities).
18
+ * Every strong signal yields ≥1 token: if it has no toolName and matches no known error class (e.g. `FAILED: …` or
19
19
  * `Error: connection refused`), it falls back to its kind (`structured_error`/`error_result`) so a real strong
20
20
  * signal is never silently tokenless — keeping `signals_match.length === 0` an honest "no strong signal" gate.
21
+ * Success signals (#578) also produce tokens so a purely successful session can yield a matchable gene.
21
22
  * Deduped, ≤8. */
22
23
  export function signalTokens(sigs) {
23
24
  const set = new Set();
@@ -38,6 +39,22 @@ export function signalTokens(sigs) {
38
39
  if (!matched)
39
40
  set.add(s.kind);
40
41
  }
42
+ // A later failure invalidates an earlier successful intermediate command. Conversely, fail-then-pass remains a
43
+ // valid repair history because the last deterministic outcome is the verified success.
44
+ const lastOutcome = sigs.findLast((s) => s.strength === 'strong' || s.strength === 'weak' || (s.strength === 'success' && !s.needsAnalysis));
45
+ const terminalSuccess = lastOutcome?.strength === 'success' && !lastOutcome.needsAnalysis;
46
+ // Only confirmed terminal success enters the deterministic path. Prose marked needsAnalysis is left to transcript
47
+ // LLM distillation instead of triggering a material cycle before analysis has happened.
48
+ for (const s of terminalSuccess ? sigs : []) {
49
+ if (s.strength !== 'success' || s.needsAnalysis)
50
+ continue;
51
+ if (s.toolName)
52
+ set.add(s.toolName);
53
+ if (s.kind === 'verified_success')
54
+ set.add('verified-success');
55
+ else
56
+ set.add(s.kind);
57
+ }
41
58
  return [...set].slice(0, 8);
42
59
  }
43
60
  /** Trim free text to a clean step: collapse whitespace, and when longer than `cap` keep as much as fits, cutting
@@ -57,8 +74,24 @@ const NARRATION_OPENER = /^(let me (take a (closer )?)?look|let me (check|see|in
57
74
  * that opens with narration is dropped ONLY when it has none of these — so "let me check … the root cause is X,
58
75
  * fix by Y" keeps its substantive remainder rather than being discarded for its opener. */
59
76
  const HAS_SUBSTANCE = /\b(because|so that|root cause|the (issue|bug|problem|fix|error)|fix(ed|es|ing)?|add(ed|ing)?|remov(e|ed|ing)|delet(e|ed|ing)|chang(e|ed|ing)?|updat(e|ed|ing)?|replac(e|ed|ing)?|renam(e|ed|ing)?|implement(ed|ing)?|revert(ed)?|switch(ed|ing)?|configur(e|ed|ing)?|install(ed|ing)?|return(s|ed)?|throw(s|n)?|catch|wrap(ped)?|guard|import(ed|s)?|export(ed|s)?|re-?run|retry|set\s)\b/i;
77
+ const HAS_CJK_TEXT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u;
78
+ // Require whitespace after ASCII punctuation unless CJK starts immediately, so dots in paths stay intact.
79
+ const NARRATION_SENTENCE_END = /^.*?(?:[.!?](?:\s+|(?=[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]))|[。!?]\s*)/u;
80
+ function narrationRemainder(raw) {
81
+ const boundary = NARRATION_SENTENCE_END.exec(raw);
82
+ if (!boundary)
83
+ return undefined;
84
+ const rest = raw.slice(boundary[0].length).trim();
85
+ return rest.length >= 40 ? rest : undefined;
86
+ }
60
87
  function isNarrationOnly(raw) {
61
- return NARRATION_OPENER.test(raw) && !HAS_SUBSTANCE.test(raw) && !/[`]|[\w/-]+\.[a-z]{2,5}\b|\/[\w./-]+/.test(raw);
88
+ if (!NARRATION_OPENER.test(raw))
89
+ return false;
90
+ const rest = narrationRemainder(raw);
91
+ const hasCjkRemainder = rest !== undefined && HAS_CJK_TEXT.test(rest);
92
+ return !hasCjkRemainder
93
+ && !HAS_SUBSTANCE.test(raw)
94
+ && !/[`]|[\w/-]+\.[a-z]{2,5}\b|\/[\w./-]+/.test(raw);
62
95
  }
63
96
  /** When a turn opens with narration but states real substance, drop the leading narration sentence so the step
64
97
  * LEADS with the cause/fix — otherwise the (capped) step could be narration while the substance is trimmed off.
@@ -66,11 +99,7 @@ function isNarrationOnly(raw) {
66
99
  function dropNarrationOpener(raw) {
67
100
  if (!NARRATION_OPENER.test(raw))
68
101
  return raw;
69
- const m = /^.*?[.!?。]\s+/.exec(raw);
70
- if (!m)
71
- return raw;
72
- const rest = raw.slice(m[0].length).trim();
73
- return rest.length >= 40 ? rest : raw;
102
+ return narrationRemainder(raw) ?? raw;
74
103
  }
75
104
  /** Draft strategy steps = the agent's own substantive (non-meta) turns — boundary-trimmed (never chopped
76
105
  * mid-word); turns that are PURELY narration ("let me look around" with no cause/action) are dropped, and a
@@ -83,7 +112,7 @@ export function draftStrategy(turns) {
83
112
  for (const t of turns) {
84
113
  if (t.role !== 'assistant' || t.isMeta)
85
114
  continue;
86
- const raw = (t.text ?? '').replace(/\s+/g, ' ').trim();
115
+ const raw = hub.redactString(t.text ?? '').replace(/\s+/g, ' ').trim();
87
116
  if (raw.length < 40)
88
117
  continue; // too short to be a step
89
118
  if (isNarrationOnly(raw))
@@ -96,6 +125,17 @@ export function draftStrategy(turns) {
96
125
  }
97
126
  return steps.slice(-6); // the latest substantive actions (closest to the resolution)
98
127
  }
128
+ const GENERIC_SUCCESS_TOPICS = new Set([
129
+ 'added', 'adjusted', 'assistant', 'change', 'changed', 'changes', 'command', 'commands', 'complete',
130
+ 'completed', 'coverage', 'fixed', 'handling', 'implementation', 'passed', 'passing', 'regression', 'result',
131
+ 'results', 'successful', 'successfully', 'tests', 'updated', 'validation', 'verified',
132
+ ]);
133
+ function successTopicSignals(strategy) {
134
+ const text = strategy.join(' ');
135
+ return hub.extractTopicKeywords(text, undefined, 24, { minOccurrences: 1, preserveSourceOrder: true })
136
+ .filter((topic) => !GENERIC_SUCCESS_TOPICS.has(topic))
137
+ .slice(0, 4);
138
+ }
99
139
  /**
100
140
  * Assemble an UNPROVEN draft GeneCandidate from a parsed session, or null when too thin to distill (no strong
101
141
  * signal OR no substantive step). The single source of the "what makes a draftable session" gate + candidate
@@ -105,10 +145,36 @@ export function draftStrategy(turns) {
105
145
  export function draftGeneCandidate(turns, sigs, agent) {
106
146
  const signals_match = signalTokens(sigs);
107
147
  const strategy = draftStrategy(turns);
108
- if (signals_match.length === 0 || strategy.length === 0) {
148
+ const hadVerifiedSuccess = sigs.some((s) => s.strength === 'success' && !s.needsAnalysis);
149
+ const hasTerminalVerifiedSuccess = signals_match.includes('verified-success');
150
+ // 当只有成功信号(没有错误信号)时,走 innovate 路径而非 repair (#578):
151
+ // 一次成功的问题解决过程不应被分类为 repair —— 它是一个可复用的成功能力。
152
+ const hasStrongError = sigs.some((s) => s.strength === 'strong');
153
+ if (signals_match.length === 0 || strategy.length === 0 || !hasStrongError) {
154
+ // Do not let the capability sniffer resurrect a success that a later unresolved outcome already superseded.
155
+ if (hadVerifiedSuccess && !hasTerminalVerifiedSuccess && !hasStrongError)
156
+ return null;
109
157
  const hit = algo.sniffConversationCapabilities(turns)[0];
110
- if (!hit)
158
+ if (!hit) {
159
+ // Sniffer 也未命中:如果有 success 信号和 strategy(仅当 hasStrongError 为 false 才走到这里且 signals_match 非空),
160
+ // 仍然产出 gene,但标记为 innovate —— 这是一个被验证的能力,而非错误修复。
161
+ if (signals_match.length > 0 && strategy.length > 0) {
162
+ const topics = successTopicSignals(strategy);
163
+ // Generic runner + success tokens are not a reusable capability identity. Let the optional transcript-LLM
164
+ // path handle prose that has no safe discriminating topic instead of storing one global shell-success gene.
165
+ if (topics.length === 0)
166
+ return null;
167
+ const successSignals = [...new Set([...signals_match, ...topics])].slice(0, 8);
168
+ return {
169
+ category: 'innovate',
170
+ signals_match: successSignals,
171
+ strategy,
172
+ summary: `Auto-drafted from ${agent} session (UNPROVEN — curate via review): ${topics.slice(0, 3).join(', ')}`,
173
+ generation_meta: { source: 'distilled' },
174
+ };
175
+ }
111
176
  return null;
177
+ }
112
178
  const fallbackStrategy = hit.evidence;
113
179
  if (fallbackStrategy.length === 0)
114
180
  return null;
@@ -136,19 +202,42 @@ export function draftGeneCandidate(turns, sigs, agent) {
136
202
  generation_meta: { source: 'distilled' },
137
203
  };
138
204
  }
205
+ // Signals injected by the fallback itself, plus generic command runners, carry no domain identity. Including them
206
+ // in Jaccard makes unrelated capabilities (for example GitHub vs Playwright) look 60% identical even though their
207
+ // one discriminating signal differs. Keep them for exact-subset detection, but omit them from soft similarity.
208
+ const GENERIC_NOVELTY_SIGNALS = new Set([
209
+ 'reusable_capability',
210
+ 'verified_workflow',
211
+ 'shell_command',
212
+ 'bash',
213
+ 'powershell',
214
+ 'pwsh',
215
+ 'sh',
216
+ 'cmd',
217
+ 'command',
218
+ 'verified-success',
219
+ 'verified_success',
220
+ ]);
221
+ function normalizeSignalSet(values) {
222
+ return new Set((values ?? []).map((value) => String(value).trim().toLowerCase()).filter(Boolean));
223
+ }
224
+ function noveltySignalSet(signals) {
225
+ const discriminating = [...signals].filter((signal) => !GENERIC_NOVELTY_SIGNALS.has(signal));
226
+ return discriminating.length > 0 ? new Set(discriminating) : signals;
227
+ }
139
228
  /**
140
229
  * Value/novelty gate run BEFORE a draft is quarantined (#117 improvement 3). `intakeGene` already rejects
141
- * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps), but two kinds of noise still
142
- * reach the human review queue: drafts too thin to be worth reviewing (one weak signal, one vague step), and
143
- * near-duplicates that escape the subset check by carrying one extra signal. Unattended auto-distill turns that
144
- * trickle into a flood, and a review gate nobody reads is no gate. This adds a substance floor + a SOFT similarity
145
- * reject. Pure and deterministic; the caller decides what to do with a non-admit (skip, never an error).
230
+ * empty/structurally-invalid candidates and EXACT signal subsets (fullyOverlaps). Admission mirrors that subset
231
+ * check so a duplicate is a per-candidate skip instead of aborting a whole batch, then adds the two missing noise
232
+ * controls: a substance floor and a SOFT near-duplicate comparison. Unattended auto-distill turns that trickle
233
+ * into a flood, and a review gate nobody reads is no gate. Pure and deterministic; the caller decides what to do
234
+ * with a non-admit (skip, never an error).
146
235
  */
147
236
  export function assessDraftAdmission(candidate, existing = [], opts = {}) {
148
237
  const minSignals = opts.minSignals ?? 2;
149
238
  const minStrategy = opts.minStrategy ?? 1;
150
239
  const maxSimilarity = opts.maxSimilarity ?? 0.6;
151
- const sigs = [...new Set((candidate.signals_match ?? []).map((s) => String(s).toLowerCase()).filter(Boolean))];
240
+ const sigs = [...normalizeSignalSet(candidate.signals_match)];
152
241
  const strategy = (candidate.strategy ?? []).filter((s) => String(s).trim());
153
242
  if (sigs.length < minSignals)
154
243
  return { admit: false, reason: `too few signals (${sigs.length} < ${minSignals})` };
@@ -156,11 +245,16 @@ export function assessDraftAdmission(candidate, existing = [], opts = {}) {
156
245
  return { admit: false, reason: `strategy too thin (${strategy.length} < ${minStrategy} steps)` };
157
246
  const newSet = new Set(sigs);
158
247
  for (const eg of existing) {
159
- const egSet = new Set((eg.signals_match ?? []).map((s) => String(s).toLowerCase()).filter(Boolean));
248
+ const egSet = normalizeSignalSet(eg.signals_match);
160
249
  if (egSet.size === 0)
161
250
  continue;
162
- const inter = [...newSet].filter((s) => egSet.has(s)).length;
163
- const union = new Set([...newSet, ...egSet]).size;
251
+ if ([...newSet].every((signal) => egSet.has(signal))) {
252
+ return { admit: false, reason: `near-duplicate of ${eg.id ?? '?'} (candidate signal subset)` };
253
+ }
254
+ const comparableNew = noveltySignalSet(newSet);
255
+ const comparableExisting = noveltySignalSet(egSet);
256
+ const inter = [...comparableNew].filter((s) => comparableExisting.has(s)).length;
257
+ const union = new Set([...comparableNew, ...comparableExisting]).size;
164
258
  const jaccard = union ? inter / union : 0;
165
259
  if (jaccard >= maxSimilarity)
166
260
  return { admit: false, reason: `near-duplicate of ${eg.id ?? '?'} (similarity ${jaccard.toFixed(2)})` };
package/dist/doctor.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // (heartbeat, proxy path) touch the proxy and are a SEPARATE, gated step — not here.
5
5
  import { readFileSync, existsSync, statSync } from 'node:fs';
6
6
  import { isAbsolute, join } from 'node:path';
7
- import { events, issueReporter } from '@evomap/evolver-core';
7
+ import { bootstrap, events, issueReporter } from '@evomap/evolver-core';
8
8
  import { expandHomePath, parseEnvFile } from '@evomap/evolver-mcp';
9
9
  import { formatMemoryGraphOperatorStatus, loadMemoryGraphOperatorStatus } from './localMemoryGraph.js';
10
10
  // Secrets that must live ONLY behind the EVOLVER_ENV_FILE pointer — never inlined into a runtime config (#217).
@@ -109,10 +109,18 @@ const ENV_CATALOG_DEFINITIONS = [
109
109
  defaultValue: 'unset',
110
110
  },
111
111
  {
112
- name: 'EVOLVER_HEARTBEAT_MS',
112
+ name: 'HEARTBEAT_INTERVAL_MS',
113
113
  group: 'hub-runtime',
114
- purpose: 'Proxy heartbeat interval.',
114
+ purpose: 'Proxy heartbeat interval for the Hub lifecycle manager.',
115
115
  requiredFor: 'proxy daemon heartbeat tuning',
116
+ defaultValue: '360000',
117
+ },
118
+ {
119
+ name: 'EVOLVER_HEARTBEAT_MS',
120
+ group: 'observability',
121
+ purpose: 'Interval for autoexec cycle.heartbeat observability events.',
122
+ requiredFor: 'autoexec heartbeat log tuning',
123
+ defaultValue: '60000',
116
124
  },
117
125
  {
118
126
  name: 'EVOLVER_PROXY_URL',
@@ -162,6 +170,20 @@ const ENV_CATALOG_DEFINITIONS = [
162
170
  requiredFor: 'reuse ranking tuning',
163
171
  defaultValue: 'enabled unless set to 0',
164
172
  },
173
+ {
174
+ name: 'EVOLVER_SEMANTIC_IDF',
175
+ group: 'autoexec-selection',
176
+ purpose: 'Emergency rollback for trusted-corpus IDF semantic weighting.',
177
+ requiredFor: 'selection ranking rollout',
178
+ defaultValue: 'enabled unless set to 0',
179
+ },
180
+ {
181
+ name: 'EVOLVER_SELECTION_POLICY',
182
+ group: 'autoexec-selection',
183
+ purpose: 'Controls plateau exploration: engine-health, UCB1 shadow, or explicit UCB1 canary.',
184
+ requiredFor: 'selection exploration rollout',
185
+ defaultValue: 'engine-health',
186
+ },
165
187
  {
166
188
  name: 'EVOLVER_REUSE_MODE',
167
189
  group: 'autoexec-reuse',
@@ -181,9 +203,15 @@ const ENV_CATALOG_DEFINITIONS = [
181
203
  requiredFor: 'probation rollout',
182
204
  defaultValue: '0',
183
205
  },
206
+ {
207
+ name: 'EVOLVER_AUTO_DISTILL',
208
+ group: 'distill',
209
+ purpose: 'Controls structural distillation from completed evolution cycles.',
210
+ requiredFor: 'structural gene distill',
211
+ defaultValue: 'enabled unless set to 0',
212
+ },
184
213
  {
185
214
  name: 'EVOLVER_AUTO_DISTILL_LLM',
186
- aliases: ['EVOLVER_AUTO_DISTILL'],
187
215
  group: 'distill',
188
216
  purpose: 'Enables LLM distillation from successful capsules.',
189
217
  requiredFor: 'online gene distill',
@@ -286,8 +314,9 @@ const ENV_CATALOG_DEFINITIONS = [
286
314
  {
287
315
  name: 'EVOLVER_SESSION_SOURCE',
288
316
  group: 'trajectory-export',
289
- purpose: 'Runtime session source selector.',
290
- requiredFor: 'runtime adapter filtering',
317
+ purpose: 'Legacy V1 session collector selector; ignored by V2 runtime behavior, detected only for migration, and has no one-to-one replacement.',
318
+ requiredFor: 'none; review explicit runtime discovery or transcript directories before removing',
319
+ defaultValue: 'ignored',
291
320
  },
292
321
  {
293
322
  name: 'EVOLVER_TRAJECTORY_INCLUDE_UNMARKED',
@@ -379,9 +408,9 @@ const ENV_CATALOG_DEFINITIONS = [
379
408
  {
380
409
  name: 'EVOLVER_ATP',
381
410
  group: 'marketplace-atp',
382
- purpose: 'Controls ATP marketplace/payment feature surface.',
383
- requiredFor: 'ATP flows',
384
- defaultValue: 'off unless explicitly enabled',
411
+ purpose: 'Legacy V1 merchant-agent mode; ignored by V2 runtime behavior, detected only for migration, and must not be mapped to buyer auto-spend consent.',
412
+ requiredFor: 'none; review the missing merchant workflow before removing',
413
+ defaultValue: 'ignored',
385
414
  },
386
415
  {
387
416
  name: 'EVOLVER_ATP_AUTOBUY',
@@ -390,12 +419,26 @@ const ENV_CATALOG_DEFINITIONS = [
390
419
  requiredFor: 'operator-approved ATP automation',
391
420
  defaultValue: 'off',
392
421
  },
422
+ {
423
+ name: 'ATP_AUTOBUY_DAILY_CAP_CREDITS',
424
+ group: 'marketplace-atp',
425
+ purpose: 'Hard UTC-day spending cap for automatic ATP purchases.',
426
+ requiredFor: 'ATP auto-buyer budget control',
427
+ defaultValue: '50',
428
+ },
429
+ {
430
+ name: 'ATP_AUTOBUY_PER_ORDER_CAP_CREDITS',
431
+ group: 'marketplace-atp',
432
+ purpose: 'Hard per-order spending cap for automatic ATP purchases.',
433
+ requiredFor: 'ATP auto-buyer budget control',
434
+ defaultValue: '10',
435
+ },
393
436
  {
394
437
  name: 'EVOLVER_ATP_AUTODELIVER',
395
438
  group: 'marketplace-atp',
396
439
  purpose: 'Controls automatic ATP delivery behavior.',
397
440
  requiredFor: 'operator-approved ATP automation',
398
- defaultValue: 'off',
441
+ defaultValue: 'on (opt-out)',
399
442
  },
400
443
  {
401
444
  name: 'EVOLVER_LIFECYCLE_COMMAND',
@@ -426,13 +469,35 @@ const ENV_CATALOG_DEFINITIONS = [
426
469
  group: 'self-update',
427
470
  purpose: 'Controls self-update behavior.',
428
471
  requiredFor: 'operator-controlled proxy update rollout',
429
- defaultValue: 'off unless explicitly enabled',
472
+ defaultValue: 'auto unless explicitly disabled (gated by supervisor attestation; default auto degrades to off without it, after a one-shot first-run bootstrap attempt)',
473
+ },
474
+ {
475
+ name: 'EVOLVER_SELF_BOOTSTRAP',
476
+ group: 'self-update',
477
+ purpose: 'Kill switch for the first-run supervision bootstrap of unsupervised startups.',
478
+ requiredFor: 'opting out of automatic service registration',
479
+ defaultValue: 'on (exact 0 or off disables)',
480
+ },
481
+ {
482
+ name: 'EVOLVER_BOOTSTRAP_MIGRATION',
483
+ group: 'self-update',
484
+ purpose: 'Kill switch for the one-time npm/JS → standalone binary migration attempted by unsupervised startups.',
485
+ requiredFor: 'opting out of automatic standalone binary migration',
486
+ defaultValue: 'on (exact 0 or off disables)',
487
+ },
488
+ {
489
+ name: 'EVOLVER_BOOTSTRAP_MIGRATION_VERSION',
490
+ group: 'self-update',
491
+ purpose: 'Target version override for the one-time standalone binary migration.',
492
+ requiredFor: 'pinning the migrated standalone binary version',
493
+ defaultValue: 'current package version',
430
494
  },
431
495
  {
432
496
  name: 'EVOLVER_SELF_UPDATE_PUBLIC_KEY',
433
497
  group: 'self-update',
434
498
  purpose: 'Public key used to verify self-update artifacts.',
435
499
  requiredFor: 'self-update verification',
500
+ defaultValue: 'built-in official v2-beta release key',
436
501
  },
437
502
  {
438
503
  name: 'EVOLVER_SELF_UPDATE_SUPERVISOR',
@@ -458,6 +523,9 @@ const POINTER_RE = /EVOLVER_ENV_FILE"?\s*[:=]\s*"([^"]+)"/;
458
523
  /** Loopback hosts a NO_PROXY entry must EXACTLY be to cover local IPC/proxy ('*' = bypass all). Exact-entry match,
459
524
  * not substring, so `127.0.0.10` / `notlocalhost.com` do not count (#279 Bugbot). */
460
525
  const LOOPBACK_ENTRIES = new Set(['127.0.0.1', 'localhost', '::1', '[::1]', '*']);
526
+ // Release asset names installed by the one-time npm/JS → standalone migration (mirrors evolver-proxy
527
+ // releaseAssetName; kept dependency-free so doctor stays read-only and self-contained).
528
+ const MIGRATION_BINARY_ASSET_NAMES = ['evolver-darwin-arm64', 'evolver-darwin-x64', 'evolver-linux-arm64', 'evolver-linux-x64', 'evolver-windows-x64.exe'];
461
529
  /**
462
530
  * Run the read-only doctor checks. Pure given its (injectable) deps — no config mutation, no env-file load into the
463
531
  * process. Returns the check list; the CLI formats + sets the exit code.
@@ -537,6 +605,36 @@ export function runDoctorChecks(deps = {}) {
537
605
  }
538
606
  }
539
607
  }
608
+ // 1b. v1-env-compat: warn when V1-only knobs are still set (process env and/or EVOLVER_ENV_FILE). Refs #698.
609
+ {
610
+ const merged = { ...env, ...envFileValues };
611
+ const compat = bootstrap.scanV1EnvCompat(merged);
612
+ if (compat.detected.length === 0) {
613
+ checks.push({
614
+ name: 'v1-env-compat',
615
+ status: 'pass',
616
+ detail: 'no deprecated V1-only env knobs detected (see `evolver migrate env`)',
617
+ });
618
+ }
619
+ else {
620
+ const names = compat.detected.map((d) => d.v1Name).join(', ');
621
+ const maps = compat.detected
622
+ .filter((d) => bootstrap.resolveV1EnvMigrationAction(d) === 'map' && d.v2Equivalent)
623
+ .map((d) => `${d.v1Name}→${d.v2Equivalent}`)
624
+ .join(', ');
625
+ const manual = compat.detected.filter((d) => bootstrap.resolveV1EnvMigrationAction(d) === 'manual').map((d) => d.v1Name).join(', ');
626
+ const drops = compat.detected.filter((d) => bootstrap.resolveV1EnvMigrationAction(d) === 'remove').map((d) => d.v1Name).join(', ');
627
+ const parts = [`${compat.detected.length} deprecated V1 env var(s): ${names}`];
628
+ if (maps)
629
+ parts.push(`map: ${maps}`);
630
+ if (manual)
631
+ parts.push(`manual: ${manual}`);
632
+ if (drops)
633
+ parts.push(`remove: ${drops}`);
634
+ parts.push('run `evolver migrate env` or see docs/migration-guide.md');
635
+ checks.push({ name: 'v1-env-compat', status: 'warn', detail: parts.join(' — ') });
636
+ }
637
+ }
540
638
  // 2. config-no-secrets: runtime config must reference creds via the EVOLVER_ENV_FILE pointer, never inline a secret.
541
639
  const offenders = [];
542
640
  for (const rel of CONFIG_FILES) {
@@ -573,6 +671,17 @@ export function runDoctorChecks(deps = {}) {
573
671
  else {
574
672
  checks.push({ name: 'no-proxy-loopback', status: 'warn', detail: 'a system proxy is set but NO_PROXY lacks 127.0.0.1/localhost — local IPC/LLM-proxy traffic may be intercepted; add them to NO_PROXY' });
575
673
  }
674
+ // 4. self-update-migration: read-only view of the one-time npm/JS → standalone migration — the
675
+ // EVOLVER_BOOTSTRAP_MIGRATION switch state and any migrated binary already under <home>/bin.
676
+ {
677
+ const migrationSwitch = effectiveEnv['EVOLVER_BOOTSTRAP_MIGRATION']?.trim();
678
+ const switchState = migrationSwitch === '0' || migrationSwitch === 'off' ? 'disabled (exact 0/off)' : 'on';
679
+ const binDir = join(events.evomapHome(effectiveEnv), 'bin');
680
+ const installed = MIGRATION_BINARY_ASSET_NAMES.filter((name) => exists(join(binDir, name)));
681
+ checks.push(installed.length > 0
682
+ ? { name: 'self-update-migration', status: 'pass', detail: `EVOLVER_BOOTSTRAP_MIGRATION ${switchState}; migrated standalone binary present: ${installed.map((name) => redact(join(binDir, name))).join(', ')}` }
683
+ : { name: 'self-update-migration', status: 'pass', detail: `EVOLVER_BOOTSTRAP_MIGRATION ${switchState}; no migrated standalone binary under ${redact(binDir)} (the npm/JS first-run migration installs it there)` });
684
+ }
576
685
  if (deps.profile === 'private-runtime') {
577
686
  checks.push(...privateRuntimeChecks(env, envFileValues, envFileReadiness));
578
687
  }
@@ -0,0 +1,9 @@
1
+ export interface ExplicitNodeCredentials {
2
+ senderId?: string;
3
+ nodeSecret?: string;
4
+ nodeSecretVersion?: string;
5
+ }
6
+ /** Select explicit node credentials without combining conflicting alias namespaces. */
7
+ export declare function resolveExplicitNodeCredentials(env?: NodeJS.ProcessEnv): ExplicitNodeCredentials;
8
+ /** Resolve the public Hub identity root without coupling credentials to Evolver state. */
9
+ export declare function resolveIdentityHome(env?: NodeJS.ProcessEnv, homeDir?: string): string;
@@ -0,0 +1,47 @@
1
+ import { homedir } from 'node:os';
2
+ import { join } from 'node:path';
3
+ function nonBlank(value) {
4
+ const trimmed = value?.trim();
5
+ return trimmed ? trimmed : undefined;
6
+ }
7
+ /** Select explicit node credentials without combining conflicting alias namespaces. */
8
+ export function resolveExplicitNodeCredentials(env = process.env) {
9
+ const evomap = credentialNamespace(env, 'EVOMAP');
10
+ const a2a = credentialNamespace(env, 'A2A');
11
+ if (evomap.senderId && evomap.nodeSecret)
12
+ return evomap;
13
+ if (a2a.senderId && a2a.nodeSecret)
14
+ return a2a;
15
+ if (evomap.senderId && a2a.senderId && evomap.senderId === a2a.senderId) {
16
+ const selected = evomap.nodeSecret ? evomap : a2a.nodeSecret ? a2a : evomap;
17
+ return selected.nodeSecret ? selected : { senderId: selected.senderId };
18
+ }
19
+ const senderId = evomap.senderId ?? a2a.senderId;
20
+ if (senderId)
21
+ return { senderId };
22
+ const selected = evomap.nodeSecret ? evomap : a2a;
23
+ return selected.nodeSecret
24
+ ? {
25
+ nodeSecret: selected.nodeSecret,
26
+ ...(selected.nodeSecretVersion ? { nodeSecretVersion: selected.nodeSecretVersion } : {}),
27
+ }
28
+ : {};
29
+ }
30
+ function credentialNamespace(env, prefix) {
31
+ const senderId = nonBlank(env[`${prefix}_NODE_ID`]);
32
+ const nodeSecret = nonBlank(env[`${prefix}_NODE_SECRET`]);
33
+ const nodeSecretVersion = nonBlank(env[`${prefix}_NODE_SECRET_VERSION`]);
34
+ return {
35
+ ...(senderId ? { senderId } : {}),
36
+ ...(nodeSecret ? { nodeSecret } : {}),
37
+ ...(nodeSecretVersion ? { nodeSecretVersion } : {}),
38
+ };
39
+ }
40
+ /** Resolve the public Hub identity root without coupling credentials to Evolver state. */
41
+ export function resolveIdentityHome(env = process.env, homeDir) {
42
+ const explicit = [env['EVOMAP_HOME'], env['EVOMAP_DIR'], env['EVOLVER_HOME']]
43
+ .map(nonBlank)
44
+ .filter((value) => value !== undefined);
45
+ const fallbackHome = nonBlank(env['HOME']) ?? homeDir ?? homedir();
46
+ return explicit[0] ?? join(fallbackHome, '.evomap');
47
+ }