// Runs the console page's inline script inside a fake DOM with manually resolved // API responses, so response-to-session attribution (review findings F1/F2) can be // observed objectively: interleaved session loads, replies while switching, // polling/stale writebacks, late attachment reads and per-session drafts. // // FileReader is stubbed so an attachment read can be completed by hand after a // session switch, which makes the "late attachment writeback" deterministic. // // usage: node console_attribution_harness.mjs // prints one line: __RESULT__ import fs from 'node:fs'; import vm from 'node:vm'; const htmlPath = process.argv[2]; if (!htmlPath) { console.error('usage: node console_attribution_harness.mjs '); process.exit(2); } const html = fs.readFileSync(htmlPath, 'utf8'); const inline = [...html.matchAll(/]*)>([\s\S]*?)<\/script>/g)] .filter((m) => !/\bsrc\s*=/.test(m[1])) .map((m) => m[2]) .join('\n;\n'); if (!inline.trim()) { console.error('no inline