Threshing Atlas: monorepo, route graph, bot importer, daily source checks

- apps/atlas: the web page (valley map, route flow, Dragon Register)
- packages/core: coding rules and statistics (engine.js) and the shared route
  graph (graph.js): scene graph, decision-variable graph, bot-to-form crosswalk,
  Beta credible intervals
- packages/ingest: DragonKind bot importer to anonymised trajectories (no prose,
  no account identifiers); data/bot holds Ken's sample
- research/python: independent reference implementation + update_sources.py
- tests: JS/Python parity checks and graph/importer unit tests
- CI, GitHub Pages deploy, daily check of the community sheets and route PDF
- Email addresses in free-text form answers are redacted; the raw spreadsheet
  is not committed
- MIT code licence, CC BY 4.0 data licence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-01 21:54:54 +00:00
co-authored by Claude Opus 5.5
parent 0052d1a5fd
commit c3d067b88c
48 changed files with 8334 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
// node --test tests/
const test = require("node:test");
const assert = require("node:assert");
const path = require("path");
const { importBot, assertPublicSafe } = require("../packages/ingest/src/bot");
const G = require("../packages/core/src/graph");
const fx = path.join(__dirname, "fixtures/bot");
const { scenes, trajectories } = importBot({ dataDir: path.join(fx, "data"), logsDir: path.join(fx, "logs"), salt: "test-salt" });
test("one trajectory per attempt, duplicates and repeated burns collapsed", () => {
assert.strictEqual(trajectories.length, 2);
const [t1, t2] = trajectories;
assert.strictEqual(t1.steps.length, 3);
assert.deepStrictEqual(t1.steps.map((s) => s.to).slice(-1), ["BURNED"]);
assert.strictEqual(t1.steps[0].to, t1.steps[1].scene);
assert.strictEqual(t2.outcome.type, "BONDED");
assert.strictEqual(t2.steps.at(-1).to, "BONDED:green");
assert.strictEqual(t2.steps[0].manual, true, "manual picks are flagged");
});
test("run metadata attached, account id hashed with the salt", () => {
const t1 = trajectories[0];
assert.strictEqual(t1.meta.target, "black");
assert.strictEqual(t1.meta.decisionMode, "explore");
assert.strictEqual(t1.outcome.intentional, true);
assert.match(t1.meta.accountKey, /^[0-9a-f]{10}$/);
assert.ok(!JSON.stringify(trajectories).includes("acct-1"));
});
test("public export contains no prose", () => {
assertPublicSafe(scenes);
assertPublicSafe(trajectories);
assert.ok(!JSON.stringify({ scenes, trajectories }).includes("Synthetic"));
assert.throws(() => assertPublicSafe({ prose: "x" }));
assert.throws(() => assertPublicSafe({ note: "y".repeat(201) }));
});
test("crosswalk maps bot choices to form variables", () => {
const { vars } = G.trajectoryVariables(trajectories[0]);
assert.strictEqual(vars.company, "Alone");
assert.strictEqual(vars.direction, "Center");
assert.strictEqual(vars.outcome, "Incinerated");
const v2 = G.trajectoryVariables(trajectories[1]).vars;
assert.strictEqual(v2.company, "1 Squadmate");
assert.strictEqual(v2.outcome_color, "Green");
});
test("variable graph counts by source", () => {
const recs = trajectories.map((t) => ({ source: "bot", vars: G.trajectoryVariables(t).vars }));
recs.push({ source: "form", vars: { company: "Alone", direction: "Center", outcome: "Bonded", outcome_color: "Blue" } });
const g = G.buildVariableGraph(recs);
const e = g.edges.find((x) => x.from === "company=Alone" && x.to === "direction=Center");
assert.deepStrictEqual(e.bySource, { bot: 1, form: 1 });
assert.ok(Math.abs(e.p.mean - 2.5 / 3) < 1e-12);
});
test("scene graph marks chance, burns and untested options", () => {
const g = G.buildSceneGraph(scenes, trajectories);
const start = Object.values(g).find((n) => Object.values(n.options).some((o) => /alone/i.test(o.text)));
assert.strictEqual(Object.values(start.options).every((o) => o.n === 1), true);
const dragon = Object.values(g).find((n) => Object.values(n.options).some((o) => /hide behind/i.test(o.text)));
const hide = Object.values(dragon.options).find((o) => /hide/i.test(o.text));
const respect = Object.values(dragon.options).find((o) => /respect/i.test(o.text));
assert.strictEqual(hide.to.BURNED, 1);
assert.strictEqual(respect.untested, true);
});
test("Beta credible interval", () => {
const p = G.betaPosterior(0, 4);
assert.ok(p.lo >= 0 && p.hi < 0.5 && p.mean === 0.1);
});