@claude-flow/cli 3.22.0 → 3.24.0

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 (59) hide show
  1. package/.claude/evolve-proof/generation-0.json +211 -0
  2. package/.claude/evolve-proof/real-generation-0.json +406 -0
  3. package/.claude/evolve-proof/real-generation-1.json +406 -0
  4. package/.claude/helpers/.helpers-version +1 -0
  5. package/.claude/helpers/helpers.manifest.json +2 -2
  6. package/.claude/helpers/hook-handler.cjs +0 -0
  7. package/.claude/helpers/intelligence.cjs +10 -0
  8. package/.claude/proven-config.manifest.json +37 -0
  9. package/.claude/proven-config.signed.json +41 -0
  10. package/.claude/proven-config.signed.rvf +0 -0
  11. package/dist/src/commands/memory-backup.d.ts +11 -0
  12. package/dist/src/commands/memory-backup.js +46 -0
  13. package/dist/src/commands/memory.js +2 -1
  14. package/dist/src/config/harness-feedback-applier.d.ts +50 -0
  15. package/dist/src/config/harness-feedback-applier.js +122 -0
  16. package/dist/src/config/proven-config-refresh.d.ts +39 -0
  17. package/dist/src/config/proven-config-refresh.js +154 -0
  18. package/dist/src/config/proven-config-rvfa.d.ts +23 -0
  19. package/dist/src/config/proven-config-rvfa.js +73 -0
  20. package/dist/src/config/proven-config.d.ts +86 -0
  21. package/dist/src/config/proven-config.js +176 -0
  22. package/dist/src/index.js +35 -0
  23. package/dist/src/mcp-tools/neural-tools.d.ts +10 -0
  24. package/dist/src/mcp-tools/neural-tools.js +107 -18
  25. package/dist/src/services/daemon-autostart.d.ts +17 -0
  26. package/dist/src/services/daemon-autostart.js +79 -0
  27. package/dist/src/services/evolve-proof.d.ts +247 -0
  28. package/dist/src/services/evolve-proof.js +341 -0
  29. package/dist/src/services/harness-benchmark.d.ts +68 -0
  30. package/dist/src/services/harness-benchmark.js +94 -0
  31. package/dist/src/services/harness-canary.d.ts +60 -0
  32. package/dist/src/services/harness-canary.js +69 -0
  33. package/dist/src/services/harness-corpus-harvester.d.ts +51 -0
  34. package/dist/src/services/harness-corpus-harvester.js +74 -0
  35. package/dist/src/services/harness-flywheel-generations.d.ts +111 -0
  36. package/dist/src/services/harness-flywheel-generations.js +354 -0
  37. package/dist/src/services/harness-flywheel-runtime.d.ts +25 -0
  38. package/dist/src/services/harness-flywheel-runtime.js +101 -0
  39. package/dist/src/services/harness-flywheel.d.ts +48 -0
  40. package/dist/src/services/harness-flywheel.js +207 -0
  41. package/dist/src/services/harness-hosts.d.ts +40 -0
  42. package/dist/src/services/harness-hosts.js +88 -0
  43. package/dist/src/services/harness-improvement-ledger.d.ts +63 -0
  44. package/dist/src/services/harness-improvement-ledger.js +101 -0
  45. package/dist/src/services/harness-loop.d.ts +53 -0
  46. package/dist/src/services/harness-loop.js +85 -0
  47. package/dist/src/services/harness-qualification.d.ts +66 -0
  48. package/dist/src/services/harness-qualification.js +143 -0
  49. package/dist/src/services/harness-replay.d.ts +37 -0
  50. package/dist/src/services/harness-replay.js +92 -0
  51. package/dist/src/services/harness-verify.d.ts +33 -0
  52. package/dist/src/services/harness-verify.js +26 -0
  53. package/dist/src/services/harness-worker.d.ts +23 -0
  54. package/dist/src/services/harness-worker.js +66 -0
  55. package/dist/src/services/memory-backup.d.ts +24 -0
  56. package/dist/src/services/memory-backup.js +94 -0
  57. package/dist/src/services/worker-daemon.d.ts +16 -1
  58. package/dist/src/services/worker-daemon.js +84 -0
  59. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -133,6 +133,41 @@ export class CLI {
133
133
  }
