From 8a2ef2ff59b93dc4d74924e5b88aba4f8b95c16a Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Wed, 11 Nov 2026 19:16:52 +0000 Subject: [PATCH 1/4] GEN-2889 run local validation with bootstrapped database --- AGENTS.md | 10 ++++++---- README.md | 2 +- package.json | 1 + scripts/bootstrap-test.mjs | 5 +++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4a10872f..d36de4ef 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,10 +11,12 @@ check` is an alias for the same suite. Targeted workspace commands remain available for iteration, but do not replace the root suite before handoff. For a fresh local VM, install PostgreSQL and Chromium as needed, then run -`npm run bootstrap:test`. It creates an isolated local database, applies -migrations, and prints the variables to export before `npm test`. Never point -validation at production or a shared database. A missing database, Node -version, or Chromium prerequisite is a hard failure with a recovery command. +`npm run test:local` to create an isolated local database, apply migrations, +and run the complete root suite with the required database variables. To +prepare the database without running tests, use `npm run bootstrap:test`; it +prints the variables to export before `npm test`. Never point validation at +production or a shared database. A missing database, Node version, or Chromium +prerequisite is a hard failure with a recovery command. ## API architecture diff --git a/README.md b/README.md index da06a5ee..92176fba 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ MCP provides selected scoped operations, not every REST capability. REST contrac Use Node 24.12.0 and npm 11.19.0 (`.node-version` and `package.json`), then run `npm ci`, `npm run dev`, and `npm test`. The root test is the complete required validation used by CI; `npm run check` is an alias, and `npm run test:backend` / `npm run test:browser` are the focused shared lanes. The Worker lives in `packages/api`, React frontend in `packages/app`, and generated public contract in `packages/api-client`. Frontend calls documented `/api/v1` routes. Keep local secrets in ignored `packages/api/.dev.vars`. -For a fresh VM, install PostgreSQL and Chromium, run `npm run bootstrap:test`, export the three printed database variables, and then run `npm test`. The bootstrap uses only an isolated local database and refuses remote URLs. Missing prerequisites must be fixed before handoff; do not mark work done after only `git diff --check`. +For a fresh VM, install PostgreSQL and Chromium, then run `npm run test:local` to create an isolated local database, apply migrations, and run the complete root suite with its database variables supplied. The bootstrap refuses remote database URLs. To prepare the database without running tests, use `npm run bootstrap:test` and export the three printed variables before `npm test`. Missing prerequisites must be fixed before handoff; do not mark work done after only `git diff --check`. Run `npm run generate --workspace=factorize-docs` after guide edits and `npm run validate --workspace=factorize-docs` before publishing. See [docs publishing](docs/mintlify.md) and [package migration](docs/package-migration.md) for development and release gates. diff --git a/package.json b/package.json index d8cf4fbc..a2785aab 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "test:proxy": "node scripts/validation.mjs proxy", "check": "npm test", "bootstrap:test": "node scripts/bootstrap-test.mjs", + "test:local": "node scripts/bootstrap-test.mjs --test", "check:backend": "npm run check:hosting && npm run check:boundaries && npm run check:client && npm run validate --workspace=factorize-docs && npm run check --workspace=factorize && npm run test:conditions-runtime && npm run test:hosting-runtime && npm run test:oauth-runtime && npm run test:rollback-runtime && npm run check --workspace=factorize-marketing && npm run check --workspace=factorize-tail-relay", "check:frontend": "npm run check --workspace=factorize-app", "deploy": "npm run deploy:marketing && npm run deploy:app && npm run deploy:tail-relay", diff --git a/scripts/bootstrap-test.mjs b/scripts/bootstrap-test.mjs index 91137319..7b0faf94 100644 --- a/scripts/bootstrap-test.mjs +++ b/scripts/bootstrap-test.mjs @@ -3,6 +3,7 @@ import { promisify } from "node:util"; import process from "node:process"; const exec = promisify(execFile); +const runTests = process.argv.includes("--test"); const databaseUrl = process.env.VALIDATION_DATABASE_URL ?? "postgresql://postgres:local-validation-only@localhost:5432/factorize_validation"; const adminUrl = process.env.VALIDATION_DATABASE_ADMIN_URL ?? "postgresql://postgres:local-validation-only@localhost:5432/postgres"; const url = new URL(databaseUrl); @@ -18,7 +19,11 @@ await exec("psql", [admin.href, "-v", "ON_ERROR_STOP=1", "-c", `CREATE DATABASE const env = { ...process.env, DATABASE_URL: databaseUrl, AUTH_TEST_DATABASE_URL: databaseUrl, QUEUE_TEST_DATABASE_URL: databaseUrl }; await exec("npm", ["run", "db:migrate", "--workspace=factorize"], { env, stdio: "inherit" }); console.log(`Isolated validation database ready: ${databaseUrl.replace(/:[^:@/]+@/, ":***@")}`); +if (runTests) { + await exec("npm", ["test"], { env, stdio: "inherit" }); +} else { console.log(`export DATABASE_URL=${JSON.stringify(databaseUrl)}`); console.log(`export AUTH_TEST_DATABASE_URL=${JSON.stringify(databaseUrl)}`); console.log(`export QUEUE_TEST_DATABASE_URL=${JSON.stringify(databaseUrl)}`); console.log("Then run: npm test"); +} From f605965f6aa90fc6933b28e6e3ef2770c56942c4 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Wed, 11 Nov 2026 19:20:09 +0000 Subject: [PATCH 2/4] GEN-2889 document prepared validation VM prerequisites --- AGENTS.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d36de4ef..19885481 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,7 +10,7 @@ validation and runs the shared backend and browser lanes used by CI. `npm run check` is an alias for the same suite. Targeted workspace commands remain available for iteration, but do not replace the root suite before handoff. -For a fresh local VM, install PostgreSQL and Chromium as needed, then run +For a Factorize validation VM with PostgreSQL and Chromium available, run `npm run test:local` to create an isolated local database, apply migrations, and run the complete root suite with the required database variables. To prepare the database without running tests, use `npm run bootstrap:test`; it diff --git a/README.md b/README.md index 92176fba..b1bf507c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ MCP provides selected scoped operations, not every REST capability. REST contrac Use Node 24.12.0 and npm 11.19.0 (`.node-version` and `package.json`), then run `npm ci`, `npm run dev`, and `npm test`. The root test is the complete required validation used by CI; `npm run check` is an alias, and `npm run test:backend` / `npm run test:browser` are the focused shared lanes. The Worker lives in `packages/api`, React frontend in `packages/app`, and generated public contract in `packages/api-client`. Frontend calls documented `/api/v1` routes. Keep local secrets in ignored `packages/api/.dev.vars`. -For a fresh VM, install PostgreSQL and Chromium, then run `npm run test:local` to create an isolated local database, apply migrations, and run the complete root suite with its database variables supplied. The bootstrap refuses remote database URLs. To prepare the database without running tests, use `npm run bootstrap:test` and export the three printed variables before `npm test`. Missing prerequisites must be fixed before handoff; do not mark work done after only `git diff --check`. +On a Factorize validation VM with PostgreSQL and Chromium available, run `npm run test:local` to create an isolated local database, apply migrations, and run the complete root suite with its database variables supplied. The bootstrap refuses remote database URLs. To prepare the database without running tests, use `npm run bootstrap:test` and export the three printed variables before `npm test`. Missing prerequisites must be fixed before handoff; do not mark work done after only `git diff --check`. Run `npm run generate --workspace=factorize-docs` after guide edits and `npm run validate --workspace=factorize-docs` before publishing. See [docs publishing](docs/mintlify.md) and [package migration](docs/package-migration.md) for development and release gates. From 620af746a7adb8a72b52a1f74d255cf96fdaaae5 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Wed, 11 Nov 2026 20:35:43 +0000 Subject: [PATCH 3/4] GEN-2889 add Factorize validation runner image --- .dockerignore | 7 +++ AGENTS.md | 21 ++++--- Dockerfile.validation-runner | 45 ++++++++++++++ README.md | 2 +- ...factorize-validation-postgres-auth.service | 12 ++++ docker/factorize-validation-postgres-auth.sh | 7 +++ docker/factorize-validation-postgres.conf | 2 + docs/ci-testing.md | 15 +++-- docs/factorize-validation-runner.md | 61 +++++++++++++++++++ scripts/bootstrap-test.mjs | 27 +++++++- scripts/build-validation-runner-image.sh | 19 ++++++ scripts/smoke-validation-runner-image.sh | 25 ++++++++ 12 files changed, 228 insertions(+), 15 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile.validation-runner create mode 100644 docker/factorize-validation-postgres-auth.service create mode 100644 docker/factorize-validation-postgres-auth.sh create mode 100644 docker/factorize-validation-postgres.conf create mode 100644 docs/factorize-validation-runner.md create mode 100644 scripts/build-validation-runner-image.sh create mode 100644 scripts/smoke-validation-runner-image.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..738624fa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +node_modules +**/node_modules +.wrangler +packages/*/dist +packages/*/coverage +npm-debug.log diff --git a/AGENTS.md b/AGENTS.md index 19885481..7b11dac7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,13 +10,20 @@ validation and runs the shared backend and browser lanes used by CI. `npm run check` is an alias for the same suite. Targeted workspace commands remain available for iteration, but do not replace the root suite before handoff. -For a Factorize validation VM with PostgreSQL and Chromium available, run -`npm run test:local` to create an isolated local database, apply migrations, -and run the complete root suite with the required database variables. To -prepare the database without running tests, use `npm run bootstrap:test`; it -prints the variables to export before `npm test`. Never point validation at -production or a shared database. A missing database, Node version, or Chromium -prerequisite is a hard failure with a recovery command. +For a fresh exe.dev VM, use the Factorize validation runner image described in +[`docs/factorize-validation-runner.md`](docs/factorize-validation-runner.md). +It provides Node 24.12.0, npm 11.19.0, PostgreSQL and the matching Playwright +Chromium build. After checkout, run `npm ci` and `npm run test:local`; this +resets only the isolated local validation database, applies migrations, and +runs the complete root suite with the database variables in its child +process. The image smoke command checks PostgreSQL password authentication +and Chromium through the non-login `exedev` process environment. Do not repair +the VM manually with apt or a browser download; fix the image and publish a +new digest instead. + +To prepare the database without running tests, use `npm run bootstrap:test`; +it prints the variables to export before `npm test`. Never point validation at +production or a shared database. The bootstrap refuses remote database URLs. ## API architecture diff --git a/Dockerfile.validation-runner b/Dockerfile.validation-runner new file mode 100644 index 00000000..7f7c1b5e --- /dev/null +++ b/Dockerfile.validation-runner @@ -0,0 +1,45 @@ +FROM ghcr.int.exe.xyz/boldsoftware/exeuntu:latest + +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] + +ARG NODE_VERSION=24.12.0 +ARG NPM_VERSION=11.19.0 +ARG PLAYWRIGHT_VERSION=1.64.0 + +# This is an image-level environment variable so exe.dev's non-login job +# process inherits the same browser location as an interactive shell. +ENV PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright + +COPY docker/factorize-validation-postgres-auth.sh /usr/local/sbin/factorize-validation-postgres-auth +COPY docker/factorize-validation-postgres-auth.service /etc/systemd/system/factorize-validation-postgres-auth.service +COPY docker/factorize-validation-postgres.conf /tmp/factorize-validation-postgres.conf + +RUN chmod 0755 /usr/local/sbin/factorize-validation-postgres-auth && \ + printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d && chmod 0755 /usr/sbin/policy-rc.d && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql postgresql-client xz-utils && \ + mkdir -p /etc/postgresql/16/main/conf.d && \ + install -m 0644 /tmp/factorize-validation-postgres.conf /etc/postgresql/16/main/conf.d/99-factorize-validation.conf && \ + rm -f /tmp/factorize-validation-postgres.conf && \ + arch="$(dpkg --print-architecture)" && \ + case "$arch" in amd64) node_arch=x64 ;; arm64) node_arch=arm64 ;; *) echo "Unsupported Node architecture: $arch" >&2; exit 1 ;; esac && \ + curl --fail --silent --show-error --location --retry 5 --retry-all-errors \ + "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${node_arch}.tar.xz" \ + | tar -xJ --strip-components=1 -C /usr/local && \ + npm install --global "npm@${NPM_VERSION}" "playwright@${PLAYWRIGHT_VERSION}" && \ + PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright playwright install --with-deps chromium && \ + rm -f /usr/sbin/policy-rc.d && \ + rm -rf /var/lib/apt/lists/* && \ + chmod -R a+rX /opt/ms-playwright && \ + systemctl enable postgresql.service factorize-validation-postgres-auth.service && \ + mkdir -p /etc/profile.d && \ + printf 'export PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright\n' \ + > /etc/profile.d/factorize-playwright.sh && \ + printf 'PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright\n' >> /etc/environment && \ + node --version | grep -Fx "v${NODE_VERSION}" && \ + npm --version | grep -Fx "${NPM_VERSION}" && \ + test "$(node -p 'require("/usr/local/lib/node_modules/playwright/package.json").version')" = "${PLAYWRIGHT_VERSION}" && \ + runuser --preserve-environment -u exedev -- node -e 'const { chromium } = require("/usr/local/lib/node_modules/playwright"); (async () => { if (process.env.PLAYWRIGHT_BROWSERS_PATH !== "/opt/ms-playwright") throw new Error("missing image browser environment"); const browser = await chromium.launch({ headless: true }); console.log(await browser.version()); await browser.close(); })().catch(error => { console.error(error); process.exit(1); });' + +COPY scripts/smoke-validation-runner-image.sh /usr/local/bin/smoke-validation-runner-image +RUN chmod 0755 /usr/local/bin/smoke-validation-runner-image diff --git a/README.md b/README.md index b1bf507c..53dc7525 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ MCP provides selected scoped operations, not every REST capability. REST contrac Use Node 24.12.0 and npm 11.19.0 (`.node-version` and `package.json`), then run `npm ci`, `npm run dev`, and `npm test`. The root test is the complete required validation used by CI; `npm run check` is an alias, and `npm run test:backend` / `npm run test:browser` are the focused shared lanes. The Worker lives in `packages/api`, React frontend in `packages/app`, and generated public contract in `packages/api-client`. Frontend calls documented `/api/v1` routes. Keep local secrets in ignored `packages/api/.dev.vars`. -On a Factorize validation VM with PostgreSQL and Chromium available, run `npm run test:local` to create an isolated local database, apply migrations, and run the complete root suite with its database variables supplied. The bootstrap refuses remote database URLs. To prepare the database without running tests, use `npm run bootstrap:test` and export the three printed variables before `npm test`. Missing prerequisites must be fixed before handoff; do not mark work done after only `git diff --check`. +On exe.dev, use the [Factorize validation runner image](docs/factorize-validation-runner.md), then run `npm ci` and `npm run test:local` after checkout. The image supplies the pinned Node, npm, PostgreSQL authentication, Playwright Chromium, and browser OS dependencies; `test:local` resets only the local validation database, applies migrations, and runs the complete root suite. The bootstrap refuses remote database URLs. To prepare the database without running tests, use `npm run bootstrap:test` and export its three printed variables before `npm test`. Missing prerequisites must be fixed in the image and published as a new digest; do not repair a fresh VM by hand or mark work done after only `git diff --check`. Run `npm run generate --workspace=factorize-docs` after guide edits and `npm run validate --workspace=factorize-docs` before publishing. See [docs publishing](docs/mintlify.md) and [package migration](docs/package-migration.md) for development and release gates. diff --git a/docker/factorize-validation-postgres-auth.service b/docker/factorize-validation-postgres-auth.service new file mode 100644 index 00000000..84c3e09d --- /dev/null +++ b/docker/factorize-validation-postgres-auth.service @@ -0,0 +1,12 @@ +[Unit] +Description=Configure loopback-only Factorize validation database authentication +Requires=postgresql.service +After=postgresql.service + +[Service] +Type=oneshot +ExecStart=/usr/local/sbin/factorize-validation-postgres-auth +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/docker/factorize-validation-postgres-auth.sh b/docker/factorize-validation-postgres-auth.sh new file mode 100644 index 00000000..284933e4 --- /dev/null +++ b/docker/factorize-validation-postgres-auth.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +# ExecStartPost runs as root after PostgreSQL has initialized/started. Use the +# postgres OS account and local peer auth so no credential is needed at build. +runuser -u postgres -- psql --dbname=postgres --set=ON_ERROR_STOP=1 \ + --command="ALTER ROLE postgres WITH LOGIN PASSWORD 'local-validation-only'" diff --git a/docker/factorize-validation-postgres.conf b/docker/factorize-validation-postgres.conf new file mode 100644 index 00000000..46918ca4 --- /dev/null +++ b/docker/factorize-validation-postgres.conf @@ -0,0 +1,2 @@ +listen_addresses = 'localhost' +password_encryption = 'scram-sha-256' diff --git a/docs/ci-testing.md b/docs/ci-testing.md index a2f5b151..5c191691 100644 --- a/docs/ci-testing.md +++ b/docs/ci-testing.md @@ -14,11 +14,16 @@ auditable implementation. Backend CI provisions an isolated PostgreSQL service; the browser job installs Chromium. A lane reports passed, failed, and unexecuted steps and exits nonzero on any missing prerequisite or failed step. -For a fresh exe.dev VM, use Node 24.12.0 and npm 11.19.0, run `npm ci`, install PostgreSQL and -Chromium, and run `npm run bootstrap:test`. Export its three local database -variables before `npm test`. The bootstrap recreates only the named local -database and applies migrations; it refuses remote database URLs. Optional -visual screenshots and stress tests remain outside required validation. +For a fresh exe.dev VM, boot the Factorize validation runner image described +in [`factorize-validation-runner.md`](factorize-validation-runner.md). Run +`scripts/smoke-validation-runner-image.sh` once after boot to check the +PostgreSQL password over loopback and launch the matching Chromium as `exedev` +through the non-login image environment. Then check out the repository, run +`npm ci`, and run `npm run test:local`. The image build enables PostgreSQL for +VM boot but does not start systemd during the build. The bootstrap recreates +only the isolated local validation database and applies the checkout's +migrations; it refuses remote database URLs. Optional visual screenshots and +stress tests remain outside required validation. Screenshot regressions and the 20,000-event trace stress case are intentionally outside required CI. Run **Optional visual regressions** from the Actions tab. diff --git a/docs/factorize-validation-runner.md b/docs/factorize-validation-runner.md new file mode 100644 index 00000000..2eb8cfb7 --- /dev/null +++ b/docs/factorize-validation-runner.md @@ -0,0 +1,61 @@ +# Factorize validation runner image + +The Factorize-specific exe.dev runner image is built from +[`Dockerfile.validation-runner`](../Dockerfile.validation-runner), using the +documented exe.dev `exeuntu` base. It keeps the base image's SSH, systemd, +`exedev` user, and agent setup while adding prerequisites for the complete +Factorize test suite. + +The image pins Node 24.12.0, npm 11.19.0, and Playwright/Chromium 1.64.0. It +installs PostgreSQL 16 without starting systemd during image build, enables +the PostgreSQL service for VM boot, and sets the `postgres` password used by +`scripts/bootstrap-test.mjs`. PostgreSQL listens on loopback; the test +bootstrap creates and recreates only its isolated validation database. The +image sets `PLAYWRIGHT_BROWSERS_PATH=/opt/ms-playwright` as an OCI environment +variable so non-login job processes inherit the installed browser location. +The Docker build launches Chromium as `exedev`; the post-boot smoke command +also checks password authentication over TCP and Chromium from the job user. + +## Build, publish, and pin + +The build/publish script uses the attached GHCR integration and prints the +immutable public image reference with its registry digest: + +```sh +scripts/build-validation-runner-image.sh +``` + +The resulting package must be public because exe.dev job images are pulled by +the host and private images are unsupported for jobs. Set the Factorize Dev +job's image to the printed +`ghcr.io/generationsoftware/factorize-validation-runner@sha256:…` reference, +preserving its other execution configuration. Do not use a mutable tag for +the job image. Record the exact digest in the issue handoff and validation +record below. + +## Fresh-VM acceptance + +After booting the pinned image, run the image smoke check, then check out the +Factorize repository and run the full local validation: + +```sh +scripts/smoke-validation-runner-image.sh +npm ci +npm run test:local +``` + +`test:local` resets the local validation database, applies the migrations +from that checkout, sets all three isolated database URLs in the root test +process, and runs `npm test`. Before it drops or recreates the database, +`test:local` launches Chromium and authenticates to the configured local +PostgreSQL admin URL, so missing image prerequisites fail before migrations +or the full suite. A failure requires correcting the image or bootstrap and +publishing a new digest, followed by repeating this sequence. + +## Validated image record + +| Field | Value | +| --- | --- | +| Public image digest | Pending publication and fresh-VM validation | +| Node / npm / Playwright | 24.12.0 / 11.19.0 / 1.64.0 | +| Fresh-VM smoke and full suite | Pending | diff --git a/scripts/bootstrap-test.mjs b/scripts/bootstrap-test.mjs index 7b0faf94..965fd427 100644 --- a/scripts/bootstrap-test.mjs +++ b/scripts/bootstrap-test.mjs @@ -1,9 +1,11 @@ -import { execFile } from "node:child_process"; +import { execFile, spawn } from "node:child_process"; import { promisify } from "node:util"; import process from "node:process"; const exec = promisify(execFile); const runTests = process.argv.includes("--test"); +const expectedNode = "v24.12.0"; +const expectedNpm = "11.19.0"; const databaseUrl = process.env.VALIDATION_DATABASE_URL ?? "postgresql://postgres:local-validation-only@localhost:5432/factorize_validation"; const adminUrl = process.env.VALIDATION_DATABASE_ADMIN_URL ?? "postgresql://postgres:local-validation-only@localhost:5432/postgres"; const url = new URL(databaseUrl); @@ -11,8 +13,29 @@ const admin = new URL(adminUrl); if (!["localhost", "127.0.0.1"].includes(url.hostname) || !["localhost", "127.0.0.1"].includes(admin.hostname)) { throw new Error("Validation databases must be local PostgreSQL instances; production or remote database URLs are refused."); } +if (process.version !== expectedNode) throw new Error(`Validation requires Node ${expectedNode}; found ${process.version}. Boot the pinned Factorize validation runner image.`); +const npmVersion = (await exec("npm", ["--version"])).stdout.trim(); +if (npmVersion !== expectedNpm) throw new Error(`Validation requires npm ${expectedNpm}; found ${npmVersion}. Boot the pinned Factorize validation runner image.`); + +function runInherited(command, args, options) { + return new Promise((resolve, reject) => { + const child = spawn(command, args, { ...options, stdio: "inherit" }); + child.once("error", reject); + child.once("close", (code, signal) => { + if (code === 0) resolve(); + else reject(new Error(`${command} ${args.join(" ")} failed${signal ? ` with signal ${signal}` : ` with exit code ${code}`}`)); + }); + }); +} await exec(process.platform === "win32" ? "where" : "which", ["psql"]); +try { + const { chromium } = await import("@playwright/test"); + const browser = await chromium.launch({ headless: true }); + await browser.close(); +} catch (error) { + throw new Error("Validation Chromium is unavailable before database reset. Boot the pinned Factorize validation runner image and preserve PLAYWRIGHT_BROWSERS_PATH from its image environment.", { cause: error }); +} await exec("psql", [admin.href, "-v", "ON_ERROR_STOP=1", "-c", `SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${url.pathname.slice(1)}' AND pid <> pg_backend_pid();`]); await exec("psql", [admin.href, "-v", "ON_ERROR_STOP=1", "-c", `DROP DATABASE IF EXISTS \"${url.pathname.slice(1)}\";`]); await exec("psql", [admin.href, "-v", "ON_ERROR_STOP=1", "-c", `CREATE DATABASE \"${url.pathname.slice(1)}\";`]); @@ -20,7 +43,7 @@ const env = { ...process.env, DATABASE_URL: databaseUrl, AUTH_TEST_DATABASE_URL: await exec("npm", ["run", "db:migrate", "--workspace=factorize"], { env, stdio: "inherit" }); console.log(`Isolated validation database ready: ${databaseUrl.replace(/:[^:@/]+@/, ":***@")}`); if (runTests) { - await exec("npm", ["test"], { env, stdio: "inherit" }); + await runInherited("npm", ["test"], { env }); } else { console.log(`export DATABASE_URL=${JSON.stringify(databaseUrl)}`); console.log(`export AUTH_TEST_DATABASE_URL=${JSON.stringify(databaseUrl)}`); diff --git a/scripts/build-validation-runner-image.sh b/scripts/build-validation-runner-image.sh new file mode 100644 index 00000000..bf95c825 --- /dev/null +++ b/scripts/build-validation-runner-image.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +repository='generationsoftware/factorize-validation-runner' +registry='ghcr.int.exe.xyz' +tag="${1:-$(git rev-parse --short=12 HEAD)}" +metadata_file="$(mktemp)" +trap 'rm -f "$metadata_file"' EXIT + +docker buildx build \ + --platform linux/amd64 \ + --file Dockerfile.validation-runner \ + --tag "${registry}/${repository}:${tag}" \ + --push \ + --metadata-file "$metadata_file" \ + . + +digest="$(jq -er '.["containerimage.digest"] | select(test("^sha256:[0-9a-f]{64}$"))' "$metadata_file")" +printf 'Published image: ghcr.io/%s@%s\n' "$repository" "$digest" diff --git a/scripts/smoke-validation-runner-image.sh b/scripts/smoke-validation-runner-image.sh new file mode 100644 index 00000000..940e86e4 --- /dev/null +++ b/scripts/smoke-validation-runner-image.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +expected_node=24.12.0 +expected_npm=11.19.0 +expected_playwright=1.64.0 + +[[ "$(node --version)" == "v${expected_node}" ]] +[[ "$(npm --version)" == "${expected_npm}" ]] +[[ "$(node -p 'require("/usr/local/lib/node_modules/playwright/package.json").version')" == "${expected_playwright}" ]] +[[ "${PLAYWRIGHT_BROWSERS_PATH:-}" == "/opt/ms-playwright" ]] + +# This must work for an ordinary non-login exedev process with the environment +# inherited from the VM image, as used by job execution. +runuser --preserve-environment -u exedev -- node --input-type=module -e ' + import { chromium } from "/usr/local/lib/node_modules/playwright/index.mjs"; + if (process.env.PLAYWRIGHT_BROWSERS_PATH !== "/opt/ms-playwright") throw new Error("Playwright image environment was not inherited"); + const browser = await chromium.launch({ headless: true }); + console.log(`Chromium ${browser.version()} launched as uid ${process.getuid()} via the non-login image environment`); + await browser.close(); +' + +# Password authentication uses the same URL and password as bootstrap-test.mjs. +psql 'postgresql://postgres:local-validation-only@localhost:5432/postgres' \ + --no-psqlrc --set=ON_ERROR_STOP=1 --tuples-only --command='SELECT current_user, inet_server_addr()' From 01ede3bd0871e90e9b83ac280479fc7194344068 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Wed, 11 Nov 2026 23:14:46 +0000 Subject: [PATCH 4/4] docs: record public validation runner checkpoint --- docs/factorize-validation-runner.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/factorize-validation-runner.md b/docs/factorize-validation-runner.md index 2eb8cfb7..1a0a68cb 100644 --- a/docs/factorize-validation-runner.md +++ b/docs/factorize-validation-runner.md @@ -56,6 +56,19 @@ publishing a new digest, followed by repeating this sequence. | Field | Value | | --- | --- | -| Public image digest | Pending publication and fresh-VM validation | +| Public image digest | `ghcr.io/generationsoftware/factorize-validation-runner@sha256:1333c4a7bb49c4cbcdd28ca2b57331dfcbff7cf611db1aaeaa4830517aacf6d4` | | Node / npm / Playwright | 24.12.0 / 11.19.0 / 1.64.0 | -| Fresh-VM smoke and full suite | Pending | +| Image smoke and full suite | Passed in a Docker container pulled anonymously from the immutable digest; not fresh-VM evidence | +| Fresh Dev VM and Dev job image pin | Pending; keep PR #392 draft and GEN-2889 In Progress until this gate passes | + +The checkpoint pull and container validation were repeated on 2026-11-11. +An unauthenticated GHCR manifest request returned HTTP 200 for the digest, +and `docker pull` with an empty Docker config downloaded the same digest. In a +container from that image, the PostgreSQL authentication helper and image smoke +passed, followed by `npm ci` and `npm run test:local` on Factorize commit +`02f96e9e23908537fffc2584b26abe85c34b1090` (backend 569 passed / 5 skipped, +browser 102 passed / 1 skipped, proxy checks and builds passed). The container +test starts PostgreSQL and invokes the image's authentication helper as setup; +it does not verify exe.dev VM boot behavior. The Dev job remains on +`ghcr.io/generationsoftware/anarack:latest`. A fresh Dev VM must still boot +from the digest and pass these checks before the job image is pinned.