@evomap/evolver-cli 2.0.0-beta.17 → 2.0.0-beta.19

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 (64) hide show
  1. package/dist/antiGeneRollout.js +7 -3
  2. package/dist/assetTrust.js +14 -1
  3. package/dist/atp.d.ts +8 -3
  4. package/dist/atp.js +82 -11
  5. package/dist/atpAutoBuyer.d.ts +120 -0
  6. package/dist/atpAutoBuyer.js +814 -0
  7. package/dist/atpAutoDeliver.js +2 -2
  8. package/dist/autoDistillLlm.js +2 -1
  9. package/dist/autoDistillTranscript.js +3 -2
  10. package/dist/autoexec.d.ts +90 -13
  11. package/dist/autoexec.js +731 -84
  12. package/dist/cli.js +13 -0
  13. package/dist/cliContracts.d.ts +5 -2
  14. package/dist/cliContracts.js +135 -8
  15. package/dist/commands.d.ts +1 -0
  16. package/dist/commands.js +1 -0
  17. package/dist/curriculumCapabilityGaps.d.ts +6 -0
  18. package/dist/curriculumCapabilityGaps.js +24 -0
  19. package/dist/cycleConsumer.d.ts +4 -0
  20. package/dist/cycleConsumer.js +175 -20
  21. package/dist/dashboard.js +47 -9
  22. package/dist/dispatch.js +6 -2
  23. package/dist/distillPrimitives.js +18 -6
  24. package/dist/doctor.js +63 -5
  25. package/dist/identityHome.js +2 -1
  26. package/dist/index.d.ts +67 -39
  27. package/dist/index.js +504 -185
  28. package/dist/learningTrace.d.ts +4 -0
  29. package/dist/learningTrace.js +30 -3
  30. package/dist/lifecycle.d.ts +54 -1
  31. package/dist/lifecycle.js +489 -37
  32. package/dist/materialSnapshot.d.ts +9 -1
  33. package/dist/materialSnapshot.js +23 -6
  34. package/dist/migrate/envTranslate.d.ts +26 -0
  35. package/dist/migrate/envTranslate.js +145 -0
  36. package/dist/migrate/oauthImport.d.ts +66 -0
  37. package/dist/migrate/oauthImport.js +667 -0
  38. package/dist/migrate/v1Import.d.ts +13 -1
  39. package/dist/migrate/v1Import.js +621 -122
  40. package/dist/promptRecallHook.d.ts +24 -0
  41. package/dist/promptRecallHook.js +425 -0
  42. package/dist/recallVerifyReport.d.ts +37 -0
  43. package/dist/recallVerifyReport.js +244 -0
  44. package/dist/requiredSandboxValidation.d.ts +5 -0
  45. package/dist/requiredSandboxValidation.js +4 -0
  46. package/dist/reuse.d.ts +1 -0
  47. package/dist/reuse.js +45 -37
  48. package/dist/runtimeCapabilities.js +13 -13
  49. package/dist/runtimeSessionSource.d.ts +3 -2
  50. package/dist/runtimeSessionSource.js +63 -11
  51. package/dist/sessionIngest.d.ts +37 -0
  52. package/dist/sessionIngest.js +156 -0
  53. package/dist/setupHooks.js +95 -1
  54. package/dist/skill2gep.d.ts +4 -7
  55. package/dist/skill2gep.js +4 -21
  56. package/dist/solo/mode.js +1 -0
  57. package/dist/sync.js +125 -23
  58. package/dist/thesis.d.ts +1 -1
  59. package/dist/thesis.js +18 -3
  60. package/dist/trajectoryExport.js +21 -3
  61. package/dist/v1Compat.d.ts +1 -0
  62. package/dist/v1Compat.js +9 -0
  63. package/dist/workflowRuntime.js +24 -18
  64. package/package.json +10 -7
