Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Precompile final guest and Patrol browser fixtures
pulse-triage[bot]199f3cc2b8ee
diff --git a/frontend-modern/browser-tests/README.md b/frontend-modern/browser-tests/README.mdindex a9c4626eea..31fb421a88 100644--- a/frontend-modern/browser-tests/README.md+++ b/frontend-modern/browser-tests/README.md@@ -38,6 +38,7 @@ Three replacement `rawData` frames per view change rendered names, rather thanmerely waiting on a timer with unchanged content.Assertions cover:+- Coverage: fewer rendered rows than the inventory (windowing enabled), non-zeroscroll, expanded restore evidence, focused expansion button and route retained.- By date: changed workload name, non-zero scroll, focused navigation link and route@@ -56,6 +57,30 @@ The test does not cover Settings Manage editing, Authentication strategy selectiexpansion padding, arbitrary inventory churn/reordering, or a deployed release.Passing is not grounds to close the mixed report #1869.+## Final guest and Patrol presentation fixtures++Prepare the existing guest filesystem, memory, reading-help and Patrol-rule+fixtures once, before browser execution, from `frontend-modern`:++```sh+node browser-tests/build-publication-fixtures.mjs+node --test browser-tests/publication-fixture-server.test.cjs+```++The four corresponding browser runners use the resulting static bundles in+`tmp/publication-final-static` at the repository root. They no longer compile+or start Vite inside the browser process tree. Rebuild after source changes:+the server refuses altered imported sources, Tailwind scan inputs, the dependency+lock, runner code, compiled assets or the shipped safety document before listening.+Only bound assets and the explicit reading-help Docs route are served; missing+JS, CSS and Markdown stay errors rather than receiving an HTML fallback.++The builder's `prepared-not-browser-verified` result and the server tests are+preparation evidence only. Desktop/phone interactions, inspected captures,+own-parent and final-content receipts still require a real browser pass. No+native guest-agent, thaw, filesystem-write, installed or publication acceptance+is established by compiling these synthetic fixtures.+## CI and release evidenceThese standalone runners are manual qualification commands: the current GitHubdiff --git a/frontend-modern/browser-tests/build-publication-fixtures.mjs b/frontend-modern/browser-tests/build-publication-fixtures.mjsnew file mode 100644index 0000000000..1da4c13c85--- /dev/null+++ b/frontend-modern/browser-tests/build-publication-fixtures.mjs@@ -0,0 +1,126 @@+// Compile before the bounded browser tree starts. This is fixture preparation,+// not browser acceptance and not a production application/release build.+import { build } from 'vite';+import solid from 'vite-plugin-solid';+import tailwindcss from '@tailwindcss/vite';+import { stop } from 'esbuild';+import fs from 'node:fs';+import path from 'node:path';+import { execFileSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import {+ entryPaths,+ harnessPaths,+ runtimePaths,+ hash,+ loadPublicationFixture,+} from './publication-fixture-server.cjs';++const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const outDir = path.resolve(root, '../tmp/publication-final-static');+const started = Date.now();+const binding = {+ version: 1,+ source_sha: execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim(),+ graph: hash(fs.readFileSync(path.join(root, 'package-lock.json'))),+ entries: entryPaths,+ sources: {},+ artifacts: {},+};+try {+ await build({+ root,+ base: '/',+ configFile: false,+ publicDir: false,+ plugins: [+ {+ name: 'publication-fixture-source-binding',+ generateBundle() {+ for (const id of this.getModuleIds()) {+ const file = id.split('?')[0];+ if (!file.startsWith(root + '/') || file.includes('/node_modules/')) continue;+ if (fs.existsSync(file) && fs.statSync(file).isFile()) {+ binding.sources[path.relative(root, file)] = hash(fs.readFileSync(file));+ }+ }+ // A required runtime must really have entered the compiled graph,+ // not be added to the manifest merely because it exists on disk.+ for (const file of [...runtimePaths, 'src/index.css']) {+ if (!binding.sources[file])+ throw new Error(`Required runtime was not compiled: ${file}`);+ }+ },+ },+ tailwindcss(),+ solid(),+ ],+ resolve: {+ alias: { '@': path.join(root, 'src') },+ conditions: ['import', 'browser', 'default'],+ },+ build: {+ target: 'esnext',+ outDir,+ emptyOutDir: true,+ rollupOptions: { input: entryPaths.map((file) => path.join(root, file)) },+ },+ });+ for (const file of [+ ...harnessPaths,+ ...entryPaths,+ 'package.json',+ 'tsconfig.json',+ 'index.html',+ 'public/docs/VM_DISK_MONITORING.md',+ ]) {+ binding.sources[file] = hash(fs.readFileSync(path.join(root, file)));+ }+ // Tailwind's @source scan and palette imports also affect the served CSS,+ // even when a scanned TSX file is not in Rollup's JS module graph.+ const bindStyleInputs = (directory) => {+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {+ const file = path.join(directory, entry.name);+ if (entry.isDirectory()) bindStyleInputs(file);+ else if (/\.(css|js|jsx|ts|tsx|html)$/.test(file)) {+ binding.sources[path.relative(root, file)] = hash(fs.readFileSync(file));+ }+ }+ };+ bindStyleInputs(path.join(root, 'src'));+ bindStyleInputs(path.join(root, 'browser-tests'));+ fs.mkdirSync(path.join(outDir, 'docs'), { recursive: true });+ fs.copyFileSync(+ path.join(root, 'public/docs/VM_DISK_MONITORING.md'),+ path.join(outDir, 'docs/VM_DISK_MONITORING.md'),+ );+ let bytes = 0;+ const walk = (directory) => {+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {+ const file = path.join(directory, entry.name);+ if (entry.isDirectory()) walk(file);+ else {+ const data = fs.readFileSync(file);+ bytes += data.length;+ binding.artifacts[path.relative(outDir, file)] = hash(data);+ }+ }+ };+ walk(outDir);+ fs.writeFileSync(path.join(outDir, 'binding.json'), JSON.stringify(binding, null, 2) + '\n');+ loadPublicationFixture(root, outDir);+ console.log(+ JSON.stringify({+ result: 'prepared-not-browser-verified',+ source_sha: binding.source_sha,+ entries: entryPaths.length,+ sources: Object.keys(binding.sources).length,+ artifacts: Object.keys(binding.artifacts).length,+ artifact_bytes: bytes,+ elapsed_ms: Date.now() - started,+ content_sha256: Object.fromEntries(runtimePaths.map((file) => [file, binding.sources[file]])),+ }),+ );+} finally {+ stop();+}diff --git a/frontend-modern/browser-tests/guest-disk-provenance.cjs b/frontend-modern/browser-tests/guest-disk-provenance.cjsindex 5c58184185..82432878cb 100644--- a/frontend-modern/browser-tests/guest-disk-provenance.cjs+++ b/frontend-modern/browser-tests/guest-disk-provenance.cjs@@ -3,6 +3,7 @@ const fs = require('node:fs');const path = require('node:path');const crypto = require('node:crypto');const { chromium, webkit } = require('playwright');+const { createPublicationFixtureServer } = require('./publication-fixture-server.cjs');const root = '/workspace/frontend-modern';const output = '/workspace/tmp/guest-disk-provenance';@@ -35,14 +36,12 @@ const settle = (page) =>'node_modules/@playwright/test'].version,);- process.chdir(root);- const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));- const server = await createServer({+ const server = createPublicationFixtureServer(root,- configFile: path.join(root, 'vite.config.ts'),- cacheDir: output + '/cache',- server: { host: '127.0.0.1', port: 5315, strictPort: true },- });+ 5315,+ 'browser-tests/guest-disk-provenance.html',+ );+ result.compiled = server.binding;let browser;try {await server.listen();diff --git a/frontend-modern/browser-tests/guest-reading-help.cjs b/frontend-modern/browser-tests/guest-reading-help.cjsindex 393b199f76..bb69900f80 100644--- a/frontend-modern/browser-tests/guest-reading-help.cjs+++ b/frontend-modern/browser-tests/guest-reading-help.cjs@@ -1,120 +1,225 @@-// New current-source static preview, not a replay of the stopped Vite request.+// Precompiled current-source preview; no compiler runs in the browser tree.const fs = require('node:fs');const path = require('node:path');-const http = require('node:http');const crypto = require('node:crypto');const assert = require('node:assert/strict');const { chromium, webkit } = require('playwright');+const { createPublicationFixtureServer } = require('./publication-fixture-server.cjs');const root = '/workspace/frontend-modern';const output = '/workspace/tmp/guest-reading-help';-const preview = output + '/preview';const origin = 'http://127.0.0.1:5331';-const runtime = ['frontend-modern/src/utils/workloadGuestPresentation.ts', 'frontend-modern/src/components/Workloads/GuestDrawerOverview.tsx'];-const hash = file => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');-const load = name => import(require.resolve(name, { paths: [root] }));+const runtime = [+ 'frontend-modern/src/utils/workloadGuestPresentation.ts',+ 'frontend-modern/src/components/Workloads/GuestDrawerOverview.tsx',+];+const hash = (file) => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');(async () => {fs.mkdirSync(output, { recursive: true });const result = {- result: 'incomplete', playwright: require('playwright/package.json').version,- runtime_hashes: Object.fromEntries(runtime.map(file => [file, hash('/workspace/' + file)])),- fixtures: Object.fromEntries(['cjs','tsx','html'].map(ext => ['guest-reading-help.' + ext, hash(root + '/browser-tests/guest-reading-help.' + ext)])),- cases: [], captures: [], cleanup: { browser: false, server: false }, phases: [],- limits: 'Static production-component preview with synthetic observations/APIs. No native guest, collector, cause, thaw, writes, restart, installed or release acceptance.',+ result: 'incomplete',+ playwright: require('playwright/package.json').version,+ runtime_hashes: Object.fromEntries(runtime.map((file) => [file, hash('/workspace/' + file)])),+ fixtures: Object.fromEntries(+ ['cjs', 'tsx', 'html'].map((ext) => [+ 'guest-reading-help.' + ext,+ hash(root + '/browser-tests/guest-reading-help.' + ext),+ ]),+ ),+ cases: [],+ captures: [],+ cleanup: { browser: false, server: false },+ phases: [],+ limits:+ 'Static production-component preview with synthetic observations/APIs. No native guest, collector, cause, thaw, writes, restart, installed or release acceptance.',};let server, browser;try {- assert.equal(result.playwright, JSON.parse(fs.readFileSync('/workspace/tests/integration/package-lock.json')).packages['node_modules/@playwright/test'].version);- const { build } = await load('vite');- const solidModule = await load('vite-plugin-solid');- const solid = solidModule.default.default || solidModule.default;- const { default: tailwind } = await load('@tailwindcss/vite');- await build({ root, configFile: false, logLevel: 'warn', plugins: [solid(), tailwind()], resolve: { alias: { '@': root + '/src' } }, build: { target: 'esnext', outDir: preview, emptyOutDir: true, minify: false, rollupOptions: { input: root + '/browser-tests/guest-reading-help.html' } } });- result.phases.push('production-component static preview compiled');- server = http.createServer((req,res) => {- const url = new URL(req.url, origin);- let file = path.resolve(preview, '.' + decodeURIComponent(url.pathname));- if (file !== preview && !file.startsWith(preview + '/')) { res.writeHead(403); return res.end(); }- if (!fs.existsSync(file) || fs.statSync(file).isDirectory()) file = preview + '/browser-tests/guest-reading-help.html';- const ext = path.extname(file); res.setHeader('Content-Type', ({'.html':'text/html','.js':'text/javascript','.css':'text/css','.md':'text/plain','.json':'application/json'})[ext] || 'application/octet-stream');- res.end(fs.readFileSync(file));- });- await new Promise(resolve => server.listen(5331, '127.0.0.1', resolve));+ assert.equal(+ result.playwright,+ JSON.parse(fs.readFileSync('/workspace/tests/integration/package-lock.json')).packages[+ 'node_modules/@playwright/test'+ ].version,+ );+ server = createPublicationFixtureServer(root, 5331, 'browser-tests/guest-reading-help.html');+ result.compiled = server.binding;+ result.phases.push('precompiled source and served bytes validated');+ await server.listen();result.phases.push('loopback-only static server listening');- for (const [name, engine, width, dark] of [['chromium-desktop', chromium, 1365, false], ['webkit-phone', webkit, 390, true]]) {- browser = await engine.launch(engine === chromium ? {headless:true, channel:'chromium', args:['--no-sandbox']} : {headless:true});- const context = await browser.newContext({viewport:{width,height:900},isMobile:width<=768,hasTouch:width<=768,locale:'en-GB'});+ for (const [name, engine, width, dark] of [+ ['chromium-desktop', chromium, 1365, false],+ ['webkit-phone', webkit, 390, true],+ ]) {+ browser = await engine.launch(+ engine === chromium+ ? { headless: true, channel: 'chromium', args: ['--no-sandbox'] }+ : { headless: true },+ );+ const context = await browser.newContext({+ viewport: { width, height: 900 },+ isMobile: width <= 768,+ hasTouch: width <= 768,+ locale: 'en-GB',+ });const page = await context.newPage();page.setDefaultTimeout(12000);- const record = { name, browser: browser.version(), width, errors: [], requests: [], states: [] };+ const record = {+ name,+ browser: browser.version(),+ width,+ errors: [],+ requests: [],+ states: [],+ };result.cases.push(record);- page.on('pageerror', err => record.errors.push(err.message));- await page.route('**/*', route => {- const request=route.request(), url=new URL(request.url());- if (url.origin !== origin) { record.requests.push({method:request.method(),path:url.pathname,blocked:true}); return route.abort(); }+ page.on('pageerror', (err) => record.errors.push(err.message));+ await page.route('**/*', (route) => {+ const request = route.request(),+ url = new URL(request.url());+ if (url.origin !== origin) {+ record.requests.push({ method: request.method(), path: url.pathname, blocked: true });+ return route.abort();+ }if (url.pathname.startsWith('/api/')) {- record.requests.push({method:request.method(),path:url.pathname,synthetic:true});- return route.fulfill({status:200,contentType:'application/json',body:JSON.stringify({success:true,data:[],alerts:[],anomalies:[],config:null})});+ record.requests.push({ method: request.method(), path: url.pathname, synthetic: true });+ return route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ success: true,+ data: [],+ alerts: [],+ anomalies: [],+ config: null,+ }),+ });}return route.continue();});- await page.addInitScript(dark => {+ await page.addInitScript((dark) => {window.__input = [];- document.addEventListener('click', event => window.__input.push(event.isTrusted), true);- document.addEventListener('DOMContentLoaded', () => { if (dark) document.documentElement.classList.add('dark'); });+ document.addEventListener('click', (event) => window.__input.push(event.isTrusted), true);+ document.addEventListener('DOMContentLoaded', () => {+ if (dark) document.documentElement.classList.add('dark');+ });}, dark);- await page.goto(origin, {waitUntil:'domcontentloaded'});+ await page.goto(origin, { waitUntil: 'domcontentloaded' });await page.waitForFunction(() => window.__readingHelp);- const disclosure=page.locator('[data-guest-id="fixture-pve:pve-a:101"] [data-row-action]').first();- if (width<=768) await page.getByText('reading-guest', {exact:true}).tap(); else {await disclosure.focus();await page.keyboard.press('Enter');}- const drawer=page.getByRole('region',{name:'Guest details'});- await drawer.waitFor({state:'visible'});- const technical=drawer.getByTestId('guest-technical-details');+ const disclosure = page+ .locator('[data-guest-id="fixture-pve:pve-a:101"] [data-row-action]')+ .first();+ if (width <= 768) await page.getByText('reading-guest', { exact: true }).tap();+ else {+ await disclosure.focus();+ await page.keyboard.press('Enter');+ }+ const drawer = page.getByRole('region', { name: 'Guest details' });+ await drawer.waitFor({ state: 'visible' });+ const technical = drawer.getByTestId('guest-technical-details');// The current production overview is a section, not a collapsed details element.for (const state of [- {name:'missing-windows',reason:'agent-not-running',retained:false,os:'Windows 11'},- {name:'retained-android',reason:'agent-not-running',retained:true,os:'Android'},- {name:'disabled',reason:'agent-disabled',retained:false,os:'Windows 11'},- {name:'unknown',reason:'future-private-detail',retained:false,os:'Android'},+ { name: 'missing-windows', reason: 'agent-not-running', retained: false, os: 'Windows 11' },+ { name: 'retained-android', reason: 'agent-not-running', retained: true, os: 'Android' },+ { name: 'disabled', reason: 'agent-disabled', retained: false, os: 'Windows 11' },+ { name: 'unknown', reason: 'future-private-detail', retained: false, os: 'Android' },]) {- await page.evaluate(state => window.__readingHelp.update(state), state);- await page.waitForFunction(() => document.querySelector('[data-testid="guest-technical-details"]').textContent.includes('Filesystem reading guidance'));- const text=await technical.innerText();- assert.doesNotMatch(text,/Install and start|Enable it in VM Options|may not be installed|qemu-guest-agent|future-private-detail/);- assert.match(text,/backup/);assert.match(text,/guest incident/);- if(state.retained) {assert.match(text,/Using last known disk stats/);assert.match(text,/Last known 50%/);assert.equal(await technical.getByRole('progressbar').count(),0);}- if(state.name==='missing-windows') assert.match(text,/does not prove it is absent or stopped/);- if(state.name==='unknown') assert.match(text,/cause is unknown/);- const link=technical.getByRole('link',{name:'Filesystem reading guidance'});- assert.equal(await link.getAttribute('href'),'/docs/VM_DISK_MONITORING#a-missing-reading-is-not-an-installation-diagnosis');- const layout=await technical.evaluate(el=>({width:el.clientWidth,scroll:el.scrollWidth,document:document.documentElement.clientWidth,documentScroll:document.documentElement.scrollWidth}));- assert.ok(layout.scroll<=layout.width+1,JSON.stringify(layout));assert.ok(layout.documentScroll<=layout.document+1,JSON.stringify(layout));- const file=name+'-'+state.name+'.png';await technical.screenshot({path:output+'/'+file});- result.captures.push({file,sha256:hash(output+'/'+file)});record.states.push({name:state.name,text,layout});+ await page.evaluate((state) => window.__readingHelp.update(state), state);+ await page.waitForFunction(() =>+ document+ .querySelector('[data-testid="guest-technical-details"]')+ .textContent.includes('Filesystem reading guidance'),+ );+ const text = await technical.innerText();+ assert.doesNotMatch(+ text,+ /Install and start|Enable it in VM Options|may not be installed|qemu-guest-agent|future-private-detail/,+ );+ assert.match(text, /backup/);+ assert.match(text, /guest incident/);+ if (state.retained) {+ assert.match(text, /Using last known disk stats/);+ assert.match(text, /Last known 50%/);+ assert.equal(await technical.getByRole('progressbar').count(), 0);+ }+ if (state.name === 'missing-windows')+ assert.match(text, /does not prove it is absent or stopped/);+ if (state.name === 'unknown') assert.match(text, /cause is unknown/);+ const link = technical.getByRole('link', { name: 'Filesystem reading guidance' });+ assert.equal(+ await link.getAttribute('href'),+ '/docs/VM_DISK_MONITORING#a-missing-reading-is-not-an-installation-diagnosis',+ );+ const layout = await technical.evaluate((el) => ({+ width: el.clientWidth,+ scroll: el.scrollWidth,+ document: document.documentElement.clientWidth,+ documentScroll: document.documentElement.scrollWidth,+ }));+ assert.ok(layout.scroll <= layout.width + 1, JSON.stringify(layout));+ assert.ok(layout.documentScroll <= layout.document + 1, JSON.stringify(layout));+ const file = name + '-' + state.name + '.png';+ await technical.screenshot({ path: output + '/' + file });+ result.captures.push({ file, sha256: hash(output + '/' + file) });+ record.states.push({ name: state.name, text, layout });+ }+ await page.evaluate(() =>+ window.__readingHelp.update({ reason: '', retained: true, os: 'Windows 11' }),+ );+ assert.equal(+ await technical.getByRole('link', { name: 'Filesystem reading guidance' }).count(),+ 0,+ );+ assert.equal(await technical.getByRole('progressbar').getAttribute('aria-valuenow'), '50');+ record.fresh =+ 'Current same-guest data restores the utilization bar and removes uncertain-read guidance.';+ await page.evaluate(() =>+ window.__readingHelp.update({+ reason: 'agent-not-running',+ retained: false,+ os: 'Windows 11',+ }),+ );+ const link = technical.getByRole('link', { name: 'Filesystem reading guidance' });+ if (width <= 768) await link.tap();+ else {+ await link.focus();+ await page.keyboard.press('Enter');}- await page.evaluate(() => window.__readingHelp.update({reason:'',retained:true,os:'Windows 11'}));- assert.equal(await technical.getByRole('link',{name:'Filesystem reading guidance'}).count(),0);- assert.equal(await technical.getByRole('progressbar').getAttribute('aria-valuenow'),'50');- record.fresh='Current same-guest data restores the utilization bar and removes uncertain-read guidance.';- await page.evaluate(() => window.__readingHelp.update({reason:'agent-not-running',retained:false,os:'Windows 11'}));- const link=technical.getByRole('link',{name:'Filesystem reading guidance'});- if(width<=768)await link.tap();else {await link.focus();await page.keyboard.press('Enter');}- const heading=page.locator('#a-missing-reading-is-not-an-installation-diagnosis');await heading.waitFor({state:'visible'});+ const heading = page.locator('#a-missing-reading-is-not-an-installation-diagnosis');+ await heading.waitFor({ state: 'visible' });// Heading and actual renderer output, not a stand-in HTML help page.- assert.match(await page.locator('article').innerText(),/does not establish whether an agent is absent or stopped/);- assert.match(await page.locator('article').innerText(),/every\s+filesystem covered by the backup/);- assert.match(await page.locator('article').innerText(),/Windows or Android/);- record.help={url:page.url(),heading:await heading.innerText()};- record.input=await page.evaluate(()=>window.__input);assert.ok(record.input.some(Boolean));- assert.deepEqual(record.errors,[]);assert.equal(record.requests.filter(r=>!['GET','HEAD'].includes(r.method)).length,0);- await context.close();await browser.close();browser=null;+ assert.match(+ await page.locator('article').innerText(),+ /does not establish whether an agent is absent or stopped/,+ );+ assert.match(+ await page.locator('article').innerText(),+ /every\s+filesystem covered by the backup/,+ );+ assert.match(await page.locator('article').innerText(), /Windows or Android/);+ record.help = { url: page.url(), heading: await heading.innerText() };+ record.input = await page.evaluate(() => window.__input);+ assert.ok(record.input.some(Boolean));+ assert.deepEqual(record.errors, []);+ assert.equal(record.requests.filter((r) => !['GET', 'HEAD'].includes(r.method)).length, 0);+ await context.close();+ await browser.close();+ browser = null;}- result.result='passed';result.verified_at=new Date().toISOString();- } catch(error) {result.error=String(error.stack||error);throw error;}- finally {+ result.result = 'passed';+ result.verified_at = new Date().toISOString();+ } catch (error) {+ result.error = String(error.stack || error);+ throw error;+ } finally {result.cleanup.browser_started = Boolean(browser) || result.cases.length > 0;- if(browser)await browser.close();result.cleanup.browser=true;+ if (browser) await browser.close();+ result.cleanup.browser = true;result.cleanup.server_started = Boolean(server);- if(server)await new Promise(resolve=>server.close(resolve));result.cleanup.server=true;- fs.writeFileSync(output+'/result.json',JSON.stringify(result,null,2)+'\n');+ if (server) await server.close();+ result.cleanup.server = true;+ fs.writeFileSync(output + '/result.json', JSON.stringify(result, null, 2) + '\n');}-})().catch(error=>{console.error(error);process.exitCode=1;});+})().catch((error) => {+ console.error(error);+ process.exitCode = 1;+});diff --git a/frontend-modern/browser-tests/guest-row-memory-provenance.cjs b/frontend-modern/browser-tests/guest-row-memory-provenance.cjsindex 93a9799512..2da2ac3e42 100644--- a/frontend-modern/browser-tests/guest-row-memory-provenance.cjs+++ b/frontend-modern/browser-tests/guest-row-memory-provenance.cjs@@ -1,4 +1,4 @@-// Production component source in the existing offline Vite preview.+// Precompiled production component source in the offline static preview.// No installation, full application build, guest operation or external service.const assert = require('node:assert/strict');const fs = require('node:fs');@@ -6,12 +6,13 @@ const path = require('node:path');const crypto = require('node:crypto');const { chromium, webkit } = require('playwright');+const { createPublicationFixtureServer } = require('./publication-fixture-server.cjs');const root = '/workspace/frontend-modern';const output = '/workspace/tmp/guest-row-memory-browser';const origin = 'http://127.0.0.1:5332';const hash = (file) => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');const manifest = {- mode: 'source-dev-preview',+ mode: 'precompiled-source-fixture',runtime: Object.fromEntries(['frontend-modern/src/components/Workloads/GuestRow.tsx',@@ -32,7 +33,7 @@ const result = {captures: [],cleanup: {},limits:- 'Production GuestRow, StackedMemoryBar, MetricMiniSparkline, drawer and actual source CSS in a dev preview; synthetic selected memory/history only. This is not a production application build. No full App, native QGA, thaw, filesystem writes, reporter, installed/release or physical-device acceptance.',+ 'Production GuestRow, StackedMemoryBar, MetricMiniSparkline, drawer and actual source CSS in a precompiled fixture; synthetic selected memory/history only. This is not a production application build. No full App, native QGA, thaw, filesystem writes, reporter, installed/release or physical-device acceptance.',};assert.equal(result.playwright,@@ -42,13 +43,12 @@ assert.equal();(async () => {const started = Date.now();- const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));- const server = await createServer({+ const server = createPublicationFixtureServer(root,- configFile: path.join(root, 'vite.config.ts'),- cacheDir: output + '/cache',- server: { host: '127.0.0.1', port: 5332, strictPort: true },- });+ 5332,+ 'browser-tests/guest-row-memory-provenance.html',+ );+ result.compiled = server.binding;await server.listen();let browser;try {@@ -339,9 +339,7 @@ assert.equal(if (browser) await browser.close();result.cleanup.browser_closed = true;await server.close();- const esbuild = await import(path.join(root, 'node_modules/esbuild/lib/main.js'));- esbuild.stop();- result.cleanup.compiler_stop_requested = true;+ result.cleanup.compiler_started = false;result.cleanup.server_closed = true;result.elapsed_ms = Date.now() - started;fs.writeFileSync(path.join(output, 'result.json'), JSON.stringify(result, null, 2) + '\n');diff --git a/frontend-modern/browser-tests/patrol-rule-removal.cjs b/frontend-modern/browser-tests/patrol-rule-removal.cjsindex 418ded52c6..e00fb49b15 100644--- a/frontend-modern/browser-tests/patrol-rule-removal.cjs+++ b/frontend-modern/browser-tests/patrol-rule-removal.cjs@@ -4,6 +4,7 @@ const fs = require('node:fs');const path = require('node:path');const crypto = require('node:crypto');const { chromium, webkit } = require('playwright');+const { createPublicationFixtureServer } = require('./publication-fixture-server.cjs');const hash = (file) => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');const files = ['src/api/patrol.ts',@@ -35,16 +36,20 @@ assert.equal();async function journey(- root, engine, width, parent = false, resume = false, visualOnly = false, compatibility = false,+ root,+ engine,+ width,+ parent = false,+ resume = false,+ visualOnly = false,+ compatibility = false,) {- process.chdir(root);- const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));- const server = await createServer({+ const server = createPublicationFixtureServer(root,- configFile: path.join(root, 'vite.config.ts'),- cacheDir: path.join(output, `vite-${parent ? 'parent' : engine}-${width}`),- server: { host: '127.0.0.1', port: 5297, strictPort: true, watch: null },- });+ 5297,+ 'browser-tests/patrol-rule-removal.html',+ );+ report.compiled = server.binding;let browser;let page;const result = {@@ -378,10 +383,14 @@ async function journey(}return observed;});- assert.deepEqual(result.abortCompatibility.map((x) => x.calls), [1, 0, 0]);- assert.deepEqual(result.abortCompatibility.map((x) => x.errorName), [- 'AbortError', 'AbortError', 'AbortError',- ]);+ assert.deepEqual(+ result.abortCompatibility.map((x) => x.calls),+ [1, 0, 0],+ );+ assert.deepEqual(+ result.abortCompatibility.map((x) => x.errorName),+ ['AbortError', 'AbortError', 'AbortError'],+ );assert.equal(result.requests.filter((r) => r.path === '/api/aborted-confirmation').length, 0);result.checks.push('Default pre-aborted API calls delegate once to native fetch; strict retry:false and expectedOrgID opt-ins stop before dispatch. All reject AbortError without a network request.',diff --git a/frontend-modern/browser-tests/publication-fixture-server.cjs b/frontend-modern/browser-tests/publication-fixture-server.cjsnew file mode 100644index 0000000000..e43d60598a--- /dev/null+++ b/frontend-modern/browser-tests/publication-fixture-server.cjs@@ -0,0 +1,145 @@+// Serve only the already-compiled, source-bound presentation fixtures. Never+// compile, proxy an API, or fall back to HTML for a missing JS/CSS/doc asset.+const assert = require('node:assert/strict');+const crypto = require('node:crypto');+const fs = require('node:fs');+const http = require('node:http');+const path = require('node:path');++const runtimePaths = [+ 'src/components/Workloads/GuestDrawerOverview.tsx',+ 'src/components/Workloads/GuestRow.tsx',+ 'src/components/Workloads/MetricMiniSparkline.tsx',+ 'src/components/Workloads/guestDrawerModel.ts',+ 'src/features/patrol/PatrolAttentionWorkbench.tsx',+];+const entryPaths = [+ 'browser-tests/guest-disk-provenance.html',+ 'browser-tests/guest-reading-help.html',+ 'browser-tests/guest-row-memory-provenance.html',+ 'browser-tests/patrol-rule-removal.html',+];+const harnessPaths = [+ 'browser-tests/build-publication-fixtures.mjs',+ 'browser-tests/publication-fixture-server.cjs',+ 'browser-tests/guest-disk-provenance.cjs',+ 'browser-tests/guest-reading-help.cjs',+ 'browser-tests/guest-row-memory-provenance.cjs',+ 'browser-tests/patrol-rule-removal.cjs',+ 'browser-tests/patrol-rule-removal-final.cjs',+];+const hash = (bytes) => crypto.createHash('sha256').update(bytes).digest('hex');+const mime = {+ '.html': 'text/html; charset=utf-8',+ '.js': 'text/javascript; charset=utf-8',+ '.css': 'text/css; charset=utf-8',+ '.md': 'text/markdown; charset=utf-8',+};++function readRegular(root, relative) {+ assert(typeof relative === 'string' && relative.length > 0, 'missing binding path');+ assert(!relative.includes('\\') && !path.posix.isAbsolute(relative), 'absolute binding path');+ assert(+ relative.split('/').every((part) => part && part !== '.' && part !== '..'),+ 'unsafe binding path',+ );+ let file = root;+ for (const part of relative.split('/')) {+ file = path.join(file, part);+ assert(!fs.lstatSync(file).isSymbolicLink(), 'symlink in binding path');+ }+ assert(fs.statSync(file).isFile(), 'binding path is not a regular file');+ return fs.readFileSync(file);+}++function loadPublicationFixture(+ root,+ compiled = path.resolve(root, '../tmp/publication-final-static'),+) {+ const binding = JSON.parse(readRegular(compiled, 'binding.json'));+ assert.equal(binding.version, 1);+ assert.match(binding.source_sha, /^[a-f0-9]{40}$/);+ assert.equal(+ binding.graph,+ hash(readRegular(root, 'package-lock.json')),+ 'dependency graph changed',+ );+ assert.equal(binding.entries.join('\n'), entryPaths.join('\n'), 'fixture entries changed');+ for (const [file, digest] of Object.entries(binding.sources)) {+ assert.match(digest, /^[a-f0-9]{64}$/);+ assert.equal(hash(readRegular(root, file)), digest, `imported source changed: ${file}`);+ }+ for (const file of [...runtimePaths, ...harnessPaths, ...entryPaths, 'src/index.css']) {+ assert(binding.sources[file], `required source was not bound: ${file}`);+ }+ const assets = new Map();+ for (const [file, digest] of Object.entries(binding.artifacts)) {+ assert.match(digest, /^[a-f0-9]{64}$/);+ const bytes = readRegular(compiled, file);+ assert.equal(hash(bytes), digest, `compiled artifact changed: ${file}`);+ // Retain verified bytes, not paths: later writes cannot change what is served.+ assets.set('/' + file, bytes);+ }+ for (const file of [...entryPaths, 'docs/VM_DISK_MONITORING.md']) {+ assert(assets.has('/' + file), `required artifact was not compiled: ${file}`);+ }+ const doc = 'public/docs/VM_DISK_MONITORING.md';+ assert(binding.sources[doc], 'shipped safety document was not bound');+ assert.equal(binding.artifacts['docs/VM_DISK_MONITORING.md'], binding.sources[doc]);+ return { binding, assets };+}++function createPublicationFixtureServer(root, port, entry, compiled) {+ assert(entryPaths.includes(entry), 'unknown fixture entry');+ assert(Number.isInteger(port) && port > 0 && port < 65536, 'invalid loopback port');+ // Fail before opening a listener when any source or served byte is stale.+ const { binding, assets } = loadPublicationFixture(root, compiled);+ const server = http.createServer((req, res) => {+ if (req.method !== 'GET' && req.method !== 'HEAD') {+ res.writeHead(405);+ return res.end();+ }+ let pathname;+ try {+ pathname = decodeURIComponent(new URL(req.url, 'http://127.0.0.1').pathname);+ } catch {+ res.writeHead(400);+ return res.end();+ }+ // This single SPA route mounts the real Docs renderer from its own fixture.+ if (pathname === '/docs/VM_DISK_MONITORING')+ pathname = '/browser-tests/guest-reading-help.html';+ if (pathname === '/') pathname = '/' + entry;+ const bytes = assets.get(pathname);+ if (!bytes) {+ res.writeHead(404);+ return res.end();+ }+ res.setHeader('Content-Type', mime[path.extname(pathname)] || 'application/octet-stream');+ res.setHeader('Content-Length', bytes.length);+ res.setHeader('Cache-Control', 'no-store');+ res.end(req.method === 'HEAD' ? undefined : bytes);+ });+ return {+ binding,+ listen: () =>+ new Promise((resolve, reject) => {+ server.once('error', reject);+ server.listen(port, '127.0.0.1', resolve);+ }),+ close: () =>+ new Promise((resolve, reject) => {+ server.close((error) => (error ? reject(error) : resolve()));+ server.closeAllConnections();+ }),+ };+}++module.exports = {+ createPublicationFixtureServer,+ loadPublicationFixture,+ runtimePaths,+ entryPaths,+ harnessPaths,+ hash,+};diff --git a/frontend-modern/browser-tests/publication-fixture-server.test.cjs b/frontend-modern/browser-tests/publication-fixture-server.test.cjsnew file mode 100644index 0000000000..9701c8960e--- /dev/null+++ b/frontend-modern/browser-tests/publication-fixture-server.test.cjs@@ -0,0 +1,215 @@+const assert = require('node:assert/strict');+const fs = require('node:fs');+const http = require('node:http');+const os = require('node:os');+const path = require('node:path');+const { afterEach, test } = require('node:test');+const {+ createPublicationFixtureServer,+ loadPublicationFixture,+ runtimePaths,+ entryPaths,+ harnessPaths,+ hash,+} = require('./publication-fixture-server.cjs');++const temporary = [];+afterEach(() => {+ for (const directory of temporary.splice(0)) fs.rmSync(directory, { recursive: true });+});++function fixture() {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'publication-fixture-'));+ temporary.push(directory);+ const root = path.join(directory, 'frontend');+ const compiled = path.join(directory, 'compiled');+ const write = (base, file, content) => {+ fs.mkdirSync(path.dirname(path.join(base, file)), { recursive: true });+ fs.writeFileSync(path.join(base, file), content);+ };+ write(root, 'package-lock.json', '{}');+ const binding = {+ version: 1,+ source_sha: '1'.repeat(40),+ graph: hash('{}'),+ entries: entryPaths,+ sources: {},+ artifacts: {},+ };+ for (const file of [+ ...runtimePaths,+ ...entryPaths,+ ...harnessPaths,+ 'src/index.css',+ 'public/docs/VM_DISK_MONITORING.md',+ ]) {+ write(root, file, file);+ binding.sources[file] = hash(file);+ }+ for (const file of [...entryPaths, 'assets/fixture.js', 'assets/fixture.css']) {+ write(compiled, file, file);+ binding.artifacts[file] = hash(file);+ }+ write(compiled, 'docs/VM_DISK_MONITORING.md', 'public/docs/VM_DISK_MONITORING.md');+ binding.artifacts['docs/VM_DISK_MONITORING.md'] =+ binding.sources['public/docs/VM_DISK_MONITORING.md'];+ const save = () => write(compiled, 'binding.json', JSON.stringify(binding));+ save();+ return { root, compiled, binding, write, save };+}++test('loads complete source-bound fixture bytes', () => {+ const f = fixture();+ const loaded = loadPublicationFixture(f.root, f.compiled);+ assert.equal(loaded.binding.source_sha, f.binding.source_sha);+ assert.equal(loaded.assets.get('/assets/fixture.js').toString(), 'assets/fixture.js');+});++for (const file of [+ ...runtimePaths,+ ...harnessPaths,+ 'src/index.css',+ 'public/docs/VM_DISK_MONITORING.md',+]) {+ test(`rejects stale imported/bound source: ${file}`, () => {+ const f = fixture();+ f.write(f.root, file, 'changed');+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /imported source changed/);+ });+}++test('rejects a changed dependency lock', () => {+ const f = fixture();+ f.write(f.root, 'package-lock.json', '{"changed":true}');+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /dependency graph changed/);+});++test('rejects a required runtime missing from the manifest', () => {+ const f = fixture();+ delete f.binding.sources[runtimePaths[0]];+ f.save();+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /required source was not bound/);+});++for (const file of [+ 'assets/fixture.js',+ 'assets/fixture.css',+ entryPaths[0],+ 'docs/VM_DISK_MONITORING.md',+]) {+ test(`rejects altered compiled bytes: ${file}`, () => {+ const f = fixture();+ f.write(f.compiled, file, 'changed');+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /compiled artifact changed/);+ });+}++test('rejects missing compiled entry and a substituted safety doc', () => {+ const f = fixture();+ delete f.binding.artifacts[entryPaths[0]];+ f.save();+ assert.throws(+ () => loadPublicationFixture(f.root, f.compiled),+ /required artifact was not compiled/,+ );+ f.binding.artifacts[entryPaths[0]] = hash(entryPaths[0]);+ f.binding.artifacts['docs/VM_DISK_MONITORING.md'] = hash('different guide');+ f.write(f.compiled, 'docs/VM_DISK_MONITORING.md', 'different guide');+ f.save();+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /strictly equal/);+});++for (const unsafe of ['../outside', '/absolute', 'assets/../outside', 'assets\\outside']) {+ test(`rejects unsafe manifest path: ${unsafe}`, () => {+ const f = fixture();+ f.binding.artifacts[unsafe] = hash('outside');+ f.save();+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /binding path/);+ });+}++test('rejects symlinked compiled files and source directories', () => {+ const f = fixture();+ fs.renameSync(path.join(f.compiled, 'assets/fixture.js'), path.join(f.compiled, 'actual.js'));+ fs.symlinkSync('../actual.js', path.join(f.compiled, 'assets/fixture.js'));+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /symlink/);+ fs.unlinkSync(path.join(f.compiled, 'assets/fixture.js'));+ fs.renameSync(path.join(f.compiled, 'actual.js'), path.join(f.compiled, 'assets/fixture.js'));+ fs.renameSync(path.join(f.root, 'src'), path.join(f.root, 'actual-src'));+ fs.symlinkSync('actual-src', path.join(f.root, 'src'));+ assert.throws(() => loadPublicationFixture(f.root, f.compiled), /symlink/);+});++test('refuses stale content before creating a listener', () => {+ const f = fixture();+ f.write(f.root, runtimePaths[0], 'changed');+ assert.throws(+ () => createPublicationFixtureServer(f.root, 5349, entryPaths[0], f.compiled),+ /source changed/,+ );+});++test('rejects unknown fixture entries and invalid ports', () => {+ const f = fixture();+ assert.throws(+ () => createPublicationFixtureServer(f.root, 5349, 'index.html', f.compiled),+ /unknown fixture/,+ );+ assert.throws(+ () => createPublicationFixtureServer(f.root, 0, entryPaths[0], f.compiled),+ /invalid loopback/,+ );+});++test('serves only verified bytes, explicit routes and GET/HEAD; closes the listener', async () => {+ const f = fixture();+ const server = createPublicationFixtureServer(f.root, 5349, entryPaths[0], f.compiled);+ f.write(f.compiled, 'assets/fixture.js', 'later changed on disk');+ f.write(f.compiled, 'unlisted.js', 'must not serve');+ const request = (url, method = 'GET') =>+ new Promise((resolve, reject) => {+ const req = http.request(+ { host: '127.0.0.1', port: 5349, path: url, method, agent: false },+ (res) => {+ const data = [];+ res.on('data', (chunk) => data.push(chunk));+ res.on('end', () =>+ resolve({+ status: res.statusCode,+ type: res.headers['content-type'],+ body: Buffer.concat(data).toString(),+ }),+ );+ },+ );+ req.once('error', reject);+ req.end();+ });+ await server.listen();+ try {+ assert.equal((await request('/')).body, entryPaths[0]);+ const js = await request('/assets/fixture.js?cache=1');+ assert.equal(js.body, 'assets/fixture.js');+ assert.match(js.type, /javascript/);+ assert.equal((await request('/assets/fixture.js', 'HEAD')).body, '');+ assert.equal((await request('/docs/VM_DISK_MONITORING')).body, entryPaths[1]);+ assert.match((await request('/docs/VM_DISK_MONITORING.md')).type, /markdown/);+ for (const url of [+ '/missing.js',+ '/missing.css',+ '/docs/missing.md',+ '/unlisted.js',+ '/binding.json',+ '/api/guests',+ '/%ZZ',+ '/%2e%2e%2foutside',+ ]) {+ assert((await request(url)).status >= 400, url);+ }+ assert.equal((await request('/assets/fixture.js', 'POST')).status, 405);+ assert.equal((await request('/api/guests', 'DELETE')).status, 405);+ } finally {+ await server.close();+ }+ await assert.rejects(request('/'), /ECONNREFUSED/);+});