@evomap/evolver-cli 2.0.0-beta.2 → 2.0.0-beta.22

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 (124) hide show
  1. package/dist/antiGeneBenchmark.js +2 -0
  2. package/dist/antiGeneRollout.js +9 -3
  3. package/dist/assetHealth.d.ts +6 -0
  4. package/dist/assetHealth.js +107 -0
  5. package/dist/assetRepair.d.ts +24 -0
  6. package/dist/assetRepair.js +172 -0
  7. package/dist/assetSidecarRecovery.d.ts +14 -0
  8. package/dist/assetSidecarRecovery.js +171 -0
  9. package/dist/assetTrust.d.ts +24 -0
  10. package/dist/assetTrust.js +231 -0
  11. package/dist/atp.d.ts +10 -5
  12. package/dist/atp.js +119 -26
  13. package/dist/atpAutoBuyer.d.ts +120 -0
  14. package/dist/atpAutoBuyer.js +814 -0
  15. package/dist/atpAutoDeliver.js +2 -2
  16. package/dist/autoDistillAntiGene.js +7 -5
  17. package/dist/autoDistillLlm.d.ts +26 -0
  18. package/dist/autoDistillLlm.js +119 -22
  19. package/dist/autoDistillTranscript.js +3 -2
  20. package/dist/autoexec.d.ts +111 -24
  21. package/dist/autoexec.js +887 -120
  22. package/dist/autoexecConfig.d.ts +10 -0
  23. package/dist/autoexecConfig.js +69 -0
  24. package/dist/cli.js +13 -0
  25. package/dist/cliContracts.d.ts +33 -2
  26. package/dist/cliContracts.js +818 -78
  27. package/dist/commandCatalog.d.ts +72 -0
  28. package/dist/commandCatalog.js +120 -0
  29. package/dist/commands.d.ts +1 -0
  30. package/dist/commands.js +1 -0
  31. package/dist/curriculumCapabilityGaps.d.ts +6 -0
  32. package/dist/curriculumCapabilityGaps.js +24 -0
  33. package/dist/cycleConsumer.d.ts +17 -2
  34. package/dist/cycleConsumer.js +374 -50
  35. package/dist/dashboard.d.ts +13 -1
  36. package/dist/dashboard.js +235 -18
  37. package/dist/dispatch.d.ts +9 -2
  38. package/dist/dispatch.js +29 -6
  39. package/dist/distillAdmission.d.ts +13 -0
  40. package/dist/distillAdmission.js +35 -0
  41. package/dist/distillObserver.js +27 -12
  42. package/dist/distillPrimitives.d.ts +11 -8
  43. package/dist/distillPrimitives.js +116 -22
  44. package/dist/doctor.d.ts +13 -0
  45. package/dist/doctor.js +177 -10
  46. package/dist/identityHome.d.ts +9 -0
  47. package/dist/identityHome.js +47 -0
  48. package/dist/index.d.ts +73 -40
  49. package/dist/index.js +745 -207
  50. package/dist/issueReport.d.ts +7 -0
  51. package/dist/issueReport.js +291 -0
  52. package/dist/learningTrace.d.ts +15 -0
  53. package/dist/learningTrace.js +73 -0
  54. package/dist/lifecycle.d.ts +199 -2
  55. package/dist/lifecycle.js +4999 -152
  56. package/dist/lifecycleBootstrapTransaction.d.ts +235 -0
  57. package/dist/lifecycleBootstrapTransaction.js +2182 -0
  58. package/dist/localMemoryGraph.d.ts +184 -0
  59. package/dist/localMemoryGraph.js +2689 -0
  60. package/dist/login.d.ts +1 -1
  61. package/dist/login.js +3 -3
  62. package/dist/materialPackage.js +3 -6
  63. package/dist/materialSnapshot.d.ts +35 -1
  64. package/dist/materialSnapshot.js +265 -18
  65. package/dist/memoryGraphOps.d.ts +8 -0
  66. package/dist/memoryGraphOps.js +140 -0
  67. package/dist/migrate/assetFormatMap.d.ts +61 -0
  68. package/dist/migrate/assetFormatMap.js +53 -0
  69. package/dist/migrate/envTranslate.d.ts +26 -0
  70. package/dist/migrate/envTranslate.js +147 -0
  71. package/dist/migrate/fieldMap.d.ts +7 -5
  72. package/dist/migrate/fieldMap.js +20 -14
  73. package/dist/migrate/oauthImport.d.ts +66 -0
  74. package/dist/migrate/oauthImport.js +667 -0
  75. package/dist/migrate/v1Import.d.ts +98 -1
  76. package/dist/migrate/v1Import.js +1532 -71
  77. package/dist/modelCompatibility.d.ts +10 -0
  78. package/dist/modelCompatibility.js +296 -0
  79. package/dist/promptRecallHook.d.ts +24 -0
  80. package/dist/promptRecallHook.js +425 -0
  81. package/dist/recallVerifyReport.d.ts +37 -0
  82. package/dist/recallVerifyReport.js +244 -0
  83. package/dist/recipe.d.ts +14 -2
  84. package/dist/recipe.js +543 -65
  85. package/dist/repairedAssetStore.d.ts +2 -0
  86. package/dist/repairedAssetStore.js +12 -0
  87. package/dist/requiredSandboxValidation.d.ts +5 -0
  88. package/dist/requiredSandboxValidation.js +4 -0
  89. package/dist/reuse.d.ts +18 -4
  90. package/dist/reuse.js +375 -107
  91. package/dist/reviewFilter.d.ts +3 -1
  92. package/dist/reviewFilter.js +3 -1
  93. package/dist/runtimeCapabilities.d.ts +18 -0
  94. package/dist/runtimeCapabilities.js +81 -0
  95. package/dist/runtimeSessionSource.d.ts +8 -2
  96. package/dist/runtimeSessionSource.js +63 -11
  97. package/dist/selectionPolicyConfig.d.ts +8 -0
  98. package/dist/selectionPolicyConfig.js +18 -0
  99. package/dist/semanticIdfConfig.d.ts +2 -0
  100. package/dist/semanticIdfConfig.js +4 -0
  101. package/dist/sessionIngest.d.ts +43 -0
  102. package/dist/sessionIngest.js +180 -0
  103. package/dist/setupHooks.d.ts +5 -0
  104. package/dist/setupHooks.js +330 -14
  105. package/dist/skill2gep.d.ts +13 -9
  106. package/dist/skill2gep.js +99 -36
  107. package/dist/skillDistill.d.ts +8 -4
  108. package/dist/skillDistill.js +39 -9
  109. package/dist/solo/mode.js +1 -0
  110. package/dist/sync.d.ts +13 -1
  111. package/dist/sync.js +1947 -265
  112. package/dist/thesis.d.ts +1 -1
  113. package/dist/thesis.js +20 -3
  114. package/dist/trajectoryExport.js +21 -3
  115. package/dist/v1Compat.d.ts +1 -0
  116. package/dist/v1Compat.js +9 -0
  117. package/dist/valueDigest.js +8 -1
  118. package/dist/windowsLegacyTaskCleanup.d.ts +228 -0
  119. package/dist/windowsLegacyTaskCleanup.js +1475 -0
  120. package/dist/workflow.d.ts +39 -0
  121. package/dist/workflow.js +386 -0
  122. package/dist/workflowRuntime.d.ts +66 -0
  123. package/dist/workflowRuntime.js +638 -0
  124. package/package.json +14 -7
