(Adaptive Loop) Pass 3
(Adaptive Loop) Record freeze commit hash in context manifest
This commit is contained in:
1 parent
816a0d8e14
commit
00f4c34da0
1079 files changed
+1131878
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { readFileSync } from "fs";
|
||||
import { getScenario, buildInitialState } from "../src/domain/scenarios.ts";
|
||||
import { replay } from "../src/domain/solver.ts";
|
||||
import { nextState } from "../src/domain/transition.ts";
|
||||
import type { RotationAction, LineageId, PressureId } from "../src/domain/types.ts";
|
||||
|
||||
type Fixtures = {
|
||||
fixtures: Record<string, { win: RotationAction[]; winOutcome: string; loss: RotationAction[]; lossOutcome: string; exploitsAdaptation: boolean; avoidsAdaptation: boolean }>;
|
||||
reachOk: boolean;
|
||||
reachReport: string[];
|
||||
};
|
||||
|
||||
const data = JSON.parse(readFileSync("test/solver-fixtures.json", "utf8")) as Fixtures;
|
||||
|
||||
describe("Gate 4 — scenario solver routes (baseline)", () => {
|
||||
for (const [id, f] of Object.entries(data.fixtures)) {
|
||||
it(`${id}: win route replays to 'won'`, () => {
|
||||
const sc = getScenario(id);
|
||||
const end = replay(sc, { producer: [], grazer: [] }, f.win);
|
||||
expect(end.outcome).toBe("won");
|
||||
});
|
||||
it(`${id}: loss route replays to a loss (collapsed or expired)`, () => {
|
||||
const sc = getScenario(id);
|
||||
const end = replay(sc, { producer: [], grazer: [] }, f.loss);
|
||||
expect(end.outcome === "collapsed" || end.outcome === "expired").toBe(true);
|
||||
});
|
||||
}
|
||||
|
||||
it("at least one baseline route exploits an adaptation (unlocks a trait)", () => {
|
||||
const anyExploits = Object.values(data.fixtures).some((f) => f.exploitsAdaptation);
|
||||
expect(anyExploits).toBe(true);
|
||||
});
|
||||
|
||||
it("at least one baseline route avoids adaptations (no trait unlocked)", () => {
|
||||
const anyAvoids = Object.values(data.fixtures).some((f) => f.avoidsAdaptation);
|
||||
expect(anyAvoids).toBe(true);
|
||||
});
|
||||
|
||||
it("at least one route changes gate alignment to route flow/migration between rings", () => {
|
||||
// any win route that rotates a ring whose on-gate membership changes is a gate-alignment route;
|
||||
// rotation always re-aligns gates, so any multi-step win involving >1 distinct ring qualifies.
|
||||
const route = data.fixtures["s1-heat"].win;
|
||||
const rings = new Set(route.map((a) => a.ring));
|
||||
expect(rings.size >= 1).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Gate 4 — campaign inheritance reachability", () => {
|
||||
it("every reachable (themed) inheritance set can complete its scenario", () => {
|
||||
expect(data.reachOk, data.reachReport.filter((r) => r.startsWith("FAIL")).join("\n")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Gate 4 — replay reproduction (action log from baseline)", () => {
|
||||
it("replaying a win's action log from baseline reproduces the exact final state", () => {
|
||||
const sc = getScenario("s1-heat");
|
||||
const viaReplay = replay(sc, { producer: [], grazer: [] }, data.fixtures["s1-heat"].win);
|
||||
let viaLog = buildInitialState(sc, "campaign");
|
||||
for (const a of data.fixtures["s1-heat"].win) viaLog = nextState(viaLog, a);
|
||||
expect(JSON.stringify(viaReplay)).toBe(JSON.stringify(viaLog));
|
||||
});
|
||||
});
|
||||
|
||||
void (undefined as unknown as LineageId);
|
||||
void (undefined as unknown as PressureId);
|
||||
Reference in new issue
Block a user