synergyspec-selfevolving 1.4.0 → 2.1.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 (93) hide show
  1. package/README.md +31 -18
  2. package/dist/commands/learn.d.ts +12 -1
  3. package/dist/commands/learn.js +158 -11
  4. package/dist/commands/self-evolution-episode.d.ts +177 -0
  5. package/dist/commands/self-evolution-episode.js +431 -0
  6. package/dist/commands/self-evolution.d.ts +12 -190
  7. package/dist/commands/self-evolution.js +114 -866
  8. package/dist/core/archive.d.ts +0 -1
  9. package/dist/core/archive.js +0 -58
  10. package/dist/core/artifact-graph/instruction-loader.d.ts +2 -4
  11. package/dist/core/artifact-graph/instruction-loader.js +3 -31
  12. package/dist/core/fitness/loss.d.ts +5 -5
  13. package/dist/core/fitness/loss.js +4 -4
  14. package/dist/core/fitness/test-failures.js +10 -2
  15. package/dist/core/project-config.d.ts +19 -0
  16. package/dist/core/project-config.js +96 -0
  17. package/dist/core/self-evolution/candidate-fitness.d.ts +23 -1
  18. package/dist/core/self-evolution/candidate-fitness.js +31 -5
  19. package/dist/core/self-evolution/candidates.d.ts +0 -9
  20. package/dist/core/self-evolution/critic-agent.d.ts +192 -0
  21. package/dist/core/self-evolution/critic-agent.js +568 -0
  22. package/dist/core/self-evolution/edits-contract.d.ts +53 -0
  23. package/dist/core/self-evolution/edits-contract.js +89 -0
  24. package/dist/core/self-evolution/episode-orchestrator.d.ts +234 -0
  25. package/dist/core/self-evolution/episode-orchestrator.js +681 -0
  26. package/dist/core/self-evolution/episode-store.d.ts +266 -0
  27. package/dist/core/self-evolution/episode-store.js +573 -0
  28. package/dist/core/self-evolution/evolution-switches.d.ts +1 -1
  29. package/dist/core/self-evolution/evolution-switches.js +5 -10
  30. package/dist/core/self-evolution/evolving-agent.d.ts +208 -0
  31. package/dist/core/self-evolution/evolving-agent.js +535 -0
  32. package/dist/core/self-evolution/host-harness.d.ts +14 -15
  33. package/dist/core/self-evolution/host-harness.js +48 -23
  34. package/dist/core/self-evolution/index.d.ts +11 -6
  35. package/dist/core/self-evolution/index.js +20 -6
  36. package/dist/core/self-evolution/line-diff.d.ts +60 -0
  37. package/dist/core/self-evolution/line-diff.js +130 -0
  38. package/dist/core/self-evolution/policy/fs-safe.d.ts +19 -0
  39. package/dist/core/self-evolution/policy/fs-safe.js +89 -0
  40. package/dist/core/self-evolution/policy/index.d.ts +13 -0
  41. package/dist/core/self-evolution/policy/index.js +13 -0
  42. package/dist/core/self-evolution/policy/policy-store.d.ts +217 -0
  43. package/dist/core/self-evolution/policy/policy-store.js +774 -0
  44. package/dist/core/self-evolution/policy/prediction-reconcile.d.ts +54 -0
  45. package/dist/core/self-evolution/policy/prediction-reconcile.js +191 -0
  46. package/dist/core/self-evolution/policy/reject-buffer.d.ts +55 -0
  47. package/dist/core/self-evolution/policy/reject-buffer.js +170 -0
  48. package/dist/core/self-evolution/promote.d.ts +1 -1
  49. package/dist/core/self-evolution/promote.js +6 -33
  50. package/dist/core/self-evolution/promotion.js +1 -2
  51. package/dist/core/self-evolution/reward-agent.d.ts +379 -0
  52. package/dist/core/self-evolution/reward-agent.js +940 -0
  53. package/dist/core/self-evolution/reward-aggregator.d.ts +59 -0
  54. package/dist/core/self-evolution/reward-aggregator.js +262 -0
  55. package/dist/core/self-evolution/scope-gate.d.ts +66 -0
  56. package/dist/core/self-evolution/scope-gate.js +107 -0
  57. package/dist/core/self-evolution/success-channel.js +2 -2
  58. package/dist/core/self-evolution/tamper-check.d.ts +24 -0
  59. package/dist/core/self-evolution/tamper-check.js +236 -0
  60. package/dist/core/self-evolution/tool-evolution.js +2 -13
  61. package/dist/core/self-evolution/verdict.d.ts +8 -5
  62. package/dist/core/self-evolution/verdict.js +4 -7
  63. package/dist/core/templates/workflows/gen-tests.js +1 -1
  64. package/dist/core/templates/workflows/learn.d.ts +3 -2
  65. package/dist/core/templates/workflows/learn.js +21 -18
  66. package/dist/core/templates/workflows/self-evolving.d.ts +6 -4
  67. package/dist/core/templates/workflows/self-evolving.js +62 -172
  68. package/dist/core/trajectory/scrub.d.ts +27 -0
  69. package/dist/core/trajectory/scrub.js +79 -0
  70. package/dist/core/trajectory/skeleton.d.ts +27 -1
  71. package/dist/core/trajectory/skeleton.js +152 -8
  72. package/dist/dashboard/data.d.ts +25 -51
  73. package/dist/dashboard/data.js +68 -180
  74. package/dist/dashboard/react-client.js +458 -503
  75. package/dist/dashboard/react-styles.js +3 -3
  76. package/dist/dashboard/server.js +23 -17
  77. package/dist/ui/ascii-patterns.d.ts +7 -15
  78. package/dist/ui/ascii-patterns.js +123 -54
  79. package/dist/ui/welcome-screen.d.ts +0 -14
  80. package/dist/ui/welcome-screen.js +16 -35
  81. package/package.json +1 -1
  82. package/dist/core/self-evolution/ga-selection.d.ts +0 -94
  83. package/dist/core/self-evolution/ga-selection.js +0 -153
  84. package/dist/core/self-evolution/proposer-agent.d.ts +0 -182
  85. package/dist/core/self-evolution/proposer-agent.js +0 -326
  86. package/dist/core/self-evolution/replay-runner.d.ts +0 -100
  87. package/dist/core/self-evolution/replay-runner.js +0 -170
  88. package/dist/core/self-evolution/replay.d.ts +0 -45
  89. package/dist/core/self-evolution/replay.js +0 -56
  90. package/dist/core/self-evolution/template-variants.d.ts +0 -62
  91. package/dist/core/self-evolution/template-variants.js +0 -171
  92. package/dist/core/self-evolution/trajectory.d.ts +0 -65
  93. package/dist/core/self-evolution/trajectory.js +0 -185
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { type AggregationOptions, type CanonicalCandidate, type CanonicalCandidateSource, type CanonicalCandidateStatus, type PromotionReportArtifact, type StaticGateResult, type RankedCandidate, type RunChangeFn, type CandidateReplayScore, type PromotionApplyResult, type RollbackResult } from '../core/self-evolution/index.js';
2
+ import { type AggregationOptions, type CanonicalCandidate, type CanonicalCandidateSource, type CanonicalCandidateStatus, type PromotionReportArtifact, type StaticGateResult, type PromotionApplyResult, type RollbackResult } from '../core/self-evolution/index.js';
3
3
  import { type LearnReport } from '../core/learn.js';
