mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-09-14 14:01:28 +08:00
87682a6e78
Adds opt-in plugin `plugins/ruflo-arena` from @shaal (Ofer Shaal). 26 files / +1781 lines, 4 vitest suites (23 tests), all green locally on this checkout. Closes #2314. Pure additive — no Ruflo-core changes, one runtime dep (zod). MCP tools: arena/run, tournament/run, evolve/run, coevolve/run, run/get, run/list. CLI: arena, tournament, evolve, coevolve, demo. Follow-up patch (5 review items: coevolve baseline cache, tournament self-skip, Math.spread → single-pass, factory doc, agentdbRecord field lift) posted in https://github.com/ruvnet/ruflo/pull/2315#issuecomment-4650114965 — will land as a follow-up PR. Admin-merged: the only failing PR check (`graph trajectory hooks smoke (ADR-130 P3)`) is an unrelated pre-existing main OOM in @ruvector/ruvllm SonaCoordinator, tracked in #2312. PR touches none of that code path. Co-Authored-By: Ofer Shaal <shaal@users.noreply.github.com>
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { prisonersDilemma as PD } from '../src/domain/games.js';
|
|
import { classicRoster } from '../src/domain/strategies.js';
|
|
import { coevolve, evolveVsField } from '../src/engine/evolution.js';
|
|
|
|
describe('evolution', () => {
|
|
it('hill-climb fitness is monotonic non-decreasing (best-so-far)', () => {
|
|
const r = evolveVsField(PD, classicRoster(PD), { generations: 200, seed: 42 });
|
|
for (let i = 1; i < r.curve.length; i++) {
|
|
expect(r.curve[i].fitness).toBeGreaterThanOrEqual(r.curve[i - 1].fitness - 1e-9);
|
|
}
|
|
});
|
|
|
|
it('improves on its random starting point', () => {
|
|
const r = evolveVsField(PD, classicRoster(PD), { generations: 300, seed: 42 });
|
|
expect(r.bestFitness).toBeGreaterThanOrEqual(r.curve[0].fitness);
|
|
});
|
|
|
|
it('is deterministic under a fixed seed', () => {
|
|
const a = evolveVsField(PD, classicRoster(PD), { generations: 150, seed: 7 });
|
|
const b = evolveVsField(PD, classicRoster(PD), { generations: 150, seed: 7 });
|
|
expect(a.bestFitness).toBe(b.bestFitness);
|
|
expect(a.best).toEqual(b.best);
|
|
});
|
|
|
|
it('co-evolution records a finite arms-race trace', () => {
|
|
const r = coevolve(PD, { generations: 200, seed: 7 });
|
|
expect(r.curve.length).toBe(201);
|
|
for (const pt of r.curve) expect(Number.isFinite(pt.payoffA)).toBe(true);
|
|
});
|
|
});
|