@evomap/evolver-cli 2.0.0-beta.1 → 2.0.0-beta.12
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/antiGeneBenchmark.js +12 -0
- package/dist/antiGeneEvidence.d.ts +15 -0
- package/dist/antiGeneEvidence.js +49 -0
- package/dist/antiGeneRollout.d.ts +3 -1
- package/dist/antiGeneRollout.js +16 -2
- package/dist/assetHealth.d.ts +6 -0
- package/dist/assetHealth.js +107 -0
- package/dist/assetSidecarRecovery.d.ts +14 -0
- package/dist/assetSidecarRecovery.js +171 -0
- package/dist/assetTrust.d.ts +24 -0
- package/dist/assetTrust.js +218 -0
- package/dist/atp.js +4 -2
- package/dist/autoDistillLlm.d.ts +6 -0
- package/dist/autoDistillLlm.js +44 -7
- package/dist/autoexec.d.ts +14 -12
- package/dist/autoexec.js +84 -34
- package/dist/autoexecConfig.d.ts +10 -0
- package/dist/autoexecConfig.js +68 -0
- package/dist/cli.js +12 -5
- package/dist/cliContracts.js +30 -3
- package/dist/cliLifecycle.d.ts +7 -0
- package/dist/cliLifecycle.js +9 -0
- package/dist/cycleConsumer.d.ts +61 -1
- package/dist/cycleConsumer.js +551 -16
- package/dist/dashboard.d.ts +33 -0
- package/dist/dashboard.js +352 -0
- package/dist/dispatch.d.ts +10 -1
- package/dist/dispatch.js +40 -2
- package/dist/distillAdmission.d.ts +13 -0
- package/dist/distillAdmission.js +35 -0
- package/dist/distillObserver.js +6 -8
- package/dist/distillPrimitives.d.ts +9 -7
- package/dist/distillPrimitives.js +65 -12
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.js +49 -3
- package/dist/index.d.ts +8 -2
- package/dist/index.js +350 -42
- package/dist/issueReport.d.ts +7 -0
- package/dist/issueReport.js +291 -0
- package/dist/lifecycle.d.ts +22 -1
- package/dist/lifecycle.js +226 -29
- package/dist/localMemoryGraph.d.ts +97 -0
- package/dist/localMemoryGraph.js +889 -0
- package/dist/login.d.ts +20 -4
- package/dist/login.js +58 -8
- package/dist/materialPackage.d.ts +52 -0
- package/dist/materialPackage.js +401 -0
- package/dist/materialSnapshot.d.ts +54 -0
- package/dist/materialSnapshot.js +370 -0
- package/dist/memoryEventMirror.d.ts +23 -0
- package/dist/memoryEventMirror.js +140 -0
- package/dist/migrate/fieldMap.js +25 -0
- package/dist/migrate/v1Import.d.ts +7 -1
- package/dist/migrate/v1Import.js +132 -11
- package/dist/nonGitWorkspaceNotice.d.ts +24 -0
- package/dist/nonGitWorkspaceNotice.js +122 -0
- package/dist/proxyToken.d.ts +10 -0
- package/dist/proxyToken.js +80 -0
- package/dist/recipe.d.ts +12 -2
- package/dist/recipe.js +381 -8
- package/dist/reuse.d.ts +5 -3
- package/dist/reuse.js +126 -15
- package/dist/reuseReport.js +16 -16
- package/dist/runtimeCapabilities.d.ts +18 -0
- package/dist/runtimeCapabilities.js +81 -0
- package/dist/runtimeSessionSource.d.ts +10 -0
- package/dist/runtimeSessionSource.js +32 -5
- package/dist/setupHooks.d.ts +11 -1
- package/dist/setupHooks.js +235 -16
- package/dist/skill2gep.d.ts +38 -9
- package/dist/skill2gep.js +147 -14
- package/dist/skillDistill.d.ts +1 -0
- package/dist/skillDistill.js +4 -4
- package/dist/skillFetch.d.ts +18 -0
- package/dist/skillFetch.js +391 -0
- package/dist/solo/mode.js +5 -0
- package/dist/sync.d.ts +38 -0
- package/dist/sync.js +1981 -0
- package/dist/trajectoryExport.js +23 -12
- package/dist/v1Compat.d.ts +24 -0
- package/dist/v1Compat.js +249 -0
- package/dist/workflow.d.ts +39 -0
- package/dist/workflow.js +386 -0
- package/dist/workflowRuntime.d.ts +66 -0
- package/dist/workflowRuntime.js +631 -0
- package/package.json +12 -6
package/dist/index.js
CHANGED
|
@@ -3,18 +3,23 @@ import { readEvents, statusReport, listCycles, showCycle, listTriggers, buildNar
|
|
|
3
3
|
import { runGeneValue } from './geneValue.js';
|
|
4
4
|
import { assetstore, algo, signals, material as materialNs } from '@evomap/evolver-core';
|
|
5
5
|
import { loadPriceTable } from '@evomap/evolver-adapter-public';
|
|
6
|
+
import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
|
|
6
7
|
import { makeInjectEmitter } from './autoexec.js';
|
|
7
8
|
import { listApprovedGenes, provenanceStoreForStore, reviewLedgerForStore } from './reviewFilter.js';
|
|
8
9
|
import { ADAPTERS, parseJsonlLines } from '@evomap/evolver-runtime-adapters';
|
|
9
10
|
import { draftGeneCandidate } from './distillPrimitives.js';
|
|
11
|
+
import { assessDraftAdmissionFromStore } from './distillAdmission.js';
|
|
10
12
|
import { emitSessionRecall } from './autoRecall.js';
|
|
11
|
-
import { isRuntimeSessionSourcePath,
|
|
13
|
+
import { isRuntimeSessionSourcePath, parseRuntimeSessionSourcesWithDiagnostics } from './runtimeSessionSource.js';
|
|
12
14
|
import { existsSync, readFileSync, readdirSync, statSync, unlinkSync } from 'node:fs';
|
|
13
15
|
import { homedir } from 'node:os';
|
|
14
|
-
import { join, resolve } from 'node:path';
|
|
16
|
+
import { dirname, join, resolve } from 'node:path';
|
|
15
17
|
import { importV1 } from './migrate/v1Import.js';
|
|
16
18
|
import { explicitRecipeHomes } from './recipe.js';
|
|
17
19
|
import { maybeAutoRestartProxyForSessionStart, sessionStartHookVerboseEnabled } from './lifecycle.js';
|
|
20
|
+
import { formatAntiGeneEvidenceAction, formatAntiGeneEvidenceSummary, summarizeAntiGeneEvidence } from './antiGeneEvidence.js';
|
|
21
|
+
import { buildRuntimeSessionMaterialSnapshot } from './materialSnapshot.js';
|
|
22
|
+
import { maybeEmitNonGitWorkspaceNotice } from './nonGitWorkspaceNotice.js';
|
|
18
23
|
/**
|
|
19
24
|
* Material consumer group for ingest: the cycle is the downstream that claims material → signals. Kept in
|
|
20
25
|
* one place so the recorded Material and any future cycle consumer agree on the group name.
|
|
@@ -54,6 +59,37 @@ function operatorActorId() {
|
|
|
54
59
|
return process.env['EVOLVER_ACTOR_ID'] ?? process.env['USER'] ?? process.env['LOGNAME'] ?? 'cli';
|
|
55
60
|
}
|
|
56
61
|
export const PACKAGE = '@evomap/evolver-cli';
|
|
62
|
+
export function cliUsage() {
|
|
63
|
+
return [
|
|
64
|
+
'Usage: evolver <command> [options]',
|
|
65
|
+
'',
|
|
66
|
+
'Options:',
|
|
67
|
+
' -h, --help Show this help',
|
|
68
|
+
' -v, --version Show the installed version',
|
|
69
|
+
'',
|
|
70
|
+
'Proxy options (evolver proxy):',
|
|
71
|
+
' --home <dir> Root for assets, store, settings, and traces',
|
|
72
|
+
' --evomap-home <dir> Identity home for node_id/node_secret; defaults to --home',
|
|
73
|
+
' --store <path> Mailbox store path',
|
|
74
|
+
' --settings <path> Proxy settings file',
|
|
75
|
+
' --env-file <path> Environment file',
|
|
76
|
+
'',
|
|
77
|
+
'Commands:',
|
|
78
|
+
' Daemon: proxy, lifecycle, proxy-token, doctor, setup-hooks',
|
|
79
|
+
' Evolution: run, cycle, autoexec, solidify, distill, review, thesis',
|
|
80
|
+
' Memory: ingest, inject, recall, reuse, reuse-report, narrative, gene-value',
|
|
81
|
+
' Assets: asset-log, asset-trust, asset-health, material, recipe, skill',
|
|
82
|
+
' Hub: login, logout, phub, sync, publish, fetch, buy, orders, atp',
|
|
83
|
+
' Operations: status, workflow status, cycles, trigger, value, retention, replay, rebuild-views',
|
|
84
|
+
' issue-report',
|
|
85
|
+
' Tools: dashboard, webui, trajectory-export, migrate, verify',
|
|
86
|
+
' Advanced: anti-gene-benchmark, anti-gene-rollout, reset-local-secret',
|
|
87
|
+
' skill-distill, skill-md-update',
|
|
88
|
+
'',
|
|
89
|
+
'Run evolver <command> --help for command-specific options.',
|
|
90
|
+
'',
|
|
91
|
+
].join('\n');
|
|
92
|
+
}
|
|
57
93
|
const LOCAL_SECRET_STATE_KEYS = ['node_secret', 'node_secret_source', 'node_secret_version'];
|
|
58
94
|
const LOCAL_SECRET_ENV_VARS = [
|
|
59
95
|
'EVOMAP_NODE_SECRET',
|
|
@@ -194,16 +230,50 @@ export function rebuildViews(opts = {}) {
|
|
|
194
230
|
replayer.rebuild(ing.readAll());
|
|
195
231
|
return { rebuilt: events.DEFAULT_PROJECTORS.map((p) => p.name) };
|
|
196
232
|
}
|
|
197
|
-
/** migrate import-v1 <v1dir> [outDir]
|
|
233
|
+
/** migrate import-v1 <v1dir> [outDir] --workspace <path>: v1→v2 read-only migration. */
|
|
198
234
|
export async function runMigrate(argv) {
|
|
235
|
+
const usage = '用法: evolver migrate import-v1 <v1dir> [outDir] [--workspace <path>]\n';
|
|
199
236
|
if (argv[0] !== 'import-v1' || !argv[1]) {
|
|
200
|
-
process.stderr.write(
|
|
237
|
+
process.stderr.write(usage);
|
|
238
|
+
return 1;
|
|
239
|
+
}
|
|
240
|
+
let outDir;
|
|
241
|
+
let workspace;
|
|
242
|
+
for (let index = 2; index < argv.length; index += 1) {
|
|
243
|
+
const arg = argv[index] ?? '';
|
|
244
|
+
if (arg === '--workspace') {
|
|
245
|
+
const value = argv[index + 1];
|
|
246
|
+
if (!value || value.startsWith('--')) {
|
|
247
|
+
process.stderr.write(usage);
|
|
248
|
+
return 1;
|
|
249
|
+
}
|
|
250
|
+
workspace = value;
|
|
251
|
+
index += 1;
|
|
252
|
+
}
|
|
253
|
+
else if (arg.startsWith('--workspace=')) {
|
|
254
|
+
workspace = arg.slice('--workspace='.length);
|
|
255
|
+
if (!workspace) {
|
|
256
|
+
process.stderr.write(usage);
|
|
257
|
+
return 1;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else if (arg.startsWith('--') || outDir !== undefined) {
|
|
261
|
+
process.stderr.write(usage);
|
|
262
|
+
return 1;
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
outDir = arg;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const envFile = loadEnvFileFromEnv(process.env);
|
|
269
|
+
if (envFile.error) {
|
|
270
|
+
process.stderr.write('migrate: failed to load EVOLVER_ENV_FILE\n');
|
|
201
271
|
return 1;
|
|
202
272
|
}
|
|
203
|
-
const
|
|
204
|
-
const store = new assetstore.LocalJsonlProvider(`${
|
|
205
|
-
const rep = await importV1(argv[1], store,
|
|
206
|
-
process.stdout.write(`迁移完成: Gene=${rep.imported.Gene} Capsule=${rep.imported.Capsule} Event=${rep.imported.EvolutionEvent} (冻结${rep.frozen}/新算${rep.recomputed}/去重${rep.deduped}); sidecar=${rep.sidecarExtensions}; memory_graph 归档=${rep.memoryGraphArchived}\n`);
|
|
273
|
+
const targetDir = outDir ?? events.evomapHome();
|
|
274
|
+
const store = new assetstore.LocalJsonlProvider(`${targetDir}/assets`);
|
|
275
|
+
const rep = await importV1(argv[1], store, targetDir, workspace ? { workspace } : {});
|
|
276
|
+
process.stdout.write(`迁移完成: Gene=${rep.imported.Gene} Capsule=${rep.imported.Capsule} Event=${rep.imported.EvolutionEvent} (冻结${rep.frozen}/新算${rep.recomputed}/去重${rep.deduped}); sidecar=${rep.sidecarExtensions}; memory_graph 归档=${rep.memoryGraphArchived} 可查询=${rep.memoryGraphImported} 延后=${rep.memoryGraphDeferred}\n`);
|
|
207
277
|
return 0;
|
|
208
278
|
}
|
|
209
279
|
/** One-line summary of an asset for `asset-log` (pure, testable). */
|
|
@@ -252,6 +322,9 @@ export async function runDistill(argv, store, deps = {}) {
|
|
|
252
322
|
signals_match: splitList(f['signals'], /,/),
|
|
253
323
|
strategy: splitList(f['strategy'], /[;\n]/),
|
|
254
324
|
...(f['summary'] ? { summary: f['summary'] } : {}),
|
|
325
|
+
// `evolver distill` is a human teaching the system a gene (actor.kind = human, see the audit below) →
|
|
326
|
+
// `manual` per V1 #302 classifyProvenance.
|
|
327
|
+
generation_meta: { source: 'manual' },
|
|
255
328
|
};
|
|
256
329
|
if (candidate.signals_match.length === 0 || candidate.strategy.length === 0) {
|
|
257
330
|
process.stderr.write('用法: evolver distill --category <c> --signals <s1,s2> --strategy "<step1; step2>" [--summary <t>]\n');
|
|
@@ -299,7 +372,7 @@ function printTraceSignals(file, turnCount, sigs) {
|
|
|
299
372
|
}
|
|
300
373
|
}
|
|
301
374
|
/** The runtime agents Material.sourceAgent can represent (closed enum on the schema). */
|
|
302
|
-
const MATERIAL_SOURCE_AGENTS = new Set(['claude-code', 'codex', 'cursor', 'gemini', 'kimi', 'kiro', 'opencode', 'generic-chat']);
|
|
375
|
+
const MATERIAL_SOURCE_AGENTS = new Set(['claude-code', 'codex', 'cursor', 'gemini', 'antigravity', 'kimi', 'kiro', 'opencode', 'generic-chat']);
|
|
303
376
|
/** Narrow an adapter's free-string agent to the Material source enum (undefined → not recordable). */
|
|
304
377
|
function toMaterialSourceAgent(agent) {
|
|
305
378
|
return MATERIAL_SOURCE_AGENTS.has(agent) ? agent : undefined;
|
|
@@ -329,12 +402,12 @@ function materialExistsFor(store, sourcePath, wm) {
|
|
|
329
402
|
* no new material and emits no event (scanFile reports `changed: false` against the persisted cursor).
|
|
330
403
|
* Returns whether new material landed + its materialId so the caller can report it.
|
|
331
404
|
*/
|
|
332
|
-
async function recordSessionMaterial(sourceAgent, absPath, signalCount, d, recordCount = 1) {
|
|
405
|
+
async function recordSessionMaterial(sourceAgent, absPath, signalCount, d, recordCount = 1, payload, diagnostics) {
|
|
333
406
|
const prev = d.watermarkStore.get(absPath);
|
|
334
407
|
const scan = materialNs.scanFile(absPath, prev);
|
|
335
408
|
// Unchanged source already recorded once → idempotent skip (no duplicate material, no duplicate event).
|
|
336
409
|
if (prev && !scan.changed)
|
|
337
|
-
return { recorded: false };
|
|
410
|
+
return { recorded: false, emitted: false };
|
|
338
411
|
const m = materialNs.buildMaterial({
|
|
339
412
|
sourceAgent,
|
|
340
413
|
sourceKind: 'runtime_session',
|
|
@@ -342,22 +415,30 @@ async function recordSessionMaterial(sourceAgent, absPath, signalCount, d, recor
|
|
|
342
415
|
kind: 'session_log',
|
|
343
416
|
watermark: scan.watermark,
|
|
344
417
|
consumerGroup: INGEST_CONSUMER_GROUP,
|
|
418
|
+
...(payload ? { payload } : {}),
|
|
345
419
|
});
|
|
346
420
|
// Crash-retry idempotency (#100): if a prior run already put this file's material but threw before the
|
|
347
421
|
// watermark advanced, don't append a duplicate row — reuse it and only (re-)emit the lost event below.
|
|
348
422
|
const isNew = !materialExistsFor(d.materialStore, absPath, scan.watermark);
|
|
349
423
|
if (isNew)
|
|
350
424
|
await d.materialStore.put(m);
|
|
425
|
+
const parseDiagnostics = diagnostics && diagnostics.invalidJson > 0
|
|
426
|
+
? { rowsScanned: diagnostics.rowsScanned, rowsRead: diagnostics.rowsRead, invalidJson: diagnostics.invalidJson }
|
|
427
|
+
: undefined;
|
|
351
428
|
await d.ingestor.ingest({
|
|
352
429
|
type: 'material.batch_ready',
|
|
353
|
-
payload: { source: absPath, recordCount, signalCount },
|
|
354
|
-
human: {
|
|
430
|
+
payload: { source: absPath, recordCount, signalCount, ...(parseDiagnostics ? { parseDiagnostics } : {}) },
|
|
431
|
+
human: {
|
|
432
|
+
title: `material 已落地: ${sourceAgent} session`,
|
|
433
|
+
...(parseDiagnostics ? { detail: `skipped ${parseDiagnostics.invalidJson} invalid JSONL row(s)` } : {}),
|
|
434
|
+
severity: 'info',
|
|
435
|
+
},
|
|
355
436
|
actor: { kind: 'machine' },
|
|
356
437
|
});
|
|
357
438
|
// Watermark LAST — only after BOTH the put and its batch_ready event succeed. If ingest throws, the watermark
|
|
358
439
|
// stays unset so a re-run re-emits the event; the content check above keeps that retry from duplicating the row.
|
|
359
440
|
d.watermarkStore.set(absPath, scan.watermark);
|
|
360
|
-
return { recorded: isNew, materialId: m.materialId };
|
|
441
|
+
return { recorded: isNew, emitted: true, materialId: m.materialId };
|
|
361
442
|
}
|
|
362
443
|
/**
|
|
363
444
|
* Record a proxy LLM-trace file as Material on the M1 substrate (#95). A trace is agent-agnostic gateway
|
|
@@ -434,18 +515,23 @@ export async function runSessionIngestTick(dirs, deps = {}) {
|
|
|
434
515
|
const sourceAgents = new Set();
|
|
435
516
|
const signalKinds = new Set();
|
|
436
517
|
const signalStrengths = new Set();
|
|
518
|
+
let invalidJsonRows = 0;
|
|
437
519
|
// #274 auto-recall (default OFF): observe which injected genes were actually used, from the transcript, so the
|
|
438
520
|
// experience loop is fed by observation instead of a self-reported tool call agents skip. Best-effort + idempotent
|
|
439
521
|
// (one value.recall set per session); off → zero extra work. auto-OBSERVE only — it never quarantines.
|
|
440
522
|
const autoRecallOn = process.env['EVOLVER_AUTO_RECALL'] === '1';
|
|
441
523
|
for (const file of scanSessionDirs(dirs)) {
|
|
442
524
|
try {
|
|
443
|
-
const
|
|
525
|
+
const parsed = parseRuntimeSessionSourcesWithDiagnostics(file);
|
|
526
|
+
const parsedSources = parsed.sources;
|
|
444
527
|
const agent = parsedSources[0] ? toMaterialSourceAgent(parsedSources[0].agent) : undefined;
|
|
445
528
|
if (parsedSources.length === 0 || !agent)
|
|
446
529
|
continue; // not a recognized, schema-recordable runtime-session source
|
|
447
530
|
const sigsBySource = parsedSources.map((source) => signals.extractSignals(source.turns));
|
|
448
|
-
const
|
|
531
|
+
const snapshot = buildRuntimeSessionMaterialSnapshot(parsedSources);
|
|
532
|
+
const r = await recordSessionMaterial(agent, file, sigsBySource.reduce((sum, sigs) => sum + sigs.length, 0), d, parsedSources.length, snapshot, parsed.diagnostics);
|
|
533
|
+
if (r.emitted)
|
|
534
|
+
invalidJsonRows += parsed.diagnostics.invalidJson;
|
|
449
535
|
if (r.recorded) {
|
|
450
536
|
recorded += 1;
|
|
451
537
|
sourceAgents.add(agent);
|
|
@@ -469,6 +555,7 @@ export async function runSessionIngestTick(dirs, deps = {}) {
|
|
|
469
555
|
sourceAgents: sortedStrings(sourceAgents),
|
|
470
556
|
signalKinds: sortedStrings(signalKinds),
|
|
471
557
|
signalStrengths: sortedStrings(signalStrengths),
|
|
558
|
+
...(invalidJsonRows > 0 ? { invalidJsonRows } : {}),
|
|
472
559
|
};
|
|
473
560
|
}
|
|
474
561
|
/**
|
|
@@ -566,8 +653,11 @@ export async function runIngest(argv, store, deps = {}, review) {
|
|
|
566
653
|
if (TRACE_FILE_RE.test(path))
|
|
567
654
|
return ingestTraceFiles([resolve(path)], distill, deps);
|
|
568
655
|
let parsedSources;
|
|
656
|
+
let parseDiagnostics;
|
|
569
657
|
try {
|
|
570
|
-
|
|
658
|
+
const parsed = parseRuntimeSessionSourcesWithDiagnostics(path);
|
|
659
|
+
parsedSources = parsed.sources;
|
|
660
|
+
parseDiagnostics = parsed.diagnostics;
|
|
571
661
|
}
|
|
572
662
|
catch (e) {
|
|
573
663
|
process.stderr.write(`ingest: cannot read ${path}: ${e instanceof Error ? e.message : String(e)}\n`);
|
|
@@ -585,6 +675,9 @@ export async function runIngest(argv, store, deps = {}, review) {
|
|
|
585
675
|
return 1;
|
|
586
676
|
}
|
|
587
677
|
const sourceSignalPairs = parsedSources.map((source) => ({ source, sigs: signals.extractSignals(source.turns) }));
|
|
678
|
+
if (parseDiagnostics && parseDiagnostics.invalidJson > 0) {
|
|
679
|
+
process.stderr.write(`ingest: skipped ${parseDiagnostics.invalidJson} invalid JSONL row(s) in ${path}\n`);
|
|
680
|
+
}
|
|
588
681
|
for (const { source, sigs } of sourceSignalPairs) {
|
|
589
682
|
process.stdout.write(`ingest [${source.label}] ${path}: ${source.turns.length} turn(s) → ${sigs.length} signal(s)\n`);
|
|
590
683
|
for (const s of sigs) {
|
|
@@ -600,7 +693,8 @@ export async function runIngest(argv, store, deps = {}, review) {
|
|
|
600
693
|
if (sourceAgent) {
|
|
601
694
|
const d = resolveIngestDeps(deps);
|
|
602
695
|
const signalCount = sourceSignalPairs.reduce((sum, pair) => sum + pair.sigs.length, 0);
|
|
603
|
-
const
|
|
696
|
+
const snapshot = buildRuntimeSessionMaterialSnapshot(parsedSources);
|
|
697
|
+
const r = await recordSessionMaterial(sourceAgent, resolve(path), signalCount, d, parsedSources.length, snapshot, parseDiagnostics);
|
|
604
698
|
if (r.recorded)
|
|
605
699
|
process.stdout.write(` → recorded as material ${r.materialId} (material.batch_ready)\n`);
|
|
606
700
|
else
|
|
@@ -613,23 +707,39 @@ export async function runIngest(argv, store, deps = {}, review) {
|
|
|
613
707
|
// --distill: assemble + intake UNPROVEN draft genes per runtime session (shared draft logic — see distillPrimitives).
|
|
614
708
|
const s = store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
615
709
|
const accepted = [];
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
710
|
+
const acceptedSignals = [];
|
|
711
|
+
let candidateCount = 0;
|
|
712
|
+
let admissionSkipped = 0;
|
|
713
|
+
let lastAdmissionSkipReason = '';
|
|
620
714
|
for (const { source, sigs } of sourceSignalPairs) {
|
|
621
715
|
const candidate = draftGeneCandidate(source.turns, sigs, source.agent);
|
|
622
716
|
if (!candidate)
|
|
623
717
|
continue;
|
|
718
|
+
candidateCount += 1;
|
|
719
|
+
// Same value/novelty gate as the live distillObserver (#562): without it, a bulk ingest over session
|
|
720
|
+
// history floods the human review queue with thin / near-duplicate drafts (118 in one run). A non-admit
|
|
721
|
+
// is a deliberate skip — the rest of the batch still distills; intake below stays the structural gate.
|
|
722
|
+
const { admission, existing } = await assessDraftAdmissionFromStore(s, candidate, acceptedSignals);
|
|
723
|
+
if (!admission.admit) {
|
|
724
|
+
admissionSkipped += 1;
|
|
725
|
+
lastAdmissionSkipReason = admission.reason ?? '';
|
|
726
|
+
process.stdout.write(`\ningest --distill skipped [${source.label}]: ${admission.reason}\n`);
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
624
729
|
const r = algo.intakeGene(candidate, existing);
|
|
625
730
|
if (!r.ok || !r.gene) {
|
|
626
731
|
process.stderr.write(`\ningest --distill rejected: ${r.errors.join('; ')}\n`);
|
|
627
732
|
return 1;
|
|
628
733
|
}
|
|
629
734
|
accepted.push({ source, candidate, gene: r.gene });
|
|
630
|
-
|
|
735
|
+
acceptedSignals.push({ id: r.gene.id, signals_match: r.gene.signals_match });
|
|
631
736
|
}
|
|
632
737
|
if (accepted.length === 0) {
|
|
738
|
+
if (candidateCount > 0 && admissionSkipped === candidateCount) {
|
|
739
|
+
const reason = lastAdmissionSkipReason ? ` Last skip reason: ${lastAdmissionSkipReason}.` : '';
|
|
740
|
+
process.stdout.write(`\ningest: all ${candidateCount} draft candidate(s) skipped by admission gate.${reason} Nothing stored.\n`);
|
|
741
|
+
return 0;
|
|
742
|
+
}
|
|
633
743
|
process.stdout.write('\ningest: not enough to distill — need ≥1 strong signal and ≥1 substantive assistant step. Nothing stored.\n');
|
|
634
744
|
return 0;
|
|
635
745
|
}
|
|
@@ -694,22 +804,22 @@ function stringArrayField(value) {
|
|
|
694
804
|
function optionalStringField(value) {
|
|
695
805
|
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
696
806
|
}
|
|
697
|
-
function
|
|
698
|
-
return
|
|
699
|
-
}
|
|
700
|
-
function numberField(value) {
|
|
701
|
-
return typeof value === 'number' && Number.isFinite(value) ? String(value) : '-';
|
|
807
|
+
function antiGeneReviewState(rev, assetId) {
|
|
808
|
+
return rev.get(assetId)?.state ?? 'unreviewed';
|
|
702
809
|
}
|
|
703
810
|
function antiGeneReviewLine(asset, rev) {
|
|
704
811
|
const assetId = String(asset.asset_id);
|
|
705
812
|
const id = optionalStringField(asset['id']) ?? assetId;
|
|
706
|
-
const state = rev
|
|
813
|
+
const state = antiGeneReviewState(rev, assetId);
|
|
707
814
|
const severity = optionalStringField(asset['severity']) ?? '-';
|
|
708
815
|
const trigger = stringArrayField(asset['trigger']).slice(0, 6).join(',') || '-';
|
|
709
816
|
const avoid = stringArrayField(asset['avoid']).slice(0, 2).join(' | ') || '-';
|
|
710
|
-
const
|
|
711
|
-
const
|
|
712
|
-
|
|
817
|
+
const summary = summarizeAntiGeneEvidence(asset);
|
|
818
|
+
const evidence = `${formatAntiGeneEvidenceSummary(summary)} ${formatAntiGeneEvidenceAction(summary, state)}`;
|
|
819
|
+
const next = state === 'quarantined' || state === 'unreviewed'
|
|
820
|
+
? summary.strength === 'weak'
|
|
821
|
+
? `next: reject/defer, or override with evolver review --approve ${id} --allow-weak-evidence <reason>`
|
|
822
|
+
: `next: approve after manual guardrail review with evolver review --approve ${id} <reason> | reject with evolver review --reject ${id} <reason>`
|
|
713
823
|
: state === 'approved'
|
|
714
824
|
? 'next: approved guardrail can be injected when signals match'
|
|
715
825
|
: state === 'rejected'
|
|
@@ -745,12 +855,12 @@ async function runAntiGeneReview(store, rev) {
|
|
|
745
855
|
process.stdout.write('(no anti-genes)\n');
|
|
746
856
|
return 0;
|
|
747
857
|
}
|
|
748
|
-
const counts = { approved: 0, quarantined: 0, rejected: 0 };
|
|
858
|
+
const counts = { approved: 0, quarantined: 0, rejected: 0, unreviewed: 0 };
|
|
749
859
|
for (const asset of antiGenes) {
|
|
750
|
-
const state = rev
|
|
860
|
+
const state = antiGeneReviewState(rev, String(asset.asset_id));
|
|
751
861
|
counts[state] += 1;
|
|
752
862
|
}
|
|
753
|
-
process.stdout.write(`anti-gene review queue: ${antiGenes.length} AntiGene asset(s); approved=${counts.approved} quarantined=${counts.quarantined} rejected=${counts.rejected}\n`);
|
|
863
|
+
process.stdout.write(`anti-gene review queue: ${antiGenes.length} AntiGene asset(s); approved=${counts.approved} quarantined=${counts.quarantined} rejected=${counts.rejected} unreviewed=${counts.unreviewed}\n`);
|
|
754
864
|
for (const asset of antiGenes)
|
|
755
865
|
process.stdout.write(`${antiGeneReviewLine(asset, rev)}\n`);
|
|
756
866
|
return 0;
|
|
@@ -760,7 +870,7 @@ async function runAntiGeneReview(store, rev) {
|
|
|
760
870
|
* gene); `--approve`/`--reject <id>` is the audited human act that lifts an auto-distilled draft out of (or
|
|
761
871
|
* confirms it out of) quarantine. Approval is what lets a distilled gene's strategy be embedded into a real run
|
|
762
872
|
* (the gate lives in makeTrustedGeneResolver, #45+review). The id may be a logical id or an asset_id.
|
|
763
|
-
* Usage: evolver review [limit] | evolver review --approve <id> [reason…] | evolver review --reject <id> [reason…]
|
|
873
|
+
* Usage: evolver review [limit] | evolver review --approve <id> [--allow-weak-evidence] [reason…] | evolver review --reject <id> [reason…]
|
|
764
874
|
*/
|
|
765
875
|
export async function runReview(argv, store, review, deps = {}) {
|
|
766
876
|
const s = store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
@@ -770,10 +880,12 @@ export async function runReview(argv, store, review, deps = {}) {
|
|
|
770
880
|
// Audited approve/reject: resolve the gene (by logical id or asset_id) to its asset_id and record the act.
|
|
771
881
|
const verb = argv.includes('--approve') ? 'approve' : argv.includes('--reject') ? 'reject' : null;
|
|
772
882
|
if (verb) {
|
|
883
|
+
const allowWeakEvidence = argv.includes('--allow-weak-evidence');
|
|
773
884
|
const flagIdx = argv.indexOf(verb === 'approve' ? '--approve' : '--reject');
|
|
774
885
|
const target = argv[flagIdx + 1];
|
|
775
886
|
if (!target || target.startsWith('--')) {
|
|
776
|
-
|
|
887
|
+
const approveExtra = verb === 'approve' ? ' [--allow-weak-evidence]' : '';
|
|
888
|
+
process.stderr.write(`用法: evolver review --${verb} <id>${approveExtra} [reason…]\n`);
|
|
777
889
|
return 1;
|
|
778
890
|
}
|
|
779
891
|
// An asset_id resolves directly via store.get, so a reviewable asset past the bounded list() window is still
|
|
@@ -794,6 +906,12 @@ export async function runReview(argv, store, review, deps = {}) {
|
|
|
794
906
|
const assetId = String(g.asset_id);
|
|
795
907
|
const geneId = typeof g['id'] === 'string' ? String(g['id']) : assetId;
|
|
796
908
|
const assetType = g.type;
|
|
909
|
+
const evidence = assetType === 'AntiGene' ? summarizeAntiGeneEvidence(g) : null;
|
|
910
|
+
const explicitlyApproved = rev.isExplicitlyApproved(assetId);
|
|
911
|
+
if (verb === 'approve' && assetType === 'AntiGene' && evidence?.strength === 'weak' && !explicitlyApproved && !allowWeakEvidence) {
|
|
912
|
+
process.stderr.write(`review --approve: AntiGene ${geneId} has weak evidence (${evidence.weakReasons.join('+')}); use --allow-weak-evidence only after manual verification or reject/defer it.\n`);
|
|
913
|
+
return 1;
|
|
914
|
+
}
|
|
797
915
|
const by = operatorActorId();
|
|
798
916
|
const reason = argv.slice(flagIdx + 2).filter((a) => !a.startsWith('--')).join(' ') || `${verb}d via CLI`;
|
|
799
917
|
if (verb === 'approve')
|
|
@@ -803,7 +921,21 @@ export async function runReview(argv, store, review, deps = {}) {
|
|
|
803
921
|
const { ingestor } = resolveIngestDeps(deps);
|
|
804
922
|
await ingestor.ingest({
|
|
805
923
|
type: verb === 'approve' ? 'actor.human.review.approve' : 'actor.human.review.reject',
|
|
806
|
-
payload: {
|
|
924
|
+
payload: {
|
|
925
|
+
geneId,
|
|
926
|
+
assetId,
|
|
927
|
+
assetType,
|
|
928
|
+
reason,
|
|
929
|
+
...(evidence
|
|
930
|
+
? {
|
|
931
|
+
evidenceQuality: evidence.strength,
|
|
932
|
+
weakReasons: evidence.weakReasons,
|
|
933
|
+
failureCount: evidence.failureCount,
|
|
934
|
+
sourceClusterCount: evidence.sourceClusterCount,
|
|
935
|
+
evidenceCapsuleCount: evidence.evidenceCapsuleCount,
|
|
936
|
+
}
|
|
937
|
+
: {}),
|
|
938
|
+
},
|
|
807
939
|
human: { title: `${verb} ${assetType} ${geneId}`, severity: 'info' },
|
|
808
940
|
actor: { kind: 'human', id: by },
|
|
809
941
|
});
|
|
@@ -898,11 +1030,177 @@ export function runNarrative(argv, deps = {}) {
|
|
|
898
1030
|
}
|
|
899
1031
|
return 0;
|
|
900
1032
|
}
|
|
1033
|
+
function formatRootEventArchive(result) {
|
|
1034
|
+
if (result.mode === 'preview') {
|
|
1035
|
+
return `retention archive-root: mode=preview active=${result.activeRecords} keep=${result.keepEvents} wouldArchive=${result.wouldArchive} retained=${result.retainedRecords} archiveId=${result.archiveId ?? '-'}\n`;
|
|
1036
|
+
}
|
|
1037
|
+
return `retention archive-root: mode=write activeBefore=${result.activeRecordsBefore} keep=${result.keepEvents} archived=${result.archivedRecords} retained=${result.retainedRecords} archiveId=${result.archiveId ?? '-'} reused=${result.reusedSegment}\n`;
|
|
1038
|
+
}
|
|
1039
|
+
function formatMaterialArchive(result) {
|
|
1040
|
+
if (result.mode === 'preview') {
|
|
1041
|
+
return `retention archive-material: mode=preview active=${result.activeRecords} archive=${result.archiveRecords} history=${result.historyRecords} keep=${result.keepRecords} minCursor=${result.minCursor} wouldArchive=${result.wouldArchive} retained=${result.retainedRecords} archiveId=${result.archiveId ?? '-'}\n`;
|
|
1042
|
+
}
|
|
1043
|
+
return `retention archive-material: mode=write activeBefore=${result.activeRecordsBefore} archived=${result.archivedRecords} archive=${result.archiveRecords} history=${result.historyRecords} keep=${result.keepRecords} minCursor=${result.minCursor} retained=${result.retainedRecords} recoveredOverlap=${result.recoveredOverlap} archiveId=${result.archiveId ?? '-'}\n`;
|
|
1044
|
+
}
|
|
1045
|
+
function archiveFailureCode(error) {
|
|
1046
|
+
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
1047
|
+
? String(error.code ?? '')
|
|
1048
|
+
: '';
|
|
1049
|
+
if (code === 'ROOT_EVENT_ARCHIVE_INVALID_LOG')
|
|
1050
|
+
return 'root_event_archive_invalid_log';
|
|
1051
|
+
if (code === 'ROOT_EVENT_ARCHIVE_INVALID_ARCHIVE')
|
|
1052
|
+
return 'root_event_archive_invalid_archive';
|
|
1053
|
+
if (code === 'ROOT_EVENT_HISTORY_GAP')
|
|
1054
|
+
return 'root_event_archive_history_gap';
|
|
1055
|
+
if (code === 'ROOT_EVENT_ARCHIVE_SEGMENT_CONFLICT')
|
|
1056
|
+
return 'root_event_archive_conflict';
|
|
1057
|
+
if (code === 'LOCK_TIMEOUT')
|
|
1058
|
+
return 'root_event_archive_locked';
|
|
1059
|
+
return 'root_event_archive_failed';
|
|
1060
|
+
}
|
|
1061
|
+
function materialArchiveFailureCode(error) {
|
|
1062
|
+
const code = typeof error === 'object' && error !== null && 'code' in error
|
|
1063
|
+
? String(error.code ?? '')
|
|
1064
|
+
: '';
|
|
1065
|
+
if (code === 'MATERIAL_ARCHIVE_INVALID_LOG')
|
|
1066
|
+
return 'material_archive_invalid_log';
|
|
1067
|
+
if (code === 'MATERIAL_ARCHIVE_INVALID_ARCHIVE')
|
|
1068
|
+
return 'material_archive_invalid_archive';
|
|
1069
|
+
if (code === 'MATERIAL_ARCHIVE_RANGE_INVALID')
|
|
1070
|
+
return 'material_archive_range_invalid';
|
|
1071
|
+
if (code === 'MATERIAL_ARCHIVE_SEGMENT_CONFLICT')
|
|
1072
|
+
return 'material_archive_conflict';
|
|
1073
|
+
if (code === 'MATERIAL_ARCHIVE_CURSOR_INVALID')
|
|
1074
|
+
return 'material_archive_cursor_invalid';
|
|
1075
|
+
if (code === 'LOCK_TIMEOUT')
|
|
1076
|
+
return 'material_archive_locked';
|
|
1077
|
+
return 'material_archive_failed';
|
|
1078
|
+
}
|
|
1079
|
+
function parseRootArchiveArgs(argv) {
|
|
1080
|
+
const parsed = { help: false, json: false, write: false };
|
|
1081
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
1082
|
+
const arg = argv[index];
|
|
1083
|
+
if (arg === '--help')
|
|
1084
|
+
parsed.help = true;
|
|
1085
|
+
else if (arg === '--json')
|
|
1086
|
+
parsed.json = true;
|
|
1087
|
+
else if (arg === '--write')
|
|
1088
|
+
parsed.write = true;
|
|
1089
|
+
else if (arg === '--keep-events') {
|
|
1090
|
+
const value = argv[index + 1];
|
|
1091
|
+
const keepEvents = parsePositiveInt(value);
|
|
1092
|
+
if (value === undefined || value.startsWith('--') || keepEvents === undefined) {
|
|
1093
|
+
parsed.error = 'invalid_keep_events';
|
|
1094
|
+
return parsed;
|
|
1095
|
+
}
|
|
1096
|
+
parsed.keepEvents = keepEvents;
|
|
1097
|
+
index += 1;
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
parsed.error = 'invalid_arguments';
|
|
1101
|
+
return parsed;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
return parsed;
|
|
1105
|
+
}
|
|
1106
|
+
function runRootEventArchive(argv, deps) {
|
|
1107
|
+
const parsed = parseRootArchiveArgs(argv);
|
|
1108
|
+
if (parsed.help) {
|
|
1109
|
+
process.stdout.write('usage: evolver retention archive-root [--keep-events N] [--write] [--json]\n');
|
|
1110
|
+
return 0;
|
|
1111
|
+
}
|
|
1112
|
+
if (parsed.error !== undefined) {
|
|
1113
|
+
process.stderr.write(`retention archive-root: ${parsed.error}\n`);
|
|
1114
|
+
return 2;
|
|
1115
|
+
}
|
|
1116
|
+
const options = {
|
|
1117
|
+
path: deps.rootEventsPath ?? events.rootEventsPath(),
|
|
1118
|
+
...(parsed.keepEvents !== undefined ? { keepEvents: parsed.keepEvents } : {}),
|
|
1119
|
+
};
|
|
1120
|
+
try {
|
|
1121
|
+
const result = parsed.write
|
|
1122
|
+
? events.archiveRootEvents(options)
|
|
1123
|
+
: events.planRootEventArchive(options);
|
|
1124
|
+
if (parsed.json)
|
|
1125
|
+
process.stdout.write(`${JSON.stringify({ ok: true, group: 'retention.archive_root', ...result })}\n`);
|
|
1126
|
+
else
|
|
1127
|
+
process.stdout.write(formatRootEventArchive(result));
|
|
1128
|
+
return 0;
|
|
1129
|
+
}
|
|
1130
|
+
catch (error) {
|
|
1131
|
+
process.stderr.write(`retention archive-root: ${archiveFailureCode(error)}\n`);
|
|
1132
|
+
return 1;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
function parseMaterialArchiveArgs(argv) {
|
|
1136
|
+
const parsed = { help: false, json: false, write: false };
|
|
1137
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
1138
|
+
const arg = argv[index];
|
|
1139
|
+
if (arg === '--help')
|
|
1140
|
+
parsed.help = true;
|
|
1141
|
+
else if (arg === '--json')
|
|
1142
|
+
parsed.json = true;
|
|
1143
|
+
else if (arg === '--write')
|
|
1144
|
+
parsed.write = true;
|
|
1145
|
+
else if (arg === '--keep-records') {
|
|
1146
|
+
const value = argv[index + 1];
|
|
1147
|
+
const keepRecords = parsePositiveInt(value);
|
|
1148
|
+
if (value === undefined || value.startsWith('--') || keepRecords === undefined) {
|
|
1149
|
+
parsed.error = 'invalid_keep_records';
|
|
1150
|
+
return parsed;
|
|
1151
|
+
}
|
|
1152
|
+
parsed.keepRecords = keepRecords;
|
|
1153
|
+
index += 1;
|
|
1154
|
+
}
|
|
1155
|
+
else {
|
|
1156
|
+
parsed.error = 'invalid_arguments';
|
|
1157
|
+
return parsed;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return parsed;
|
|
1161
|
+
}
|
|
1162
|
+
function runMaterialArchive(argv, deps) {
|
|
1163
|
+
const parsed = parseMaterialArchiveArgs(argv);
|
|
1164
|
+
if (parsed.help) {
|
|
1165
|
+
process.stdout.write('usage: evolver retention archive-material [--keep-records N] [--write] [--json]\n');
|
|
1166
|
+
return 0;
|
|
1167
|
+
}
|
|
1168
|
+
if (parsed.error !== undefined) {
|
|
1169
|
+
process.stderr.write(`retention archive-material: ${parsed.error}\n`);
|
|
1170
|
+
return 2;
|
|
1171
|
+
}
|
|
1172
|
+
const path = deps.materialStorePath ?? events.materialStorePath();
|
|
1173
|
+
const cursorPaths = deps.materialCursorPaths
|
|
1174
|
+
?? (deps.materialCursorPath !== undefined
|
|
1175
|
+
? [deps.materialCursorPath]
|
|
1176
|
+
: [join(dirname(path), 'cycle-consumer.json'), join(dirname(path), 'distill-consumer.json')]);
|
|
1177
|
+
const options = {
|
|
1178
|
+
path,
|
|
1179
|
+
cursorPaths,
|
|
1180
|
+
...(parsed.keepRecords !== undefined ? { keepRecords: parsed.keepRecords } : {}),
|
|
1181
|
+
};
|
|
1182
|
+
try {
|
|
1183
|
+
const result = parsed.write
|
|
1184
|
+
? materialNs.archiveMaterialStore(options)
|
|
1185
|
+
: materialNs.planMaterialArchive(options);
|
|
1186
|
+
if (parsed.json) {
|
|
1187
|
+
process.stdout.write(`${JSON.stringify({ ok: true, group: 'retention.archive_material', ...result })}\n`);
|
|
1188
|
+
}
|
|
1189
|
+
else {
|
|
1190
|
+
process.stdout.write(formatMaterialArchive(result));
|
|
1191
|
+
}
|
|
1192
|
+
return 0;
|
|
1193
|
+
}
|
|
1194
|
+
catch (error) {
|
|
1195
|
+
process.stderr.write(`retention archive-material: ${materialArchiveFailureCode(error)}\n`);
|
|
1196
|
+
return 1;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
901
1199
|
export function formatRetentionReport(report) {
|
|
902
1200
|
const lines = [
|
|
903
1201
|
`retention: mode=${report.mode} prune=${report.destructivePruneSupported ? 'enabled' : 'disabled'} generatedAt=${report.generatedAt}`,
|
|
904
|
-
` root_events: state=${report.rootEvents.state} records=${report.rootEvents.records} bytes=${report.rootEvents.bytes} invalid=${report.rootEvents.invalidLines} firstSeq=${report.rootEvents.firstSeq ?? '-'} lastSeq=${report.rootEvents.lastSeq ?? '-'} protectTail=${report.rootEvents.protectTailEvents}`,
|
|
905
|
-
` material: state=${report.material.state} records=${report.material.records} bytes=${report.material.bytes} invalid=${report.material.invalidLines} cursor=${report.material.cursor} effectiveCursor=${report.material.effectiveCursor} cursorValid=${report.material.cursorValid} cursorInRange=${report.material.cursorInRange} consumedPrefix=${report.material.consumedPrefix} pending=${report.material.pending}`,
|
|
1202
|
+
` root_events: state=${report.rootEvents.state} records=${report.rootEvents.records} bytes=${report.rootEvents.bytes} invalid=${report.rootEvents.invalidLines} archiveSegments=${report.rootEvents.archiveSegments} archiveRecords=${report.rootEvents.archiveRecords} archiveBytes=${report.rootEvents.archiveBytes} archiveInvalid=${report.rootEvents.archiveInvalidLines} historyRecords=${report.rootEvents.historyRecords} historyConflicts=${report.rootEvents.historyConflicts} historyGaps=${report.rootEvents.historyGaps} historyIntegrityErrors=${report.rootEvents.historyIntegrityErrors} firstSeq=${report.rootEvents.firstSeq ?? '-'} lastSeq=${report.rootEvents.lastSeq ?? '-'} protectTail=${report.rootEvents.protectTailEvents}`,
|
|
1203
|
+
` material: state=${report.material.state} records=${report.material.records} bytes=${report.material.bytes} invalid=${report.material.invalidLines} archiveSegments=${report.material.archiveSegments} archiveRecords=${report.material.archiveRecords} archiveBytes=${report.material.archiveBytes} archiveInvalid=${report.material.archiveInvalidLines} historyRecords=${report.material.historyRecords} cursorCount=${report.material.cursorCount} minCursor=${report.material.minCursor} cursor=${report.material.cursor} effectiveCursor=${report.material.effectiveCursor} cursorValid=${report.material.cursorValid} cursorInRange=${report.material.cursorInRange} consumedPrefix=${report.material.consumedPrefix} pending=${report.material.pending} archiveSafe=${report.material.archiveRotationSafe}`,
|
|
906
1204
|
];
|
|
907
1205
|
if (report.warnings.length > 0) {
|
|
908
1206
|
lines.push(' warnings:');
|
|
@@ -918,11 +1216,16 @@ export function formatRetentionReport(report) {
|
|
|
918
1216
|
return `${lines.join('\n')}\n`;
|
|
919
1217
|
}
|
|
920
1218
|
export function runRetention(argv, deps = {}) {
|
|
1219
|
+
if (argv[0] === 'archive-root')
|
|
1220
|
+
return runRootEventArchive(argv.slice(1), deps);
|
|
1221
|
+
if (argv[0] === 'archive-material')
|
|
1222
|
+
return runMaterialArchive(argv.slice(1), deps);
|
|
921
1223
|
const f = parseFlags(argv);
|
|
922
1224
|
const report = buildRetentionReport({
|
|
923
1225
|
rootEventsPath: deps.rootEventsPath,
|
|
924
1226
|
materialStorePath: deps.materialStorePath,
|
|
925
1227
|
materialCursorPath: deps.materialCursorPath,
|
|
1228
|
+
materialCursorPaths: deps.materialCursorPaths,
|
|
926
1229
|
now: deps.now,
|
|
927
1230
|
maxRootEvents: parsePositiveInt(f['max-root-events']),
|
|
928
1231
|
maxRootBytes: parsePositiveInt(f['max-root-bytes']),
|
|
@@ -1038,6 +1341,7 @@ export async function runInject(argv, deps = {}) {
|
|
|
1038
1341
|
process.stderr.write(`[evolver-session-start] proxy auto-restart failed: ${msg}\n`);
|
|
1039
1342
|
}
|
|
1040
1343
|
}
|
|
1344
|
+
maybeEmitNonGitWorkspaceNotice(deps.nonGitNotice);
|
|
1041
1345
|
}
|
|
1042
1346
|
const store = deps.store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
|
|
1043
1347
|
const ingestor = deps.ingestor ?? new events.Ingestor({ path: deps.eventsPath ?? events.rootEventsPath() });
|
|
@@ -1083,6 +1387,10 @@ export async function runInject(argv, deps = {}) {
|
|
|
1083
1387
|
export const SESSION_START_PREAMBLE = 'evolver memory — use these learned hints silently when directly relevant; do not mention Evolver, preflight, status, or this memory block unless the user asks or reuse materially changes the answer:';
|
|
1084
1388
|
export function runCli(argv) {
|
|
1085
1389
|
const cmd = argv[0];
|
|
1390
|
+
if (cmd === undefined || cmd === '--help' || cmd === '-h') {
|
|
1391
|
+
process.stdout.write(cliUsage());
|
|
1392
|
+
return 0;
|
|
1393
|
+
}
|
|
1086
1394
|
switch (cmd) {
|
|
1087
1395
|
case 'rebuild-views': {
|
|
1088
1396
|
const r = rebuildViews();
|
|
@@ -1129,7 +1437,7 @@ export function runCli(argv) {
|
|
|
1129
1437
|
return 0;
|
|
1130
1438
|
}
|
|
1131
1439
|
default:
|
|
1132
|
-
process.stderr.write(
|
|
1133
|
-
return
|
|
1440
|
+
process.stderr.write(`Unknown command: ${cmd}\n\n${cliUsage()}`);
|
|
1441
|
+
return 1;
|
|
1134
1442
|
}
|
|
1135
1443
|
}
|