/** Reproduce the EXP-005 flight-delay result from the committed snapshot. */ import { readFile } from "node:fs/promises"; import { resolve } from "node:path"; import { analyseRetrogradeFlightDelays, type FlightDelaySnapshot, type RetrogradeEstimate, } from "../src/lib/retrograde-audit"; const DEFAULT_SNAPSHOT = resolve(process.cwd(), "src/content/data/retrograde-flight-delays.json"); function percent(value: number) { return `${(value * 100).toFixed(2)}%`; } function printEstimate(estimate: RetrogradeEstimate) { console.log(`\n${estimate.label === "primary" ? "PRIMARY · ASTRONOMICAL WINDOW" : "SECONDARY · +7-DAY SHADOW"}`); console.log(` inside days ${estimate.insideDays.toLocaleString("en-US")}`); console.log(` outside days ${estimate.outsideDays.toLocaleString("en-US")}`); console.log(` inside flights ${estimate.insideFlights.toLocaleString("en-US")}`); console.log(` outside flights ${estimate.outsideFlights.toLocaleString("en-US")}`); console.log(` raw inside rate ${percent(estimate.insideRate)}`); console.log(` raw outside rate ${percent(estimate.outsideRate)}`); console.log(` adjusted RR ${estimate.rateRatio.toFixed(6)}`); console.log(` 95% CI ${estimate.ciLow.toFixed(6)}–${estimate.ciHigh.toFixed(6)}`); console.log(` two-sided p ${estimate.pValue.toFixed(6)}`); console.log(` Pearson dispersion ${estimate.pearsonDispersion.toFixed(3)}`); console.log(` quasi sensitivity ${estimate.quasiCiLow.toFixed(6)}–${estimate.quasiCiHigh.toFixed(6)}, p=${estimate.quasiPValue.toFixed(6)}`); console.log(` IRLS ${estimate.converged ? "converged" : "DID NOT CONVERGE"} in ${estimate.iterations} iterations`); } async function main() { const path = resolve(process.cwd(), process.argv[2] ?? DEFAULT_SNAPSHOT); const snapshot = JSON.parse(await readFile(path, "utf8")) as FlightDelaySnapshot; const result = analyseRetrogradeFlightDelays(snapshot); console.log("\nEXP-005 — BTS flight delays against Mercury retrograde"); console.log("Protocol: protocols/EXP-005.md §§4–6"); console.log(`Coverage: ${result.coverageStart} to ${result.coverageEnd}`); console.log(`Complete cycles: ${result.completeCycles}`); console.log(`Archives: ${snapshot.archives.length}`); printEstimate(result.primary); printEstimate(result.shadow); console.log(""); } main().catch((error) => { console.error(error instanceof Error ? error.message : error); process.exitCode = 1; });