package/dist/thesis.d.ts CHANGED
@@ -35,7 +35,7 @@ export interface ThesisCommandDeps {
35
35
  now?: () => number;
36
36
  }
37
37
  /**
38
- * `evolver thesis --suite <file> [--repo <allowlisted>] [--min-samples N] [--min-delta D] [--interleave] [--json]`.
38
+ * `evolver thesis --suite <file> [--repo <allowlisted>] [--runner gemini] [--min-samples N] [--min-delta D] [--interleave] [--json]`.
39
39
  * Runs the controlled A/B and prints baseline-vs-evolver pass rates + the verdict. A LIVE run needs `--repo` (the
40
40
  * single allowlisted root the agent may touch); tests inject `deps.execute` instead.
41
41
  */
package/dist/thesis.js CHANGED
@@ -10,6 +10,7 @@ import { tmpdir } from 'node:os';
10
10
  import { join, resolve } from 'node:path';
11
11
  import { spawn } from 'node:child_process';
12
12
  import { events, assetstore, algo, exec, benchmark } from '@evomap/evolver-core';
13
+ import { semanticIdfEnabled } from './semanticIdfConfig.js';
13
14
  const NOW_FALLBACK = () => Date.now();
14
15
  /** Build a minimal ProblemPattern from a task's signals (the cycle needs a problem to evolve against). */
