@evomap/evolver-cli 2.0.36 → 2.0.38

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 (40) hide show
  1. package/dist/antiGeneRollout.d.ts +2 -0
  2. package/dist/antiGeneRollout.js +21 -3
  3. package/dist/assetTrust.js +9 -0
  4. package/dist/atpAutoDeliver.d.ts +10 -0
  5. package/dist/atpAutoDeliver.js +28 -1
  6. package/dist/autoRecall.js +8 -4
  7. package/dist/autoexec.d.ts +15 -0
  8. package/dist/autoexec.js +148 -7
  9. package/dist/autoexecConfig.d.ts +1 -1
  10. package/dist/autoexecConfig.js +1 -1
  11. package/dist/cliContracts.d.ts +7 -2
  12. package/dist/cliContracts.js +97 -13
  13. package/dist/cursorRewrite.d.ts +6 -0
  14. package/dist/cursorRewrite.js +64 -6
  15. package/dist/cycleConsumer.js +1 -0
  16. package/dist/index.js +11 -3
  17. package/dist/localPublishBinding.d.ts +25 -0
  18. package/dist/localPublishBinding.js +139 -0
  19. package/dist/promptRecallHook.js +86 -10
  20. package/dist/recall.d.ts +2 -0
  21. package/dist/recall.js +19 -1
  22. package/dist/recipe.d.ts +5 -1
  23. package/dist/recipe.js +123 -42
  24. package/dist/referenceAccess.d.ts +3 -0
  25. package/dist/referenceAccess.js +232 -0
  26. package/dist/referencePublish.d.ts +4 -0
  27. package/dist/referencePublish.js +40 -0
  28. package/dist/requiredSandboxValidation.js +6 -1
  29. package/dist/reviewFilter.d.ts +1 -1
  30. package/dist/reviewFilter.js +12 -1
  31. package/dist/sourceQualification.d.ts +2 -0
  32. package/dist/sourceQualification.js +120 -0
  33. package/dist/taskCommitments.d.ts +135 -0
  34. package/dist/taskCommitments.js +492 -0
  35. package/dist/taskReceiver.d.ts +151 -0
  36. package/dist/taskReceiver.js +459 -0
  37. package/dist/thesis.d.ts +3 -0
  38. package/dist/thesis.js +122 -100
  39. package/dist/workflowRuntime.js +13 -2
  40. package/package.json +7 -7
@@ -1,5 +1,7 @@
1
1
  import { assetstore, benchmark, events, exec } from '@evomap/evolver-core';
2
2
  export interface AntiGeneRolloutCommandDeps {
3
+ env?: Readonly<NodeJS.ProcessEnv>;
4
+ provenance?: assetstore.ProvenanceStore;
3
5
  store?: assetstore.AssetStoreProvider;
4
6
  review?: assetstore.ReviewLedger;
5
7
  readEvents?: (eventsPath?: string) => events.ReportEvent[];
@@ -194,7 +194,7 @@ function validationCommand(commandLine, cwd) {
194
194
  });
195
195
  }
