1
0

feat(arena): add deterministic headless RL environments

This commit is contained in:
2026-08-19 01:10:30 -07:00
parent 79793faed2
commit 747744fa6c
23 changed files with 2387 additions and 1 deletions
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env node
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { ARENA_SOURCE_HASHES } from "../src/arena/sourceHashes.ts";
const root = fileURLToPath(new URL("../", import.meta.url));
const sharedEnvironment = [
"src/arena/base.ts",
"src/arena/checksum.ts",
"src/arena/random.ts",
"src/arena/scenarios.ts",
"src/arena/types.ts",
];
const sourceSets = {
"drive-101-v1": {
environment: [...sharedEnvironment, "src/arena/drive101.ts"],
simulator: [
"src/transport/california.ts",
"src/transport/types.ts",
"src/transport/vehicleController.ts",
"src/transport/vehicleSim.ts",
],
},
"office-nav-v1": {
environment: [...sharedEnvironment, "src/arena/officeNav.ts"],
simulator: [
"src/interiors/plan.ts",
"src/interiors/types.ts",
"src/interiors/walker.ts",
"src/offices/frontier-valley.ts",
],
},
"crow-nav-v1": {
environment: [...sharedEnvironment, "src/arena/crowNav.ts"],
simulator: ["src/actors/controller.ts"],
},
"california-flight-v1": {
environment: [...sharedEnvironment, "src/arena/californiaFlight.ts"],
simulator: ["src/aircraft/controller.ts"],
},
};
async function digest(paths) {
const hash = createHash("sha256");
for (const relative of [...paths].sort()) {
hash.update(relative);
hash.update("\0");
hash.update(await readFile(new URL(`../${relative}`, import.meta.url)));
hash.update("\0");
}
return `sha256:${hash.digest("hex")}`;
}
let failed = false;
for (const [envId, sets] of Object.entries(sourceSets)) {
const actual = {
environment: await digest(sets.environment),
simulator: await digest(sets.simulator),
};
const expected = ARENA_SOURCE_HASHES[envId];
try {
assert.deepEqual(actual, expected);
console.log(`arena source hashes: ${envId} ok`);
} catch {
failed = true;
console.error(`arena source hashes: ${envId} mismatch`);
console.error(JSON.stringify(actual, null, 2));
}
}
if (failed) process.exitCode = 1;