15
16
  function buildProblem(id, signals, now) {
@@ -40,14 +41,14 @@ const parseFlags = (argv) => {
40
41
  };
41
42
  const pct = (r) => `${(r * 100).toFixed(0)}%`;
42
43
  /**
43
- * `evolver thesis --suite <file> [--repo <allowlisted>] [--min-samples N] [--min-delta D] [--interleave] [--json]`.
44
+ * `evolver thesis --suite <file> [--repo <allowlisted>] [--runner gemini] [--min-samples N] [--min-delta D] [--interleave] [--json]`.
44
45
  * Runs the controlled A/B and prints baseline-vs-evolver pass rates + the verdict. A LIVE run needs `--repo` (the
45
46
  * single allowlisted root the agent may touch); tests inject `deps.execute` instead.
46
47
  */
47
48
  export async function runThesisCommand(argv, deps = {}) {
48
49
  const flags = parseFlags(argv);
49
50
  if (!flags['suite']) {
50
- process.stderr.write('用法: evolver thesis --suite <file> [--repo <allowlisted>] [--min-samples N] [--min-delta D] [--alpha A] [--target-power P] [--interleave] [--json]\n');
51
+ process.stderr.write('用法: evolver thesis --suite <file> [--repo <allowlisted>] [--runner gemini] [--min-samples N] [--min-delta D] [--alpha A] [--target-power P] [--interleave] [--json]\n');
51
52
  return 1;
52
53
  }
53
54
  let suite;
@@ -76,6 +77,10 @@ export async function runThesisCommand(argv, deps = {}) {
76
77
  process.stderr.write('thesis: a controlled A/B needs an external verifier — add a non-empty "validation" array to the suite. Refusing (passed must not come from agent self-report).\n');
77
78
  return 1;
78
79
  }
80
+ if (!deps.execute && flags['runner'] !== 'gemini') {
81
+ process.stderr.write('thesis: execute capability is unsupported for built-in Claude/Codex; select --runner gemini\n');
82
+ return 1;
83
+ }
79
84
  // HERMETIC experiment (Bugbot #168): the evolver arm READS genes from the pool but its cycle WRITES (capsules,
80
85
  // evolution events) must NOT land in production — that would pollute real selection + bans. So seed a THROWAWAY
81
86
  // evolver store with a copy of the pool's genes; both arms write only into temp stores that are discarded after.
@@ -98,7 +103,18 @@ export async function runThesisCommand(argv, deps = {}) {
98
103
  }
99
104
  return { passed: true, score: 0.95 };
100
105
  };
101
- execute = exec.makeSafeExecute(repo, evolverStore, { allowedRoots: [repo] }, { validate });
106
+ try {
107
+ execute = exec.makeSafeExecute(repo, evolverStore, { allowedRoots: [repo], runner: 'gemini' }, { validate });
108
+ }
109
+ catch (error) {
110
+ rmSync(expDir, { recursive: true, force: true });
111
+ if (error instanceof exec.UnsupportedAutonomousClaudeRunnerError
112
+ || error instanceof exec.UnsupportedAutonomousCodexRunnerError) {
113
+ process.stderr.write('thesis: execute capability is unsupported: built-in autonomous runners require a verified host filesystem sandbox\n');
114
+ return 1;
115
+ }
116
+ throw error;
117
+ }
102
118
  }
103
119
  const agent = execute;
104
120
  const solver = benchmark.makeEvolutionThesisSolver({
@@ -111,6 +127,7 @@ export async function runThesisCommand(argv, deps = {}) {
111
127
  expectedEffect: t.input.expectedEffect ?? 'fix',
112
128
  summary: t.input.summary ?? `thesis ${t.id}`,
113
129
  confidence: t.input.confidence ?? 0.9,
130
+ ...(!semanticIdfEnabled() ? { disableSemanticIdf: true } : {}),
114
131
  }),
115
132
  });
