Refactor: lay the repo out by section (core, collection, analysis, planner, site) (#8)
Moves only; no behaviour changes. Every file now lives under the part of the project it belongs to, each section has a README, and docs/PRIVACY.md collects the rules all parts follow. core/ engine.js, graph.js, solver.js, python/clean.py collection/ sources/ (form, register, PDF check, daily update), bot/ (importer) analysis/ stats/ (Python statistics), network/ (build-graph.js), reports/ (POLICY.md) planner/ build-policy.js, policy-report.js site/ atlas/ (the page), build.js, qa/ tests/ core/ (unit), parity/ (JS vs Python), fixtures/ Checked against the previous layout: tests pass; coded runs, test outputs, graph.json and policy.json are byte-identical; the built site differs only in comments that name file paths. The published file names Ken's bot downloads (solver.js, graph.js, data/policy.json) are unchanged. Also removes the undefined/ folder of QA screenshots committed by mistake (the QA scripts now default to a temp folder) and test.txt, and drops the unused npm workspaces. Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dcd5117373
commit
432e04c2c7
@@ -0,0 +1,35 @@
|
||||
// Build data/public/graph.json from every source: community form runs + DragonKind bot trajectories.
|
||||
// node analysis/network/build-graph.js
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const E = require("../../core/engine.js");
|
||||
const G = require("../../core/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);
|
||||
Reference in New Issue
Block a user