fix: feat: Push3 evolution — diverse seed population (#638)

Add seed-generator.ts module and seed-gen-cli.ts CLI that produce
parametric Push3 variants for initial population seeding.

Variants systematically cover:
  - Staked% thresholds: 80, 85, 88, 91, 94, 97
  - Penalty thresholds: 30, 50, 70, 100
  - Bull params: 4 presets (aggressive → mild)
  - Bear params: 4 presets (standard → very mild)
  - Tax distributions: exponential (seed), linear, sqrt

Total combination space: 6×4×4×4×3 = 1152 variants.
selectVariants(n) samples evenly so every axis is represented.

evolve.sh gains --diverse-seeds flag: when set, gen_0 is seeded with
parametric variants instead of N copies of the same mutated seed.
Remaining slots (if population > generated variants) fall back to
mutations of the base seed.

All generated programs pass transpiler stack validation (33 new tests).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-13 04:48:04 +00:00
parent b8a503c2df
commit 850131b74f
4 changed files with 686 additions and 17 deletions

View file

@ -0,0 +1,63 @@
/**
* seed-gen-cli.ts CLI for generating diverse Push3 seed variants (#638).
*
* Usage:
* tsx seed-gen-cli.ts --count <N> --output-dir <dir>
*
* Writes N Push3 variant files to <dir>/variant_000.push3 ... variant_NNN.push3
* and prints each file path to stdout (one per line).
*
* The variants are systematically diverse: different staked% thresholds,
* penalty thresholds, bull/bear output params, and tax rate distributions.
*
* Options:
* --count <N> Number of variants to generate (required, positive integer)
* --output-dir <dir> Directory to write variant files (required, created if absent)
*/
import { mkdirSync, writeFileSync } from 'fs';
import { join } from 'path';
import { selectVariants, generateSeedVariant } from './seed-generator';
function usage(): void {
process.stderr.write('Usage: seed-gen-cli --count <N> --output-dir <dir>\n');
}
const args = process.argv.slice(2);
let count: number | undefined;
let outputDir: string | undefined;
for (let i = 0; i < args.length; i++) {
if (args[i] === '--count' && args[i + 1] !== undefined) {
count = parseInt(args[++i]!, 10);
} else if (args[i] === '--output-dir' && args[i + 1] !== undefined) {
outputDir = args[++i];
} else {
process.stderr.write(`Unknown argument: ${args[i]!}\n`);
usage();
process.exit(1);
}
}
if (count === undefined || isNaN(count) || count < 1) {
process.stderr.write('Error: --count must be a positive integer\n');
usage();
process.exit(1);
}
if (!outputDir) {
process.stderr.write('Error: --output-dir is required\n');
usage();
process.exit(1);
}
mkdirSync(outputDir, { recursive: true });
const variants = selectVariants(count);
for (let i = 0; i < variants.length; i++) {
const text = generateSeedVariant(variants[i]!);
const filename = `variant_${String(i).padStart(3, '0')}.push3`;
const filepath = join(outputDir, filename);
writeFileSync(filepath, text + '\n', 'utf8');
process.stdout.write(filepath + '\n');
}