116
133
  const tasks = suite.tasks.map((s) => ({
@@ -2,7 +2,7 @@ import { closeSync, existsSync, lstatSync, openSync, readSync, readdirSync, read
2
2
  import { basename, delimiter, dirname, extname, join, resolve, sep } from 'node:path';
3
3
  import { homedir } from 'node:os';
4
4
  import { events, ops, trace } from '@evomap/evolver-core';
5
- import { ADAPTERS, adapterForPath, genericChatAdapter, isCursorStateVscdbPath, parseCursorStateVscdb, parseJsonlLines, parseJsonlLinesWithStats, } from '@evomap/evolver-runtime-adapters';
5
+ import { ADAPTERS, isRemovedAdapter, adapterForPath, genericChatAdapter, isCursorStateVscdbPath, parseCursorStateVscdb, parseJsonlLines, parseJsonlLinesWithStats, } from '@evomap/evolver-runtime-adapters';
6
6
  const TRACE_FILE_RE = /(^|[/\\])llm-trace-[^/\\]*\.jsonl$/i;
7
7
  const RUNTIME_SESSION_ENABLE_ENV = 'EVOLVER_TRAJECTORY_RUNTIME_SESSIONS';
8
8
  const RUNTIME_SESSION_ENABLE_ENV_LEGACY = 'EVOLVER_TRAJECTORY_EXPORT_RUNTIME_SESSIONS';
@@ -165,7 +165,9 @@ function traceLikeContent(chunk) {
165
165
  return parseJsonlLines(chunk).some(isTraceLikeRow);
166
166
  }
167
167
  function adapterForContent(chunk) {
168
- for (const adapter of [genericChatAdapter, ...ADAPTERS.filter((candidate) => candidate !== genericChatAdapter)]) {
168
+ // Never probe REMOVED_ADAPTERS / isRemovedAdapter agents — their parse() always throws.
169
+ const candidates = [genericChatAdapter, ...ADAPTERS.filter((candidate) => candidate !== genericChatAdapter && !isRemovedAdapter(candidate.agent))];
170
+ for (const adapter of candidates) {
169
171
  if (adapter.parse(chunk).some((turn) => turn.isMeta !== true))
170
172
  return adapter;
171
173
  }
@@ -194,6 +196,7 @@ function cursorGlobalStorageDir(home) {
194
196
  function cursorGlobalStorageDirs(home) {
195
197
  const dirs = [
196
198
  cursorGlobalStorageDir(home),
199
+ join(home, 'AppData', 'Roaming', 'Cursor', 'User', 'globalStorage'),
197
200
  join(home, '.config', 'Cursor', 'User', 'globalStorage'),
198
201
  ];
199
202
  const appData = process.env['APPDATA'];
@@ -779,6 +782,7 @@ export async function runTrajectoryExport(argv) {
779
782
  let files = [];
780
783
  let sessionFileCount = 0;
781
784
  let sessionTurnCount = 0;
785
+ let cursorParseFailures = 0;
782
786
  let excludedUnmarked = 0;
783
787
  let excludedGatewayCaptured = 0;
784
788
  const discoveredRuntimeDirs = runtimeSessionDirs(flags);
@@ -807,7 +811,19 @@ export async function runTrajectoryExport(argv) {
807
811
  // Read Cursor chat out of the sqlite db (read-only) and convert each composer to a trajectory. The
808
812
  // marker/gateway gates run PER COMPOSER here (each composerId is its own session_id), so a state.vscdb
809
813
  // holding many composers contributes only the ones evolver marked (and not already gateway-captured).
810
- for (const parsedSession of parseCursorStateVscdb(file.path)) {
814
+ let parsedSessions;
815
+ try {
816
+ parsedSessions = parseCursorStateVscdb(file.path);
817
+ }
818
+ catch (error) {
819
+ // Default discovery spans several optional platform locations. One stale/corrupt profile must not block
820
+ // healthy profiles or other runtime sources; explicit inputs still fail with the detailed parser error.
821
+ if (!file.fromRuntimeDiscovery)
822
+ throw error;
823
+ cursorParseFailures += 1;
824
+ continue;
825
+ }
826
+ for (const parsedSession of parsedSessions) {
811
827
  const { turns, ...adapterMetadata } = parsedSession;
812
828
  if (file.fromRuntimeDiscovery) {
813
829
  const composerSessionId = typeof adapterMetadata.sessionId === 'string' ? adapterMetadata.sessionId : undefined;
@@ -898,6 +914,8 @@ export async function runTrajectoryExport(argv) {
898
914
  process.stdout.write(`[trajectory-export] Read ${allRows.length} trace row(s) and ${sessionTurnCount} session turn(s) from ${files.length} file(s).\n`);
899
915
  if (sessionFileCount > 0)
900
916
  process.stdout.write(`[trajectory-export] Converted ${sessionFileCount} runtime session file(s).\n`);
917
+ if (cursorParseFailures > 0)
918
+ process.stdout.write(`[trajectory-export] Skipped ${cursorParseFailures} unreadable Cursor state database(s).\n`);
901
919
  if (excludedUnmarked > 0 || excludedGatewayCaptured > 0) {
902
920
  process.stdout.write(`[trajectory-export] Runtime session gate: excluded ${excludedUnmarked} unmarked (no evolver value.inject) and ${excludedGatewayCaptured} already-gateway-captured session(s). Pass --include-unmarked / --include-gateway-captured to collect them.\n`);
903
921
  }
@@ -21,4 +21,5 @@ export declare function runV1RunCompat(argv: readonly string[], deps?: V1CompatD
21
21
  export declare function runV1SolidifyCompat(argv: readonly string[], deps?: V1CompatDeps): Promise<number>;
22
22
  export declare function runV1FetchCompat(argv: readonly string[], deps?: V1CompatDeps): Promise<number>;
23
23
  export declare function runV1WebuiCompat(argv: readonly string[], deps?: V1CompatDeps): Promise<number>;
24
+ export declare function runV1ExecCompat(argv: readonly string[], deps?: V1CompatDeps): Promise<number>;
24
25
  export {};
package/dist/v1Compat.js CHANGED
@@ -10,6 +10,7 @@ const RUN_USAGE = 'usage: evolver run [-v | --verbose] [--loop | --mad-dog] [--j
10
10
  const SOLIDIFY_USAGE = 'usage: evolver solidify [--dry-run] [--json]\n';
11
11
  const FETCH_USAGE = 'usage: evolver fetch (--skill <id> | -s <id> | <id>) [--out <dir>] [--force] [--json]\n';
12
12
  const WEBUI_USAGE = 'usage: evolver webui [--port N] [--no-open]\n';
13
+ const EXEC_USAGE = 'usage: evolver exec <command>\n';
13
14
  const V1_WEBUI_DEFAULT_PORT = 19_821;
14
15
  const V1_WEBUI_PORT_ATTEMPTS = 50;
15
16
  function io(deps) {
@@ -246,4 +247,12 @@ export async function runV1WebuiCompat(argv, deps = {}) {
246
247
  if (deps.dashboard)
247
248
  return deps.dashboard(mapped, dashboardOptions);
248
249
  return runDashboardCommand(mapped, {}, dashboardOptions);
250
+ }
251
+ export async function runV1ExecCompat(argv, deps = {}) {
252
+ if (argv.includes('--help') || argv.includes('-h')) {
253
+ io(deps).stdout(EXEC_USAGE);
254
+ return 0;
255
+ }
256
+ const json = argv.includes('--json');
257
+ return migrationRequired('exec', 'evolver autoexec', 'V1 exec cannot be mapped safely to V2; use `evolver autoexec` for resident execution', json, deps, { mode: 'no_action' });
249
258
  }
@@ -9,7 +9,7 @@
9
9
  // tick the cadence check — this is the bus's first live built-in observer.
10
10
  import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
11
11
  import { dirname, join } from 'node:path';
12
- import { events, observers, ops } from '@evomap/evolver-core';
12
+ import { assetstore, events, observers, ops } from '@evomap/evolver-core';
13
13
  import { loadPriceTable } from '@evomap/evolver-adapter-public';
14
14
  /** Markdown file sink: appends each weekly digest to <home>/evolution/value-digest.md (inspectable history). */
15
15
  export function fileDigestSink(path) {
@@ -87,6 +87,13 @@ export function resolveValueDigestObserver(env = process.env, opts = {}) {
87
87
  events: events.readEvents(eventsPath),
88
88
  prices,
89
89
  }, window),
90
+ digestExtras: async () => {
91
+ const store = new assetstore.LocalJsonlProvider(events.assetsDir());
92
+ const review = assetstore.reviewLedgerForStore(store);
93
+ return {
94
+ pendingReviewCount: (await assetstore.pendingGeneReviewRecords(store, review)).length,
95
+ };
96
+ },
90
97
  sink: multiSink(sinks),
91
98
  state: new FileDigestState(join(home, 'evolution', 'value-digest-state.json')),
92
99
  });
@@ -0,0 +1,228 @@
1
+ import { acquireBootstrapOwnerLock } from './lifecycleBootstrapTransaction.js';
2
+ /** The only task names this module ever probes; nothing outside this set is ever touched. */
3
+ export declare const LEGACY_WINDOWS_TASK_NAMES: readonly ["EvoMapEvolverProxyDaemon", "EvoMapEvolverAutoexecDaemon"];
4
+ export type LegacyWindowsTaskName = (typeof LEGACY_WINDOWS_TASK_NAMES)[number];
5
+ export declare const LEGACY_TASK_SKIP_ENV = "EVOLVER_SKIP_LEGACY_TASK_PROBE";
6
+ export declare const LEGACY_TASK_COOLDOWN_FILE = "legacy-task-cleanup.json";
7
+ export declare const LEGACY_TASK_PREIMAGE_DIR = "legacy-task-preimages";
8
+ export declare const LEGACY_TASK_PROVENANCE_FILE = "legacy-task-provenance.json";
9
+ export declare const LEGACY_TASK_PROVENANCE_PUBLIC_KEY_ENV = "EVOLVER_LEGACY_TASK_PROVENANCE_PUBLIC_KEY";
10
+ export declare const LEGACY_TASK_PROVENANCE_SCHEMA = "evolver/windows-legacy-task-provenance/v1";
11
+ export declare const LEGACY_TASK_COOLDOWN_MS: number;
12
+ declare const COOLDOWN_MARKER_SCHEMA = "evolver/legacy-task-cleanup/v1";
13
+ export type LegacyTaskCleanupStatus = 'clean' | 'legacy_detected' | 'cleaned' | 'inconclusive' | 'failed' | 'skipped';
14
+ export type LegacyTaskClassification = 'absent' | 'legacy' | 'current' | 'foreign' | 'ambiguous';
15
+ export interface LegacyTaskRunResult {
16
+ status: number | null;
17
+ error?: Error;
18
+ stdout?: string;
19
+ stderr?: string;
20
+ }
21
+ /** Spawn seam: tests inject a fake PowerShell; production uses the trusted absolute path. */
22
+ export type LegacyTaskRun = (command: string, args: readonly string[], timeoutMs: number) => LegacyTaskRunResult;
23
+ export interface LegacyTaskEntry {
24
+ name: string;
25
+ classification: LegacyTaskClassification;
26
+ /** Bounded, operator-safe reason (no raw output, no absolute paths). */
27
+ reason?: string;
28
+ outcome?: 'removed' | 'kept' | 'removal-failed' | 'removal-aborted';
29
+ /** State-relative preimage filename, present once removal succeeded for this task. */
30
+ preimage?: string;
31
+ }
32
+ export interface LegacyTaskCleanupResult {
33
+ status: LegacyTaskCleanupStatus;
34
+ dryRun: boolean;
35
+ tasks: LegacyTaskEntry[];
36
+ /** Bounded detail for inconclusive/failed/skipped states. */
37
+ detail?: string;
38
+ }
39
+ export interface LegacyTaskCleanupOptions {
40
+ env: NodeJS.ProcessEnv;
41
+ stateDir?: string;
42
+ dryRun?: boolean;
43
+ platform?: NodeJS.Platform;
44
+ run?: LegacyTaskRun;
45
+ now?: () => number;
46
+ /**
47
+ * Caller already holds the bootstrap owner lock (post-commit bootstrap sweep). When set,
48
+ * this module asserts ownership through the seam instead of re-acquiring the lock.
49
+ */
50
+ assertOwner?: () => void;
51
+ lock?: {
52
+ maxTries?: number;
53
+ waitMs?: number;
54
+ };
55
+ }
56
+ export interface LegacyTaskProbeResult {
57
+ conclusive: boolean;
58
+ legacy: string[];
59
+ detail: string;
60
+ }
61
+ export interface LegacyTaskProvenancePayload {
62
+ schema: typeof LEGACY_TASK_PROVENANCE_SCHEMA;
63
+ taskName: LegacyWindowsTaskName;
64
+ taskPath: '\\';
65
+ definitionHash: string;
66
+ principalSid: string;
67
+ issuedAt: string;
68
+ expiresAt?: string;
69
+ signatureAlg: 'ed25519';
70
+ }
71
+ export interface LegacyTaskProvenanceReceipt extends LegacyTaskProvenancePayload {
72
+ signature: string;
73
+ }
74
+ interface LoadedLegacyTaskProvenance {
75
+ receipts: ReadonlyMap<LegacyWindowsTaskName, LegacyTaskProvenanceReceipt>;
76
+ detail?: string;
77
+ }
78
+ interface ProbedTaskRecord {
79
+ name?: unknown;
80
+ present?: unknown;
81
+ ambiguous?: unknown;
82
+ count?: unknown;
83
+ taskPath?: unknown;
84
+ actionCount?: unknown;
85
+ execute?: unknown;
86
+ arguments?: unknown;
87
+ workingDirectory?: unknown;
88
+ triggerCount?: unknown;
89
+ userId?: unknown;
90
+ principalSid?: unknown;
91
+ logonType?: unknown;
92
+ runLevel?: unknown;
93
+ enabled?: unknown;
94
+ restartCount?: unknown;
95
+ description?: unknown;
96
+ definitionHash?: unknown;
97
+ }
98
+ interface CooldownMarker {
99
+ schema: typeof COOLDOWN_MARKER_SCHEMA;
100
+ lastConclusiveAt: string;
101
+ status: 'clean' | 'cleaned' | 'inconclusive' | 'failed';
102
+ removed: string[];
103
+ /** Consecutive inconclusive/failed sweep count; present only on negative markers. */
104
+ attempts?: number;
105
+ /** Earliest instant the next automatic sweep may retry; present only on negative markers. */
106
+ nextRetryAt?: string;
107
+ }
108
+ declare function defaultLegacyTaskRun(): LegacyTaskRun;
109
+ export declare function canonicalLegacyTaskProvenanceBytes(payload: LegacyTaskProvenancePayload): Buffer;
110
+ declare function parseLegacyTaskProvenanceReceipt(value: unknown, publicKey: string, now: number): LegacyTaskProvenanceReceipt | undefined;
111
+ declare function loadLegacyTaskProvenance(stateDir: string, env: NodeJS.ProcessEnv, now: number): LoadedLegacyTaskProvenance;
112
+ /** True when the automatic entry points must never cross the Task Scheduler boundary. */
113
+ export declare function legacyTaskProbeSkipped(env: NodeJS.ProcessEnv): boolean;
114
+ declare function renderExportScript(name: LegacyWindowsTaskName, expectedHash?: string, receipt?: LegacyTaskProvenanceReceipt): string;
115
+ /**
116
+ * Fingerprint revalidation → stop → revalidation → unregister → absence verification for
117
+ * one task (the bootstrap rollback unregister pattern). Exit codes: 0 removed, 3 count
118
+ * drift, 4 action drift, 5 execute/provenance refusal, 6 TaskPath drift, 7 stop timeout, 8
119
+ * absence not confirmed, 9 scheduler error, 10 definition drift.
120
+ */
121
+ declare function renderMutationScript(name: LegacyWindowsTaskName, expectedHash?: string, receipt?: LegacyTaskProvenanceReceipt): string;
122
+ /**
123
+ * Restore refuses to overwrite: it re-registers a persisted preimage only when the known
124
+ * name is currently absent. Exit codes: 0 restored, 3 name already present, 4 registration
125
+ * verification failed after a guarded rollback, 5 preimage changed while restoring, 9
126
+ * scheduler error, 11 rollback could not prove that the just-registered generation was still
127
+ * present (the task is deliberately left for operator inspection).
128
+ */
129
+ declare function renderRestoreScript(name: LegacyWindowsTaskName, preimageReadPath: string, expectedHash?: string): string;
130
+ declare function parseProbeRecords(stdout: string): ProbedTaskRecord[] | undefined;
131
+ export declare function classifyProbedTask(record: ProbedTaskRecord | undefined, provenance?: LegacyTaskProvenanceReceipt): {
132
+ classification: LegacyTaskClassification;
133
+ reason?: string;
134
+ };
135
+ declare function preimageDirFor(stateDir: string): string;
136
+ declare function cooldownMarkerPath(stateDir: string): string;
137
+ declare function readCooldownMarker(stateDir: string): CooldownMarker | undefined;
138
+ /** Negative-backoff delay for inconclusive/failed sweeps: 1h base, doubling, capped at 24h. */
139
+ declare function legacyTaskNegativeBackoffMs(attempts: number): number;
140
+ declare function writeCooldownMarker(stateDir: string, status: 'clean' | 'cleaned', removed: string[], now: () => number): void;
141
+ declare function writeNegativeCooldownMarker(stateDir: string, status: 'inconclusive' | 'failed', attempts: number, now: () => number): void;
142
+ /**
143
+ * Manual cleanup owns the lifecycle lock before it probes. Without this outer lock a clean
144
+ * probe could race a concurrent bootstrap that registers a legacy-named task and then publish
145
+ * a positive cooldown marker, suppressing the next real sweep for 24 hours. Automatic callers
146
+ * already hold the same lock and pass `assertOwner`, while dry-run remains read-only.
147
+ */
148
+ export declare function cleanupLegacyWindowsDaemonTasks(options: LegacyTaskCleanupOptions): LegacyTaskCleanupResult;
149
+ /** Read-only probe for `evolver doctor` — never mutates, never throws. */
150
+ export declare function probeLegacyWindowsDaemonTasks(options: {
151
+ env: NodeJS.ProcessEnv;
152
+ platform?: NodeJS.Platform;
153
+ run?: LegacyTaskRun;
154
+ stateDir?: string;
155
+ }): LegacyTaskProbeResult;
156
+ /**
157
+ * Automatic entry point (SessionStart hook). Throttled by the cooldown marker: after a
158
+ * conclusive success the sweep skips re-probing for the cooldown window; an
159
+ * inconclusive/failed run writes a NEGATIVE backoff marker (1h base, doubling per
160
+ * consecutive failure, capped at 24h) and the sweep skips until `nextRetryAt`, so a
161
+ * constrained host does not spawn PowerShell on every session. A conclusive success
162
+ * overwrites the marker, resetting the backoff counter. Never throws.
163
+ */
164
+ export declare function maybeCleanupLegacyWindowsDaemonTasks(options: {
165
+ env: NodeJS.ProcessEnv;
166
+ platform?: NodeJS.Platform;
167
+ stateDir?: string;
168
+ run?: LegacyTaskRun;
169
+ now?: () => number;
170
+ cooldownMs?: number;
171
+ lock?: {
172
+ maxTries?: number;
173
+ waitMs?: number;
174
+ };
175
+ }): LegacyTaskCleanupResult | undefined;
176
+ /**
177
+ * Post-bootstrap sweep seam: runs under the already-held bootstrap owner lock and returns
178
+ * report lines for the bootstrap `actions`. Never throws and never fails the bootstrap —
179
+ * but a failed/inconclusive sweep is reported honestly instead of being dropped.
180
+ */
181
+ export declare function sweepLegacyWindowsDaemonTasksAfterBootstrap(options: {
182
+ env: NodeJS.ProcessEnv;
183
+ stateDir: string;
184
+ assertOwner: () => void;
185
+ platform?: NodeJS.Platform;
186
+ run?: LegacyTaskRun;
187
+ }): string[];
188
+ /**
189
+ * Manual restore of a persisted preimage. Only files named `<KnownTaskName>.<stamp>.xml`
190
+ * are accepted, the target name must be currently ABSENT (restore never overwrites), and
191
+ * the XML is validated before it reaches PowerShell. Never throws.
192
+ */
193
+ export declare function restoreLegacyTaskPreimage(preimagePath: string, options: {
194
+ env: NodeJS.ProcessEnv;
195
+ platform?: NodeJS.Platform;
196
+ run?: LegacyTaskRun;
197
+ stateDir?: string;
198
+ lock?: {
199
+ maxTries?: number;
200
+ waitMs?: number;
201
+ };
202
+ }): {
203
+ status: 'restored' | 'failed';
204
+ task?: string;
205
+ detail: string;
206
+ };
207
+ export declare const _legacyTaskInternalsForTest: {
208
+ PROBE_SCRIPT: string;
209
+ acquireBootstrapOwnerLock: typeof acquireBootstrapOwnerLock;
210
+ defaultLegacyTaskRun: typeof defaultLegacyTaskRun;
211
+ canonicalLegacyTaskProvenanceBytes: typeof canonicalLegacyTaskProvenanceBytes;
212
+ parseLegacyTaskProvenanceReceipt: typeof parseLegacyTaskProvenanceReceipt;
213
+ loadLegacyTaskProvenance: typeof loadLegacyTaskProvenance;
214
+ renderExportScript: typeof renderExportScript;
215
+ renderMutationScript: typeof renderMutationScript;
216
+ renderRestoreScript: typeof renderRestoreScript;
217
+ parseProbeRecords: typeof parseProbeRecords;
218
+ readCooldownMarker: typeof readCooldownMarker;
219
+ writeCooldownMarker: typeof writeCooldownMarker;
220
+ writeNegativeCooldownMarker: typeof writeNegativeCooldownMarker;
221
+ negativeBackoffMs: typeof legacyTaskNegativeBackoffMs;
222
+ cooldownMarkerPath: typeof cooldownMarkerPath;
223
+ preimageDirFor: typeof preimageDirFor;
224
+ cleanupClassifiedLegacyTasksForTest: typeof cleanupClassifiedLegacyTasksForTest;
225
+ };
226
+ /** Test-only wrapper for mutation mechanics; callers must supply preclassified legacy entries. */
227
+ declare function cleanupClassifiedLegacyTasksForTest(options: LegacyTaskCleanupOptions, entries: LegacyTaskEntry[], expectedDefinitionHashes?: ReadonlyMap<string, string>, expectedProvenanceReceipts?: ReadonlyMap<string, LegacyTaskProvenanceReceipt>): LegacyTaskCleanupResult;
228
+ export {};