From d0b513f6c12cf14744c5e428ca52c9043561a162 Mon Sep 17 00:00:00 2001 From: Mehar Khanna Date: Mon, 12 Oct 2026 22:20:25 -0400 Subject: [PATCH] ci: scripted check of the live double-click demo on genclass.dev (headless, visible tab, daily and on demand) The demo had only ever been verified by hand. The check asserts document.visibilityState first, because the runtime skips held decisions in a hidden tab by design (an embedded or occluded browser reproduces a false failure), then runs the lab with its explicit hold budget (blocking) and with the runtime's automatic budget (informational). Co-Authored-By: Claude Fable 5.1 --- .github/workflows/live-demo-check.yml | 36 ++++++++++++++++ site/check/live-demo.mjs | 60 +++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/live-demo-check.yml create mode 100644 site/check/live-demo.mjs diff --git a/.github/workflows/live-demo-check.yml b/.github/workflows/live-demo-check.yml new file mode 100644 index 00000000..f5294ed1 --- /dev/null +++ b/.github/workflows/live-demo-check.yml @@ -0,0 +1,36 @@ +name: Live demo check + +# Loads genclass.dev in headless Chromium (a visible tab, which the runtime requires for held decisions) and asserts +# that the double-click demo coalesces the duplicate. Run after every site deploy and daily. +on: + workflow_dispatch: + inputs: + url: + description: "Page to check" + default: "https://genclass.dev/" + required: false + schedule: + - cron: "17 6 * * *" + +permissions: + contents: read + +jobs: + demo: + name: "genclass.dev: double-click demo" + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Install Playwright (Chromium only) + run: | + mkdir -p /tmp/pw && cd /tmp/pw && npm init -y >/dev/null && npm i --no-audit --no-fund playwright + cd /tmp/pw && npx playwright install --with-deps chromium + - name: Check the live demo + env: + DEMO_URL: ${{ github.event.inputs.url || 'https://genclass.dev/' }} + NODE_PATH: /tmp/pw/node_modules + run: node site/check/live-demo.mjs diff --git a/site/check/live-demo.mjs b/site/check/live-demo.mjs new file mode 100644 index 00000000..e713c0b8 --- /dev/null +++ b/site/check/live-demo.mjs @@ -0,0 +1,60 @@ +// Live demo check for genclass.dev: loads the home page in headless Chromium, waits for the model, presses +// "Double-click both" and asserts that the GenClass side sent one invoice while the plain side sent two. +// Run by .github/workflows/live-demo-check.yml (after a site deploy, and daily). Local use: +// DEMO_URL=https://genclass.dev/ node site/check/live-demo.mjs +// +// Two runs: the first with the lab's explicit hold budget (?lab-hold=900), which checks the page and the runtime's +// action path on a WASM-only runner; the second with the runtime's automatic budget (?lab-hold=auto), which is +// informational: on WASM the first decision can be slower than the first automatic budget (see PR #4). +// +// The runtime skips held decisions in a hidden tab by design, so the check asserts document.visibilityState first. +import { chromium } from "playwright"; + +const base = process.env.DEMO_URL || "https://genclass.dev/"; +const sep = base.includes("?") ? "&" : "?"; + +async function run(label, query, { mustPass }) { + const browser = await chromium.launch(); + const page = await browser.newPage(); + const consoleLines = []; + page.on("console", (m) => { + const t = m.text(); + if (t.includes("[GenClass]")) consoleLines.push(t); + }); + const url = `${base}${sep}${query}&check=${Date.now()}`; + await page.goto(url, { waitUntil: "load" }); + const vis = await page.evaluate(() => document.visibilityState); + if (vis !== "visible") throw new Error(`${label}: visibilityState is ${vis}; the runtime skips held decisions in a hidden tab, so this run proves nothing`); + await page.waitForFunction(() => window.GenClass?.runtime?.status?.state === "ready", null, { timeout: 120_000 }); + const model = await page.evaluate(() => { + const s = GenClass.runtime.status; + return { device: s.device, variant: s.variant, loadMs: s.loadMs, holdBudgetMs: GenClass.runtime.holdBudgetMs(), latency: s.latency }; + }); + await page.waitForFunction(() => !document.getElementById("dup-go")?.disabled, null, { timeout: 10_000 }); + await page.click("#dup-go"); + await page.waitForFunction( + () => /invoice/.test(document.getElementById("inv-on-v")?.textContent || "") && /invoice/.test(document.getElementById("inv-off-v")?.textContent || ""), + null, + { timeout: 20_000 }, + ); + const result = await page.evaluate(() => { + const a = GenClass.runtime.audit(); + const recs = Array.isArray(a) ? a : a.decisions || []; + return { + on: document.getElementById("inv-on-v").textContent, + off: document.getElementById("inv-off-v").textContent, + decisions: recs.map((d) => ({ trigger: d.trigger, diagnosis: d.diagnosis, p: d.diagnosisConfidence, ran: d.ran, executed: d.executed, held: d.held, holdBudgetMs: d.holdBudgetMs, latencyMs: d.latencyMs, reason: d.reason })), + }; + }); + await browser.close(); + const ok = /^1 invoice sent/.test(result.on) && /^2 identical invoices sent/.test(result.off); + console.log(`\n== ${label} (${url})`); + console.log(JSON.stringify({ model, ...result, consoleLines }, null, 2)); + console.log(ok ? `${label}: OK` : `${label}: FAILED (${mustPass ? "blocking" : "informational"})`); + return ok; +} + +const explicit = await run("explicit hold budget", "lab-hold=900", { mustPass: true }); +const auto = await run("automatic hold budget", "lab-hold=auto", { mustPass: false }); +console.log(`\nsummary: explicit=${explicit ? "ok" : "FAILED"} automatic=${auto ? "ok" : "failed (informational)"}`); +if (!explicit) process.exit(1);