@@ -0,0 +1,244 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { events, mailbox } from '@evomap/evolver-core';
4
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
5
+ const SUCCESS_THRESHOLD = 0.95;
6
+ const KNOWN_OUTCOMES = new Set(['ok', 'missing', 'mismatch', 'error', 'skipped']);
7
+ function parseSince(value, now) {
8
+ const relative = /^(\d+)\s*(s|m|h|d)$/i.exec(value);
9
+ if (relative) {
10
+ const amount = Number(relative[1]);
11
+ const unit = relative[2].toLowerCase();
12
+ const factor = unit === 's' ? 1_000 : unit === 'm' ? 60_000 : unit === 'h' ? 3_600_000 : 86_400_000;
13
+ return now - amount * factor;
14
+ }
15
+ if (!/[-T]/.test(value))
16
+ return undefined;
17
+ const parsed = Date.parse(value);
18
+ return Number.isFinite(parsed) ? parsed : undefined;
19
+ }
20
+ function parseArgs(argv, now) {
21
+ let json = false;
22
+ let help = false;
23
+ let sinceMs = null;
24
+ let namespace = 'default';
25
+ for (let index = 0; index < argv.length; index += 1) {
26
+ const arg = argv[index];
27
+ if (arg === '--json') {
28
+ json = true;
29
+ continue;
30
+ }
31
+ if (arg === '--help' || arg === '-h') {
32
+ help = true;
33
+ continue;
34
+ }
35
+ const readValue = (flag) => {
36
+ if (arg?.startsWith(`${flag}=`))
37
+ return arg.slice(flag.length + 1);
38
+ if (arg === flag) {
39
+ index += 1;
40
+ return argv[index];
41
+ }
42
+ return undefined;
43
+ };
44
+ const since = readValue('--since');
45
+ if (since !== undefined) {
46
+ const parsed = parseSince(since, now);
47
+ if (parsed === undefined)
48
+ return 'invalid --since (expected ISO-8601 or a duration such as 1h, 30m, or 2d)';
49
+ sinceMs = parsed;
50
+ continue;
51
+ }
52
+ const requestedNamespace = readValue('--namespace');
53
+ if (requestedNamespace !== undefined) {
54
+ if (!/^[A-Za-z0-9._-]{1,128}$/.test(requestedNamespace))
55
+ return 'invalid --namespace';
56
+ namespace = requestedNamespace;
57
+ continue;
58
+ }
59
+ return `unknown argument: ${arg ?? '(missing)'}`;
60
+ }
61
+ return { json, help, sinceMs, namespace };
62
+ }
63
+ function percentile(values, fraction) {
64
+ if (values.length === 0)
65
+ return 0;
66
+ const sorted = [...values].sort((left, right) => left - right);
67
+ return sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * fraction))] ?? 0;
68
+ }
69
+ function emptyRow(assetType) {
70
+ return {
71
+ assetType,
72
+ total: 0,
73
+ ok: 0,
74
+ missing: 0,
75
+ mismatch: 0,
76
+ error: 0,
77
+ skipped: 0,
78
+ successRate: 0,
79
+ p50LatencyMs: 0,
80
+ p95LatencyMs: 0,
81
+ p99LatencyMs: 0,
82
+ p50AgeMs: 0,
83
+ p95AgeMs: 0,
84
+ p99AgeMs: 0,
85
+ };
86
+ }
87
+ export function aggregateRecallVerifyState(state, sinceMs) {
88
+ const outcomes = (state?.outcomes ?? []).filter((outcome) => sinceMs === null || outcome.at >= sinceMs);
89
+ const buckets = new Map();
90
+ for (const outcome of outcomes) {
91
+ const assetType = outcome.assetType ?? 'Unknown';
92
+ const bucket = buckets.get(assetType) ?? { row: emptyRow(assetType), latencies: [], ages: [], blockingSkips: 0 };
93
+ bucket.row.total += 1;
94
+ bucket.row[outcome.outcome] += 1;
95
+ // V1 state can contain terminal verifier failures as `skipped`. Only intentional sampling is non-blocking.
96
+ if (outcome.outcome === 'skipped' && outcome.reason !== 'sampled_out')
97
+ bucket.blockingSkips += 1;
98
+ if (Number.isFinite(outcome.latencyMs) && outcome.latencyMs >= 0)
99
+ bucket.latencies.push(outcome.latencyMs);
100
+ if (Number.isFinite(outcome.ageMs) && outcome.ageMs >= 0)
101
+ bucket.ages.push(outcome.ageMs);
102
+ buckets.set(assetType, bucket);
103
+ }
104
+ const rows = [...buckets.values()].map(({ row, latencies, ages, blockingSkips }) => {
105
+ const denominator = row.ok + row.missing + row.mismatch + row.error + blockingSkips;
106
+ return {
107
+ ...row,
108
+ successRate: denominator > 0 ? row.ok / denominator : 0,
109
+ p50LatencyMs: percentile(latencies, 0.5),
110
+ p95LatencyMs: percentile(latencies, 0.95),
111
+ p99LatencyMs: percentile(latencies, 0.99),
112
+ p50AgeMs: percentile(ages, 0.5),
113
+ p95AgeMs: percentile(ages, 0.95),
114
+ p99AgeMs: percentile(ages, 0.99),
115
+ };
116
+ }).sort((left, right) => left.assetType.localeCompare(right.assetType));
117
+ const totals = rows.reduce((total, row) => ({
118
+ ...total,
119
+ total: total.total + row.total,
120
+ ok: total.ok + row.ok,
121
+ missing: total.missing + row.missing,
122
+ mismatch: total.mismatch + row.mismatch,
123
+ error: total.error + row.error,
124
+ skipped: total.skipped + row.skipped,
125
+ }), emptyRow('TOTAL'));
126
+ const blockingSkips = [...buckets.values()].reduce((total, bucket) => total + bucket.blockingSkips, 0);
127
+ const denominator = totals.ok + totals.missing + totals.mismatch + totals.error + blockingSkips;
128
+ totals.successRate = denominator > 0 ? totals.ok / denominator : 0;
129
+ const totalLatencies = outcomes
130
+ .map((outcome) => outcome.latencyMs)
131
+ .filter((latency) => Number.isFinite(latency) && latency >= 0);
132
+ totals.p50LatencyMs = percentile(totalLatencies, 0.5);
133
+ totals.p95LatencyMs = percentile(totalLatencies, 0.95);
134
+ totals.p99LatencyMs = percentile(totalLatencies, 0.99);
135
+ const totalAges = outcomes
136
+ .map((outcome) => outcome.ageMs)
137
+ .filter((age) => age !== undefined && Number.isFinite(age) && age >= 0);
138
+ totals.p50AgeMs = percentile(totalAges, 0.5);
139
+ totals.p95AgeMs = percentile(totalAges, 0.95);
140
+ totals.p99AgeMs = percentile(totalAges, 0.99);
141
+ let gate = rows.length === 0 ? 'RED' : 'GREEN';
142
+ for (const row of rows) {
143
+ if (row.mismatch > 0 || row.successRate < 0.85) {
144
+ gate = 'RED';
145
+ break;
146
+ }
147
+ if (row.successRate < SUCCESS_THRESHOLD)
148
+ gate = 'YELLOW';
149
+ }
150
+ return {
151
+ since: sinceMs === null ? null : new Date(sinceMs).toISOString(),
152
+ retainedOutcomes: state?.outcomes.length ?? 0,
153
+ queued: state?.queue.length ?? 0,
154
+ rows,
155
+ totals,
156
+ gate,
157
+ retentionNotice: 'This gate covers only outcomes retained in the bounded proxy state; it is not an all-time history.',
158
+ };
159
+ }
160
+ function parseState(raw) {
161
+ if (raw === undefined)
162
+ return undefined;
163
+ const parsed = JSON.parse(raw);
164
+ if (parsed.version !== 1 || !Array.isArray(parsed.queue) || !Array.isArray(parsed.outcomes)) {
165
+ throw new Error('invalid_recall_verify_state');
166
+ }
167
+ const outcomes = parsed.outcomes.filter((outcome) => (outcome !== null
168
+ && typeof outcome === 'object'
169
+ && typeof outcome.assetId === 'string'
170
+ && KNOWN_OUTCOMES.has(outcome.outcome)
171
+ && Number.isFinite(outcome.at)
172
+ && Number.isFinite(outcome.latencyMs)
173
+ && (outcome.ageMs === undefined || (Number.isFinite(outcome.ageMs) && outcome.ageMs >= 0))));
174
+ if (outcomes.length !== parsed.outcomes.length)
175
+ throw new Error('invalid_recall_verify_state');
176
+ return { version: 1, queue: parsed.queue, outcomes, counts: parsed.counts };
177
+ }
178
+ function formatPercent(value) {
179
+ return `${(value * 100).toFixed(1)}%`;
180
+ }
181
+ function printReport(report, log) {
182
+ log(`# Publish Recall Report (since ${report.since ?? 'retained window'})`);
183
+ log('');
184
+ log(report.retentionNotice);
185
+ log(`Retained outcomes: ${report.retainedOutcomes}; queued: ${report.queued}`);
186
+ log('');
187
+ if (report.rows.length === 0) {
188
+ log('_No publish recall outcomes found._');
189
+ }
190
+ else {
191
+ log('| asset_type | total | ok | missing | mismatch | error | skipped | success_rate | p50_latency_ms | p95_latency_ms | p99_latency_ms | p50_age_ms | p95_age_ms | p99_age_ms |');
192
+ log('|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|');
193
+ for (const row of [...report.rows, report.totals]) {
194
+ log(`| ${row.assetType} | ${row.total} | ${row.ok} | ${row.missing} | ${row.mismatch} | ${row.error} | ${row.skipped} | ${formatPercent(row.successRate)} | ${row.p50LatencyMs} | ${row.p95LatencyMs} | ${row.p99LatencyMs} | ${row.p50AgeMs} | ${row.p95AgeMs} | ${row.p99AgeMs} |`);
195
+ }
196
+ }
197
+ log('');
198
+ log(`Ship gate: **${report.gate}** (${report.gate === 'GREEN' ? 'exit 0' : 'exit 2'})`);
199
+ }
200
+ export async function runRecallVerifyReport(argv, deps = {}) {
201
+ const log = deps.log ?? ((line) => process.stdout.write(`${line}\n`));
202
+ const err = deps.err ?? ((line) => process.stderr.write(`${line}\n`));
203
+ const env = deps.env ?? process.env;
204
+ const parsed = parseArgs(argv, (deps.now ?? Date.now)());
205
+ if (typeof parsed === 'string') {
206
+ err(`recall-verify-report: ${parsed}`);
207
+ return 1;
208
+ }
209
+ if (parsed.help) {
210
+ log('Usage: evolver recall-verify-report [--since <Nh|Nm|Nd|ISO>] [--namespace <name>] [--json]');
211
+ return 0;
212
+ }
213
+ const envFile = loadEnvFileFromEnv(env);
214
+ if (envFile.error) {
215
+ err('recall-verify-report: env_file_unavailable');
216
+ return 1;
217
+ }
218
+ const storePath = deps.storePath ?? env['EVOLVER_PROXY_STORE']?.trim() ?? join(events.evomapHome(env), 'proxy', 'mailbox.db');
219
+ let store;
220
+ try {
221
+ const key = `publish_recall_verifier:${parsed.namespace}:v1`;
222
+ let raw;
223
+ if (deps.readState)
224
+ raw = deps.readState(key);
225
+ else if (existsSync(storePath)) {
226
+ store = new mailbox.MailboxStore({ path: storePath });
227
+ raw = store.getState(key);
228
+ }
229
+ const report = aggregateRecallVerifyState(parseState(raw), parsed.sinceMs);
230
+ if (parsed.json)
231
+ log(JSON.stringify(report, null, 2));
232
+ else
233
+ printReport(report, log);
234
+ return report.gate === 'GREEN' ? 0 : 2;
235
+ }
236
+ catch {
237
+ err('recall-verify-report: invalid_or_unavailable_state');
238
+ return 1;
239
+ }
240
+ finally {
241
+ store?.close();
242
+ }
243
+ }
244
+ export const runRecallVerifyReportCommand = (argv) => runRecallVerifyReport(argv);
@@ -0,0 +1,5 @@
1
+ import { verify } from '@evomap/evolver-core';
2
+ export type SandboxedValidationRunner = typeof verify.runSandboxedValidation;
3
+ type SandboxedValidationOptions = NonNullable<Parameters<SandboxedValidationRunner>[2]>;
4
+ export declare function runRequiredSandboxedValidation(commands: readonly string[], cwd: string, options?: SandboxedValidationOptions, runner?: SandboxedValidationRunner): ReturnType<SandboxedValidationRunner>;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ import { verify } from '@evomap/evolver-core';
2
+ export function runRequiredSandboxedValidation(commands, cwd, options = {}, runner = verify.runSandboxedValidation) {
3
+ return runner(commands, cwd, { ...options, requireIsolation: true });
4
+ }
package/dist/reuse.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface ReuseCliDeps {
29
29
  hub?: AssetByIdFetcher;
30
30
  callLog?: {
31
31
  append(entry: hubNs.AssetCallEntry): void;
32
+ assetCostIndex?(): Record<string, number>;
32
33
  };
33
34
  env?: NodeJS.ProcessEnv;
34
35
  stdout?: (line: string) => void;
package/dist/reuse.js CHANGED
@@ -81,7 +81,7 @@ export async function runReuseCommand(argv, deps = {}) {
81
81
  const store = deps.store ?? new assetstore.LocalJsonlProvider(deps.assetsDir ?? events.assetsDir(env));
82
82
  // 1) Already in the local recall library → reuse is idempotent: log + ok, no hub round-trip.
83
83
  const local = await resolveLocalReuseAsset(store, opts.id);
84
- if (local) {
84
+ if (local && !isUnsafeUnverifiedLocalAsset(local, store, deps)) {
85
85
  logReuse(deps, opts, local, 'local');
86
86
  return emit({ ok: true, status: 'ok', message: 'asset already in local recall library' }, ctx);
87
87
  }
@@ -246,7 +246,6 @@ async function ingestHubAsset(store, deps, asset, requestedId) {
246
246
  else if (stringField(cleaned, 'id') !== requestedId) {
247
247
  throw new ReuseIntegrityError(INTEGRITY_LOGICAL_ID_MESSAGE);
248
248
  }
249
- await assertNoLocalReuseIdConflict(cleaned, store);
250
249
  const provenance = new assetstore.ProvenanceStore(storeBaseDir(store, deps));
251
250
  // Identity is confirmed; now content integrity. When the (marker-free) payload hashes to its declared id it
252
251
  // lands verified (still sidecar-marked untrusted per #30). When it does NOT, the hub rewrote the delivered
@@ -254,11 +253,15 @@ async function ingestHubAsset(store, deps, asset, requestedId) {
254
253
  // unverified so the save actually happens and the loop (which already reuses hub content without
255
254
  // re-verifying) can use it, while trust-first selection keeps it out of the reasoning pool until promotion.
256
255
  if (actualAssetId === contentAssetId) {
257
- const stored = await assetstore.ingestUntrusted(store, provenance, cleaned, 'hub');
256
+ const stored = await assetstore.ingestUntrustedConditional(store, provenance, cleaned);
257
+ if (stored.status === 'logical_collision')
258
+ throw new Error('local asset id conflict');
258
259
  return { record: { ...cleaned, asset_id: stored.asset_id }, verified: true };
259
260
  }
260
261
  const reason = synthesized ? 'unverified_hub_synthesized' : 'unverified_hub_rewrite';
261
- const stored = await assetstore.ingestUnverified(store, provenance, cleaned, reason, 'hub');
262
+ const stored = await assetstore.ingestUnverifiedConditional(store, provenance, cleaned, reason);
263
+ if (stored.status === 'logical_collision')
264
+ throw new Error('local asset id conflict');
262
265
  return { record: { ...cleaned, asset_id: stored.asset_id }, verified: false };
263
266
  }
264
267
  /**
@@ -272,31 +275,9 @@ function withoutHubDeliveryMarkers(asset) {
272
275
  return rest;
273
276
  }
274
277
  async function resolveLocalReuseAsset(store, id) {
275
- const direct = await store.get(id);
276
- if (direct)
277
- return direct;
278
- for (const kind of ['Gene', 'Capsule']) {
279
- const rows = await store.list(kind, 10_000);
280
- const match = rows.find((row) => stringField(row, 'id') === id || String(row.asset_id) === id);
281
- if (match)
282
- return match;
283
- }
284
- return null;
285
- }
286
- async function assertNoLocalReuseIdConflict(asset, store) {
287
- if (asset.type !== 'Gene' && asset.type !== 'Capsule')
288
- return;
289
- const id = stringField(asset, 'id');
290
- if (!id)
291
- return;
292
- const rows = await store.list(asset.type, 10_000);
293
- const local = rows.find((row) => stringField(row, 'id') === id);
294
- if (!local)
295
- return;
296
- const incomingAssetId = wire.computeAssetId(asset);
297
- const localAssetId = wire.computeAssetId(local);
298
- if (incomingAssetId !== localAssetId)
299
- throw new Error('local asset id conflict');
278
+ // A logical id does not identify an asset type. Gene and Capsule ids may overlap, so only the Hub can resolve
279
+ // which remote asset the caller requested; treating either local type as a hit can silently reuse the wrong one.
280
+ return isContentAssetId(id) ? store.get(id) : null;
300
281
  }
301
282
  function unwrapHubAssetContent(asset) {
302
283
  const payload = asset.payload;
@@ -322,6 +303,22 @@ function storeBaseDir(store, deps) {
322
303
  ? store.baseDir
323
304
  : deps.assetsDir ?? events.assetsDir(deps.env ?? process.env);
324
305
  }
306
+ function isUnsafeUnverifiedLocalAsset(asset, store, deps) {
307
+ if (wire.verifyAssetId(asset))
308
+ return false;
309
+ const record = new assetstore.ProvenanceStore(storeBaseDir(store, deps)).get(asset.asset_id);
310
+ if (record?.trusted === true || record?.decision !== undefined)
311
+ return false;
312
+ const supportedReason = (record?.source === 'hub'
313
+ && (record.reason === 'unverified_hub_rewrite' || record.reason === 'unverified_hub_synthesized')) || (record?.source === 'migrated' && record.reason === 'unverified_gepx_import');
314
+ const isActiveWaiver = supportedReason
315
+ && record.trusted === false
316
+ && record.decision === undefined
317
+ && record.decidedBy === undefined
318
+ && record.promotedBy === undefined
319
+ && record.frozenContentId === wire.computeAssetId(asset);
320
+ return !isActiveWaiver;
321
+ }
325
322
  function stringField(record, key) {
326
323
  const value = record[key];
327
324
  return typeof value === 'string' && value.length > 0 ? value : undefined;
@@ -332,14 +329,25 @@ function isContentAssetId(value) {
332
329
  function logReuse(deps, opts, asset, source) {
333
330
  // AssetCallLog.append is best-effort (never throws) — a logging failure must not break the reuse write.
334
331
  const callLog = deps.callLog ?? new hubNs.AssetCallLog(events.assetCallLogPath(deps.env ?? process.env));
335
- callLog.append({
336
- action: 'asset_reuse',
337
- asset_id: asset.asset_id,
338
- asset_type: asset.type,
339
- mode: opts.mode,
340
- ...(opts.runId ? { run_id: opts.runId } : {}),
341
- extra: { source },
342
- });
332
+ let indexedTokenCost;
333
+ try {
334
+ indexedTokenCost = callLog.assetCostIndex?.()[asset.asset_id];
335
+ }
336
+ catch { /* fall back to the estimator */ }
337
+ const savings = hubNs.reuseSavingsForAsset(asset, opts.mode, indexedTokenCost);
338
+ try {
339
+ callLog.append({
340
+ action: opts.mode === 'reference' ? 'asset_reference' : 'asset_reuse',
341
+ asset_id: asset.asset_id,
342
+ asset_type: asset.type,
343
+ mode: opts.mode,
344
+ tokens_saved: savings.tokens_saved,
345
+ tokens_saved_basis: savings.tokens_saved_basis,
346
+ ...(opts.runId ? { run_id: opts.runId } : {}),
347
+ extra: { source },
348
+ });
349
+ }
350
+ catch { /* an injected logger must preserve the production logger's non-fatal contract */ }
343
351
  }
344
352
  async function establishReuseTrust(hub) {
345
353
  if (typeof hub.hello !== 'function')
@@ -7,25 +7,25 @@ export const RUNTIME_CAPABILITY_MATRIX = {
7
7
  runtime: 'claude-code',
8
8
  ingest: supported('normalized Claude Code JSONL adapter'),
9
9
  inject: supported('MCP registration plus SessionStart hook'),
10
- execute: supported('run-verified claude -p runner'),
11
- verify: supported('git diff proof plus external validation hook'),
12
- resume: unsupported('cycle runner does not bind ingested session ids to claude resume'),
10
+ execute: unsupported('built-in Claude is fail-closed until host filesystem and network containment is verified'),
11
+ verify: unsupported('no safely runnable autonomous Claude verification path'),
12
+ resume: unsupported('native session identity mapping is implemented, but built-in Claude execution is disabled until host containment is verified'),
13
13
  },
14
14
  codex: {
15
15
  runtime: 'codex',
16
16
  ingest: supported('normalized Codex rollout adapter'),
17
17
  inject: supported('project MCP config plus SessionStart hook'),
18
- execute: supported('run-verified codex exec runner'),
19
- verify: supported('git diff proof plus external validation hook'),
18
+ execute: unsupported('built-in Codex is fail-closed because workspace-write does not contain host filesystem reads'),
19
+ verify: unsupported('no safely runnable autonomous Codex verification path without external host containment'),
20
20
  resume: unsupported('cycle runner starts a new codex exec session'),
21
21
  },
22
22
  cursor: {
23
23
  runtime: 'cursor',
24
24
  ingest: supported('Cursor transcript and state.vscdb adapters'),
25
25
  inject: supported('always-on project rules injection'),
26
- execute: experimental('CLI flags are contract-tested but the repository still treats the runner as a scaffold'),
27
- verify: supported('git diff proof plus external validation hook'),
28
- resume: unsupported('no verified headless session resume mapping'),
26
+ execute: unsupported('headless Cursor workspace trust grants uncontained host filesystem and network access'),
27
+ verify: unsupported('no safely runnable autonomous Cursor execution path'),
28
+ resume: unsupported('native session identity mapping is implemented, but autonomous Cursor execution is disabled until host filesystem and network containment are verified'),
29
29
  },
30
30
  gemini: {
31
31
  runtime: 'gemini',
@@ -45,7 +45,7 @@ export const RUNTIME_CAPABILITY_MATRIX = {
45
45
  },
46
46
  kimi: {
47
47
  runtime: 'kimi',
48
- ingest: supported('normalized Kimi session adapter'),
48
+ ingest: experimental('registered parser for the documented Kimi wire.jsonl shape; no sanitized real-log golden fixture'),
49
49
  inject: unsupported('no Evolver Kimi injection installer'),
50
50
  execute: unsupported('no verified Kimi runner contract'),
51
51
  verify: unsupported('no Kimi execution runner exists'),
@@ -53,16 +53,16 @@ export const RUNTIME_CAPABILITY_MATRIX = {
53
53
  },
54
54
  kiro: {
55
55
  runtime: 'kiro',
56
- ingest: supported('normalized Kiro session adapter'),
57
- inject: unsupported('automatic Kiro setup is not available on the current main branch'),
56
+ ingest: unsupported('transcript adapter is not registered; no real-log golden fixture'),
57
+ inject: supported('verified Kiro MCP config installer for tool discovery; no lifecycle prompt injection'),
58
58
  execute: unsupported('no verified Kiro runner contract'),
59
59
  verify: unsupported('no Kiro execution runner exists'),
60
60
  resume: unsupported('no verified Kiro resume contract'),
61
61
  },
62
62
  opencode: {
63
63
  runtime: 'opencode',
64
- ingest: supported('normalized OpenCode session adapter'),
65
- inject: unsupported('automatic OpenCode setup is not available on the current main branch'),
64
+ ingest: unsupported('transcript adapter is not registered; no real-log golden fixture'),
65
+ inject: supported('verified OpenCode MCP config installer for tool discovery; no lifecycle prompt injection'),
66
66
  execute: unsupported('no verified OpenCode runner contract'),
67
67
  verify: unsupported('no OpenCode execution runner exists'),
68
68
  resume: unsupported('no verified OpenCode resume contract'),
@@ -3,6 +3,7 @@ export interface RuntimeSessionSource {
3
3
  agent: string;
4
4
  label: string;
5
5
  sessionId?: string;
6
+ resumeIdentityProvenance?: 'canonical_native_transcript';
6
7
  turns: NormalizedTurn[];
7
8
  }
8
9
  export interface RuntimeSessionParseDiagnostics {
@@ -15,5 +16,5 @@ export interface RuntimeSessionParseResult {
15
16
  diagnostics: RuntimeSessionParseDiagnostics;
16
17
  }
17
18
  export declare function isRuntimeSessionSourcePath(path: string): boolean;
18
- export declare function parseRuntimeSessionSourcesWithDiagnostics(path: string, readSource?: (path: string) => string): RuntimeSessionParseResult;
19
- export declare function parseRuntimeSessionSources(path: string, readSource?: (path: string) => string): RuntimeSessionSource[];
19
+ export declare function parseRuntimeSessionSourcesWithDiagnostics(path: string, readSource?: (path: string) => string, nativeSessionHome?: string): RuntimeSessionParseResult;
20
+ export declare function parseRuntimeSessionSources(path: string, readSource?: (path: string) => string, nativeSessionHome?: string): RuntimeSessionSource[];
@@ -1,7 +1,25 @@
1
- import { readFileSync } from 'node:fs';
2
- import { resolve } from 'node:path';
1
+ import { readFileSync, realpathSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { isAbsolute, join, relative, resolve } from 'node:path';
3
4
  import { adapterForPath, isCursorStateVscdbPath, parseJsonlLinesWithStats, parseCursorStateVscdb, stripUtf8Bom, } from '@evomap/evolver-runtime-adapters';
4
5
  const EMPTY_DIAGNOSTICS = { rowsScanned: 0, rowsRead: 0, invalidJson: 0 };
6
+ function canonicalNativeSessionSource(path, agent, nativeSessionHome) {
7
+ const runtimeRoot = agent === 'claude-code'
8
+ ? join(nativeSessionHome, '.claude', 'projects')
9
+ : agent === 'cursor' ? join(nativeSessionHome, '.cursor', 'projects') : undefined;
10
+ if (!runtimeRoot)
11
+ return path;
12
+ try {
13
+ const canonicalRoot = realpathSync(runtimeRoot);
14
+ const canonicalPath = realpathSync(path);
15
+ const child = relative(canonicalRoot, canonicalPath);
16
+ return child !== '' && !child.startsWith(`..${process.platform === 'win32' ? '\\' : '/'}`)
17
+ && child !== '..' && !isAbsolute(child) ? canonicalPath : undefined;
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ }
5
23
  export function isRuntimeSessionSourcePath(path) {
6
24
  return isCursorStateVscdbPath(path) || adapterForPath(path) !== undefined;
7
25
  }
@@ -28,7 +46,7 @@ function diagnosticsForRuntimeSource(raw) {
28
46
  return parseJsonlLinesWithStats(raw).stats;
29
47
  }
30
48
  }
31
- export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource = (p) => readFileSync(p, 'utf8')) {
49
+ export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource = (p) => readFileSync(p, 'utf8'), nativeSessionHome = homedir()) {
32
50
  const absPath = resolve(path);
33
51
  if (isCursorStateVscdbPath(absPath)) {
34
52
  const sources = parseCursorStateVscdb(absPath)
@@ -39,18 +57,52 @@ export function parseRuntimeSessionSourcesWithDiagnostics(path, readSource = (p)
39
57
  const adapter = adapterForPath(absPath);
40
58
  if (!adapter)
41
59
  return { sources: [], diagnostics: { ...EMPTY_DIAGNOSTICS } };
42
- const raw = readSource(absPath);
43
- const sessionId = adapter.sessionIdFromPath?.(absPath)?.trim();
44
- return {
45
- sources: [{
60
+ const canonicalResumeSource = adapter.resumeIdentityFromSource
61
+ ? canonicalNativeSessionSource(absPath, adapter.agent, nativeSessionHome)
62
+ : undefined;
63
+ const raw = readSource(canonicalResumeSource ?? absPath);
64
+ const nativeResumeIdentity = adapter.resumeIdentityFromSource && canonicalResumeSource
65
+ ? adapter.resumeIdentityFromSource(canonicalResumeSource, raw)
66
+ : undefined;
67
+ if (adapter.resumeIdentityFromSource) {
68
+ const sessionId = nativeResumeIdentity?.sessionId.trim();
69
+ return {
70
+ sources: [{
71
+ agent: adapter.agent,
72
+ label: sessionId ? `${adapter.agent}:${sessionId}` : adapter.agent,
73
+ ...(sessionId ? { sessionId } : {}),
74
+ ...(sessionId ? { resumeIdentityProvenance: 'canonical_native_transcript' } : {}),
75
+ turns: adapter.parse(raw),
76
+ }],
77
+ diagnostics: diagnosticsForRuntimeSource(raw),
78
+ };
79
+ }
80
+ const pathSessionId = adapter.sessionIdFromPath?.(absPath)?.trim();
81
+ const parsedSessions = adapter.parseSessions?.(raw)
82
+ ?? (adapter.parseSession ? [adapter.parseSession(raw)] : []);
83
+ const sources = parsedSessions.length > 0
84
+ ? parsedSessions.map((session, index) => {
85
+ const sessionId = pathSessionId ?? session.sessionId?.trim();
86
+ return {
46
87
  agent: adapter.agent,
47
- label: sessionId ? `${adapter.agent}:${sessionId}` : adapter.agent,
88
+ label: sessionId
89
+ ? `${adapter.agent}:${sessionId}`
90
+ : parsedSessions.length > 1 ? `${adapter.agent}:${index + 1}` : adapter.agent,
48
91
  ...(sessionId ? { sessionId } : {}),
92
+ turns: session.turns,
93
+ };
94
+ })
95
+ : [{
96
+ agent: adapter.agent,
97
+ label: pathSessionId ? `${adapter.agent}:${pathSessionId}` : adapter.agent,
98
+ ...(pathSessionId ? { sessionId: pathSessionId } : {}),
49
99
  turns: adapter.parse(raw),
50
- }],
100
+ }];
101
+ return {
102
+ sources,
51
103
  diagnostics: diagnosticsForRuntimeSource(raw),
52
104
  };
53
105
  }
54
- export function parseRuntimeSessionSources(path, readSource = (p) => readFileSync(p, 'utf8')) {
55
- return parseRuntimeSessionSourcesWithDiagnostics(path, readSource).sources;
106
+ export function parseRuntimeSessionSources(path, readSource = (p) => readFileSync(p, 'utf8'), nativeSessionHome = homedir()) {
107
+ return parseRuntimeSessionSourcesWithDiagnostics(path, readSource, nativeSessionHome).sources;
56
108
  }
@@ -0,0 +1,37 @@
1
+ import { events, material as materialNs } from '@evomap/evolver-core';
2
+ import { type RuntimeSessionMaterialSnapshotV1 } from './materialSnapshot.js';
3
+ import { type RuntimeSessionParseDiagnostics } from './runtimeSessionSource.js';
4
+ /** Material consumer group shared by ingestion and the downstream cycle consumer. */
5
+ export declare const INGEST_CONSUMER_GROUP = "cycle";
6
+ /** Injectable substrate dependencies for session and trace ingestion. */
7
+ export interface IngestDeps {
8
+ materialStore?: materialNs.MaterialStore;
9
+ watermarkStore?: materialNs.WatermarkStore;
10
+ ingestor?: events.Ingestor;
11
+ /** User home whose native runtime directories may contribute resumable session identities. */
12
+ nativeSessionHome?: string;
13
+ }
14
+ export interface SessionIngestTickResult {
15
+ recorded: number;
16
+ sourceAgents: string[];
17
+ signalKinds: string[];
18
+ signalStrengths: string[];
19
+ invalidJsonRows?: number;
20
+ /** Cursor databases that could not be opened or parsed; no path or native error text is exposed. */
21
+ parseFailures?: number;
22
+ }
23
+ export declare function resolveIngestDeps(deps: IngestDeps): {
24
+ materialStore: materialNs.MaterialStore;
25
+ watermarkStore: materialNs.WatermarkStore;
26
+ ingestor: events.Ingestor;
27
+ };
28
+ export declare function toMaterialSourceAgent(agent: string): materialNs.BuildMaterialInput['sourceAgent'] | undefined;
29
+ export declare function recordSessionMaterial(sourceAgent: materialNs.BuildMaterialInput['sourceAgent'], absPath: string, signalCount: number, deps: ReturnType<typeof resolveIngestDeps>, recordCount?: number, payload?: RuntimeSessionMaterialSnapshotV1, diagnostics?: RuntimeSessionParseDiagnostics): Promise<{
30
+ recorded: boolean;
31
+ emitted: boolean;
32
+ materialId?: string;
33
+ }>;
34
+ /** Recursively enumerate recognized runtime-session sources, skipping inaccessible directories. */
35
+ export declare function scanSessionDirs(dirs: readonly string[]): string[];
36
+ /** Record all new or changed runtime sessions as material for the auto-distill loop. */
37
+ export declare function runSessionIngestTick(dirs: readonly string[], deps?: IngestDeps): Promise<SessionIngestTickResult>;