134
134
  }
135
135
  catch { /* silent */ }
136
+ // ADR-177: adopt a signed proven-configuration champion if the package
137
+ // ships one newer than this project's stamp AND it is authentic +
138
+ // suitable for this environment. Sibling of the helper channel above —
139
+ // its own stamp + trust root; additive no-op when no champion ships.
140
+ try {
141
+ const { autoAdoptProvenConfigIfStale } = await import('./config/proven-config-refresh.js');
142
+ const a = await autoAdoptProvenConfigIfStale(process.cwd());
143
+ if (a.adopted && this.output.isVerbose()) {
144
+ this.output.printDebug(`Adopted proven config (${a.from} → ${a.to})`);
145
+ }
146
+ // Close the loop (ADR-176 phase 9): promote the adopted champion to the
147
+ // ACTIVE policy that consumers (neural_patterns retrieval, …) read. A
148
+ // no-op if nothing is adopted or it is already active; reversible.
149
+ const { applyChampion } = await import('./config/harness-feedback-applier.js');
150
+ const ap = applyChampion(process.cwd());
151
+ if (ap.applied && this.output.isVerbose()) {
152
+ this.output.printDebug(`Applied proven config to active policy (${ap.from ?? '(none)'} → ${ap.to})`);
153
+ }
154
+ }
155
+ catch { /* silent */ }
156
+ // Self-running daemon: ensure the background workers (distillation,
157
+ // backup, …) are actually firing without a manual `daemon start`.
158
+ // Single-instance (only spawns when none is alive; the spawned daemon
159
+ // re-checks its own lock), bounded (TTL/idle self-shutdown), opt-out via
160
+ // RUFLO_DAEMON_AUTOSTART=0. Skipped for `daemon` (no recursion). Detached
161
+ // + fire-and-forget, so it never blocks the command.
162
+ if (commandPath[0] !== 'daemon') {
163
+ try {
164
+ const { ensureDaemonRunning } = await import('./services/daemon-autostart.js');
165
+ const d = ensureDaemonRunning(process.cwd());
166
+ if (d.started && this.output.isVerbose())
167
+ this.output.printDebug('Started background daemon (auto)');
168
+ }
169
+ catch { /* silent */ }
170
+ }
136
171
  }
137
172
  // Handle lazy-loaded commands that weren't recognized by the parser
138
173
  // If commandPath is empty but positional has a command name, check if it's lazy-loadable
@@ -12,6 +12,16 @@
12
12
  * Note: For production neural features, use @claude-flow/neural module
13
13
  */
14
14
  import { type MCPTool } from './types.js';