4
4
  export declare function registerSelfEvolutionCommand(program: Command): void;
5
5
  /**
@@ -41,34 +41,19 @@ export interface RunProposeCanonicalArgs {
41
41
  /** If true, emit JSON output. */
42
42
  json?: boolean;
43
43
  /**
44
- * HEADLESS FALLBACK. When true (and `editsInput` is absent), spawn the
45
- * canonical proposer agent to draft a real diff for each group's target
46
- * (proposal-only) — for cron/CI runs with no host agent. Ignored when
47
- * `editsInput` is present. When both are false/omitted, the candidate carries
48
- * the placeholder diff and a human supplies the change before the gate.
49
- */
50
- agent?: boolean;
51
- /**
52
- * Population-based generation: draft N competing variant candidates (clamped
53
- * 1-5; default 1) for the single surviving group, each on a distinct
54
- * improvement angle, so the GA outer loop (`evolve`) can select the best.
55
- * Requires `agent` (divergence is prompt-side; the host `--from-edits` path
56
- * carries one payload). Ignored/treated as 1 otherwise.
57
- */
58
- variants?: number;
59
- /**
60
- * HOST-AGENT path (preferred). Candidate edits the host code agent already
61
- * authored. When present, the CLI validates + packages these (frozen + target
62
- * scope) instead of spawning the proposer agent, and `agent` is ignored.
44
+ * HOST-AGENT path. Candidate edits the host code agent already authored. When
45
+ * present, the CLI validates + packages these (frozen + target scope).
63
46
  * Requires exactly one surviving hint group (narrow via --target /
64
- * --threshold-key) so the single payload is not misattributed.
47
+ * --threshold-key) so the single payload is not misattributed. When absent the
48
+ * candidate carries the placeholder diff and a human supplies the change
49
+ * before the gate.
65
50
  */
