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:
co-authored by
Claude Opus 5.5
parent
0052d1a5fd
commit
c3d067b88c
@@ -0,0 +1,35 @@
|
||||
// Build data/public/graph.json from every source: community form runs + DragonKind bot trajectories.
|
||||
// node scripts/build-graph.js
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const E = require("../packages/core/src/engine.js");
|
||||
const G = require("../packages/core/src/graph.js");
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const rel = (p) => path.join(root, p);
|
||||
|
||||
const raw = JSON.parse(fs.readFileSync(rel("data/public/form_responses.json"), "utf8"));
|
||||
const { runs } = E.codeRows(raw.rows, raw.headers);
|
||||
const records = runs.map((r) => ({ source: r.source === "Form" ? "form" : "form-bulk", vars: G.formRunVariables(r) }));
|
||||
|
||||
const botDir = rel("data/bot");
|
||||
const scenes = fs.existsSync(path.join(botDir, "scenes.json")) ? JSON.parse(fs.readFileSync(path.join(botDir, "scenes.json"), "utf8")) : {};
|
||||
const trajs = [];
|
||||
for (const f of fs.readdirSync(botDir).filter((f) => /^trajectories-.*\.jsonl$/.test(f)).sort()) {
|
||||
for (const line of fs.readFileSync(path.join(botDir, f), "utf8").split("\n")) if (line.trim()) trajs.push(JSON.parse(line));
|
||||
}
|
||||
const unmapped = {};
|
||||
for (const t of trajs) {
|
||||
const { vars, unmapped: u } = G.trajectoryVariables(t);
|
||||
records.push({ source: "bot", vars });
|
||||
for (const x of u) unmapped[x] = (unmapped[x] || 0) + 1;
|
||||
}
|
||||
|
||||
const graph = {
|
||||
sources: records.reduce((m, r) => ((m[r.source] = (m[r.source] || 0) + 1), m), {}),
|
||||
variables: G.buildVariableGraph(records),
|
||||
scenes: G.buildSceneGraph(scenes, trajs)
|
||||
};
|
||||
fs.writeFileSync(rel("data/public/graph.json"), JSON.stringify(graph));
|
||||
console.log(`graph.json: ${JSON.stringify(graph.sources)}, ${Object.keys(graph.variables.nodes).length} variable nodes, ${Object.keys(graph.scenes).length} scenes`);
|
||||
const um = Object.keys(unmapped).filter((t) => !/^(head deeper|investigate the scream|lower your|show your bravery|hide behind|run and hope|reds are too|jump|daggers or not|engage the smaller)/i.test(t));
|
||||
if (um.length) console.log("bot choices with no form equivalent:", um);
|
||||
@@ -0,0 +1,22 @@
|
||||
// Assemble the static Atlas site into dist/ (no dependencies).
|
||||
// node scripts/build-site.js [outDir]
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const out = path.resolve(root, process.argv[2] || "dist");
|
||||
|
||||
const copy = (from, to) => {
|
||||
fs.mkdirSync(path.dirname(path.join(out, to)), { recursive: true });
|
||||
fs.copyFileSync(path.join(root, from), path.join(out, to));
|
||||
};
|
||||
|
||||
fs.rmSync(out, { recursive: true, force: true });
|
||||
for (const f of fs.readdirSync(path.join(root, "apps/atlas"))) copy(`apps/atlas/${f}`, f);
|
||||
copy("packages/core/src/engine.js", "engine.js");
|
||||
copy("packages/core/src/graph.js", "graph.js");
|
||||
for (const f of ["form_responses.json", "register.json", "graph.json"]) copy(`data/public/${f}`, `data/${f}`);
|
||||
// Source files shown in the page's "view the code" panel
|
||||
for (const f of ["analyze.py", "clean.py", "stats_core.py"]) copy(`research/python/${f}`, `python/${f}`);
|
||||
copy("README.md", "README.md");
|
||||
fs.writeFileSync(path.join(out, ".nojekyll"), "");
|
||||
console.log(`Site built in ${path.relative(root, out) || "."}`);
|
||||
Reference in New Issue
Block a user