15
+ /**
16
+ * ADR-176 flywheel: expose the stored patterns (id/name/content) so the
17
+ * self-optimizing loop can harvest a benchmark corpus from real usage. Additive,
18
+ * read-only, never throws.
19
+ */
20
+ export declare function getStorePatterns(): Array<{
21
+ id: string;
22
+ name: string;
23
+ content?: string;
24
+ }>;
15
25
  /**
16
26
  * Public helper: read-only stats about the neural store, for the unified
17
27
  * learning-stats aggregator. Returns total pattern count + per-type breakdown
@@ -15,6 +15,55 @@ import { getProjectCwd } from './types.js';
15
15
  import { validateIdentifier, validateText } from './validate-input.js';
16
16
  import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
17
17
  import { join } from 'node:path';
18
+ let _corpusStatsCache = null;
19
+ // (query, store) → embedding + cosine cache. Small LRU (not size-1): the flywheel
20
+ // scores many configs across several queries in interleaved order, so a size-1
21
+ // cache would thrash. Cap keeps memory bounded; eviction is oldest-first.
22
+ const _cosineCache = new Map();
23
+ const _COSINE_CACHE_MAX = 128;
24
+ function _cosineCacheGet(key) {
25
+ const v = _cosineCache.get(key);
26
+ if (v) {
27
+ _cosineCache.delete(key);
28
+ _cosineCache.set(key, v);
29
+ } // LRU touch
30
+ return v;
31
+ }
32
+ function _cosineCacheSet(key, v) {
33
+ _cosineCache.set(key, v);
34
+ if (_cosineCache.size > _COSINE_CACHE_MAX)
35
+ _cosineCache.delete(_cosineCache.keys().next().value);
36
+ }
37
+ function corpusFingerprint(patterns) {
38
+ let h = 2166136261 >>> 0;
39
+ for (const p of patterns) {
40
+ const s = `${p.id}|${p.name?.length ?? 0}|${p.content?.length ?? 0}`;
41
+ for (let i = 0; i < s.length; i++) {
42
+ h ^= s.charCodeAt(i);
43
+ h = Math.imul(h, 16777619) >>> 0;
44
+ }
45
+ }
46
+ return `${patterns.length}:${h.toString(16)}`;
47
+ }
48
+ let _champCache = null;
49
+ function activeChampionParams() {
50
+ try {
51
+ if (_champCache && Date.now() - _champCache.at < 30_000)
52
+ return _champCache.params;
53
+ const p = join(getProjectCwd(), '.claude-flow', 'harness-active-policy.json');
54
+ let params = {};
55
+ if (existsSync(p)) {
56
+ const active = JSON.parse(readFileSync(p, 'utf-8'));
57
+ if (active && !active.rolledBack && active.params && typeof active.params === 'object')
58
+ params = active.params;
59
+ }
60
+ _champCache = { at: Date.now(), params };
61
+ return params;
62
+ }
63
+ catch {
64
+ return {};
65
+ }
66
+ }
18
67
  // Real embeddings — resolved LAZILY on first use.
19
68
  // Perf (measured 2026-07): the previous top-level-await version of this block
20
69
  // ran `await import('ruvector')` + `initOnnxEmbedder()` + a probe embed at
@@ -159,6 +208,19 @@ function loadNeuralStore() {
159
208
  }
160
209
  return { models: {}, patterns: {}, version: '3.0.0' };
161
210
  }
211
+ /**
212
+ * ADR-176 flywheel: expose the stored patterns (id/name/content) so the
213
+ * self-optimizing loop can harvest a benchmark corpus from real usage. Additive,
214
+ * read-only, never throws.
215
+ */
216
+ export function getStorePatterns() {
217
+ try {
218
+ return Object.values(loadNeuralStore().patterns ?? {}).map((p) => ({ id: p.id, name: p.name, content: p.content }));
219
+ }
220
+ catch {
221
+ return [];
222
+ }
223
+ }
162
224
  function saveNeuralStore(store) {
163
225
  ensureNeuralDir();
164
226
  writeFileSync(getNeuralPath(), JSON.stringify(store, null, 2), 'utf-8');
@@ -604,13 +666,28 @@ export const neuralTools = [
604
666
  // sub-params than non-rerank (the cross-encoder adds semantic depth,
605
667
  // so the hybrid stage can be more keyword-focused). nDCG@3 0.900 →
606
668
  // 0.963 on rerank just by switching sw 2.0 → 3.0 in the hybrid stage.
607
- const alpha = Number(input.alpha ?? 0.5);
608
- const mmrLambda = Number(input.mmrLambda ?? 0.7);
669
+ // Champion-provided defaults (ADR-176/177): explicit input wins, then the
670
+ // adopted proven-config champion, then the hardcoded ADR-082 defaults.
671
+ const champ = activeChampionParams();
672
+ const alpha = Number(input.alpha ?? champ.alpha ?? 0.5);
673
+ const mmrLambda = Number(input.mmrLambda ?? champ.mmrLambda ?? 0.7);
609
674
  const { tokenize, buildCorpusStats, hybridScores, mmrRerank, multiFieldBM25, typePenalty } = await import('../memory/hybrid-retrieval.js');
610
- const queryEmbedding = await generateEmbedding(query, 384);
611
675
  const patterns = Object.values(store.patterns);
612
- // Compute cosine for every pattern (this is what the old path did).
613
- const cosineArr = patterns.map((p) => cosineSimilarity(queryEmbedding, p.embedding));
676
+ // Query embedding + cosine array depend only on (query, store) NOT the
677
+ // retrieval config. Cache them so scoring many configs for one query
678
+ // (the flywheel's access pattern) embeds + cosines once, not per config.
679
+ const _cosKey = `${corpusFingerprint(patterns)}::${query}`;
680
+ let queryEmbedding, cosineArr;
681
+ const _hit = _cosineCacheGet(_cosKey);
682
+ if (_hit) {
683
+ queryEmbedding = _hit.queryEmbedding;
684
+ cosineArr = _hit.cosineArr;
685
+ }
686
+ else {
687
+ queryEmbedding = await generateEmbedding(query, 384);
688
+ cosineArr = patterns.map((p) => cosineSimilarity(queryEmbedding, p.embedding));
689
+ _cosineCacheSet(_cosKey, { queryEmbedding, cosineArr });
690
+ }
614
691
  if (mode === 'cosine') {
615
692
  const ranked = patterns
616
693
  .map((p, i) => ({ ...p, similarity: cosineArr[i] }))
@@ -630,23 +707,35 @@ export const neuralTools = [
630
707
  // Hybrid path — multi-field BM25 (subject 3×, body 1×) + type penalty
631
708
  // for meta-commits (release bumps / merges) per ADR-079. Falls back
632
709
  // to single-field BM25 when no content is stored.
633
- const subjectDocs = patterns.map((p) => tokenize(p.name ?? ''));
634
- const bodyDocs = patterns.map((p) => {
635
- // Body is content minus the subject — if content starts with name,
636
- // strip it; otherwise use full content (with name removed if duplicated).
637
- const c = p.content ?? '';
638
- const n = p.name ?? '';
639
- return tokenize(c.startsWith(n) ? c.slice(n.length) : c);
640
- });
641
- const subjectStats = buildCorpusStats(subjectDocs);
642
- const bodyStats = buildCorpusStats(bodyDocs);
710
+ // Cache the (config-independent) tokenized docs + BM25 stats by store fingerprint.
711
+ const _fp = corpusFingerprint(patterns);
712
+ let subjectDocs, bodyDocs, subjectStats, bodyStats;
713
+ if (_corpusStatsCache && _corpusStatsCache.fp === _fp) {
714
+ subjectDocs = _corpusStatsCache.subjectDocs;
715
+ bodyDocs = _corpusStatsCache.bodyDocs;
716
+ subjectStats = _corpusStatsCache.subjectStats;
717
+ bodyStats = _corpusStatsCache.bodyStats;
718
+ }
719
+ else {
720
+ subjectDocs = patterns.map((p) => tokenize(p.name ?? ''));
721
+ bodyDocs = patterns.map((p) => {
722
+ // Body is content minus the subject — if content starts with name,
723
+ // strip it; otherwise use full content (with name removed if duplicated).
724
+ const c = p.content ?? '';
725
+ const n = p.name ?? '';
726
+ return tokenize(c.startsWith(n) ? c.slice(n.length) : c);
727
+ });
728
+ subjectStats = buildCorpusStats(subjectDocs);
729
+ bodyStats = buildCorpusStats(bodyDocs);
730
+ _corpusStatsCache = { fp: _fp, subjectDocs, bodyDocs, subjectStats, bodyStats };
731
+ }
643
732
  const queryTokens = tokenize(query);
644
733
  // ADR-082: subjectWeight 3.0 → 2.0 from grid (sw=2 dominates at hybrid-only).
645
734
  // ADR-083 joint grid: when rerank is on, the cross-encoder handles
646
735
  // semantic understanding, so the hybrid stage can be MORE
647
736
  // subject-focused (sw=3) — recovers nDCG@3 0.963.
648
- const subjectWeight = Number(input.subjectWeight ?? (useRerank ? 3.0 : 2.0));
649
- const bodyWeight = Number(input.bodyWeight ?? 1.0);
737
+ const subjectWeight = Number(input.subjectWeight ?? champ.subjectWeight ?? (useRerank ? 3.0 : 2.0));
738
+ const bodyWeight = Number(input.bodyWeight ?? champ.bodyWeight ?? 1.0);
650
739
  const bm25Arr = patterns.map((_, i) => multiFieldBM25(queryTokens, subjectDocs[i], bodyDocs[i], subjectStats, bodyStats, subjectWeight, bodyWeight));
651
740
  const baseHybrid = hybridScores(cosineArr, bm25Arr, alpha);
652
741
  // Type penalty — opt-in (default 1.0 = disabled). Ablation in ADR-079
@@ -654,7 +743,7 @@ export const neuralTools = [
654
743
  // penalty enabled) because some relevant work commits also match the
655
744
  // Merge/release regex. Callers wanting aggressive meta-commit
656
745
  // suppression can set {typePenaltyFactor: 0.5}.
657
- const typeFactor = Number(input.typePenaltyFactor ?? 1.0);
746
+ const typeFactor = Number(input.typePenaltyFactor ?? champ.typePenaltyFactor ?? 1.0);
658
747
  const hybridArr = typeFactor === 1.0
659
748
  ? baseHybrid
660
749
  : baseHybrid.map((s, i) => s * typePenalty(patterns[i].name, typeFactor));
@@ -0,0 +1,17 @@
1
+ /** True if a live daemon already holds the project's pidfile. */
2
+ export declare function isDaemonAlive(projectRoot: string): boolean;
3
+ export interface EnsureResult {
4
+ started: boolean;
5
+ reason?: string;
6
+ }
7
+ /** Spawn `daemon start` detached, reusing all its lock/TTL machinery. Injectable for tests. */
8
+ export type SpawnDaemonFn = (projectRoot: string) => void;
9
+ /**
10
+ * Ensure a daemon is running for `projectRoot`. No-op when disabled or when one
11
+ * is already alive. Best-effort; never throws.
12
+ */
13
+ export declare function ensureDaemonRunning(projectRoot: string, opts?: {
14
+ spawnFn?: SpawnDaemonFn;
15
+ isAlive?: (root: string) => boolean;
16
+ }): EnsureResult;
17
+ //# sourceMappingURL=daemon-autostart.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Self-running daemon (auto-start).
3
+ *
4
+ * The self-optimizing loop's workers (distillation, backup, and the future
5
+ * evolve worker) are inert unless the daemon runs — but it required a manual
6
+ * `ruflo daemon start`. This ensures a daemon is running on CLI use, SAFELY:
7
+ *
8
+ * - single-instance: only starts when no live daemon holds the pidfile, and
9
+ * the spawned `daemon start` independently enforces single-instance via its
10
+ * own lock + checkExistingDaemon() — so a race spawns at most one survivor,
11
+ * - bounded lifetime: the daemon self-terminates on TTL/idle (12h default,
12
+ * RUFLO_DAEMON_TTL_SECS) — auto-start never means "runs forever",
13
+ * - opt-out: RUFLO_DAEMON_AUTOSTART=0|false|no disables it entirely,
14
+ * - cheap: a pidfile read + a signal-0 liveness check on the fast path,
15
+ * - best-effort + silent: never blocks or fails a command.
16
+ *
17
+ * Reuses `daemon start` verbatim (all its lock/TTL/worker machinery) — this
18
+ * module only decides WHETHER to spawn, never reimplements the daemon.
19
+ */
20
+ import * as fs from 'fs';
21
+ import * as path from 'path';
22
+ import { spawn } from 'child_process';
23
+ /** True if a live daemon already holds the project's pidfile. */
24
+ export function isDaemonAlive(projectRoot) {
25
+ const pidFile = path.join(projectRoot, '.claude-flow', 'daemon.pid');
26
+ try {
27
+ if (!fs.existsSync(pidFile))
28
+ return false;
29
+ const pid = parseInt(fs.readFileSync(pidFile, 'utf-8').trim(), 10);
30
+ if (Number.isNaN(pid) || pid === process.pid)
31
+ return false;
32
+ process.kill(pid, 0); // signal 0 = existence check
33
+ return true;
34
+ }
35
+ catch {
36
+ // Dead process → stale pidfile. Clean it so `daemon start` proceeds cleanly.
37
+ try {
38
+ fs.unlinkSync(pidFile);
39
+ }
40
+ catch { /* ignore */ }
41
+ return false;
42
+ }
43
+ }
44
+ function autostartDisabled() {
45
+ return /^(0|false|no|off)$/i.test(process.env.RUFLO_DAEMON_AUTOSTART ?? '');
46
+ }
47
+ const defaultSpawn = (projectRoot) => {
48
+ const cliBin = process.argv[1]; // the running bin/cli.js
49
+ const child = spawn(process.execPath, [cliBin, 'daemon', 'start', '--quiet'], {
50
+ cwd: projectRoot,
51
+ detached: true,
52
+ stdio: 'ignore',
53
+ env: { ...process.env },
54
+ });
55
+ child.unref();
56
+ };
57
+ /**
58
+ * Ensure a daemon is running for `projectRoot`. No-op when disabled or when one
59
+ * is already alive. Best-effort; never throws.
60
+ */
61
+ export function ensureDaemonRunning(projectRoot, opts = {}) {
62
+ try {
63
+ if (autostartDisabled())
64
+ return { started: false, reason: 'disabled (RUFLO_DAEMON_AUTOSTART=0)' };
65
+ // Only in an initialized project (avoid scaffolding a daemon in a random dir).
66
+ if (!fs.existsSync(path.join(projectRoot, '.claude-flow')) && !fs.existsSync(path.join(projectRoot, '.claude'))) {
67
+ return { started: false, reason: 'not a ruflo project' };
68
+ }
69
+ const alive = (opts.isAlive ?? isDaemonAlive)(projectRoot);
70
+ if (alive)
71
+ return { started: false, reason: 'already running' };
72
+ (opts.spawnFn ?? defaultSpawn)(projectRoot);
73
+ return { started: true };
74
+ }
75
+ catch (e) {
76
+ return { started: false, reason: `error: ${e?.message ?? e}` };
77
+ }
78
+ }
79
+ //# sourceMappingURL=daemon-autostart.js.map
@@ -0,0 +1,247 @@
1
+ import { type PromotionVerdict, type AcceptResult } from './harness-benchmark.js';
2
+ import { type ProvenConfigManifest } from '../config/proven-config.js';
3
+ /**
4
+ * The promotion rule is versioned so a receipt pins exactly which semantics
5
+ * decided it. v1+sig = the accept() conjunction AND a statistical-significance
6
+ * term: the per-held-out-task deltas must have a positive one-sided 95% bootstrap
7
+ * lower bound, so a small-N mean gain can't ride on noise. The canary term is a
8
+ * SEPARATE deployment-safety signal (a distinct slice), not held-out dominance.
9
+ */
10
+ export declare const PROMOTION_RULE_VERSION = "accept/v1+sig";
11
+ export declare const PROOF_LABEL = "single-round proof-of-mechanism";
12
+ export declare const NOT_CLAIMS: readonly ["not flywheel proof", "not compounding learning", "not production learning"];
13
+ export interface HoldoutTask {
14
+ taskId: string;
15
+ baselineScore: number;
16
+ candidateScore: number;
17
+ }
18
+ export interface DecisionReceipt {
19
+ promotionRuleVersion: string;
20
+ verdictInputs: PromotionVerdict;
21
+ result: AcceptResult;
22
+ significant: boolean;
23
+ deltaCILow: number;
24
+ promoted: boolean;
25
+ reason: string;
26
+ }
27
+ export interface ShadowRegistration {
28
+ registrationId: string;
29
+ state: 'shadow';
30
+ served: false;
31
+ candidateManifestHash: string;
32
+ registeredAt: number;
33
+ }
34
+ export interface CostReceipt {
35
+ usd: number;
36
+ llmCalls: number;
37
+ tier: string;
38
+ notes: string;
39
+ }
40
+ /** Multi-dimensional deltas vs the parent — distinguishes *why* a change is (un)safe. */
41
+ export interface ChangeDeltas {
42
+ benchmark: number;
43
+ security: number;
44
+ cost: number;
45
+ }
46
+ /**
47
+ * Causal promotion record (not just provenance). Answers *why* a candidate won —
48
+ * and, aggregated across the lineage, *which mutation classes* reliably pay off.
49
+ * This is what turns the lineage from an audit trail into a knowledge base.
50
+ */
51
+ export interface PromotionRecord {
52
+ parentManifestHash: string | null;
53
+ candidateManifestHash: string;
54
+ mutationClass: string;
55
+ mutationSummary: string;
56
+ deltas: ChangeDeltas;
57
+ decisionReceipt: DecisionReceipt;
58
+ }
59
+ /** Regression ancestry — a rejected candidate records the gate that killed it + its ancestor. */
60
+ export interface RegressionRecord {
61
+ candidateManifestHash: string;
62
+ ancestor: string | null;
63
+ mutationClass: string;
64
+ failureCause: 'holdout' | 'security' | 'drift' | 'replay' | 'governance' | 'canary' | 'significance';
65
+ failedTerms: string[];
66
+ }
67
+ export interface EvolveReceiptBundle {
68
+ label: typeof PROOF_LABEL;
69
+ disclaimers: typeof NOT_CLAIMS;
70
+ generation: number;
71
+ parent: string | null;
72
+ branch: string;
73
+ kind: 'synthetic' | 'real';
74
+ createdAt: number;
75
+ inputHoldoutHash: string;
76
+ baselineManifestHash: string;
77
+ candidateManifestHash: string;
78
+ meetsPromotionRule: {
79
+ version: string;
80
+ result: boolean;
81
+ };
82
+ decisionReceipt: DecisionReceipt;
83
+ shadow: ShadowRegistration | null;
84
+ costReceipt: CostReceipt;
85
+ mutationClass: string;
86
+ mutationSummary: string;
87
+ deltas: ChangeDeltas;
88
+ promotion: PromotionRecord | null;
89
+ regression: RegressionRecord | null;
90
+ holdout: HoldoutTask[];
91
+ baselineManifest: ProvenConfigManifest;
92
+ candidateManifest: ProvenConfigManifest;
93
+ }
94
+ /** Classify a policy mutation by which fields changed → a repeatable mutation CLASS + a diff summary. */
95
+ export declare function classifyMutation(baseline: Record<string, number>, candidate: Record<string, number>): {
96
+ mutationClass: string;
97
+ mutationSummary: string;
98
+ };
99
+ export interface AssembleOpts {
100
+ generation: number;
101
+ parent: string | null;
102
+ branch: string;
103
+ now: number;
104
+ kind: 'synthetic' | 'real';
105
+ cost: {
106
+ tier: string;
107
+ notes: string;
108
+ };
109
+ redblue?: 'PASS' | 'FAIL' | 'SKIPPED';
110
+ drift?: number;
111
+ canaryRollbackRate?: number;
112
+ layer?: string;
113
+ corpus?: string;
114
+ }
115
+ /**
116
+ * Assemble a receipt bundle from a holdout + configs. This is the SHARED core:
117
+ * the synthetic proof and a REAL measured round produce byte-identical bundle
118
+ * structure and run the SAME versioned accept() — so `verifyReceiptBundle`
119
+ * replays a real bundle exactly as it replays the synthetic fixture.
120
+ */
121
+ export declare function assembleBundle(baseline: Record<string, number>, candidate: Record<string, number>, holdout: HoldoutTask[], o: AssembleOpts): EvolveReceiptBundle;
122
+ /**
123
+ * Build a REAL evolve-round receipt bundle from MEASURED holdout scores (live
124
+ * retrieval over a frozen anchor). Same gate, same replayability as the
125
+ * synthetic proof — but `kind: 'real'` and the scores come from actual runs.
126
+ * `redblue` should be 'FAIL' if the candidate regressed a frozen security/anchor
127
+ * slice; drift from real distribution shift. $0 (no LLM/network on this path).
128
+ */
129
+ export declare function runRealEvolveRound(opts: {
130
+ baseline: Record<string, number>;
131
+ candidate: Record<string, number>;
132
+ holdout: HoldoutTask[];
133
+ generation: number;
134
+ parent: string | null;
135
+ branch?: string;
136
+ now: number;
137
+ redblue?: 'PASS' | 'FAIL' | 'SKIPPED';
138
+ drift?: number;
139
+ canaryRollbackRate?: number;
140
+ corpus: string;
141
+ }): EvolveReceiptBundle;
142
+ /**
143
+ * Run ONE deterministic synthetic evolve round and produce the receipt bundle.
144
+ * `now` is injected (no Date in the pure path) for reproducible fixtures.
145
+ * The default scenario is a strict Pareto improvement (candidate ≥ baseline on
146
+ * every task, > on the mean) so the full PROMOTE→SHADOW path is exercised; pass
147
+ * `regress: true` to exercise the REJECT path instead.
148
+ */
149
+ export declare function runSyntheticProofRound(opts?: {
150
+ now: number;
151
+ generation?: number;
152
+ regress?: boolean;
153
+ parent?: string | null;
154
+ branch?: string;
155
+ baseline?: Record<string, number>;
156
+ candidate?: Record<string, number>;
157
+ }): EvolveReceiptBundle;
158
+ export interface VerifyReport {
159
+ valid: boolean;
160
+ hashChecks: {
161
+ inputHoldout: boolean;
162
+ baselineManifest: boolean;
163
+ candidateManifest: boolean;
164
+ };
165
+ recomputed: {
166
+ baselineHeldOut: number;
167
+ candidateHeldOut: number;
168
+ canaryRollbackRate: number;
169
+ decision: AcceptResult;
170
+ };
171
+ decisionMatches: boolean;
172
+ ruleVersionMatches: boolean;
173
+ noAutoServe: boolean;
174
+ causalConsistent: boolean;
175
+ explanation: string;
176
+ mismatches: string[];
177
+ }
178
+ /**
179
+ * Independently verify a receipt bundle WITHOUT trusting any service log: rehash
180
+ * the embedded holdout + manifests, recompute the held-out means + canary rate
181
+ * from the embedded per-task scores, RE-RUN the same versioned accept(), and
182
+ * confirm the recomputed decision equals the recorded one. Also confirms the
183
+ * SHADOW registration is not served (no auto-serve). Pure; never throws.
184
+ */
185
+ export declare function verifyReceiptBundle(bundle: EvolveReceiptBundle): VerifyReport;
186
+ export interface LineageTelemetry {
187
+ generations: number;
188
+ candidatesEvaluated: number;
189
+ promotions: number;
190
+ rejections: number;
191
+ cumulativeHeldOutImprovement: number;
192
+ rootHash: string | null;
193
+ branches: string[];
194
+ lineageIntact: boolean;
195
+ allReplayable: boolean;
196
+ nodes: Array<{
197
+ generation: number;
198
+ branch: string;
199
+ promoted: boolean;
200
+ parent: string | null;
201
+ candidateManifestHash: string;
202
+ mutationClass: string;
203
+ delta: number;
204
+ replayable: boolean;
205
+ }>;
206
+ problems: string[];
207
+ }
208
+ /**
209
+ * Reconstruct + audit a lineage DAG. Independently replays every bundle and
210
+ * checks the graph invariants back to the immutable root. Pure; never throws.
211
+ */
212
+ export declare function reconstructLineage(bundles: EvolveReceiptBundle[]): LineageTelemetry;
213
+ export interface MutationStat {
214
+ mutationClass: string;
215
+ attempts: number;
216
+ promotions: number;
217
+ meanDelta: number;
218
+ }
219
+ /**
220
+ * Aggregate per-mutation-class effectiveness across a lineage. After enough
221
+ * generations the optimizer can bias toward classes with higher historical
222
+ * payoff — meta-learning grounded in evidence, not intuition.
223
+ */
224
+ export declare function mutationEffectiveness(bundles: EvolveReceiptBundle[]): MutationStat[];
225
+ export type PlateauStatus = 'insufficient-data' | 'active' | 'local-optimum' | 'noisy-benchmark' | 'optimizer-failure';
226
+ export interface PlateauReport {
227
+ status: PlateauStatus;
228
+ window: number;
229
+ medianImprovement: number;
230
+ promotionRate: number;
231
+ varianceShrinking: boolean;
232
+ candidateVariance: number;
233
+ rationale: string;
234
+ }
235
+ /**
236
+ * Distinguish local optimum vs noisy benchmark vs optimizer failure — rigorously,
237
+ * not by intuition. Over a rolling window: near-zero median improvement AND low
238
+ * promotion rate is a plateau; shrinking candidate variance ⇒ converged
239
+ * (local optimum); high, non-shrinking variance ⇒ the benchmark is noisy; low
240
+ * variance with no promotions ⇒ the optimizer stopped exploring (failure).
241
+ */
242
+ export declare function detectPlateau(bundles: EvolveReceiptBundle[], opts?: {
243
+ window?: number;
244
+ epsilon?: number;
245
+ maxPromotionRate?: number;
246
+ }): PlateauReport;
247
+ //# sourceMappingURL=evolve-proof.d.ts.map