@evomap/evolver-cli 2.0.0-beta.10 → 2.0.0-beta.13

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.
@@ -18,6 +18,7 @@ function renderText(report, stdout) {
18
18
  `corrupt=${report.totals.corruptRows}`,
19
19
  `duplicate=${report.totals.duplicateRows}`,
20
20
  `hash_mismatch=${report.totals.hashMismatchRows}`,
21
+ `unverified=${report.totals.unverifiedRows}`,
21
22
  `schema_invalid=${report.totals.schemaInvalidRows}`,
22
23
  `unsafe=${report.totals.unsafeFiles}`,
23
24
  `unavailable=${report.totals.unavailableFiles}`,
@@ -32,6 +33,7 @@ function renderText(report, stdout) {
32
33
  `corrupt=${file.corruptRows}`,
33
34
  `duplicate=${file.duplicateRows}`,
34
35
  `hash_mismatch=${file.hashMismatchRows}`,
36
+ `unverified=${file.unverifiedRows}`,
35
37
  `schema_invalid=${file.schemaInvalidRows}`,
36
38
  ...(file.unterminated ? ['unterminated=true'] : []),
37
39
  ...(file.reason ? [`reason=${file.reason}`] : []),
@@ -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
@@ -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
@@ -83,7 +100,7 @@ export function draftStrategy(turns) {
83
100
  for (const t of turns) {
84
101
  if (t.role !== 'assistant' || t.isMeta)
85
102
  continue;
86
- const raw = (t.text ?? '').replace(/\s+/g, ' ').trim();
103
+ const raw = hub.redactString(t.text ?? '').replace(/\s+/g, ' ').trim();
87
104
  if (raw.length < 40)
88
105
  continue; // too short to be a step
89
106
  if (isNarrationOnly(raw))
@@ -96,6 +113,17 @@ export function draftStrategy(turns) {
96
113
  }
97
114
  return steps.slice(-6); // the latest substantive actions (closest to the resolution)
98
115
  }
116
+ const GENERIC_SUCCESS_TOPICS = new Set([
117
+ 'added', 'adjusted', 'assistant', 'change', 'changed', 'changes', 'command', 'commands', 'complete',
118
+ 'completed', 'coverage', 'fixed', 'handling', 'implementation', 'passed', 'passing', 'regression', 'result',
119
+ 'results', 'successful', 'successfully', 'tests', 'updated', 'validation', 'verified',
120
+ ]);
121
+ function successTopicSignals(strategy) {
122
+ const text = strategy.join(' ');
123
+ return hub.extractTopicKeywords(text, undefined, 24, { minOccurrences: 1, preserveSourceOrder: true })
124
+ .filter((topic) => !GENERIC_SUCCESS_TOPICS.has(topic))
125
+ .slice(0, 4);
126
+ }
99
127
  /**
100
128
  * Assemble an UNPROVEN draft GeneCandidate from a parsed session, or null when too thin to distill (no strong
101
129
  * signal OR no substantive step). The single source of the "what makes a draftable session" gate + candidate
@@ -105,10 +133,36 @@ export function draftStrategy(turns) {
105
133
  export function draftGeneCandidate(turns, sigs, agent) {
106
134
  const signals_match = signalTokens(sigs);
107
135
  const strategy = draftStrategy(turns);
108
- if (signals_match.length === 0 || strategy.length === 0) {
136
+ const hadVerifiedSuccess = sigs.some((s) => s.strength === 'success' && !s.needsAnalysis);
137
+ const hasTerminalVerifiedSuccess = signals_match.includes('verified-success');
138
+ // 当只有成功信号(没有错误信号)时,走 innovate 路径而非 repair (#578):
139
+ // 一次成功的问题解决过程不应被分类为 repair —— 它是一个可复用的成功能力。
140
+ const hasStrongError = sigs.some((s) => s.strength === 'strong');
141
+ if (signals_match.length === 0 || strategy.length === 0 || !hasStrongError) {
142
+ // Do not let the capability sniffer resurrect a success that a later unresolved outcome already superseded.
143
+ if (hadVerifiedSuccess && !hasTerminalVerifiedSuccess && !hasStrongError)
144
+ return null;
109
145
  const hit = algo.sniffConversationCapabilities(turns)[0];
110
- if (!hit)
146
+ if (!hit) {
147
+ // Sniffer 也未命中:如果有 success 信号和 strategy(仅当 hasStrongError 为 false 才走到这里且 signals_match 非空),
148
+ // 仍然产出 gene,但标记为 innovate —— 这是一个被验证的能力,而非错误修复。
149
+ if (signals_match.length > 0 && strategy.length > 0) {
150
+ const topics = successTopicSignals(strategy);
151
+ // Generic runner + success tokens are not a reusable capability identity. Let the optional transcript-LLM
152
+ // path handle prose that has no safe discriminating topic instead of storing one global shell-success gene.
153
+ if (topics.length === 0)
154
+ return null;
155
+ const successSignals = [...new Set([...signals_match, ...topics])].slice(0, 8);
156
+ return {
157
+ category: 'innovate',
158
+ signals_match: successSignals,
159
+ strategy,
160
+ summary: `Auto-drafted from ${agent} session (UNPROVEN — curate via review): ${topics.slice(0, 3).join(', ')}`,
161
+ generation_meta: { source: 'distilled' },
162
+ };
163
+ }
111
164
  return null;
165
+ }
112
166
  const fallbackStrategy = hit.evidence;
113
167
  if (fallbackStrategy.length === 0)
114
168
  return null;
@@ -149,6 +203,8 @@ const GENERIC_NOVELTY_SIGNALS = new Set([
149
203
  'sh',
150
204
  'cmd',
151
205
  'command',
206
+ 'verified-success',
207
+ 'verified_success',
152
208
  ]);
153
209
  function normalizeSignalSet(values) {
154
210
  return new Set((values ?? []).map((value) => String(value).trim().toLowerCase()).filter(Boolean));
@@ -34,9 +34,12 @@ export interface LifecycleResult {
34
34
  files?: string[];
35
35
  service?: string;
36
36
  }
37
+ type UnixRecoveryControllerModule = Pick<typeof import('@evomap/evolver-proxy'), 'provisionStableUnixRecoveryController' | 'stableUnixRecoveryControllerPathForTarget' | 'UNIX_RECOVERY_CONTROLLER_ARG'>;
38
+ type LoadUnixRecoveryController = () => Promise<UnixRecoveryControllerModule>;
37
39
  interface RunLifecycleDeps {
38
40
  argv1?: string;
39
41
  env?: NodeJS.ProcessEnv;
42
+ loadUnixRecoveryController?: LoadUnixRecoveryController;
40
43
  stdout?: (text: string) => void;
41
44
  stderr?: (text: string) => void;
42
45
  }
package/dist/lifecycle.js CHANGED
@@ -73,7 +73,7 @@ async function runLifecycleCommandInner(argv, deps) {
73
73
  if (envFileResult.error)
74
74
  throw new Error('failed to load lifecycle environment file');
75
75
  const target = serviceTarget(flags);
76
- const result = await installService(target, flags, env, deps.argv1 ?? process.argv[1]);
76
+ const result = await installService(target, flags, env, deps.argv1 ?? process.argv[1], deps.loadUnixRecoveryController);
77
77
  stdout(`${JSON.stringify(result, null, 2)}\n`);
78
78
  return 0;
79
79
  }
@@ -494,7 +494,7 @@ function serviceTarget(flags) {
494
494
  return value;
495
495
  throw new Error('missing or invalid --target (expected: launchd|systemd|windows)');
496
496
  }
497
- async function installService(target, flags, env, argv1) {
497
+ async function installService(target, flags, env, argv1, loadUnixRecoveryController = () => import('@evomap/evolver-proxy')) {
498
498
  const dryRun = flags['dry-run'] === true;
499
499
  const envFile = typeof flags['env-file'] === 'string' ? flags['env-file'] : env['EVOLVER_ENV_FILE'];
500
500
  const supervised = configuredSelfUpdateTarget(env)
@@ -506,7 +506,7 @@ async function installService(target, flags, env, argv1) {
506
506
  let unixController;
507
507
  let unixControllerStateDir;
508
508
  if (target !== 'windows' && standaloneTarget) {
509
- const { provisionStableUnixRecoveryController, stableUnixRecoveryControllerPathForTarget, UNIX_RECOVERY_CONTROLLER_ARG, } = await import('@evomap/evolver-proxy');
509
+ const { provisionStableUnixRecoveryController, stableUnixRecoveryControllerPathForTarget, UNIX_RECOVERY_CONTROLLER_ARG, } = await loadUnixRecoveryController();
510
510
  const stateDir = env['EVOLVER_SELF_UPDATE_STATE_DIR']?.trim() || undefined;
511
511
  const controllerPath = dryRun
512
512
  ? stableUnixRecoveryControllerPathForTarget(standaloneTarget, stateDir)
package/dist/reuse.js CHANGED
@@ -98,9 +98,20 @@ export async function runReuseCommand(argv, deps = {}) {
98
98
  const asset = await hub.fetchAssetById(opts.id);
99
99
  if (!asset)
100
100
  return emit({ ok: false, status: 'not_found', message: `asset ${opts.id} not found on the hub` }, ctx);
101
- const cleaned = await ingestHubAsset(store, deps, asset, opts.id);
102
- logReuse(deps, opts, cleaned, 'hub');
103
- return emit({ ok: true, status: 'ok', message: 'reused into local recall library' }, ctx);
101
+ const { record, verified } = await ingestHubAsset(store, deps, asset, opts.id);
102
+ logReuse(deps, opts, record, 'hub');
103
+ // Both land the asset (exit 0). A verified reuse is a plain success; an unverified one is a first-class
104
+ // success too — the operator's save happened — but carries reason `unverified` so the desktop adapter can
105
+ // surface "added (unverified)" instead of a plain "added". status stays `ok` so older desktop builds, which
106
+ // key success on status==='ok' and ignore reason, keep working unchanged.
107
+ return emit(verified
108
+ ? { ok: true, status: 'ok', message: 'reused into local recall library' }
109
+ : {
110
+ ok: true,
111
+ status: 'ok',
112
+ reason: 'unverified',
113
+ message: 'reused into local recall library as untrusted: hub-delivered content does not match its content fingerprint and could not be verified',
114
+ }, ctx);
104
115
  }
105
116
  catch (e) {
106
117
  return emit(mapError(e), ctx);
@@ -176,27 +187,59 @@ class ReuseIntegrityError extends Error {
176
187
  const INTEGRITY_MISMATCH_MESSAGE = 'hub-delivered content does not match the asset content fingerprint';
177
188
  const INTEGRITY_BACKFILLED_MESSAGE = 'hub delivered a synthesized payload for this asset; the original published content is unavailable for verification';
178
189
  const INTEGRITY_LOGICAL_ID_MESSAGE = 'hub-delivered asset does not match the requested logical id';
179
- function integrityError(content) {
180
- const backfilled = stringField(content, 'payload_backfill_reason') !== undefined;
181
- return new ReuseIntegrityError(backfilled ? INTEGRITY_BACKFILLED_MESSAGE : INTEGRITY_MISMATCH_MESSAGE);
190
+ function integrityError(synthesized) {
191
+ return new ReuseIntegrityError(synthesized ? INTEGRITY_BACKFILLED_MESSAGE : INTEGRITY_MISMATCH_MESSAGE);
182
192
  }
183
193
  async function ingestHubAsset(store, deps, asset, requestedId) {
184
- const cleaned = stripHubMetadata(unwrapHubAssetContent(asset));
194
+ const delivered = stripHubMetadata(unwrapHubAssetContent(asset));
195
+ // `payload_backfill_reason` is a hub DELIVERY marker (unwrapHubAssetContent lifts it onto the content so a
196
+ // synthesized payload can be classified). It is NOT publisher content, so it must be excluded from EVERY hash
197
+ // — identity, the local-conflict check, AND the stored bytes — and never persisted. Capture the
198
+ // classification fact, then drop the marker ONCE, up front: hashing it here but stripping it before storage
199
+ // made assertNoLocalReuseIdConflict hash a different byte string than what landed on disk, throwing a false
200
+ // id conflict on the second reuse of the same synthesized asset (Bugbot HIGH, broke idempotency).
201
+ const synthesized = stringField(delivered, 'payload_backfill_reason') !== undefined;
202
+ const cleaned = withoutHubDeliveryMarkers(delivered);
185
203
  const actualAssetId = wire.computeAssetId(cleaned);
186
204
  const contentAssetId = stringField(cleaned, 'asset_id');
187
- if (!actualAssetId || !contentAssetId || actualAssetId !== contentAssetId) {
188
- throw integrityError(cleaned);
205
+ if (!actualAssetId || !contentAssetId) {
206
+ // Malformed beyond classification — no computable hash or no declared id — stays a hard reject.
207
+ throw integrityError(synthesized);
189
208
  }
190
- if (isContentAssetId(requestedId) && actualAssetId !== requestedId) {
191
- throw integrityError(cleaned);
209
+ // Identity guards stay STRICT: a hub that returned a DIFFERENT asset than requested (a self-consistent asset
210
+ // B under a request for A, or a different logical id) is a delivery fault, not the hub's known content-rewrite
211
+ // of the RIGHT asset — reject it so a reuse never silently pulls the wrong gene.
212
+ if (isContentAssetId(requestedId)) {
213
+ if (contentAssetId !== requestedId)
214
+ throw integrityError(synthesized);
192
215
  }
193
- if (!isContentAssetId(requestedId) && stringField(cleaned, 'id') !== requestedId) {
216
+ else if (stringField(cleaned, 'id') !== requestedId) {
194
217
  throw new ReuseIntegrityError(INTEGRITY_LOGICAL_ID_MESSAGE);
195
218
  }
196
219
  await assertNoLocalReuseIdConflict(cleaned, store);
197
220
  const provenance = new assetstore.ProvenanceStore(storeBaseDir(store, deps));
198
- const stored = await assetstore.ingestUntrusted(store, provenance, cleaned, 'hub');
199
- return { ...cleaned, asset_id: stored.asset_id };
221
+ // Identity is confirmed; now content integrity. When the (marker-free) payload hashes to its declared id it
222
+ // lands verified (still sidecar-marked untrusted per #30). When it does NOT, the hub rewrote the delivered
223
+ // bytes of the right asset (#570) — DOWNGRADE instead of reject: freeze it under the network id and mark it
224
+ // unverified so the save actually happens and the loop (which already reuses hub content without
225
+ // re-verifying) can use it, while trust-first selection keeps it out of the reasoning pool until promotion.
226
+ if (actualAssetId === contentAssetId) {
227
+ const stored = await assetstore.ingestUntrusted(store, provenance, cleaned, 'hub');
228
+ return { record: { ...cleaned, asset_id: stored.asset_id }, verified: true };
229
+ }
230
+ const reason = synthesized ? 'unverified_hub_synthesized' : 'unverified_hub_rewrite';
231
+ const stored = await assetstore.ingestUnverified(store, provenance, cleaned, reason, 'hub');
232
+ return { record: { ...cleaned, asset_id: stored.asset_id }, verified: false };
233
+ }
234
+ /**
235
+ * Drop hub DELIVERY markers that unwrapHubAssetContent lifts onto the content for classification but that must
236
+ * never reach content-addressed storage. Right now that is `payload_backfill_reason`; keeping this as a named
237
+ * helper localizes the "these keys describe HOW the hub delivered the asset, not the asset" rule.
238
+ */
239
+ function withoutHubDeliveryMarkers(asset) {
240
+ const rest = { ...asset };
241
+ delete rest['payload_backfill_reason'];
242
+ return rest;
200
243
  }
201
244
  async function resolveLocalReuseAsset(store, id) {
202
245
  const direct = await store.get(id);
@@ -332,7 +375,7 @@ function mapError(e) {
332
375
  function emit(outcome, ctx) {
333
376
  if (ctx.jsonOut) {
334
377
  // stdout ONLY, exactly one object — the desktop adapter json.Unmarshals the whole stdout stream.
335
- const envelope = { ok: outcome.ok, contract: REUSE_CONTRACT, status: outcome.status, reason: outcome.status, message: outcome.message };
378
+ const envelope = { ok: outcome.ok, contract: REUSE_CONTRACT, status: outcome.status, reason: outcome.reason ?? outcome.status, message: outcome.message };
336
379
  ctx.stdout(JSON.stringify(envelope));
337
380
  }
338
381
  else if (outcome.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-cli",
3
- "version": "2.0.0-beta.10",
3
+ "version": "2.0.0-beta.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "evolver CLI (status/watch/cycles/rebuild-views/...)",
@@ -20,12 +20,12 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@evomap/evolver-core": "2.0.0-beta.10",
24
- "@evomap/evolver-adapter-public": "2.0.0-beta.10",
25
- "@evomap/evolver-mcp": "2.0.0-beta.10",
26
- "@evomap/evolver-proxy": "2.0.0-beta.10",
27
- "@evomap/evolver-runtime-adapters": "2.0.0-beta.10",
28
- "@evomap/evolver-webui": "2.0.0-beta.10"
23
+ "@evomap/evolver-core": "2.0.0-beta.13",
24
+ "@evomap/evolver-adapter-public": "2.0.0-beta.13",
25
+ "@evomap/evolver-mcp": "2.0.0-beta.13",
26
+ "@evomap/evolver-proxy": "2.0.0-beta.13",
27
+ "@evomap/evolver-runtime-adapters": "2.0.0-beta.13",
28
+ "@evomap/evolver-webui": "2.0.0-beta.13"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",