66
51
  editsInput?: HostEditsInput;
67
52
  /**
68
53
  * Aggregation thresholds. Self-evolution is gradient descent: ONE forward
69
54
  * pass (a change's trajectory + pass-rate) is a complete loss signal, so
70
- * auto-evolve passes single-change thresholds (all min-occurrences = 1, no
71
- * diversity requirement) to act on one change. Omitted → conservative
55
+ * the host evolve-from-edits path passes single-change thresholds (all
56
+ * min-occurrences = 1, no diversity requirement) to act on one change. Omitted → conservative
72
57
  * cross-change defaults (recurrence required).
73
58
  */
74
59
  aggregationOptions?: AggregationOptions;
@@ -76,10 +61,6 @@ export interface RunProposeCanonicalArgs {
76
61
  export interface RunProposeCanonicalOptions {
77
62
  /** Project root used to resolve the candidate base dir. */
78
63
  repoRoot: string;
79
- /** Test seam: spawn used by the proposer agent (defaults to node's spawn). */
80
- proposerSpawn?: typeof import('node:child_process').spawn;
81
- /** Test seam: proposer agent binary override. */
82
- proposerBinary?: string;
83
64
  /** Override for stdout (defaults to console.log). */
84
65
  stdout?: (line: string) => void;
85
66
  /** Override for stderr (defaults to console.error). */
@@ -124,9 +105,8 @@ export declare function parseHostEditsInput(raw: string): HostEditsInput;
124
105
  *
125
106
  * SAFETY:
126
107
  * - Never writes outside `<repoRoot>/.synergyspec-selfevolving/self-evolution/candidates/`.
127
- * - Generation is EITHER the host-agent `--from-edits` path (validate + package)
128
- * OR the headless `--agent` proposer fallback; without either, diff.patch is
129
- * the placeholder for a human to complete.
108
+ * - Generation is the host-agent `--from-edits` path (validate + package); when
109
+ * absent, diff.patch is the placeholder for a human to complete.
130
110
  */
131
111
  export declare function runProposeCanonical(args: RunProposeCanonicalArgs, opts: RunProposeCanonicalOptions): Promise<RunProposeCanonicalResult>;
132
112
  export interface RunPromoteArgs {
@@ -146,7 +126,7 @@ export interface RunPromoteResult {
146
126
  }
147
127
  /**
148
128
  * Programmatic entrypoint for `self-evolution promote <id>` — the close-the-loop
149
- * apply/rollback. Exported so tests + auto-evolve can drive it directly.
129
+ * apply/rollback. Exported so tests + the host evolve-from-edits path can drive it directly.
150
130
  */
151
131
  export declare function runPromoteCommand(args: RunPromoteArgs, opts: {
152
132
  repoRoot: string;
@@ -175,95 +155,6 @@ export declare function runRejectCommand(args: RunRejectArgs, opts: {
175
155
  stderr?: (l: string) => void;
176
156
  now?: () => Date;
177
157
  }): Promise<RunRejectResult>;
178
- export interface RunTrajectoryArgs {
179
- targetId: string;
180
- /** Cap the number of prior candidates shown (default in buildOptimizationTrajectory: 6). */
181
- maxEntries?: number;
182
- json?: boolean;
183
- }
184
- export interface RunTrajectoryResult {
185
- exitCode: number;
186
- error?: string;
187
- }
188
- /**
189
- * Programmatic entrypoint for `self-evolution trajectory <targetId>` — a
190
- * READ-ONLY view of the scored optimization-trajectory block the headless
191
- * proposer receives, so a HOST code agent (which authors edits via
192
- * `--from-edits` and never sees that prompt) can read the same prior-candidate
193
- * loss/verdict history before authoring. Reuses the exact builder/renderer the
194
- * proposer uses. Never mutates anything.
195
- */
196
- export declare function runTrajectoryCommand(args: RunTrajectoryArgs, opts: {
197
- repoRoot: string;
198
- stdout?: (l: string) => void;
199
- stderr?: (l: string) => void;
200
- }): Promise<RunTrajectoryResult>;
201
- export interface RunAutoEvolveArgs {
202
- /**
203
- * One or more completed changes to learn from and evolve. A SINGLE change is
204
- * enough; pass several to let a signal recurring across them be the trigger.
205
- */
206
- changeNames: string[];
207
- /** Default true; false (via --no-auto) runs the pipeline but stops before applying. */
208
- auto?: boolean;
209
- requireProven?: boolean;
210
- /**
211
- * Minimum occurrences a signal must reach to be proposed. Default 1 — so a
212
- * single change CAN evolve. Raise it (and pass several `changeNames`) to
213
- * require a signal to RECUR across changes before it evolves. Neither
214
- * single-change nor multi-change is mandatory.
215
- */
216
- minOccurrences?: number;
217
- /** Force-propose only the aggregated signal with this exact thresholdKey. */
218
- thresholdKey?: string;
219
- evolveTarget?: string;
220
- freezeTarget?: string;
221
- json?: boolean;
222
- }
223
- export interface RunAutoEvolveOptions {
224
- repoRoot: string;
225
- stdout?: (l: string) => void;
226
- stderr?: (l: string) => void;
227
- now?: () => Date;
228
- /** Injected for tests; forwarded to the proposer agent. */
229
- proposerSpawn?: typeof import('node:child_process').spawn;
230
- proposerBinary?: string;
231
- }
232
- export interface AutoEvolveReport {
233
- exitCode: number;
234
- changeNames: string[];
235
- /** Mean per-change loss (functional ⊕ health) from learn; null when unmeasurable. */
236
- loss: number | null;
237
- /** Mean RAW code-health penalty across the change(s); null when no health signal. */
238
- healthPenalty?: number | null;
239
- hintCount: number;
240
- hintsPaths: string[];
241
- proposed: string[];
242
- gated: {
243
- candidateId: string;
244
- passed: boolean;
245
- }[];
246
- promoted: {
247
- candidateId: string;
248
- targetIds: string[];
249
- files: string[];
250
- }[];
251
- skipped: {
252
- candidateId: string;
253
- reason: string;
254
- }[];
255
- error?: string;
256
- }
257
- /**
258
- * ONE-BUTTON auto-evolve: learn → hints → propose(--agent) → gate → promote, in
259
- * one motion. Auto-applies the gate-passing winner per target onto the canonical
260
- * template (no per-change human approval), honoring the per-target switch + the
261
- * oracle/gate freeze, and snapshotting every write for rollback.
262
- *
263
- * Exported + fully injectable (proposer spawn, clock, io) so it is unit-testable
264
- * without a real `claude` binary.
265
- */
266
- export declare function runAutoEvolve(args: RunAutoEvolveArgs, opts: RunAutoEvolveOptions): Promise<AutoEvolveReport>;
267
158
  export interface RunEvolveFromEditsArgs {
268
159
  /** The change's learn hints.json to aggregate into a single signal/target. */
269
160
  fromLearn: string;
@@ -285,7 +176,7 @@ export interface RunEvolveFromEditsArgs {
285
176
  requireProven?: boolean;
286
177
  /** Mutually exclusive with this host path; presence is a hard error. */
287
178
  agent?: boolean;
288
- /** Non-interactive confirmation; required to run (like auto-evolve). */
179
+ /** Non-interactive confirmation; required to run (one-button host-authored apply). */
289
180
  yes?: boolean;
290
181
  json?: boolean;
291
182
  }
@@ -402,73 +293,4 @@ export interface RunPromotionReportResult {
402
293
  * - Exit code 0 on success, non-zero when the candidate cannot be loaded.
403
294
  */
404
295
  export declare function runPromotionReportCommand(args: RunPromotionReportArgs, opts: RunPromotionReportOptions): Promise<RunPromotionReportResult>;
405
- export interface RunEvolveOuterLoopArgs {
406
- /** Restrict the loop to a single canonical target id. */
407
- target?: string;
408
- /** Replay a corpus to score candidates (requires `changeIds`). */
409
- replay?: boolean;
410
- /** The replay corpus (change ids). Only used when `replay` is true. */
411
- changeIds?: string[];
412
- /** Write a human-gated promotion-report.md for each selected best. */
413
- write?: boolean;
414
- /**
415
- * Mark proven sibling variants that lost the ranking to `best` (same
416
- * variantGroup, higher meanLoss) with verdict `outcompeted`, so the
417
- * optimization-trajectory block shows them as negative examples. Never
418
- * transitions status (rejected is human-owned); advisory metadata only.
419
- */
420
- markOutcompeted?: boolean;
421
- /** Per-target evolution policy overrides (supports all/none). */
422
- evolveTarget?: string;
423
- freezeTarget?: string;
424
- json?: boolean;
425
- /**
426
- * ISO-8601 timestamp stamped onto appended fitness records. Defaults to the
427
- * current time; supplied explicitly by tests for determinism.
428
- */
429
- at?: string;
430
- /**
431
- * Injected replay re-runner (see {@link makeReplayRunChange}). Defaults to a
432
- * live agent shell-out; tests pass a fake to drive the loop without an agent.
433
- */
434
- runChange?: RunChangeFn;
435
- }
436
- export interface RunEvolveOuterLoopOptions {
437
- repoRoot: string;
438
- stdout?: (line: string) => void;
439
- stderr?: (line: string) => void;
440
- }
441
- export interface TargetEvolveSummary {
442
- targetId: string;
443
- candidateIds: string[];
444
- /** Skipped because the per-target policy froze this target. */
445
- frozen: boolean;
446
- /** Replay scoring outcomes (only present in --replay mode). */
447
- scored?: CandidateReplayScore[];
448
- /** Candidates ranked best-first by accumulated fitness. */
449
- ranked: RankedCandidate[];
450
- /** The selected best candidate id, or null when there are no candidates. */
451
- best: string | null;
452
- /** Path to the promotion report written for `best` (only with --write). */
453
- promotionReportPath?: string;
454
- /** Sibling variants marked `outcompeted` this run (only with --mark-outcompeted). */
455
- outcompeted?: string[];
456
- }
457
- export interface RunEvolveOuterLoopResult {
458
- exitCode: number;
459
- targets: TargetEvolveSummary[];
460
- error?: string;
461
- }
462
- /**
463
- * Programmatic entrypoint for `self-evolution evolve` — the GA outer loop.
464
- *
465
- * Chains the previously-inert pieces into one live pass:
466
- * groupCandidatesByTarget → (optional replay scoring that APPENDS fitness)
467
- * → rankCandidatesForTarget → select best → human-gated promotion report.
468
- *
469
- * Invariants: frozen targets (per the resolved policy) are skipped; promotion
470
- * is NEVER applied here (the report keeps its human-review gate); the oracle is
471
- * never touched (replay only runs tests).
472
- */
473
- export declare function runEvolveOuterLoopCommand(args: RunEvolveOuterLoopArgs, opts: RunEvolveOuterLoopOptions): Promise<RunEvolveOuterLoopResult>;
474
296
  //# sourceMappingURL=self-evolution.d.ts.map