Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(ci): main-green companion — 12 GB build heap + hosted-suite validator (#17350/#17851) and byte-pinned mirror tests (#17250) (#18252)
Diego Rodrigues de Sa e Souza55ccad495c4a
diff --git a/.github/workflows/nightly-release-green.yml b/.github/workflows/nightly-release-green.ymlindex dcca0fb050..5fc51f9217 100644--- a/.github/workflows/nightly-release-green.yml+++ b/.github/workflows/nightly-release-green.yml@@ -66,11 +66,125 @@ env:OMNIROUTE_SKIP_SYSTEM_TRUST: "1"jobs:+ # Schedule/dispatch only: the commit the hosted suites and the slot validation share.+ # Resolved once so a push landing mid-sweep cannot split the lanes across two commits.+ resolve-target:+ name: Resolve sweep target+ if: ${{ github.event_name != 'push' && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}+ runs-on: ubuntu-latest+ timeout-minutes: 5+ outputs:+ target: ${{ steps.resolve.outputs.target }}+ sha: ${{ steps.resolve.outputs.sha }}+ node-version: ${{ steps.runtime.outputs.node-version }}+ steps:+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7+ id: runtime+ with:+ node-version: "24"+ package-manager-cache: false+ - name: Resolve the active release branch and its tip+ id: resolve+ env:+ GH_TOKEN: ${{ github.token }}+ INPUT_BRANCH: ${{ github.event.inputs.branch }}+ run: |+ set -euo pipefail+ if [ -n "${INPUT_BRANCH:-}" ]; then+ TARGET="$INPUT_BRANCH"+ else+ TARGET=$(gh api "repos/$GITHUB_REPOSITORY/branches?per_page=100" --paginate \+ --jq '.[].name' | grep -E '^release/v[0-9]+\.[0-9]+\.[0-9]+$' | sort -t/ -k2 -V | tail -1)+ fi+ if ! printf '%s' "$TARGET" | grep -qE '^release/v[0-9]+\.[0-9]+\.[0-9]+$'; then+ echo "Refusing non-canonical branch name: $TARGET"; exit 1+ fi+ SHA=$(gh api "repos/$GITHUB_REPOSITORY/branches/$TARGET" --jq '.commit.sha')+ if ! printf '%s' "$SHA" | grep -qE '^[0-9a-f]{40}$'; then echo "No tip for $TARGET"; exit 1; fi+ echo "target=$TARGET" >> "$GITHUB_OUTPUT"+ echo "sha=$SHA" >> "$GITHUB_OUTPUT"+ echo "Sweep target: $TARGET @ $SHA"++ # The full sweep's unit, integration and vitest lanes, on hosted runners with ci.yml's own+ # shards and commands. On the 8-core omni-release slot they took ~4h15 per sweep and failed+ # timing tests on CPU starvation (2026-10-19/20); hosted, a shard takes ~13 min. The shard+ # counts must match ci.yml (tests/unit/validate-release-green.test.ts pins it).+ suites:+ name: Hosted suite (${{ matrix.name }})+ needs: resolve-target+ if: ${{ github.event_name != 'push' && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}+ runs-on: ubuntu-latest+ timeout-minutes: 30+ strategy:+ fail-fast: false+ matrix:+ include:+ - { name: unit-1, script: "test:unit:ci:shard", shard: "1/8" }+ - { name: unit-2, script: "test:unit:ci:shard", shard: "2/8" }+ - { name: unit-3, script: "test:unit:ci:shard", shard: "3/8" }+ - { name: unit-4, script: "test:unit:ci:shard", shard: "4/8" }+ - { name: unit-5, script: "test:unit:ci:shard", shard: "5/8" }+ - { name: unit-6, script: "test:unit:ci:shard", shard: "6/8" }+ - { name: unit-7, script: "test:unit:ci:shard", shard: "7/8" }+ - { name: unit-8, script: "test:unit:ci:shard", shard: "8/8" }+ - { name: integration-1, script: "test:integration:ci", shard: "1/2" }+ - { name: integration-2, script: "test:integration:ci", shard: "2/2" }+ - { name: vitest, script: "test:vitest", shard: "" }+ env:+ JWT_SECRET: ci-nightly-secret-with-sufficient-length-for-validation+ API_KEY_SECRET: ci-nightly-api-key-secret-long+ DISABLE_SQLITE_AUTO_BACKUP: "true"+ steps:+ - uses: actions/checkout@v7+ with:+ ref: ${{ needs.resolve-target.outputs.sha }}+ persist-credentials: false+ - uses: actions/setup-node@v7+ with:+ node-version: ${{ needs.resolve-target.outputs.node-version }}+ cache: npm+ - uses: ./.github/actions/npm-ci-retry+ - name: Run the suite and record its result+ env:+ NAME: ${{ matrix.name }}+ SUITE: ${{ matrix.script }}+ TEST_SHARD: ${{ matrix.shard }}+ NODE_OPTIONS: --max-old-space-size=8192+ run: |+ set +e+ if [[ "$NAME" == integration-* ]]; then+ # as ci.yml's test-integration job+ export DATA_DIR="/tmp/omniroute-ci-${NAME#integration-}"+ export INITIAL_PASSWORD=ci-test-password-for-integration+ fi+ (+ if [ "$NAME" = "vitest" ]; then+ npm run test:vitest && npm run test:vitest:ui+ else+ npm run "$SUITE"+ fi+ ) 2>&1 | tee suite.log+ code=${PIPESTATUS[0]}+ node scripts/ci/release-green-suite.mjs "$NAME" "$code" suite.log suite-results \+ "$GITHUB_WORKFLOW_SHA" "$SUITE" "$TEST_SHARD" || exit "$?"+ exit "$code"+ - name: Upload the suite result+ if: always()+ uses: actions/upload-artifact@v7+ with:+ name: release-green-suite-${{ github.run_attempt }}-${{ matrix.name }}+ path: suite-results/+ if-no-files-found: ignore+ retention-days: 7+release-green:name: Validate active release branch# On a push, only run for release/* pushes — a push to main is handled by the# main-green job below. Schedule/dispatch always run (they validate the highest release).- if: ${{ (github.event_name != 'push' || startsWith(github.ref_name, 'release/')) && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}+ # On push the two jobs above are skipped; !cancelled() keeps this job from being skipped+ # with them, and on schedule/dispatch it still reports when a suite job failed.+ needs: [resolve-target, suites]+ if: ${{ !cancelled() && (github.event_name != 'push' || startsWith(github.ref_name, 'release/')) && (github.event_name != 'schedule' || github.repository == 'diegosouzapw/OmniRoute') }}# Dynamic runner: with USE_VPS_RUNNER=true (release window / on-demand pre-flight)# this runs on the dedicated VPS runner — clean env (no operator OMNIROUTE_API_KEY,# no local noauth CLIs => zero machine-specific false positives) and no contention.@@ -98,9 +212,13 @@ jobs:INPUT_BRANCH: ${{ github.event.inputs.branch }}EVENT_NAME: ${{ github.event_name }}PUSHED_REF: ${{ github.ref_name }}+ SWEEP_TARGET: ${{ needs.resolve-target.outputs.target }}run: |set -euo pipefail- if [ -n "${INPUT_BRANCH:-}" ]; then+ if [ -n "${SWEEP_TARGET:-}" ]; then+ # schedule/dispatch: the branch the hosted suites tested+ TARGET="$SWEEP_TARGET"+ elif [ -n "${INPUT_BRANCH:-}" ]; thenTARGET="$INPUT_BRANCH"elif [ "$EVENT_NAME" = "push" ]; then# validate exactly what was pushed, not the highest branch@@ -126,10 +244,14 @@ jobs:TARGET: ${{ steps.branch.outputs.target }}EVENT_NAME: ${{ github.event_name }}PUSH_SHA: ${{ github.sha }}+ SWEEP_SHA: ${{ needs.resolve-target.outputs.sha }}run: |set -euo pipefailif [ "$EVENT_NAME" = "push" ]; thengit checkout --detach "$PUSH_SHA"+ elif [ -n "${SWEEP_SHA:-}" ]; then+ # the exact commit the hosted suites tested+ git checkout --detach "$SWEEP_SHA"elsegit checkout --detach "origin/$TARGET"fi@@ -141,11 +263,22 @@ jobs:- uses: actions/setup-node@v7with:- node-version: "24"+ node-version: ${{ needs.resolve-target.outputs.node-version || '24' }}cache: npm- uses: ./.github/actions/npm-ci-retry+ - name: Collect the hosted suite results+ if: github.event_name != 'push'+ continue-on-error: true+ uses: actions/download-artifact@v8+ with:+ # A partial re-run cannot reuse receipts from an earlier attempt;+ # rerun all suite jobs for a new complete observation of the same tip.+ pattern: release-green-suite-${{ github.run_attempt }}-*+ path: suite-results+ merge-multiple: true+- name: Release-green validation (full)id: validateenv:@@ -164,12 +297,15 @@ jobs:if [ "$EVENT_NAME" = "push" ]; thenMODE="--quick"else- MODE="--with-build --full-ci"+ # unit/integration/vitest ran in the hosted `suites` jobs; a missing result fails+ mkdir -p suite-results+ MODE="--with-build --full-ci --suites-from suite-results"fiecho "[release-green] mode: $MODE (event: $EVENT_NAME)"# MODE is an intentional flag list, so word-splitting is wanted here# shellcheck disable=SC2086node scripts/quality/validate-release-green.mjs --json --hermetic $MODE \+ --suites-workflow-sha "$GITHUB_WORKFLOW_SHA" \1> release-green.json 2> release-green.logvalidation_exit=$?node scripts/ci/release-green-result.mjs release-green.json "$validation_exit" "$VALIDATED_SHA" "$EVENT_NAME" >> release-green.log@@ -264,6 +400,7 @@ jobs:path: |release-green.jsonrelease-green.log+ suite-results/_artifacts/release-green/if-no-files-found: errorretention-days: 14diff --git a/changelog.d/fixes/0000-release-green-suite-provenance.md b/changelog.d/fixes/0000-release-green-suite-provenance.mdnew file mode 100644index 0000000000..8e63332667--- /dev/null+++ b/changelog.d/fixes/0000-release-green-suite-provenance.md@@ -0,0 +1 @@+- Bind hosted Release-Green suite receipts to their exact commit, workflow, run/attempt, Node patch, lockfile, command/shard and retained log hash; reject stale, malformed, unexpected or duplicate evidence. Artifacts are attempt-scoped, so partial reruns require rerunning all suite jobs before a complete verdict. Pass suite context explicitly through the CI command rather than product environment settings, and fail the hosted job if its receipt cannot be written.diff --git a/changelog.d/maintenance/0000-release-green-hosted-suites.md b/changelog.d/maintenance/0000-release-green-hosted-suites.mdnew file mode 100644index 0000000000..316ee061c9--- /dev/null+++ b/changelog.d/maintenance/0000-release-green-hosted-suites.md@@ -0,0 +1 @@+- **ci:** the scheduled full Release-Green sweep runs unit, integration and vitest as hosted jobs with `ci.yml`'s own shards (8 unit, 2 integration, vitest MCP + UI) on one resolved commit, and the `omni-release` slot keeps the static gates and the package build, now with a 12 GB build heap. On the 8-core slot the suites took ~4h15 per sweep and failed timing tests on CPU starvation, and the webpack build died at the 8 GB default heap.diff --git a/config/quality/test-masking-allowlist.json b/config/quality/test-masking-allowlist.jsonindex 3789a6933b..d365f3ac35 100644--- a/config/quality/test-masking-allowlist.json+++ b/config/quality/test-masking-allowlist.json@@ -32,6 +32,11 @@"tests/unit/provider-registry-github-copilot-gpt-4o.test.ts": "PR #12759: legacy `gpt-4o` and `gpt-4o-2024-11-20` Copilot entries are retired. Their former positive registration and chat-target assertions are replaced by checks that both ids are absent from the curated catalog and live discovery while a supported model remains; the shared deprecations test covers the retired-id fallback matrix. Net 6→3 reflects the removed model surface, not masking. Prune after #12759 merges to main.","tests/unit/account-fallback-service.test.ts": "v3.8.52 #15159: fix(resilience) delete the dead isProviderFailureCode export (B-04) — isProviderFailureCode and PROVIDER_FAILURE_ERROR_CODES had ZERO importers on release/v3.8.52 (verified against the base ref: the only hits were the definition itself at open-sse/services/accountFallback.ts:1349 and a stale pointer comment in open-sse/services/combo/comboPredicates.ts:222, which B-05 corrected in the same PR), so the 11 asserts that pinned that function were removed along with it (333→322). The removed case asserted `isProviderFailureCode(429) === true`, which is the OPPOSITE of the shipped breaker policy — AGENTS.md scopes 429 to connection cooldown / model lockout and reserves whole-provider trips for 408/500/502/503/504 — so the deleted test pinned wrong behaviour on dead code rather than guarding anything real. The live surface is now covered MORE strictly by tests/unit/breaker-status-set-single-source-15159.test.ts, which asserts the export is gone, that no production module imports it, and that both the combo copy and the live PROVIDER_BREAKER_FAILURE_STATUSES deepEqual [408, 500, 502, 503, 504] with 429 excluded. Dead export removed, coverage relocated to the single source of truth, not weakened. Prune after v3.8.52 merges to main.","tests/unit/combo-dispatch-prelude.test.ts": "PR #16420: four assertions (64 to 60) move to tests/unit/combo-pinned-empty-turn.test.ts so the oversized fixture shrinks. Both prefixed and alias targets now exercise trusted and untrusted execution evidence, preserving success checks and adding rejection when only a selected-connection header is present. Coverage relocated and strengthened, not removed.",+ "tests/unit/cli-env-quality-docs-mirrors.test.ts": "release/v3.8.53 PR #17250 (2026-10-20): the ENVIRONMENT.md / AUTO-COMBO.md provenance test asserted .i18n-state.json source_hash against the CURRENT English source (11→9, 2 asserts) — a duplicate of the i18n drift gate (check-translation-drift.mjs, PR-scoped since this PR) that turned every inherited translation drift into a red unit shard on unrelated PRs. The variable/path presence checks in every locale stay. Content assertions and target_hash provenance are unchanged. Verified legitimate, not masking. Prune after the next i18n wave lands.",+ "tests/unit/resilience-pre-dispatch-docs-mirrors.test.ts": "release/v3.8.53 PR #17250 (2026-10-20): the RESILIENCE_GUIDE provenance test asserted .i18n-state.json source_hash against the CURRENT English source (7→5, 2 asserts) — a duplicate of the i18n drift gate (check-translation-drift.mjs, PR-scoped since this PR) that turned every inherited translation drift into a red unit shard on unrelated PRs. The pre-dispatch retry/terminal contract tokens in every locale stay. Content assertions and target_hash provenance are unchanged. Verified legitimate, not masking. Prune after the next i18n wave lands.",+ "tests/unit/docs/vision-key-scope-locales.test.ts": "release/v3.8.53 PR #17250 (2026-10-20): the GUARDRAILS vision-key-scope section test asserted .i18n-state.json source_hash against the CURRENT English source (7→5, 2 asserts) — a duplicate of the i18n drift gate (check-translation-drift.mjs, PR-scoped since this PR) that turned every inherited translation drift into a red unit shard on unrelated PRs. Section presence, the nine literals and the no-English-fallback check in every locale stay. Content assertions and target_hash provenance are unchanged. Verified legitimate, not masking. Prune after the next i18n wave lands.",+ "tests/unit/docs/route-guard-import-locales.test.ts": "release/v3.8.53 PR #17250 (2026-10-20): the route-guard import section test asserted .i18n-state.json source_hash against the CURRENT English source (9→7, 2 asserts) — a duplicate of the i18n drift gate (check-translation-drift.mjs, PR-scoped since this PR) that turned every inherited translation drift into a red unit shard on unrelated PRs. Section presence and literals in every locale stay. Content assertions and target_hash provenance are unchanged. Verified legitimate, not masking. Prune after the next i18n wave lands.",+ "tests/unit/docs/remote-token-privilege-locales.test.ts": "release/v3.8.53 PR #17250 (2026-10-20): the remote-token privilege section test asserted .i18n-state.json source_hash against the CURRENT English source (7→5, 2 asserts) — a duplicate of the i18n drift gate (check-translation-drift.mjs, PR-scoped since this PR) that turned every inherited translation drift into a red unit shard on unrelated PRs. Section presence and literals in every locale stay. Content assertions and target_hash provenance are unchanged. Verified legitimate, not masking. Prune after the next i18n wave lands.","_deletedWithReplacement": {"_comment": "Deleções de arquivo de teste com SUBSTITUTO verificado (o gate exige que o replacement exista no HEAD e seja arquivo de teste). Uso restrito ao caso 'reescrito em outro path sem rename detectável pelo -M do git'. Cada entrada precisa de reason com PR ref e passa por revisão humana no release PR. Prune após o release mergear para main.","tests/unit/gemini-web-image-account-fallback.test.ts": {diff --git a/scripts/ci/release-green-suite.mjs b/scripts/ci/release-green-suite.mjsnew file mode 100644index 0000000000..c3209a8a19--- /dev/null+++ b/scripts/ci/release-green-suite.mjs@@ -0,0 +1,50 @@+#!/usr/bin/env node+// Writes the result of one hosted Release-Green suite job (a `suites` matrix leg of+// nightly-release-green.yml) for the validator's --suites-from reader.+// Usage: node scripts/ci/release-green-suite.mjs <name> <exitCode> <logFile> <outDir> <workflowSha> <script> [shard]+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";+import { createHash } from "node:crypto";+import { join } from "node:path";+import { fileURLToPath } from "node:url";+import { firstFailureLine, hostedSuiteIdentity } from "../quality/validate-release-green.mjs";++const NAME_RE = /^(unit-\d+|integration-\d+|vitest)$/;++/** The JSON one suite job reports: its name, exit code and first failure line. */+export function suiteResult(name, exitCode, log) {+ if (!NAME_RE.test(name)) throw new Error(`unknown suite name: ${name}`);+ const code = Number(exitCode);+ if (+ !/^(0|[1-9][0-9]*)$/.test(String(exitCode)) ||+ !Number.isInteger(code) ||+ code < 0 ||+ code > 255+ ) {+ throw new Error(`invalid exit code: ${exitCode}`);+ }+ return { name, code, detail: code === 0 ? "pass" : firstFailureLine(log) };+}++if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {+ const [name, exitCode, logFile, outDir, workflowSha, script, shard = ""] = process.argv.slice(2);+ let log = "";+ try {+ log = readFileSync(logFile, "utf8");+ } catch {+ log = "";+ }+ if (!log.trim()) throw new Error("missing or empty hosted suite log");+ const identity = hostedSuiteIdentity(process.cwd(), workflowSha);+ if (!identity) throw new Error("missing hosted suite execution identity");+ const result = {+ ...suiteResult(name, exitCode, log),+ ...identity,+ script: name === "vitest" ? "test:vitest+test:vitest:ui" : script,+ shard,+ logSha256: createHash("sha256").update(log).digest("hex"),+ };+ mkdirSync(outDir, { recursive: true });+ writeFileSync(join(outDir, `${name}.log`), log);+ writeFileSync(join(outDir, `${name}.json`), `${JSON.stringify(result)}\n`);+ console.log(`[release-green-suite] ${name}: exit ${result.code}`);+}diff --git a/scripts/quality/validate-release-green.mjs b/scripts/quality/validate-release-green.mjsindex 67464b7b4e..3b55f67d6e 100644--- a/scripts/quality/validate-release-green.mjs+++ b/scripts/quality/validate-release-green.mjs@@ -44,13 +44,15 @@// --hermetic scrub OMNIROUTE_API_KEY/OMNIROUTE_URL from gate env so live// tests self-skip exactly like CI (dev machines otherwise run// them against localhost and produce false-positive reds)+// --suites-from <dir> consume hosted receipts instead of local suite execution;+// requires --suites-workflow-sha <sha> from the producing workflow.//// Per-gate output is saved to _artifacts/release-green/<gate>.log (gitignored) —// diagnose a red from the file instead of re-running the gate.import { execFileSync } from "node:child_process";-import { randomUUID } from "node:crypto";-import { mkdirSync, readFileSync, writeFileSync } from "node:fs";+import { createHash, randomUUID } from "node:crypto";+import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";import { availableParallelism } from "node:os";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";@@ -451,13 +453,18 @@ export function extractCiGates(* different denominator, unparsable YAML) returns null: the caller then runs the unsharded suite.*/export function unitShardCountFromCi(yamlText) {+ return shardCountFromCi(yamlText, "test-unit");+}++/** Same reading for any sharded ci.yml job (`test-unit`, `test-integration`). */+export function shardCountFromCi(yamlText, jobId) {let doc;try {doc = parseYaml(yamlText);} catch {return null;}- const job = doc?.jobs?.["test-unit"];+ const job = doc?.jobs?.[jobId];const matrix = job?.strategy?.matrix?.shard;if (!Array.isArray(matrix) || matrix.length < 2) return null;if (!matrix.every((value, index) => value === index + 1)) return null;@@ -515,6 +522,118 @@ export function mergeUnitShardResults(shardResults) {return { code: failed[0].code, out, detail: `unit shard ${named}${line}` };}+// ─── Hosted suite results (2026-10-20) ───────────────────────────────────────++/**+ * Names of the hosted Release-Green suite jobs, in the order they are reported: ci.yml's unit+ * shards, its integration shards, then vitest (MCP + UI). The workflow's `suites` matrix writes+ * one `<name>.json` per job; a name with no file is a job that never reported.+ */+export function hostedSuiteNames(unitShards, integrationShards) {+ const range = (n, prefix) => Array.from({ length: n }, (_, i) => `${prefix}-${i + 1}`);+ return [...range(unitShards, "unit"), ...range(integrationShards, "integration"), "vitest"];+}++/** Exact execution identity shared by hosted writers and their consuming observer. */+export function hostedSuiteIdentity(cwd, workflowSha) {+ try {+ const identity = {+ schemaVersion: 1,+ candidateSha: execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8" }).trim(),+ workflowSha,+ runId: process.env.GITHUB_RUN_ID,+ runAttempt: process.env.GITHUB_RUN_ATTEMPT,+ nodeVersion: process.version,+ lockfileSha256: createHash("sha256")+ .update(readFileSync(join(cwd, "package-lock.json")))+ .digest("hex"),+ };+ if (+ ![identity.candidateSha, identity.workflowSha].every((value) =>+ /^[a-f0-9]{40}$/.test(value ?? "")+ ) ||+ ![identity.runId, identity.runAttempt].every((value) => /^[1-9][0-9]*$/.test(value ?? ""))+ )+ return null;+ return identity;+ } catch {+ return null;+ }+}++/** Parses one hosted suite result file; anything malformed counts as "no result". */+export function parseHostedSuiteResult(text, expected) {+ try {+ const r = JSON.parse(text);+ if (typeof r?.name !== "string" || !Number.isInteger(r?.code) || r.code < 0 || r.code > 255)+ return null;+ if (+ expected === null ||+ (expected && Object.entries(expected).some(([key, value]) => r[key] !== value))+ )+ return null;+ return { name: r.name, code: r.code, detail: typeof r.detail === "string" ? r.detail : "" };+ } catch {+ return null;+ }+}++/**+ * Folds the hosted suite results into the `unit`, `integration` and `vitest` HARD gates the+ * local lanes used to record, so the verdict, the tracking issue and every reader of+ * release-green.json keep the same ids. A lane passes only when every expected job reported+ * exit 0; a job that never reported (cancelled, timed out, upload lost) fails it.+ */+export function foldHostedSuiteResults(results, { unitShards, integrationShards }) {+ const byName = new Map(results.filter(Boolean).map((r) => [r.name, r]));+ const lane = (id, label, names) => {+ const parts = [];+ let line = "";+ for (const name of names) {+ const r = byName.get(name);+ if (!r) {+ parts.push(`${name} no result`);+ continue;+ }+ if (r.code === 0) continue;+ parts.push(`${name} ${r.code === 124 ? "TIMEOUT" : `exit ${r.code}`}`);+ if (!line && r.code !== 124 && r.detail) line = r.detail;+ }+ return {+ id,+ label,+ kind: "hard",+ ok: parts.length === 0,+ detail: parts.length === 0 ? "pass" : `${parts.join(", ")}${line ? ` — ${line}` : ""}`,+ };+ };+ const names = hostedSuiteNames(unitShards, integrationShards);+ return [+ ...(results.some((r) => !r || !names.includes(r.name)) || byName.size !== results.length+ ? [+ {+ id: "hosted-suites",+ label: "Hosted suite receipt integrity",+ kind: "hard",+ ok: false,+ detail: "invalid, unexpected or duplicate hosted suite receipt",+ },+ ]+ : []),+ lane(+ "unit",+ `Unit tests (ci.yml's ${unitShards} shards on hosted runners)`,+ names.filter((n) => n.startsWith("unit-"))+ ),+ lane(+ "integration",+ `Integration tests (ci.yml's ${integrationShards} shards on hosted runners)`,+ names.filter((n) => n.startsWith("integration-"))+ ),+ lane("vitest", "Vitest (MCP + UI, hosted runner)", ["vitest"]),+ ];+}+// ─── Orchestration (only when run directly) ─────────────────────────────────/**@@ -559,6 +678,15 @@ let hermetic = false;*/const PACK_GATE_ENV = { OMNIROUTE_RELEASE_REF: "HEAD" };+/**+ * Heap for the sweep's webpack build. build-next-isolated.mjs defaults to 8192 MB, and on the+ * omni-release slot the Next build worker died with "JavaScript heap out of memory" after+ * ~20 min (sweep 39254440706, 2026-10-19); the earlier sweeps sat in the same phase until their+ * ceiling. docker-publish builds with 12288 (proven 2026-10-16/17); the build runs alone in the+ * slot's 20 GB memory.high, so 12 GB of V8 heap fits.+ */+const BUILD_GATE_ENV = { OMNIROUTE_BUILD_MEMORY_MB: "12288" };+function buildGateEnv(extra) {const env = { ...process.env, FORCE_COLOR: "0", ...(extra || {}) };if (hermetic) for (const k of HERMETIC_SCRUB) delete env[k];@@ -600,7 +728,7 @@ const runAsync = run;async function runPackArtifactGate(timeoutMs) {const deadline = Date.now() + timeoutMs;const steps = [- { cmd: npmCmd, args: ["run", "build:cli"] },+ { cmd: npmCmd, args: ["run", "build:cli"], env: BUILD_GATE_ENV },{ cmd: process.execPath, args: ["scripts/build/write-build-sha.mjs"] },{cmd: npmCmd,@@ -646,6 +774,14 @@ async function main() {const QUICK = args.has("--quick");const FULL_CI = args.has("--full-ci");hermetic = args.has("--hermetic");+ // --suites-from <dir>: unit, integration and vitest already ran as hosted jobs (the+ // workflow's `suites` matrix); read their results instead of running them on this slot.+ const suitesFromIndex = process.argv.indexOf("--suites-from");+ const SUITES_FROM = suitesFromIndex >= 0 ? process.argv[suitesFromIndex + 1] : null;+ // Explicit workflow identity accompanies hosted receipts; it is not application .env config.+ const suitesWorkflowIndex = process.argv.indexOf("--suites-workflow-sha");+ const SUITES_WORKFLOW_SHA =+ suitesWorkflowIndex >= 0 ? process.argv[suitesWorkflowIndex + 1] : null;const results = [];const record = (r) => {@@ -854,6 +990,74 @@ async function main() {unitShards = null; // unreadable ci.yml: the unsharded suite below still runs}const unitPool = unitShards ? unitShardPool(unitShards, availableParallelism()) : 1;+ if (SUITES_FROM) {+ // The 2026-10-19/20 sweeps showed the 8-core slot cannot run the suites in useful time+ // (4h15 per sweep, shards 26-40 min against ~13 min hosted, timing tests failing on CPU+ // starvation such as the catalog's 8 s build bound). The suites now run on hosted+ // runners exactly like a PR's CI; this slot keeps the static gates and the build.+ let integrationShards = null;+ try {+ integrationShards = shardCountFromCi(+ readFileSync(join(ROOT, ".github/workflows/ci.yml"), "utf8"),+ "test-integration"+ );+ } catch {+ integrationShards = null;+ }+ if (!unitShards || !integrationShards) {+ record({+ id: "hosted-suites",+ label: "Hosted suites: read ci.yml's unit and integration matrices",+ kind: "hard",+ ok: false,+ detail: "could not read the shard counts from .github/workflows/ci.yml",+ });+ } else {+ let files = [];+ try {+ files = readdirSync(SUITES_FROM).filter((f) => f.endsWith(".json"));+ } catch {+ files = [];+ }+ const expected = hostedSuiteIdentity(ROOT, SUITES_WORKFLOW_SHA);+ const names = hostedSuiteNames(unitShards, integrationShards);+ const results = files.map((f) => {+ try {+ const name = f.slice(0, -5);+ if (!names.includes(name)) return null;+ const log = readFileSync(join(SUITES_FROM, `${name}.log`));+ if (log.length === 0) return null;+ const isUnit = name.startsWith("unit-");+ const script =+ name === "vitest"+ ? "test:vitest+test:vitest:ui"+ : isUnit+ ? "test:unit:ci:shard"+ : "test:integration:ci";+ const shard =+ name === "vitest"+ ? ""+ : `${name.split("-")[1]}/${isUnit ? unitShards : integrationShards}`;+ return parseHostedSuiteResult(+ readFileSync(join(SUITES_FROM, f), "utf8"),+ expected && {+ ...expected,+ name,+ script,+ shard,+ logSha256: createHash("sha256").update(log).digest("hex"),+ }+ );+ } catch {+ return null;+ }+ });+ for (const r of foldHostedSuiteResults(results, { unitShards, integrationShards })) {+ announce(r.label);+ record(r);+ }+ }+ }const slow = [unitShards? {@@ -898,8 +1102,10 @@ async function main() {timeout: 20 * 60 * 1000,});}+ // With --suites-from only the build lane is left for this slot.+ const lanes = SUITES_FROM ? slow.filter((g) => g.id === "pack-artifact") : slow;const slowResults = [];- for (const g of slow) {+ for (const g of lanes) {announce(g.label);const result = await (g.run? g.run(g.timeout)@@ -920,7 +1126,7 @@ async function main() {// check:pack-artifact is the builder for dist/ when staging is absent, so the// boot smoke MUST run after it completes, never alongside it: it would race// check:pack-boot against dist/server.js creation on clean worktrees.- const packArtifactIndex = slow.findIndex((g) => g.id === "pack-artifact");+ const packArtifactIndex = lanes.findIndex((g) => g.id === "pack-artifact");const packArtifactResult = slowResults[packArtifactIndex];const bootLabel = "Tarball boot-smoke (installed CLI serves /health)";diff --git a/tests/unit/build/release-green-hosted-suites.test.ts b/tests/unit/build/release-green-hosted-suites.test.tsnew file mode 100644index 0000000000..0b8ba13ffb--- /dev/null+++ b/tests/unit/build/release-green-hosted-suites.test.ts@@ -0,0 +1,119 @@+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";+import { load as parseYaml } from "js-yaml";++// The full Release-Green sweep runs unit/integration/vitest as hosted jobs (2026-10-20): on the+// 8-core omni-release slot they took ~4h15 per sweep and failed timing tests on CPU starvation.+const read = (path: string) => readFileSync(new URL(`../../../${path}`, import.meta.url), "utf8");+const { shardCountFromCi } = await import("../../../scripts/quality/validate-release-green.mjs");+const { suiteResult } = await import("../../../scripts/ci/release-green-suite.mjs");++type Job = {+ needs?: string | string[];+ if?: string;+ "runs-on"?: string;+ outputs?: Record<string, string>;+ strategy?: { matrix?: { include?: { name: string; script: string; shard: string }[] } };+ steps?: {+ uses?: string;+ run?: string;+ with?: Record<string, unknown>;+ env?: Record<string, string>;+ }[];+};+const workflow = parseYaml(read(".github/workflows/nightly-release-green.yml")) as {+ jobs: Record<string, Job>;+};+const ci = read(".github/workflows/ci.yml");++test("the hosted suite matrix has exactly ci.yml's unit and integration shards plus vitest", () => {+ const include = workflow.jobs.suites.strategy?.matrix?.include ?? [];+ const units = shardCountFromCi(ci, "test-unit");+ const integrations = shardCountFromCi(ci, "test-integration");+ const expected = [+ ...Array.from({ length: units }, (_, i) => ({+ name: `unit-${i + 1}`,+ script: "test:unit:ci:shard",+ shard: `${i + 1}/${units}`,+ })),+ ...Array.from({ length: integrations }, (_, i) => ({+ name: `integration-${i + 1}`,+ script: "test:integration:ci",+ shard: `${i + 1}/${integrations}`,+ })),+ { name: "vitest", script: "test:vitest", shard: "" },+ ];+ assert.deepEqual(include, expected);+ const pkg = JSON.parse(read("package.json")) as { scripts: Record<string, string> };+ for (const script of [+ "test:unit:ci:shard",+ "test:integration:ci",+ "test:vitest",+ "test:vitest:ui",+ ]) {+ assert.ok(pkg.scripts[script], `package.json has ${script}`);+ }+});++test("suites run hosted on the resolved commit and only outside push", () => {+ const suites = workflow.jobs.suites;+ assert.equal(suites["runs-on"], "ubuntu-latest");+ assert.equal(suites.needs, "resolve-target");+ assert.match(suites.if ?? "", /github\.event_name != 'push'/);+ const checkout = suites.steps?.find((s) => s.uses?.startsWith("actions/checkout@"));+ assert.equal(checkout?.with?.ref, "${{ needs.resolve-target.outputs.sha }}");+ const runtime = suites.steps?.find((s) => s.uses?.startsWith("actions/setup-node@"));+ assert.equal(runtime?.with?.["node-version"], "${{ needs.resolve-target.outputs.node-version }}");+ assert.match(workflow.jobs["resolve-target"].if ?? "", /github\.event_name != 'push'/);+ assert.deepEqual(Object.keys(workflow.jobs["resolve-target"].outputs ?? {}).sort(), [+ "node-version",+ "sha",+ "target",+ ]);+});++test("the slot validation waits for the suites, reads their results and still runs on push", () => {+ const job = workflow.jobs["release-green"];+ assert.deepEqual(job.needs, ["resolve-target", "suites"]);+ assert.match(job.if ?? "", /^\$\{\{ !cancelled\(\) && /, "push skips the suites, not this job");+ const steps = job.steps ?? [];+ const download = steps.find((s) => s.uses?.startsWith("actions/download-artifact@"));+ assert.equal(download?.with?.pattern, "release-green-suite-${{ github.run_attempt }}-*");+ assert.equal(download?.with?.path, "suite-results");+ const upload = workflow.jobs.suites.steps?.find((s) =>+ s.uses?.startsWith("actions/upload-artifact@")+ );+ assert.equal(+ upload?.with?.name,+ "release-green-suite-${{ github.run_attempt }}-${{ matrix.name }}"+ );+ const validate = steps.find((s) => s.run?.includes("validate-release-green.mjs"));+ assert.match(validate?.run ?? "", /--suites-workflow-sha "\$GITHUB_WORKFLOW_SHA"/);+ assert.match(validate?.run ?? "", /MODE="--with-build --full-ci --suites-from suite-results"/);+ assert.match(validate?.run ?? "", /MODE="--quick"/, "push keeps the quick profile");+ const checkout = steps.find((s) => s.run?.includes("SWEEP_SHA"));+ assert.equal(checkout?.env?.SWEEP_SHA, "${{ needs.resolve-target.outputs.sha }}");+});++test("main-green keeps its own local sweep (main runs main's copy of the validator)", () => {+ const job = workflow.jobs["main-green"];+ assert.equal(job.needs, undefined);+ const validate = (job.steps ?? []).find((s) => s.run?.includes("validate-release-green.mjs"));+ assert.doesNotMatch(validate?.run ?? "", /--suites-from/);+});++test("a suite job reports its name, exit code and first failure line", () => {+ assert.deepEqual(suiteResult("unit-3", "0", "ℹ pass 10"), {+ name: "unit-3",+ code: 0,+ detail: "pass",+ });+ assert.deepEqual(suiteResult("integration-2", "1", "✔ ok (1ms)\n✖ broken (2ms)\n"), {+ name: "integration-2",+ code: 1,+ detail: "✖ broken (2ms)",+ });+ assert.throws(() => suiteResult("unit-x; rm -rf /", "0", ""), /unknown suite name/);+ assert.throws(() => suiteResult("vitest", "abc", ""), /invalid exit code/);+});diff --git a/tests/unit/build/release-green-suite-provenance.test.mjs b/tests/unit/build/release-green-suite-provenance.test.mjsnew file mode 100644index 0000000000..866c5a5c82--- /dev/null+++ b/tests/unit/build/release-green-suite-provenance.test.mjs@@ -0,0 +1,364 @@+import assert from "node:assert/strict";+import { spawnSync } from "node:child_process";+import { createHash } from "node:crypto";+import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { join } from "node:path";+import { tmpdir } from "node:os";+import { fileURLToPath } from "node:url";+import test from "node:test";+import { load as parseYaml } from "js-yaml";++const root = fileURLToPath(new URL("../../../", import.meta.url));+const sha = "1".repeat(40);+const workflowSha = "3".repeat(40);+const hash = (value) => createHash("sha256").update(value).digest("hex");+const names = ["unit-1", "unit-2", "integration-1", "integration-2", "vitest"];+const log = "Tests 5 passed\n";+const command = (name) => ({+ script: name.startsWith("unit-")+ ? "test:unit:ci:shard"+ : name.startsWith("integration-")+ ? "test:integration:ci"+ : "test:vitest+test:vitest:ui",+ shard: name === "vitest" ? "" : `${name.split("-")[1]}/2`,+});++// Public observer JSON + exit, with only unrelated external commands substituted.+function observe(mutate = () => {}, { extra = false, workflow = workflowSha } = {}) {+ mkdirSync(join(root, "_artifacts"), { recursive: true });+ const dir = mkdtempSync(join(root, "_artifacts/suite-provenance-"));+ try {+ for (const path of [+ "scripts/quality",+ "scripts/ci",+ "config/quality",+ ".github/workflows",+ "bin",+ "suites",+ ])+ mkdirSync(join(dir, path), { recursive: true });+ writeFileSync(join(dir, "package.json"), '{"type":"commonjs"}');+ writeFileSync(join(dir, "package-lock.json"), "{}");+ for (const file of ["validate-release-green.mjs", "gate-process.mjs"])+ copyFileSync(join(root, "scripts/quality", file), join(dir, "scripts/quality", file));+ writeFileSync(+ join(dir, "config/quality/quality-baseline.json"),+ JSON.stringify({+ metrics: { cognitiveComplexity: { value: 0 }, eslintWarnings: { value: 0 } },+ })+ );+ writeFileSync(+ join(dir, ".github/workflows/ci.yml"),+ `jobs:+ test-unit:+ strategy: {matrix: {shard: [1, 2]}}+ steps:+ - env: {TEST_SHARD: "\${{ matrix.shard }}/2"}+ test-integration:+ strategy: {matrix: {shard: [1, 2]}}+ steps:+ - env: {TEST_SHARD: "\${{ matrix.shard }}/2"}+`+ );+ const executable = (name, body) =>+ writeFileSync(join(dir, "bin", name), `#!${process.execPath}\n${body}`, { mode: 0o755 });+ executable("git", `console.log("${sha}");`);+ executable("npx", 'console.log("[]");');+ executable(+ "npm",+ `+ if(process.argv[3] === "check:complexity-ratchets") console.log("complexity=0\\ncognitiveComplexity=0\\n[complexity] OK — 0 violações (baseline 0)\\n[cognitive-complexity] OK — 0 violações (baseline 0)");+ if(process.argv[3] === "check:workflows") console.log("workflowAuditState=MEASURED\\nworkflowFindings=0\\nprovenanceRunnerFindings=0\\nscheduledGuardFindings=0");+ `+ );+ for (const name of names) {+ const receipt = {+ schemaVersion: 1,+ name,+ code: 0,+ detail: "pass",+ candidateSha: sha,+ workflowSha,+ runId: "101",+ runAttempt: "2",+ nodeVersion: process.version,+ lockfileSha256: hash("{}"),+ logSha256: hash(log),+ ...command(name),+ };+ if (name === "unit-1") mutate(receipt);+ writeFileSync(join(dir, "suites", `${name}.json`), JSON.stringify(receipt));+ writeFileSync(join(dir, "suites", `${name}.log`), log);+ }+ if (extra)+ writeFileSync(+ join(dir, "suites/duplicate.json"),+ readFileSync(join(dir, "suites/unit-1.json"))+ );+ const result = spawnSync(+ process.execPath,+ [+ join(dir, "scripts/quality/validate-release-green.mjs"),+ "--json",+ "--suites-from",+ join(dir, "suites"),+ "--suites-workflow-sha",+ workflow,+ ],+ {+ cwd: dir,+ encoding: "utf8",+ timeout: 20000,+ env: {+ ...process.env,+ PATH: join(dir, "bin"),+ GITHUB_RUN_ID: "101",+ GITHUB_RUN_ATTEMPT: "2",+ GITHUB_OUTPUT: "",+ },+ }+ );+ assert.equal(result.error, undefined);+ const report = JSON.parse(result.stdout);+ assert.deepEqual(+ report.hardFailures.filter(+ (entry) => !["unit", "integration", "vitest", "hosted-suites"].includes(entry.id)+ ),+ [],+ result.stderr+ );+ return { status: result.status, report };+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+}++test(+ "the observer rejects a successful hosted suite from a different candidate",+ { skip: process.platform === "win32" },+ () => {+ const result = observe((receipt) => {+ receipt.candidateSha = "2".repeat(40);+ });+ assert.equal(result.status, 1);+ assert.equal(result.report.releaseGreen, false);+ }+);++test(+ "the observer rejects a successful hosted suite from an earlier run attempt",+ { skip: process.platform === "win32" },+ () => {+ const result = observe((receipt) => {+ receipt.runAttempt = "1";+ });+ assert.equal(result.status, 1);+ assert.equal(result.report.releaseGreen, false);+ }+);++test(+ "the observer rejects a receipt whose retained log does not match its hash",+ { skip: process.platform === "win32" },+ () => {+ const result = observe((receipt) => {+ receipt.logSha256 = "f".repeat(64);+ });+ assert.equal(result.status, 1);+ assert.equal(result.report.releaseGreen, false);+ }+);++test(+ "an extra or duplicated receipt cannot be silently discarded",+ { skip: process.platform === "win32" },+ () => {+ const result = observe(() => {}, { extra: true });+ assert.equal(result.status, 1);+ assert.equal(result.report.releaseGreen, false);+ }+);++test(+ "an empty exit-code argument cannot become a successful receipt",+ { skip: process.platform === "win32" },+ () => {+ const result = writeReceipt({ code: "" });+ assert.notEqual(result.status, 0);+ assert.equal(result.receipt, undefined);+ }+);++test(+ "the writer cannot certify a suite without a readable nonempty log",+ { skip: process.platform === "win32" },+ () => {+ const result = writeReceipt({ missingLog: true });+ assert.notEqual(result.status, 0);+ assert.equal(result.receipt, undefined);+ }+);++function writeReceipt({ code = "0", missingLog = false, context = true } = {}) {+ const dir = mkdtempSync(join(tmpdir(), "hosted-suite-writer-"));+ try {+ mkdirSync(join(dir, "bin"));+ writeFileSync(join(dir, "bin/git"), `#!${process.execPath}\nconsole.log("${sha}");`, {+ mode: 0o755,+ });+ writeFileSync(join(dir, "package-lock.json"), "{}");+ if (!missingLog) writeFileSync(join(dir, "suite.log"), log);+ const result = spawnSync(+ process.execPath,+ [+ join(root, "scripts/ci/release-green-suite.mjs"),+ "unit-1",+ code,+ "suite.log",+ "out",+ workflowSha,+ "test:unit:ci:shard",+ "1/2",+ ],+ {+ cwd: dir,+ encoding: "utf8",+ timeout: 10000,+ env: {+ ...process.env,+ PATH: join(dir, "bin"),+ GITHUB_RUN_ID: context ? "101" : "",+ GITHUB_RUN_ATTEMPT: "2",+ },+ }+ );+ let receipt, evidenceLog;+ try {+ receipt = JSON.parse(readFileSync(join(dir, "out/unit-1.json"), "utf8"));+ } catch {}+ try {+ evidenceLog = readFileSync(join(dir, "out/unit-1.log"), "utf8");+ } catch {}+ return { ...result, receipt, evidenceLog };+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+}++test(+ "the suite writer binds JSON and retained log to the actual execution identity",+ { skip: process.platform === "win32" },+ () => {+ const result = writeReceipt();+ assert.equal(result.status, 0, result.stderr);+ assert.equal(result.receipt.candidateSha, sha);+ assert.equal(result.receipt.workflowSha, workflowSha);+ assert.equal(result.receipt.runId, "101");+ assert.equal(result.receipt.runAttempt, "2");+ assert.equal(result.receipt.nodeVersion, process.version);+ assert.equal(result.receipt.lockfileSha256, hash("{}"));+ assert.equal(result.receipt.logSha256, hash(log));+ assert.equal(result.receipt.script, "test:unit:ci:shard");+ assert.equal(result.receipt.shard, "1/2");+ assert.equal(result.evidenceLog, log);+ }+);++test(+ "complete matching receipts retain a passing observer verdict",+ { skip: process.platform === "win32" },+ () => {+ const result = observe();+ assert.equal(result.status, 0);+ assert.equal(result.report.releaseGreen, true);+ }+);++test(+ "the public observer requires the workflow commit argument for hosted receipts",+ { skip: process.platform === "win32" },+ () => {+ const result = observe(() => {}, { workflow: "" });+ assert.equal(result.status, 1);+ assert.equal(result.report.releaseGreen, false);+ }+);++test(+ "the hosted job fails when its receipt writer cannot persist evidence",+ { skip: process.platform === "win32" },+ () => {+ const dir = mkdtempSync(join(tmpdir(), "hosted-suite-shell-"));+ try {+ for (const [name, body] of [+ ["npm", 'console.log("test passed");'],+ ["node", "process.exit(23);"],+ ]) {+ writeFileSync(join(dir, name), `#!${process.execPath}\n${body}`, { mode: 0o755 });+ }+ const workflow = parseYaml(+ readFileSync(join(root, ".github/workflows/nightly-release-green.yml"), "utf8")+ );+ const step = workflow.jobs.suites.steps.find((item) =>+ item.run?.includes("scripts/ci/release-green-suite.mjs")+ );+ const result = spawnSync("bash", ["-c", step.run], {+ cwd: dir,+ encoding: "utf8",+ timeout: 10000,+ env: {+ ...process.env,+ PATH: `${dir}:${process.env.PATH}`,+ NAME: "unit-1",+ SUITE: "test:unit:ci:shard",+ TEST_SHARD: "1/8",+ GITHUB_WORKFLOW_SHA: workflowSha,+ },+ });+ assert.equal(result.error, undefined);+ assert.equal(result.status, 23, result.stdout + result.stderr);+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ }+);++for (const [key, value] of Object.entries({+ schemaVersion: 0,+ runId: "100",+ workflowSha: "4".repeat(40),+ nodeVersion: "v24.0.0",+ lockfileSha256: "0".repeat(64),+ script: "test:unit:fast",+ shard: "1/8",+ code: 256,+})) {+ test(+ `receipt ${key} mismatch is not a successful execution`,+ { skip: process.platform === "win32" },+ () => {+ const result = observe((receipt) => {+ receipt[key] = value;+ });+ assert.equal(result.status, 1);+ assert.equal(result.report.releaseGreen, false);+ }+ );+}++test(+ "a complete failing suite stays a failure and missing context cannot write a receipt",+ { skip: process.platform === "win32" },+ () => {+ assert.equal(+ observe((receipt) => {+ receipt.code = 1;+ receipt.detail = "failed assertion";+ }).status,+ 1+ );+ const result = writeReceipt({ context: false });+ assert.notEqual(result.status, 0);+ assert.equal(result.receipt, undefined);+ }+);diff --git a/tests/unit/build/release-green-workflow-verdict.test.ts b/tests/unit/build/release-green-workflow-verdict.test.tsindex 87ddc43d7f..ffa08638a1 100644--- a/tests/unit/build/release-green-workflow-verdict.test.ts+++ b/tests/unit/build/release-green-workflow-verdict.test.ts@@ -40,6 +40,7 @@ function execute(job: string, validatorExit: number, report: string, event = "sc...process.env,EVENT_NAME: event,GITHUB_OUTPUT: outputs,+ GITHUB_WORKFLOW_SHA: "3".repeat(40),FIXTURE_EXIT: String(validatorExit),FIXTURE_REPORT: report,VALIDATED_SHA: sha,diff --git a/tests/unit/cli-env-quality-docs-mirrors.test.ts b/tests/unit/cli-env-quality-docs-mirrors.test.tsindex 90baa8856b..30e6e27d17 100644--- a/tests/unit/cli-env-quality-docs-mirrors.test.ts+++ b/tests/unit/cli-env-quality-docs-mirrors.test.ts@@ -63,14 +63,20 @@ test("CodeBuddy rows preserve the opt-in cap and replacement provenance in every}});-test("the two source-delta mirror records describe current source and translated bytes", () => {+test("the two source-delta mirror records describe the translated bytes", () => {+ // Whether the English source moved on since the translation is the i18n drift gate's call+ // (scripts/i18n/check-translation-drift.mjs — PR-scoped since 2026-10-20); pinning it here+ // turned every inherited drift of ENVIRONMENT.md into a red unit shard on unrelated PRs+ // (release/v3.8.53, translation backend down). What a unit test CAN pin is that each mirror+ // still holds the bytes its record describes — no hand edit, no truncated write.for (const relative of [envDoc, qualityDoc]) {- const sourceHash = hash(read(relative));- assert.equal(state.sources[relative].source_hash, sourceHash);for (const locale of locales) {const record = state.sources[relative].locales[locale];- assert.equal(record.source_hash, sourceHash);- assert.equal(record.target_hash, hash(read(`docs/i18n/${locale}/${relative}`)));+ assert.equal(+ record.target_hash,+ hash(read(`docs/i18n/${locale}/${relative}`)),+ `${locale}: ${relative} mirror bytes differ from the recorded translation`+ );}}});diff --git a/tests/unit/docs/remote-token-privilege-locales.test.ts b/tests/unit/docs/remote-token-privilege-locales.test.tsindex c98e33ca75..323336fd94 100644--- a/tests/unit/docs/remote-token-privilege-locales.test.ts+++ b/tests/unit/docs/remote-token-privilege-locales.test.ts@@ -7,7 +7,6 @@ import test from "node:test";const root = resolve(import.meta.dirname, "../../..");const sourcePath = "docs/guides/REMOTE-MODE.md";const hash = (text: string) => createHash("sha256").update(text).digest("hex");-const sourceHash = hash(readFileSync(resolve(root, sourcePath), "utf8"));const state = JSON.parse(readFileSync(resolve(root, ".i18n-state.json"), "utf8")) as {sources: Record<string,@@ -19,9 +18,11 @@ const state = JSON.parse(readFileSync(resolve(root, ".i18n-state.json"), "utf8")};const entry = state.sources[sourcePath];+// Source freshness (does the English doc still match .i18n-state.json) is the i18n drift gate's call —+// check-translation-drift.mjs, PR-scoped since 2026-10-20. This test pins what no gate re-checks: the+// translated section is present in every locale and each mirror still holds the bytes its record describes.test("remote token privilege guidance is translated, not only marked current", () => {assert.equal(Object.keys(entry.locales).length, 66);- assert.equal(entry.source_hash, sourceHash);for (const [locale, info] of Object.entries(entry.locales)) {const text = readFileSync(resolve(root, "docs/i18n", locale, sourcePath), "utf8");const start = text.indexOf("omniroute tokens scopes");@@ -40,7 +41,6 @@ test("remote token privilege guidance is translated, not only marked current", (assert(section.includes("`" + literal + "`"), `missing ${literal}: ${locale}`);}assert(!section.includes("A token can never be minted"), `English fallback: ${locale}`);- assert.equal(info.source_hash, sourceHash, `stale source hash: ${locale}`);assert.equal(info.target_hash, hash(text), `stale target hash: ${locale}`);}});diff --git a/tests/unit/docs/route-guard-import-locales.test.ts b/tests/unit/docs/route-guard-import-locales.test.tsindex 6462c97966..c4401ae5fb 100644--- a/tests/unit/docs/route-guard-import-locales.test.ts+++ b/tests/unit/docs/route-guard-import-locales.test.ts@@ -7,7 +7,6 @@ import test from "node:test";const root = resolve(import.meta.dirname, "../../..");const sourcePath = "docs/security/ROUTE_GUARD_TIERS.md";const hash = (text: string) => createHash("sha256").update(text).digest("hex");-const sourceHash = hash(readFileSync(resolve(root, sourcePath), "utf8"));const state = JSON.parse(readFileSync(resolve(root, ".i18n-state.json"), "utf8")) as {sources: Record<string,@@ -19,9 +18,11 @@ const state = JSON.parse(readFileSync(resolve(root, ".i18n-state.json"), "utf8")};const entry = state.sources[sourcePath];+// Source freshness (does the English doc still match .i18n-state.json) is the i18n drift gate's call —+// check-translation-drift.mjs, PR-scoped since 2026-10-20. This test pins what no gate re-checks: the+// translated section is present in every locale and each mirror still holds the bytes its record describes.test("route-guard import and snapshot protection is translated in every mirror", () => {assert.equal(Object.keys(entry.locales).length, 66);- assert.equal(entry.source_hash, sourceHash);for (const [locale, info] of Object.entries(entry.locales)) {const text = readFileSync(resolve(root, "docs/i18n", locale, sourcePath), "utf8");// The policy paragraph runs from the Kiro auto-import deny-list entry (#16691) to the@@ -37,7 +38,6 @@ test("route-guard import and snapshot protection is translated in every mirror",`missing deny-list proof: ${locale}`);assert(!section.includes("The runtime snapshot loader"), `English fallback: ${locale}`);- assert.equal(info.source_hash, sourceHash, `stale source hash: ${locale}`);assert.equal(info.target_hash, hash(text), `stale target hash: ${locale}`);}});diff --git a/tests/unit/docs/vision-key-scope-locales.test.ts b/tests/unit/docs/vision-key-scope-locales.test.tsindex 2616c1ae7a..d2b2b714ad 100644--- a/tests/unit/docs/vision-key-scope-locales.test.ts+++ b/tests/unit/docs/vision-key-scope-locales.test.ts@@ -7,7 +7,6 @@ import test from "node:test";const root = resolve(import.meta.dirname, "../../..");const sourcePath = "docs/security/GUARDRAILS.md";const hash = (text: string) => createHash("sha256").update(text).digest("hex");-const sourceHash = hash(readFileSync(resolve(root, sourcePath), "utf8"));const state = JSON.parse(readFileSync(resolve(root, ".i18n-state.json"), "utf8")) as {sources: Record<string,@@ -15,10 +14,12 @@ const state = JSON.parse(readFileSync(resolve(root, ".i18n-state.json"), "utf8")>;};+// Source freshness (does the English doc still match .i18n-state.json) is the i18n drift gate's call —+// check-translation-drift.mjs, PR-scoped since 2026-10-20. This test pins what no gate re-checks: the+// translated section is present in every locale and each mirror still holds the bytes its record describes.test("vision bridge key scope is translated without certifying stale locale content", () => {const entry = state.sources[sourcePath];assert.equal(Object.keys(entry.locales).length, 66);- assert.equal(entry.source_hash, sourceHash);for (const [locale, info] of Object.entries(entry.locales)) {const text = readFileSync(resolve(root, "docs/i18n", locale, sourcePath), "utf8");const start = text.indexOf("visionBridgeKeyScope.ts");@@ -39,7 +40,6 @@ test("vision bridge key scope is translated without certifying stale locale contassert(section.includes(literal), `missing ${literal}: ${locale}`);}assert(!section.includes("When the caller's API key restricts"), `English fallback: ${locale}`);- assert.equal(info.source_hash, sourceHash, `stale source hash: ${locale}`);assert.equal(info.target_hash, hash(text), `stale target hash: ${locale}`);}});diff --git a/tests/unit/resilience-pre-dispatch-docs-mirrors.test.ts b/tests/unit/resilience-pre-dispatch-docs-mirrors.test.tsindex 6414fb12b4..5fdffe7540 100644--- a/tests/unit/resilience-pre-dispatch-docs-mirrors.test.ts+++ b/tests/unit/resilience-pre-dispatch-docs-mirrors.test.ts@@ -57,12 +57,18 @@ test("every resilience mirror includes the pre-dispatch retry and terminal contrassert.equal(missing.length, 0, missing.slice(0, 8).join(", "));});-test("resilience mirror provenance describes current source and target bytes", () => {+test("resilience mirror provenance describes the translated target bytes", () => {+ // Source-vs-state drift is the i18n drift gate's call (check-translation-drift.mjs, PR-scoped+ // since 2026-10-20) — asserting it here made every inherited RESILIENCE_GUIDE drift a red unit+ // shard on unrelated PRs. The unit test pins what no gate re-checks: each mirror still holds+ // the bytes its record describes.const entry = state.sources[relativeSource];- assert.equal(entry.source_hash, hash(current));for (const [locale, info] of Object.entries(entry.locales)) {- assert.equal(info.source_hash, hash(current));- assert.equal(info.target_hash, hash(read(`docs/i18n/${locale}/${relativeSource}`)));+ assert.equal(+ info.target_hash,+ hash(read(`docs/i18n/${locale}/${relativeSource}`)),+ `${locale}: mirror bytes differ from the recorded translation`+ );}});diff --git a/tests/unit/validate-release-green.test.ts b/tests/unit/validate-release-green.test.tsindex 312bce36e2..ac3b133135 100644--- a/tests/unit/validate-release-green.test.ts+++ b/tests/unit/validate-release-green.test.ts@@ -20,6 +20,10 @@ const {fullCiKindFor,ESLINT_TIMEOUT_MS,unitShardCountFromCi,+ shardCountFromCi,+ hostedSuiteNames,+ parseHostedSuiteResult,+ foldHostedSuiteResults,unitShardPool,runPool,mergeUnitShardResults,@@ -293,10 +297,10 @@ test("pre-flight runs the heavy lanes one at a time, with unit split like ci.ymlassert.doesNotMatch(src, /Promise\.all\(\s*slow\.map\(/, "no parallel wave of heavy lanes");assert.match(src,- /for \(const g of slow\) \{\s*announce\(g\.label\);\s*const result = await \(/,+ /for \(const g of lanes\) \{\s*announce\(g\.label\);\s*const result = await \(/,"each heavy lane must be awaited before the next one starts");- const wave = src.slice(src.indexOf("const slow = ["), src.indexOf("for (const g of slow)"));+ const wave = src.slice(src.indexOf("const slow = ["), src.indexOf("for (const g of lanes)"));const order = ["unit", "integration", "vitest", "pack-artifact"].map((id) =>wave.indexOf(`id: "${id}"`));@@ -426,7 +430,7 @@ test("pre-flight runs tarball boot only after the package artifact builder complnew URL("../../scripts/quality/validate-release-green.mjs", import.meta.url),"utf8");- const laneLoop = src.indexOf("for (const g of slow)");+ const laneLoop = src.indexOf("for (const g of lanes)");const packBoot = src.indexOf('id: "pack-boot"');assert.ok(laneLoop >= 0, "the sequential slow-lane loop must exist");@@ -712,3 +716,94 @@ jobs:const ids = extract(yaml).map((g) => g.id);assert.deepEqual(ids, ["check:public-creds", "check:db-rules"]);});++// ─── Hosted suites (2026-10-20): unit/integration/vitest run as hosted jobs ──────++test("hosted suites: the REAL ci.yml yields the integration shard count too", async () => {+ const fs = await import("node:fs");+ const ci = fs.readFileSync(new URL("../../.github/workflows/ci.yml", import.meta.url), "utf8");+ const integration = shardCountFromCi(ci, "test-integration");+ assert.ok(+ Number.isInteger(integration) && integration >= 2,+ `integration shards: ${integration}`+ );+ assert.equal(shardCountFromCi(ci, "no-such-job"), null);+});++test("hosted suites: names list unit shards, integration shards, then vitest", () => {+ assert.deepEqual(hostedSuiteNames(2, 2), [+ "unit-1",+ "unit-2",+ "integration-1",+ "integration-2",+ "vitest",+ ]);+});++test("hosted suites: a malformed result file is no result", () => {+ assert.deepEqual(parseHostedSuiteResult('{"name":"unit-1","code":0,"detail":"pass"}'), {+ name: "unit-1",+ code: 0,+ detail: "pass",+ });+ assert.equal(parseHostedSuiteResult("not json"), null);+ assert.equal(parseHostedSuiteResult('{"name":"unit-1","code":"0"}'), null);+ assert.equal(parseHostedSuiteResult('{"code":0}'), null);+});++test("hosted suites fold into the unit/integration/vitest gates the verdict already reads", () => {+ const green = foldHostedSuiteResults(+ [+ { name: "unit-1", code: 0, detail: "pass" },+ { name: "unit-2", code: 0, detail: "pass" },+ { name: "integration-1", code: 0, detail: "pass" },+ { name: "vitest", code: 0, detail: "pass" },+ ],+ { unitShards: 2, integrationShards: 1 }+ );+ assert.deepEqual(+ green.map((g) => [g.id, g.kind, g.ok, g.detail]),+ [+ ["unit", "hard", true, "pass"],+ ["integration", "hard", true, "pass"],+ ["vitest", "hard", true, "pass"],+ ]+ );++ const red = foldHostedSuiteResults(+ [+ { name: "unit-1", code: 124, detail: "Error: fixture noise" },+ { name: "unit-3", code: 1, detail: "✖ broken test (5ms)" },+ { name: "integration-1", code: 0, detail: "pass" },+ null,+ ],+ { unitShards: 3, integrationShards: 2 }+ );+ const byId = Object.fromEntries(red.map((g) => [g.id, g]));+ assert.equal(byId.unit.ok, false);+ assert.equal(+ byId.unit.detail,+ "unit-1 TIMEOUT, unit-2 no result, unit-3 exit 1 — ✖ broken test (5ms)"+ );+ assert.equal(byId.integration.ok, false, "a shard that never reported fails the lane");+ assert.equal(byId.integration.detail, "integration-2 no result");+ assert.equal(byId.vitest.ok, false);+ assert.equal(byId.vitest.detail, "vitest no result");+});++test("--suites-from replaces the local suite lanes and keeps only the build on the slot", async () => {+ const fs = await import("node:fs");+ const src = fs.readFileSync(+ new URL("../../scripts/quality/validate-release-green.mjs", import.meta.url),+ "utf8"+ );+ assert.match(src, /process\.argv\.indexOf\("--suites-from"\)/);+ assert.match(+ src,+ /const lanes = SUITES_FROM \? slow\.filter\(\(g\) => g\.id === "pack-artifact"\) : slow;/+ );+ assert.match(src, /foldHostedSuiteResults\(results, \{ unitShards, integrationShards \}\)/);+ // the webpack build gets the docker-publish heap instead of build-next-isolated's 8192 MB+ assert.match(src, /const BUILD_GATE_ENV = \{ OMNIROUTE_BUILD_MEMORY_MB: "12288" \};/);+ assert.match(src, /args: \["run", "build:cli"\], env: BUILD_GATE_ENV/);+});