// ============================================================================ // Project : anomaly-atlas // File : web/server.js // Purpose : Public atlas platform — routes and pages (English, light) // Author : Simon-Pierre Boucher // Contact : contact@spboucher.ai // Data src : hfmarketdata.io (sole data source) // Created : 2026-08-12 // Modified : 2026-08-12 // Platform : macOS / Apple Silicon (arm64) — Node.js (deployed on MacLustr) // License : All rights reserved (research code) // ============================================================================ "use strict"; const fs = require("fs"); const os = require("os"); const path = require("path"); const express = require("express"); const C = require("./lib/content"); const R = require("./lib/render"); const charts = require("./lib/charts"); const app = express(); const PORT = process.env.PORT || 8150; // Comments live OUTSIDE the deploy directory so rsync --delete redeploys // never erase them. const COMMENTS_PATH = process.env.COMMENTS_PATH || path.join(os.homedir(), ".anomaly-atlas", "comments.json"); app.use("/static", express.static(path.join(__dirname, "public"), { maxAge: "1h" })); app.use(express.urlencoded({ extended: false, limit: "16kb" })); function page(res, opts) { res.send(R.layout({ ...opts, buildInfo: C.buildInfo() })); } function metaChips(data) { if (!data || !Object.keys(data).length) return ""; const fields = ["document", "author", "created", "modified", "status"]; const chips = fields .filter((f) => data[f]) .map((f) => `${f}${R.esc(data[f])}`) .join(""); return chips ? `
Independent statistics + market-microstructure research · Apple Silicon · hfmarketdata.io
A systematic, reproducible atlas of statistical regularities in open high-frequency market data — mean-reversion, lead-lag, calendar effects — where every claim survives (or visibly fails) out-of-sample testing, multiple-comparison correction, artifact nulls, and realistic transaction costs. Negative results are first-class findings.
detectable in-sample ≠ reproducible out-of-sample ≠ robust to artifacts ≠ meaningful after costs
A finding only advances one level at a time, and only Level ≥ 1 is ever published. A large in-sample effect with zero out-of-sample survival is a negative result — published as one.
${R.esc(f.summary)}
${R.levelBadge(f.level)}` ) .join(""); const empty = `The atlas publishes only Level ≥ 1 findings: effects that survive multiple-testing correction and a clean out-of-sample split with the artifact null subtracted. Nothing has earned that yet — the framework is being built so that nothing can enter without earning it. The artifact taxonomy and the validation methodology are primary deliverables in their own right.
Confidence-labeled statistical regularities (and non-regularities) in hfmarketdata.io data. Every entry carries provenance — commit, config, data-manifest hash, hardware — and the exact command that regenerates it. Negative results are first-class entries.
${published.length ? `The catalogue of artifacts in this dataset that masquerade as anomalies — often the most useful output.
The pre-registered protocol that turns a hypothesis into a confidence-labeled entry.
Atlas / ${R.esc(f.id)} / ${R.esc(f.version)}
${R.levelBadge(f.level)}${f.negative ? ' negative result' : ""}
${R.esc(f.summary)}
${conf ? `${R.highlightFile(JSON.stringify(f.finding, null, 2), "x.json")}Past statistical regularity does not imply future returns. Not investment advice.
`; page(res, { title: f.title, active: "Atlas", body }); }); // ---------------------------------------------------------------- publications function listPublications() { return (C.listDir("research/publications") || []) .filter((f) => f.name.endsWith(".md") && f.name !== "README.md") .map((f) => { const md = C.readMarkdown(f.rel); return md ? { rel: f.rel, slug: f.name.replace(/\.md$/, ""), data: md.data, content: md.content } : null; }) .filter(Boolean) .sort((a, b) => String(b.data.created).localeCompare(String(a.data.created))); } app.get("/publications", (req, res) => { const pubs = listPublications(); const cards = pubs.map((p) => ` ${R.esc(p.data.pub_id || "")} · ${R.esc(String(p.data.created || ""))} · v${R.esc(String(p.data.version || "1"))}${R.esc(p.data.subtitle)}
` : ""}${R.esc(p.data.abstract ? String(p.data.abstract).slice(0, 260) + "…" : "")}
${R.esc(p.data.status || "draft")}`).join(""); const body = `Formal write-ups of the project's results, versioned in the repository like everything
else. Every number is regenerated from committed results.json files and every figure is rendered
live from them — nothing is hand-typed. Each publication states its evidence level; negative results are
published with the same care as positive ones.
No publications yet.
'}\s*\{\{figure:([\w-]+)\}\}\s*<\/p>|\{\{figure:([\w-]+)\}\}/g,
(m, a, b) => charts.figuresFor(a || b, C) || "");
const d = pub.data;
const body = ` ${R.esc(d.pub_id || "")} · version ${R.esc(String(d.version || "1"))} · ${R.esc(String(d.created || ""))} ${R.esc(d.subtitle)} ${R.esc(d.abstract)} ${desc} Phase 1 literature notes — ${lines} lines.${R.esc(d.title || pub.slug)}
${d.subtitle ? `${title}
${R.esc(f.name.replace(".md", "").replace(/_/g, " "))}
The project charter itself is public: read the full research charter.
`; page(res, { title: "Research", active: "Research", body }); }); // ---------------------------------------------------------------- markdown viewer app.get(/^\/doc\/(.+)$/, (req, res) => { const rel = req.params[0]; const md = rel.endsWith(".md") ? C.readMarkdown(rel) : null; if (!md) return notFound(res); const crumb = `Research / ${R.esc(rel)}
`; if (rel === "research/LOG.md") { const entries = C.parseLogEntries(); const body = `${crumb} ${R.docHeader({ ...md.data, document: "Research log" }, rel)}Append-only, newest first — every question, experiment, result, interpretation, and decision, as required by the charter (§12). ${entries.length} entries.
${R.logTimeline(entries, rel)}`; return page(res, { title: "Research log", active: "Research", body }); } const { html, toc } = R.markdownToHtml(md.content, rel); const tocBox = R.tocHtml(toc); const body = `${crumb}${R.docHeader(md.data, rel)}${R.esc(e.purpose)}
${e.status} ${e.runs ? `${e.runs} result run${e.runs > 1 ? "s" : ""}` : ""}` ) .join(""); const body = `Every experiment carries a registered hypothesis with an explicit falsification criterion and its artifact null(s), a benchmark implementation, raw results, and an analysis. Detectors must first pass the synthetic-series tests — a detector that finds anomalies in a random walk is broken. Negative results are kept.
View benchmark implementation (benchmark.py) →
` : ""; const figures = charts.figuresFor(exp.id, C); const figuresHtml = figures ? `Generated server-side from the latest committed results.json — never hand-typed.
Experiments / ${R.esc(exp.id)}
${R.esc(exp.purpose)}
${codeLink}${figuresHtml}${sections.join("")}${runsHtml}`; page(res, { title: exp.id, active: "Experiments", body }); }); // ---------------------------------------------------------------- results app.get("/results", (req, res) => { const runs = C.listResultRuns(); const rows = runs .map( (r) => `Every result is reproducible from commit hash + config + data-manifest index + seed + hardware manifest, and each JSON embeds the manifest of the exact machine that produced it.
| Experiment | Run (UTC) | Files |
|---|---|---|
| No result runs yet. | ||
${R.highlightFile(JSON.stringify(obj, null, 2), "x.json")}`;
} else {
bodyContent = `${R.esc(raw.slice(0, 200000))}`;
}
const body = `Results / ${R.esc(rel)}
Core library (src/anomaly_atlas/) — including the single
hf_client every byte of data flows through — tooling, benchmark harness, and experiment
implementations. Every file carries the project's author header and the hfmarketdata.io data-source attribution.
Code / ${R.esc(rel)}
${R.highlightFile(raw.slice(0, 400000), name)}anomaly-atlas is an independent research project by Simon-Pierre Boucher (contact@spboucher.ai) that asks: given only open high-frequency market data from hfmarketdata.io (the sole data source), which statistical regularities — mean-reversion, lead-lag relationships, calendar/seasonal effects — are real, and which are artifacts of bid-ask bounce, stale or non-synchronized timestamps, survivorship, look-ahead, or microstructure noise?
The methodology is deliberately strict: pre-specified hypotheses and splits, artifact nulls that every detector must beat, mandatory multiple-testing correction, a holdout touched exactly once, realistic transaction-cost models, an append-only research log, hardware manifests embedded in every result, and no result reported from an uncommitted tree. Detectors are validated on synthetic series first — a detector that finds anomalies in a pure random walk is broken. The full methodology is codified in the research charter.
Not a trading system, not trading advice, not a claim of arbitrage or "free money". The honest answer "nothing survives" is an acceptable — and publishable — outcome. Do not assume Level-3 findings exist; the research establishes the truth either way.
Everything runs on a consumer Apple Silicon Mac: DuckDB + parquet on the internal NVMe for out-of-core columnar queries, NumPy/Accelerate for the math. This site is generated from the repository itself — no hand-typed numbers.
Questions, methodological objections, artifact reports, pointers to literature — all welcome. The most valuable comment here is "your effect is explained by X". Comments are public. Nothing on this page (or this site) is investment advice.
Comment posted — thank you.
`; else if (req.query.err) flash = `${R.esc(String(req.query.err))}
`; page(res, { title: "Comments", active: "Comments", body: commentsBody(flash) }); }); app.post("/comments", (req, res) => { const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress || "?"; const now = Date.now(); const err = (msg) => res.redirect(303, "/comments?err=" + encodeURIComponent(msg)); if (now - (lastPostByIp.get(ip) || 0) < 30_000) return err("Please wait 30 seconds between comments."); const { name = "", message = "", page: pageRef = "", website = "" } = req.body || {}; if (website.trim() !== "") return err("Submission rejected."); const cleanName = String(name).trim().slice(0, 60); const cleanMsg = String(message).trim().slice(0, 2000); const cleanPage = String(pageRef).trim().slice(0, 120); if (cleanName.length < 1) return err("Name is required."); if (cleanMsg.length < 3) return err("Comment is too short."); lastPostByIp.set(ip, now); saveComment({ name: cleanName, message: cleanMsg, page: cleanPage || null, ts: new Date().toISOString(), }); res.redirect(303, "/comments?ok=1"); }); // ---------------------------------------------------------------- misc app.get("/health", (req, res) => res.json({ ok: true, app: "anomaly-atlas-web", author: "Simon-Pierre Boucher", data_source: "hfmarketdata.io" })); function notFound(res) { res.status(404); page(res, { title: "Not found", active: "", body: `That page does not exist. Back to home.
No comments yet — be the first.
'}