196
196
  function liveMakeExecute(repo, runner, validation, deps = {}) {
197
- return ({ store, review }) => {
197
+ return ({ store, review, provenance, benchmark: sourceBenchmark }) => {
198
198
  const validate = async (_mutation, _decision, cwd) => {
199
199
  for (const command of validation) {
200
200
  if (await validationCommand(command, cwd) !== 0)
@@ -207,6 +207,7 @@ function liveMakeExecute(repo, runner, validation, deps = {}) {
207
207
  ...(runner ? { runner } : {}),
208
208
  }, {
209
209
  review,
210
+ ...(sourceBenchmark ? { benchmark: sourceBenchmark, provenance } : {}),
210
211
  validate,
211
212
  validationCmds: validation,
212
213
  ...(deps.agent ? { agent: deps.agent } : {}),
@@ -240,6 +241,14 @@ export async function runAntiGeneRolloutCommand(argv, deps = {}) {
240
241
  process.stderr.write(usage);
241
242
  return 1;
242
243
  }
244
+ let sourceBenchmark;
245
+ try {
246
+ sourceBenchmark = assetstore.benchmarkContext((deps.env ?? process.env)['EVOLVER_BENCHMARK_ID']);
247
+ }
248
+ catch {
249
+ process.stderr.write('anti-gene-rollout: invalid_benchmark_id\n');
250
+ return 1;
251
+ }
243
252
  if (flags.minSamples !== undefined && (!Number.isFinite(flags.minSamples) || flags.minSamples < 1)) {
244
253
  process.stderr.write('anti-gene-rollout: --min-samples must be >= 1\n');
245
254
  return 1;
@@ -274,12 +283,21 @@ export async function runAntiGeneRolloutCommand(argv, deps = {}) {
274
283
  return 1;
275
284
  }
276
285
  const assetsDir = flags.assets ? resolve(flags.assets) : events.assetsDir();
277
- const reviewDir = flags.reviewDir ? resolve(flags.reviewDir) : assetsDir;
278
286
  const store = deps.store ?? new assetstore.LocalJsonlProvider(assetsDir);
287
+ if (sourceBenchmark && !(store instanceof assetstore.LocalJsonlProvider)
288
+ && (!deps.provenance || (!deps.review && !flags.reviewDir))) {
289
+ process.stderr.write('anti-gene-rollout: benchmark_source_ledgers_required\n');
290
+ return 1;
291
+ }
292
+ const reviewDir = flags.reviewDir ? resolve(flags.reviewDir)
293
+ : sourceBenchmark && store instanceof assetstore.LocalJsonlProvider ? store.baseDir : assetsDir;
279
294
  const review = deps.review ?? new assetstore.ReviewLedger(reviewDir, deps.now);
280
295
  const eventsPath = flags.events ? resolve(flags.events) : join(mkdtempSync(join(tmpdir(), 'anti-gene-rollout-events-')), 'root_events.jsonl');
281
296
  const makeExecute = deps.makeExecute ?? liveMakeExecute(resolve(flags.repo), flags.runner, suite.validation, deps);
282
- const report = await benchmark.runAntiGeneRollout(suite, { store, review, makeExecute }, {
297
+ const report = await benchmark.runAntiGeneRollout(suite, { store, review, makeExecute,
298
+ ...(deps.provenance ? { provenance: deps.provenance } : {}),
299
+ }, {
300
+ ...(sourceBenchmark ? { benchmark: sourceBenchmark } : {}),
283
301
  eventsPath,
284
302
  now: deps.now,
285
303
  ...(!semanticIdfEnabled() ? { disableSemanticIdf: true } : {}),
@@ -1,5 +1,7 @@
1
1
  import { assetstore, events, hub } from '@evomap/evolver-core';
2
2
  import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
3
+ import { runSourceQualificationCommand } from './sourceQualification.js';
4
+ import { runReferenceAccessCommand } from './referenceAccess.js';
3
5
  const GROUP = 'asset-trust';
4
6
  const DEFAULT_LIMIT = 50;
5
7
  const MAX_LIMIT = 200;
@@ -13,6 +15,9 @@ const USAGE = [
13
15
  ' evolver asset-trust show <asset_id> [--json]',
14
16
  ' evolver asset-trust promote <asset_id> --reason <text> [--json]',
15
17
  ' evolver asset-trust revoke <asset_id> --reason <text> [--json]',
18
+ ' evolver asset-trust qualify <asset_id> --evidence <file> --reason <text> [--exception <reason>] [--json]',
19
+ ' evolver asset-trust qualification <asset_id> --benchmark <id> [--evidence-digest <sha256>] [--json]',
20
+ ' evolver asset-trust access <replay|get|read> --help',
16
21
  '',
17
22
  ].join('\n');
18
23
  function parseArgs(argv) {
@@ -133,6 +138,10 @@ async function recordTrustEvent(ingestor, action, view, reason, actorId) {
133
138
  }
134
139
  }
135
140
  export async function runAssetTrustCommand(argv, deps = {}) {
141
+ if (argv[0] === 'access')
142
+ return runReferenceAccessCommand(argv.slice(1), deps);
143
+ if (argv[0] === 'qualify' || argv[0] === 'qualification')
144
+ return runSourceQualificationCommand(argv, deps, safeActorId);
136
145
  const stdout = deps.stdout ?? ((text) => { process.stdout.write(text); });
137
146
  const stderr = deps.stderr ?? ((text) => { process.stderr.write(text); });
138
147
  if (argv.includes('--help') || argv.includes('-h')) {
@@ -9,6 +9,12 @@ export declare const ATP_AUTODELIVER_COOLDOWN_CAP_MS: number;
9
9
  export interface AtpAutoDeliverClient {
10
10
  listMyTasks(limit?: number, nodeId?: string): Promise<AtpResult>;
11
11
  submitDelivery(orderId: string, proofPayload?: unknown): Promise<AtpResult>;
12
+ /**
13
+ * The node this client authenticates as — the only node its deliveries can be for.
14
+ * Optional so an older injected client still compiles and still runs; not answering is
15
+ * simply not being trusted, because there is no fallback identity to guess with.
16
+ */
17
+ nodeId?(): string | undefined;
12
18
  }
13
19
  export interface AtpAutoDeliverLedger {
14
20
  version: 2;
@@ -23,6 +29,8 @@ export interface AtpAutoDeliverTickResult {
23
29
  checked: number;
24
30
  delivered: number;
25
31
  skippedTasks: number;
32
+ /** Tasks another node holds. Delivering those is what the Hub rejects. */
33
+ skippedForeign: number;
26
34
  terminalFailures: number;
27
35
  transientFailures: number;
28
36
  /** 429 rate-limit hits this tick — backed off (a subset of "failed", tracked apart for observability). */
@@ -30,6 +38,8 @@ export interface AtpAutoDeliverTickResult {
30
38
  }
31
39
  export interface AtpAutoDeliverDeps {
32
40
  client?: AtpAutoDeliverClient;
41
+ /** Which node we are. A task claimed by anyone else is not ours to deliver. */
42
+ nodeId?: string;
33
43
  createClient?: (env: NodeJS.ProcessEnv) => AtpAutoDeliverClient;
34
44
  env?: NodeJS.ProcessEnv;
35
45
  ledgerPath?: string;
@@ -11,7 +11,7 @@ export const ATP_AUTODELIVER_LEDGER_MAX_ENTRIES = 500;
11
11
  // capped. The first 429 waits BASE; subsequent ones BASE*2^(hits-1) up to CAP.
12
12
  export const ATP_AUTODELIVER_COOLDOWN_BASE_MS = 5 * 60_000; // 5 min
13
13
  export const ATP_AUTODELIVER_COOLDOWN_CAP_MS = 6 * 60 * 60_000; // 6 h
14
- const EMPTY_TICK = { checked: 0, delivered: 0, skippedTasks: 0, terminalFailures: 0, transientFailures: 0, cooldownFailures: 0 };
14
+ const EMPTY_TICK = { checked: 0, delivered: 0, skippedTasks: 0, skippedForeign: 0, terminalFailures: 0, transientFailures: 0, cooldownFailures: 0 };
15
15
  export function isAtpAutoDeliverEnabled(env = process.env) {
16
16
  const raw = (env['EVOLVER_ATP_AUTODELIVER'] ?? 'on').toLowerCase().trim();
17
17
  return raw !== 'off' && raw !== '0' && raw !== 'false';
@@ -38,6 +38,24 @@ export async function runAtpAutoDeliverTick(deps = {}) {
38
38
  const nowMs = deps.nowMs ?? (() => Date.now());
39
39
  const log = deps.log ?? (() => { });
40
40
  const out = { ...EMPTY_TICK };
41
+ // The identity that filters has to BE the identity that submits. The client is the one
42
+ // that will be on the wire, so when it can name itself it decides — a caller-supplied
43
+ // nodeId only fills in for a client that cannot, and a caller that disagrees with the
44
+ // credentials is a misconfiguration whose every delivery the Hub would reject anyway.
45
+ // Called defensively: a client from before this method existed is a stranger, not a
46
+ // crash. It delivers nothing either way, but it fails the check rather than the process.
47
+ const nodeId = typeof client.nodeId === 'function' ? client.nodeId() : undefined;
48
+ if (deps.nodeId && nodeId && deps.nodeId !== nodeId) {
49
+ log(`[ATP-AutoDeliver] refusing to deliver: asked to act as ${deps.nodeId} with ${nodeId}'s credentials`);
50
+ return out;
51
+ }
52
+ // Only the submitting client's own credentials can say whose work this is. An env or
53
+ // caller-supplied id is unbound to them, and filtering by one identity while submitting
54
+ // as another is the separation this check exists to stop. Fail closed, loudly.
55
+ if (!nodeId) {
56
+ log('[ATP-AutoDeliver] the hub client cannot name the node it authenticates as; refusing to deliver (ownership cannot be checked)');
57
+ return out;
58
+ }
41
59
  try {
42
60
  const listed = await client.listMyTasks(deps.limit ?? 20);
43
61
  if (!listed.ok)
@@ -68,6 +86,15 @@ export async function runAtpAutoDeliverTick(deps = {}) {
68
86
  out.skippedTasks += 1;
69
87
  continue;
70
88
  }
89
+ // /a2a/task/my answers with every task this node can see, including ones another
90
+ // node claimed. Delivering someone else's work is what the Hub rejects (#1168).
91
+ // A task that names no claimant proves nothing either: "not visibly someone else's"
92
+ // is not "ours", so only an explicit match gets delivered.
93
+ const claimedBy = taskString(task, 'claimed_by') ?? taskString(task, 'claimedBy');
94
+ if (claimedBy !== nodeId) {
95
+ out.skippedForeign += 1;
96
+ continue;
97
+ }
71
98
  const status = taskString(task, 'status') ?? taskString(task, 'task_status');
72
99
  if (status && status !== 'claimed' && status !== 'completed') {
73
100
  out.skippedTasks += 1;
@@ -4,7 +4,7 @@
4
4
  // This feeds the experience loop with OBSERVED data, turning the inert manual `evolver recall` into the loop's
5
5
  // real, unbiased input. PURE-ish + injectable; best-effort + never throws (it must never break session ingest).
6
6
  import { events, ops, assetstore } from '@evomap/evolver-core';
7
- import { sessionIdFromTranscript, pickInjectEvent, geneIdsOf, geneFromAsset, resolveGene } from './recall.js';
7
+ import { sessionIdFromTranscript, pickInjectEvent, geneIdsOf, geneFromRecallSelection, resolveGene } from './recall.js';
8
8
  /**
9
9
  * Derive + emit `value.recall` for ONE session transcript. Returns the number of verdicts emitted (0 when there is
10
10
  * no matching inject, no resolvable gene, or the session was already recalled). Idempotent: a session whose
@@ -49,8 +49,11 @@ export async function emitSessionRecall(transcriptPath, turns, deps) {
49
49
  const genes = [];
50
50
  for (const id of geneIds) {
51
51
  const a = await resolveGene(store, id);
52
- if (a)
53
- genes.push(geneFromAsset(a));
52
+ if (a) {
53
+ const gene = geneFromRecallSelection(a, id, inject);
54
+ if (gene)
55
+ genes.push(gene);
56
+ }
54
57
  }
55
58
  if (genes.length === 0)
56
59
  return 0;
@@ -65,7 +68,8 @@ export async function emitSessionRecall(transcriptPath, turns, deps) {
65
68
  try {
66
69
  await deps.ingestor.ingest({
67
70
  type: ops.VALUE_RECALL_EVENT,
68
- human: { title: `recall ${r.recalled}: ${r.geneId}`, detail: `session ${sessionId}` },
71
+ // 展示标题遵守既有 80 字符上限;payload 中的完整版本身份不能截断。
72
+ human: { title: `recall ${r.recalled}: ${r.geneId}`.slice(0, 80), detail: `session ${sessionId}` },
69
73
  payload: payload,
70
74
  });
71
75
  emitted += 1;
@@ -32,6 +32,12 @@ export interface AutoExecDirs {
32
32
  /** Create the queue layout under <home>/autoexec/{tasks,inflight,done,refused}. */
33
33
  export declare function ensureAutoExecDirs(base: string): AutoExecDirs;
34
34
  export declare function summarizeSandboxedValidation(result: verify.SandboxedValidationResult): string | null;
35
+ /**
36
+ * Whether a claim for this queue id is already checked out to the exec pass. The name has
37
+ * to match on both ends — `--hub-1` is a prefix of `--hub-10`, and treating one task as
38
+ * another's execution either strands it until its commitment lapses or runs it twice.
39
+ */
40
+ export declare function hasInflightClaim(dirs: AutoExecDirs, queueTaskId: string): boolean;
35
41
  /**
36
42
  * One queue pass: atomically claim regular tasks/*.json into inflight/, then route each verdict to done/
37
43
  * (success or failure) or refused/ (deny-by-default). A claim is atomically marked started before runOne;
@@ -41,6 +47,15 @@ export declare function summarizeSandboxedValidation(result: verify.SandboxedVal
41
47
  export declare function autoExecPass(dirs: AutoExecDirs, runOne: (task: exec.AutoExecTask) => Promise<exec.AutoExecVerdict>, options?: {
42
48
  executePendingTasks?: boolean;
43
49
  }): Promise<exec.AutoExecVerdict[]>;
50
+ /**
51
+ * Which repo Hub tasks land in. A Hub task does not say which one it belongs to, so a
52
+ * multi-repo allowlist cannot be spread across — one receiver serves one repo. Silently
53
+ * taking the first is a guess the operator never made, so EVOLVER_TASK_RECEIVER_REPO lets
54
+ * them say; it must still be allowlisted, or the receiver has no repo and stays off.
55
+ */
56
+ export declare function taskReceiverRepo(env: NodeJS.ProcessEnv, allowedRoots: readonly string[]): string | undefined;
57
+ /** Runners cleared to take work off the queue, rather than only keeping the daemon alive. */
58
+ export declare function canExecuteQueue(runner: exec.RunnerName): boolean;
44
59
  /** Keep unsupported built-in runners away from the execution queue without stopping the resident daemon. */
45
60
  export declare function runnerBoundAutoExecPass(runner: exec.RunnerName, dirs: AutoExecDirs, runOne: (task: exec.AutoExecTask) => Promise<exec.AutoExecVerdict>): () => Promise<exec.AutoExecVerdict[]>;
46
61
  /**
package/dist/autoexec.js CHANGED
@@ -22,6 +22,7 @@ import { runTranscriptDistillTick, transcriptDistillMode } from './autoDistillTr
22
22
  import { runSessionIngestTick, scanSessionDirs } from './sessionIngest.js';
23
23
  import { LocalMemoryGraph, resolveLocalMemoryUserIdentity } from './localMemoryGraph.js';
24
24
  import { resolveAtpAutoDeliver } from './atpAutoDeliver.js';
25
+ import { memoryEventsFromCycleLog, resolveTaskReceiver } from './taskReceiver.js';
25
26
  import { createAtpClientFromEnv, getAtpConsent, resolveAtpHome, resolveAtpSenderId } from './atp.js';
26
27
  import { AtpAutoBuyer } from './atpAutoBuyer.js';
27
28
  import { resolveExplicitNodeCredentials, resolveIdentityHome } from './identityHome.js';
@@ -78,6 +79,13 @@ function validationCommandDisplay(cmd) {
78
79
  }
79
80
  export function summarizeSandboxedValidation(result) {
80
81
  const parts = [];
82
+ if (result.failureReason)
83
+ parts.push(result.failureReason);
84
+ if (result.isolationTier !== undefined) {
85
+ parts.push(result.isolationTier === 'no-network'
86
+ ? 'isolation: no-network (private root, read-only source; no aggregate cgroup limits)'
87
+ : `isolation: ${result.isolationTier}`);
88
+ }
81
89
  if (result.skipped.length > 0) {
82
90
  const skipped = result.skipped.map((item) => clippedValidationText(`node ${item.script} (${item.reason})`));
83
91
  parts.push(`skipped ${result.skipped.length} validation command(s): ${skipped.join('; ')}`);
@@ -178,6 +186,18 @@ function parseAutoExecClaim(name) {
178
186
  }
179
187
  return encodedName.endsWith('.json') ? { name, originalName: encodedName, phase: 'legacy' } : null;
180
188
  }
189
+ /**
190
+ * Whether a claim for this queue id is already checked out to the exec pass. The name has
191
+ * to match on both ends — `--hub-1` is a prefix of `--hub-10`, and treating one task as
192
+ * another's execution either strands it until its commitment lapses or runs it twice.
193
+ */
194
+ export function hasInflightClaim(dirs, queueTaskId) {
195
+ // `.json` is the pre-suffix layout a running daemon may still have on disk after an
196
+ // upgrade; parseAutoExecClaim reads those as legacy claims, so this has to see them too.
197
+ const suffixes = [CLAIMED_TASK_SUFFIX, STARTED_TASK_SUFFIX, '.json'];
198
+ return readdirSync(dirs.inflight)
199
+ .some((name) => suffixes.some((suffix) => name.endsWith(`--${queueTaskId}${suffix}`)));
200
+ }
181
201
  function taskClaimName(originalName) {
182
202
  return `${randomUUID()}--${originalName.slice(0, -'.json'.length)}${CLAIMED_TASK_SUFFIX}`;
183
203
  }
@@ -341,9 +361,25 @@ export async function autoExecPass(dirs, runOne, options = {}) {
341
361
  cleanupOrphanReceiptArtifacts(dirs);
342
362
  return out;
343
363
  }
364
+ /**
365
+ * Which repo Hub tasks land in. A Hub task does not say which one it belongs to, so a
366
+ * multi-repo allowlist cannot be spread across — one receiver serves one repo. Silently
367
+ * taking the first is a guess the operator never made, so EVOLVER_TASK_RECEIVER_REPO lets
368
+ * them say; it must still be allowlisted, or the receiver has no repo and stays off.
369
+ */
370
+ export function taskReceiverRepo(env, allowedRoots) {
371
+ const chosen = env['EVOLVER_TASK_RECEIVER_REPO']?.trim();
372
+ if (!chosen)
373
+ return allowedRoots[0];
374
+ return allowedRoots.includes(chosen) ? chosen : undefined;
375
+ }
376
+ /** Runners cleared to take work off the queue, rather than only keeping the daemon alive. */
377
+ export function canExecuteQueue(runner) {
378
+ return runner === 'gemini' || runner === 'llm';
379
+ }
344
380
  /** Keep unsupported built-in runners away from the execution queue without stopping the resident daemon. */
345
381
  export function runnerBoundAutoExecPass(runner, dirs, runOne) {
346
- return () => autoExecPass(dirs, runOne, { executePendingTasks: runner === 'gemini' });
382
+ return () => autoExecPass(dirs, runOne, { executePendingTasks: canExecuteQueue(runner) });
347
383
  }
348
384
  const ATP_CAPABILITY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,47}$/;
349
385
  function atpCapabilityGaps(signals) {
@@ -579,7 +615,8 @@ async function emitReuseHit(ingestor, hit) {
579
615
  /** Build the same event for byte-budget admission and durable emission. */
580
616
  export function injectEvent(info) {
581
617
  const payload = {
582
- geneIds: info.geneIds,
618
+ geneIds: info.sourceQualifications ? info.sourceQualifications.map((item) => item.assetId) : info.geneIds,
619
+ ...(info.sourceQualifications ? assetstore.compactQualificationReceipts(info.sourceQualifications) : {}),
583
620
  ...(info.contentSchema ? { contentSchema: info.contentSchema } : {}),
584
621
  ...(info.content ? { content: info.content } : {}),
585
622
  ...(info.omittedByBudget !== undefined ? { omittedByBudget: info.omittedByBudget } : {}),
@@ -1499,8 +1536,8 @@ export async function runAutoExec(argv) {
1499
1536
  const home = argv.find((a) => !a.startsWith('-')) ?? join(events.evomapHome(), 'autoexec');
1500
1537
  const dirs = ensureAutoExecDirs(home);
1501
1538
  const cfg = readAutoExecConfig(home);
1502
- if (cfg.runner !== 'gemini') {
1503
- process.stderr.write('evolver autoexec: execute queue is disabled for the configured built-in runner; non-execution daemon duties remain active. Set "runner":"gemini" only after reviewing its experimental capability boundary\n');
1539
+ if (!canExecuteQueue(cfg.runner)) {
1540
+ process.stderr.write('evolver autoexec: execute queue is disabled for the configured built-in runner; non-execution daemon duties remain active. Set "runner":"llm" (no agent CLI needed) or "runner":"gemini" after reviewing its experimental capability boundary\n');
1504
1541
  }
1505
1542
  // Solo mode (--solo): the "constrained wild" profile. Hard-cut network + ATP
1506
1543
  // at the SOURCE — in-process, before any resolve* below reads its env gate — so
@@ -1589,6 +1626,7 @@ export async function runAutoExec(argv) {
1589
1626
  };
1590
1627
  const deps = withAutoExecSelectionConfig({
1591
1628
  engine, store, provenance, review, personality: personalityStore, memoryGraph,
1629
+ ...(process.env['EVOLVER_BENCHMARK_ID'] !== undefined ? { benchmark: assetstore.benchmarkContext(process.env['EVOLVER_BENCHMARK_ID']) } : {}),
1592
1630
  executionBinding: {
1593
1631
  journal: new exec.ExecutionBindingJournal(ingestor),
1594
1632
  authority: executionBindingAuthority,
@@ -1630,6 +1668,8 @@ export async function runAutoExec(argv) {
1630
1668
  results: r.results,
1631
1669
  skipped: r.skipped,
1632
1670
  isolated: r.isolated,
1671
+ ...(r.isolationTier !== undefined ? { isolationTier: r.isolationTier } : {}),
1672
+ ...(r.failureReason !== undefined ? { failureReason: r.failureReason } : {}),
1633
1673
  },
1634
1674
  };
1635
1675
  },
@@ -1666,9 +1706,23 @@ export async function runAutoExec(argv) {
1666
1706
  const antiGeneDistill = resolveAutoDistillAntiGene(process.env, { store, review, ingestor });
1667
1707
  const transcriptDistill = resolveAutoDistillTranscript(process.env, { store, review, ingestor });
1668
1708
  const atpAutoDeliver = resolveAtpAutoDeliver(process.env);
1709
+ const taskReceiver = resolveTaskReceiver(process.env, {
1710
+ repo: taskReceiverRepo(process.env, cfg.allowedRoots),
1711
+ queueDir: dirs.tasks,
1712
+ memoryEvents: () => memoryEventsFromCycleLog(events.readEvents(events.rootEventsPath())),
1713
+ // An unreadable inflight directory is not an empty one: answering "nothing is running"
1714
+ // there would hand the executor a task it may already be running. Say "busy" instead —
1715
+ // a task that waits one beat is recoverable, one run twice is not.
1716
+ inFlight: (queueTaskId) => { try {
1717
+ return hasInflightClaim(dirs, queueTaskId);
1718
+ }
1719
+ catch {
1720
+ return true;
1721
+ } },
1722
+ });
1669
1723
  const uninstallBrokenPipeGuards = installAutoexecBrokenPipeGuards();
1670
1724
  const reuseEnabled = process.env['EVOLVER_REUSE_BEFORE_SOLVE'] === '1' && hubLink !== undefined;
1671
- process.stdout.write(`evolver autoexec: runner=${cfg.runner} queue=${dirs.tasks} allowlist=${JSON.stringify(cfg.allowedRoots)} poll=${cfg.pollMs}ms reuse=${reuseEnabled ? 'on' : 'off'} reuse-signal=${reuseSignalOn ? 'on' : 'off'} semantic-idf=${semanticIdfOn ? 'on' : 'off'} selection-policy=${selectionPolicy} selection-guard=${selectionGuard} selection-floor=${selectionFloor === undefined ? 'unset' : selectionFloor} probation=${probationOn ? 'on' : 'off'} questions=${hubQuestionLink ? 'on' : 'off'} permit=${solidifyPermit ? 'on' : 'off'} value-digest=${digest.enabled ? 'on' : 'off'} reflection=${reflection.enabled ? 'on' : 'off'} learning-trace=${learningTrace.enabled ? `on(upload=${learningTrace.upload})` : 'off'} memory-event-mirror=${memoryEventMirror.enabled ? 'on' : `off(${memoryEventMirror.reason ?? 'no_hub'})`} cursor-rewrite=${cursorRewrite.enabled ? 'on' : `off(${cursorRewrite.reason})`} auto-distill=${distill.enabled ? 'on' : 'off'} auto-distill-llm=${llmDistill.enabled ? llmDistill.mode : 'off'} auto-distill-anti-gene=${antiGeneDistill.enabled ? antiGeneDistill.mode : 'off'} auto-distill-transcript=${transcriptDistill.enabled ? transcriptDistill.mode : 'off'} atp-autodeliver=${atpAutoDeliver.enabled ? 'on' : `off(${atpAutoDeliver.reason})`}\n`);
1725
+ process.stdout.write(`evolver autoexec: runner=${cfg.runner} queue=${dirs.tasks} allowlist=${JSON.stringify(cfg.allowedRoots)} poll=${cfg.pollMs}ms reuse=${reuseEnabled ? 'on' : 'off'} reuse-signal=${reuseSignalOn ? 'on' : 'off'} semantic-idf=${semanticIdfOn ? 'on' : 'off'} selection-policy=${selectionPolicy} selection-guard=${selectionGuard} selection-floor=${selectionFloor === undefined ? 'unset' : selectionFloor} probation=${probationOn ? 'on' : 'off'} questions=${hubQuestionLink ? 'on' : 'off'} permit=${solidifyPermit ? 'on' : 'off'} value-digest=${digest.enabled ? 'on' : 'off'} reflection=${reflection.enabled ? 'on' : 'off'} learning-trace=${learningTrace.enabled ? `on(upload=${learningTrace.upload})` : 'off'} memory-event-mirror=${memoryEventMirror.enabled ? 'on' : `off(${memoryEventMirror.reason ?? 'no_hub'})`} cursor-rewrite=${cursorRewrite.enabled ? 'on' : `off(${cursorRewrite.reason})`} auto-distill=${distill.enabled ? 'on' : 'off'} auto-distill-llm=${llmDistill.enabled ? llmDistill.mode : 'off'} auto-distill-anti-gene=${antiGeneDistill.enabled ? antiGeneDistill.mode : 'off'} auto-distill-transcript=${transcriptDistill.enabled ? transcriptDistill.mode : 'off'} atp-autodeliver=${atpAutoDeliver.enabled ? 'on' : `off(${atpAutoDeliver.reason})`} task-receiver=${taskReceiver.enabled ? `on(repo=${taskReceiverRepo(process.env, cfg.allowedRoots)})` : `off(${taskReceiver.reason})`}\n`);
1672
1726
  if (cfg.allowedRoots.length === 0)
1673
1727
  process.stdout.write(' (allowlist empty → deny-by-default: nothing runs until you add a repo to config.json)\n');
1674
1728
  // Single-instance lock (#106): a second daemon on the same home would double-process the queue. That is harmless
@@ -1720,11 +1774,20 @@ export async function runAutoExec(argv) {
1720
1774
  const guardedAntiGeneDistill = antiGeneDistill.enabled ? exec.singleFlight(() => antiGeneDistill.tick()) : null;
1721
1775
  const guardedTranscriptDistill = transcriptDistill.enabled ? exec.singleFlight(() => transcriptDistill.tick()) : null;
1722
1776
  const guardedAtpAutoDeliver = atpAutoDeliver.enabled ? exec.singleFlight(() => atpAutoDeliver.tick()) : null;
1777
+ const guardedTaskReceiver = taskReceiver.enabled ? exec.singleFlight(() => taskReceiver.tick()) : null;
1723
1778
  if (distill.observer)
1724
1779
  distill.observer.kick(); // recover any un-acked backlog from a prior run (restart)
1725
1780
  // One idle-aware resident beat runs the exec pass, ATP auto-delivery, THEN the distill scan (single-flight
1726
1781
  // guarded). Idle-aware pacing (#106): an idle machine polls more often, an active one backs off to the base
1727
1782
  // cadence. Off via EVOLVER_IDLE_AWARE=0 → fixed cfg.pollMs (exactly the previous behavior).
1783
+ const completionLine = (ack, assetId) => {
1784
+ if (ack.completed)
1785
+ return 'reported';
1786
+ // The asset outlived the claim: name it, or the work is lost with no way back to it.
1787
+ if (ack.error === 'commitment_expired')
1788
+ return `commitment expired, asset ${assetId} not sent`;
1789
+ return `${ack.pending ? 'owed, will retry' : 'failed'} ${ack.error ?? ''}`;
1790
+ };
1728
1791
  const tick = async (beat) => {
1729
1792
  let failed = false;
1730
1793
  const r = await guarded();
@@ -1735,6 +1798,33 @@ export async function runAutoExec(argv) {
1735
1798
  // default / not in allowlist) is a no-op, not a broken edit.
1736
1799
  if (r.some((v) => v.status === 'failed'))
1737
1800
  failed = true;
1801
+ // A claim is a promise. The Hub only learns it was kept when the produced capsule
1802
+ // comes back — but a cycle solo rollback is about to revert has not kept it, and the
1803
+ // Hub cannot take a completion back. Stay silent and let the commitment expire.
1804
+ // Only a registered claim is Hub work: the `hub-` prefix is a naming convention a
1805
+ // local task may also use, and reporting its capsule would complete someone's task
1806
+ // with an unrelated asset. The generation narrows it further — a queue id can be
1807
+ // claimed, run and claimed again, and a result from the earlier filing is not this
1808
+ // claim's to hand over.
1809
+ const hubDone = r.flatMap((v) => {
1810
+ const claim = v.status === 'solidified' && v.resultAssetId ? taskReceiver.claimFor(v.taskId) : null;
1811
+ if (!claim || !v.resultAssetId)
1812
+ return [];
1813
+ if (claim.generation !== v.generation) {
1814
+ process.stdout.write(` task-complete: ${claim.hubTaskId} result is from an earlier claim (${v.generation ?? 'none'} ≠ ${claim.generation}); not reporting it\n`);
1815
+ return [];
1816
+ }
1817
+ return [{ hubTaskId: claim.hubTaskId, resultAssetId: v.resultAssetId, generation: claim.generation }];
1818
+ });
1819
+ if (failed && solo && hubDone.length > 0) {
1820
+ process.stdout.write(` task-complete: holding ${hubDone.length} report(s) — this cycle rolls back\n`);
1821
+ }
1822
+ else {
1823
+ for (const task of hubDone) {
1824
+ const ack = await taskReceiver.complete(task.hubTaskId, task.resultAssetId, task.generation);
1825
+ process.stdout.write(` task-complete: ${task.hubTaskId} ${completionLine(ack, task.resultAssetId)}\n`);
1826
+ }
1827
+ }
1738
1828
  }
1739
1829
  // Evidence-based auto-promote (#306 phase 2): after a pass, a probation gene that has proven itself (>= K clean
1740
1830
  // successes, 0 failures) is auto-approved — the cross-AI loop self-closes without a human quality gate. Bad ones
@@ -1747,6 +1837,45 @@ export async function runAutoExec(argv) {
1747
1837
  }
1748
1838
  catch { /* never break the loop on a promotion side-effect */ }
1749
1839
  }
1840
+ // Take work before delivering it: a task claimed this beat lands in the queue the
1841
+ // next pass reads, and the Hub only accepts delivery for tasks this node holds.
1842
+ // Debts before new work, and outside the receive switch: a claim taken by an earlier run
1843
+ // still owes the Hub its report, and a delivery the Hub never acknowledged gets
1844
+ // re-dispatched when the commitment expires. Turning the receiver off stops new work
1845
+ // only. A debt this beat just created is not due yet, so it waits for the next one.
1846
+ const requeued = await taskReceiver.retryQueueWrites();
1847
+ if (requeued.retried > 0 || requeued.dropped > 0)
1848
+ process.stdout.write(` task-receiver: requeued=${requeued.queued}/${requeued.retried} still-unqueued=${requeued.pending}${requeued.dropped > 0 ? ` dropped=${requeued.dropped}` : ''}\n`);
1849
+ const owed = await taskReceiver.retryCompletions();
1850
+ if (owed.retried > 0)
1851
+ process.stdout.write(` task-complete: retried=${owed.retried} reported=${owed.completed} abandoned=${owed.abandoned} owed=${owed.pending}${owed.unrecorded > 0 ? ` unrecorded=${owed.unrecorded}` : ''}\n`);
1852
+ for (const gone of owed.abandonedTasks) {
1853
+ // Dropped from the ledger after the retry budget: nothing will mention it again.
1854
+ process.stdout.write(` task-complete: GAVE UP on ${gone.taskId} (asset ${gone.resultAssetId}) — ${gone.lastError}\n`);
1855
+ }
1856
+ if (guardedTaskReceiver) {
1857
+ const t = await guardedTaskReceiver();
1858
+ if (t && !('skipped' in t) && t.claimed && t.task) {
1859
+ process.stdout.write(` task-receiver: ${t.reason} ${t.task.task_id}${t.commitmentDeadline ? ` until=${t.commitmentDeadline}` : ''}\n`);
1860
+ }
1861
+ else if (t && !('skipped' in t) && t.reason === 'claim_failed') {
1862
+ process.stdout.write(` task-receiver: claim failed ${t.task?.task_id ?? ''} ${t.error ?? ''}\n`);
1863
+ }
1864
+ else if (t && !('skipped' in t) && t.reason === 'expired') {
1865
+ process.stdout.write(` task-receiver: commitment on ${t.task?.task_id ?? ''} already expired, not resuming\n`);
1866
+ }
1867
+ else if (t && !('skipped' in t) && t.reason === 'fetch_failed') {
1868
+ process.stdout.write(` task-receiver: fetch failed ${t.error ?? ''}\n`);
1869
+ }
1870
+ else if (t && !('skipped' in t) && t.reason === 'queue_failed') {
1871
+ process.stdout.write(` task-receiver: claimed ${t.task?.task_id ?? ''} but could not queue it — ${t.error ?? ''}\n`);
1872
+ }
1873
+ else if (t && !('skipped' in t) && (t.seen > 0 || (t.rejected ?? 0) > 0)) {
1874
+ // The Hub had work but none of it was ours to take. Saying so is the only
1875
+ // way an operator can tell "fetching works" from "nothing ever ran".
1876
+ process.stdout.write(` task-receiver: none (seen=${t.seen}${t.rejected ? ` rejected=${t.rejected}` : ''})\n`);
1877
+ }
1878
+ }
1750
1879
  if (guardedAtpAutoDeliver) {
1751
1880
  const d = await guardedAtpAutoDeliver();
1752
1881
  if (d && !('skipped' in d) && (d.delivered > 0 || d.terminalFailures > 0 || d.transientFailures > 0 || d.cooldownFailures > 0)) {
@@ -1795,7 +1924,9 @@ export async function runAutoExec(argv) {
1795
1924
  process.stderr.write(`[Solo] 连续失败 ${soloState.consecutiveFailures} 次达阈值,熔断停机(非盲重生)。\n`);
1796
1925
  // Stop scheduling, release the lock, and exit non-zero. Detached so we
1797
1926
  // don't await our own loop.stop() from inside a tick.
1798
- void loop.stop().then(() => { cleanupAutoexecRuntime(); process.exit(1); });
1927
+ void stopRuntime().catch((error) => {
1928
+ process.stderr.write(`[Solo] shutdown drain failed: ${error instanceof Error ? error.message : String(error)}\n`);
1929
+ }).finally(() => { cleanupAutoexecRuntime(); process.exit(1); });
1799
1930
  }
1800
1931
  };
1801
1932
  // Heartbeat (#106): record liveness + pacing on the AE spine for the WebUI console, THROTTLED so a fast poll does
@@ -1803,6 +1934,7 @@ export async function runAutoExec(argv) {
1803
1934
  const heartbeatMinMs = Math.max(0, Number(process.env['EVOLVER_HEARTBEAT_MS'] ?? 60_000));
1804
1935
  let lastBeatAt = 0;
1805
1936
  let lastIntensity = '';
1937
+ await cursorRewrite.start?.();
1806
1938
  const loop = startResidentLoop({
1807
1939
  tick: solo ? soloTick : tick,
1808
1940
  basePollMs: cfg.pollMs,
@@ -1823,5 +1955,14 @@ export async function runAutoExec(argv) {
1823
1955
  });
1824
1956
  // SIGINT/SIGTERM drain the in-flight beat before cleanup. SIGHUP cannot hot-reload this composition safely,
1825
1957
  // so it is explicit and non-destructive: keep running until the operator performs a normal restart.
1826
- return await waitForAutoexecShutdown({ stop: loop.stop, cleanup: cleanupAutoexecRuntime });
1958
+ async function stopRuntime() {
1959
+ try {
1960
+ await loop.stop();
1961
+ await bus.drain();
1962
+ }
1963
+ finally {
1964
+ await cursorRewrite.stop?.();
1965
+ }
1966
+ }
1967
+ return await waitForAutoexecShutdown({ stop: stopRuntime, cleanup: cleanupAutoexecRuntime });
1827
1968
  }
@@ -1,4 +1,4 @@
1
- export type AutoExecRunner = 'claude' | 'codex' | 'cursor' | 'gemini';
1
+ export type AutoExecRunner = 'claude' | 'codex' | 'cursor' | 'gemini' | 'llm';
2
2
  export interface AutoExecConfig {
3
3
  allowedRoots: string[];
4
4
  pollMs: number;
@@ -10,7 +10,7 @@ const MAX_VALIDATION_COMMAND_LENGTH = 300;
10
10
  const PROFILE_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
11
11
  const SECRET_TEXT_RE = /(?:\bBearer\s+[A-Za-z0-9._~+/=-]{8,}|\b(?:sk|gh[oprsu])_[A-Za-z0-9_-]{8,}|-----BEGIN [A-Z ]*PRIVATE KEY-----|\b(?:password|passwd|secret|token|api[_-]?key)\s*[:=]\s*\S+)/i;
12
12
  function parseRunner(value) {
13
- return value === 'codex' || value === 'cursor' || value === 'gemini' ? value : 'claude';
13
+ return value === 'codex' || value === 'cursor' || value === 'gemini' || value === 'llm' ? value : 'claude';
14
14
  }
15
15
  function isSafeValidationCommand(value) {
16
16
  if (typeof value !== 'string')
@@ -1,8 +1,9 @@
1
1
  import { assetstore, hub } from '@evomap/evolver-core';
2
+ import { type LocalPublishVerifierClient } from './localPublishBinding.js';
2
3
  type WritableLike = {
3
4
  write(chunk: string): unknown;
4
5
  };
5
- type ContractReason = 'missing_id' | 'cli_unavailable' | 'auth_required' | 'not_found' | 'network_error' | 'unsupported' | 'internal_error' | 'redaction_unavailable' | 'leak_detected' | 'schema_invalid' | 'bundle_required' | 'quality_gate_failed' | 'gene_unproven' | 'insufficient_credits' | 'unsafe_validation_command';
6
+ type ContractReason = 'missing_id' | 'cli_unavailable' | 'auth_required' | 'not_found' | 'network_error' | 'unsupported' | 'internal_error' | 'redaction_unavailable' | 'leak_detected' | 'schema_invalid' | 'bundle_required' | 'quality_gate_failed' | 'gene_unproven' | 'insufficient_credits' | 'unsafe_validation_command' | 'verification_required';
6
7
  export interface ReuseParseResult {
7
8
  ok: boolean;
8
9
  assetId?: string;
@@ -18,6 +19,7 @@ export interface PublishParseResult {
18
19
  dryRun?: boolean;
19
20
  repair?: boolean;
20
21
  noRecipe?: boolean;
22
+ reverify?: boolean;
21
23
  jsonOut?: boolean;
22
24
  reason?: ContractReason;
23
25
  message?: string;
@@ -31,7 +33,7 @@ interface GateSummary {
31
33
  quality_evidence?: PublishQualityEvidenceSource;
32
34
  validation_command?: 'pass' | 'fail';
33
35
  }
34
- type PublishQualityEvidenceSource = 'local_history' | 'bundle_seed' | 'none' | 'unavailable';
36
+ type PublishQualityEvidenceSource = 'local_history' | 'bundle_seed' | 'reference_integrity' | 'none' | 'unavailable';
35
37
  interface PublishAssetSummary {
36
38
  asset_id?: string;
37
39
  type?: assetstore.AssetKind;
@@ -63,6 +65,8 @@ interface ContractHubTransport {
63
65
  composeRecipe?(payload: hub.RecipeComposeInput): Promise<hub.RecipeComposeResult>;
64
66
  }
65
67
  interface PrivateContractProxy {
68
+ authorizeAssetPublication?: LocalPublishVerifierClient['authorizeAssetPublication'];
69
+ reverifyAssets?: LocalPublishVerifierClient['reverifyAssets'];
66
70
  status(): Promise<unknown>;
67
71
  fetchAsset(args: {
68
72
  assetId: string;
@@ -96,6 +100,7 @@ export declare function runPublishCommand(args: readonly string[], deps?: CliCon
96
100
  export declare function parseReuseArgs(args: readonly string[]): ReuseParseResult;
97
101
  export declare function parsePublishArgs(args: readonly string[]): PublishParseResult;
98
102
  export declare function buildPublishBundle(refs: readonly string[], deps?: CliContractDeps): Promise<PublishBundleResult>;
103
+ export declare function assessPublishRecords(original: assetstore.AssetRecord[], deps: CliContractDeps): Promise<PublishBundleResult>;
99
104
  /** Resolve `<asset_id|logical_id|path>` the way publish does. Shared so `asset-repair` speaks the same refs. */
100
105
  export declare function loadAssetRef(ref: string, deps: CliContractDeps): Promise<assetstore.AssetRecord>;
101
106
  export declare function hasExplicitValidatePass(body: unknown): boolean;