Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(ci): r10-m3 reject failed private recovery suite selection

Josué96edd855bfcc
diff --git a/.github/workflows/ci-public.yml b/.github/workflows/ci-public.yml
index 095ff8b1a..14cb4d8a7 100644
--- a/.github/workflows/ci-public.yml
+++ b/.github/workflows/ci-public.yml
@@ -369,6 +369,8 @@ jobs:
run: npm run build
- name: Validate recovery suite selection contract
+ env:
+ CODEX_SCRATCH_ROOT: ${{ runner.temp }}
run: node --test scripts/tests/password-recovery-suite-contract.test.mjs
- name: Run control-api real Postgres suites (migration + GFS)
diff --git a/scripts/ci/run-pr1056-private-recovery-postgres.sh b/scripts/ci/run-pr1056-private-recovery-postgres.sh
index 9b07357c0..e743afd99 100755
--- a/scripts/ci/run-pr1056-private-recovery-postgres.sh
+++ b/scripts/ci/run-pr1056-private-recovery-postgres.sh
@@ -28,7 +28,7 @@ require_environment() {
run_suite() {
local suite="$1"
local output
- if [[ ! -s "$CONTROL_API_DIR/$suite" ]]; then
+ if [[ -z "$suite" || "$suite" == *$'\n'* || ! -f "$CONTROL_API_DIR/$suite" || ! -s "$CONTROL_API_DIR/$suite" ]]; then
printf 'Required producer-backed suite is missing or empty: %s\n' "$suite" >&2
return 1
fi
@@ -57,7 +57,9 @@ run_local_producer_suite() {
printf 'Build External REST before the local composed producer suite\n' >&2
return 1
}
- run_suite "$(node "$REPO_ROOT/scripts/ci/password-recovery-suite-contract.mjs" private local)"
+ local suite
+ suite="$(node "$REPO_ROOT/scripts/ci/password-recovery-suite-contract.mjs" private local)" || return 1
+ run_suite "$suite"
}
run_configured_producer_suite() {
@@ -66,7 +68,9 @@ run_configured_producer_suite() {
CONTROL_API_REAL_MEMBER_REGISTRATION_PG_URL \
CONTROL_API_MEMBER_REGISTRATION_SERVICE_BASE_URL \
CONTROL_API_MEMBER_REGISTRATION_HMAC_SECRET
- run_suite "$(node "$REPO_ROOT/scripts/ci/password-recovery-suite-contract.mjs" private configured)"
+ local suite
+ suite="$(node "$REPO_ROOT/scripts/ci/password-recovery-suite-contract.mjs" private configured)" || return 1
+ run_suite "$suite"
}
case "$MODE" in
diff --git a/scripts/tests/password-recovery-suite-contract.test.mjs b/scripts/tests/password-recovery-suite-contract.test.mjs
index c44e0057a..4aba81148 100644
--- a/scripts/tests/password-recovery-suite-contract.test.mjs
+++ b/scripts/tests/password-recovery-suite-contract.test.mjs
@@ -1,5 +1,7 @@
import assert from 'node:assert/strict'
-import { readFileSync } from 'node:fs'
+import { spawnSync } from 'node:child_process'
+import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
+import { join } from 'node:path'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
import { reportViolations, verifySuiteManifest } from '../ci/password-recovery-suite-contract.mjs'
@@ -124,3 +126,78 @@ for (const [label, mutate] of [
})
test('unknown report lane rejects', () =>
assert.notDeepEqual(reportViolations(root, manifest, 'unknown', green()), []))
+
+// Exercise shell selection with fake node/npm only; never execute a private producer suite.
+for (const mode of ['local', 'configured']) {
+ for (const selector of ['failure', 'empty', 'directory', 'multiple', 'valid']) {
+ test(`${mode} selector ${selector} enforces exact execution`, () => {
+ const scratchRoot = process.env.CODEX_SCRATCH_ROOT
+ assert.ok(scratchRoot, 'CODEX_SCRATCH_ROOT is required for hermetic runner fixtures')
+ const repositoryScratch = join(scratchRoot, 'evenfire')
+ mkdirSync(repositoryScratch, { recursive: true })
+ const fixture = mkdtempSync(join(repositoryScratch, 'recovery-selector-'))
+ try {
+ for (const directory of [
+ 'scripts/ci',
+ 'control-api/test',
+ 'external-rest-api/dist',
+ 'bin',
+ 'node_modules/.bin',
+ ])
+ mkdirSync(join(fixture, directory), { recursive: true })
+ copyFileSync(
+ join(root, 'scripts/ci/run-pr1056-private-recovery-postgres.sh'),
+ join(fixture, 'scripts/ci/runner.sh')
+ )
+ writeFileSync(
+ join(fixture, 'external-rest-api/dist/app.js'),
+ '// synthetic build prerequisite\n'
+ )
+ writeFileSync(join(fixture, 'control-api/test/fake.test.ts'), '// fixture only\n')
+ mkdirSync(join(fixture, 'node_modules/.bin'), { recursive: true })
+ writeFileSync(join(fixture, 'node_modules/.bin/tsx'), '#!/bin/sh\nexit 91\n', {
+ mode: 0o755,
+ })
+ const output =
+ selector === 'failure'
+ ? 'exit 1'
+ : selector === 'empty'
+ ? 'exit 0'
+ : selector === 'directory'
+ ? "printf 'test/\\n'"
+ : selector === 'valid'
+ ? "printf 'test/fake.test.ts\\n'"
+ : "printf 'test/fake.test.ts\\ntest/fake.test.ts\\n'"
+ writeFileSync(join(fixture, 'bin/node'), '#!/bin/sh\n' + output + '\n', { mode: 0o755 })
+ const marker = join(fixture, 'test-launched')
+ writeFileSync(
+ join(fixture, 'bin/npm'),
+ '#!/bin/sh\nprintf launched > "$TASK_SELECTION_MARKER"\nprintf "Test Files 1 passed\\nTests 1 passed\\n"\n',
+ { mode: 0o755 }
+ )
+ const result = spawnSync('/bin/bash', [join(fixture, 'scripts/ci/runner.sh'), mode], {
+ timeout: 5000,
+ encoding: 'utf8',
+ env: {
+ PATH: join(fixture, 'bin') + ':' + process.env.PATH,
+ TASK_SELECTION_MARKER: marker,
+ CONTROL_API_REAL_PG_ADMIN_URL: 'synthetic-not-a-database',
+ CONTROL_API_REAL_MEMBER_REGISTRATION_PG_URL: 'synthetic-not-a-database',
+ CONTROL_API_MEMBER_REGISTRATION_SERVICE_BASE_URL: 'synthetic-not-a-service',
+ CONTROL_API_MEMBER_REGISTRATION_HMAC_SECRET: 'synthetic-fixture-only',
+ EVENFIRE_MEMBER_REGISTRATION_ROOT: fixture,
+ },
+ })
+ if (selector === 'valid') {
+ assert.equal(result.status, 0, 'valid exact fixture selection must run')
+ assert.equal(readFileSync(marker, 'utf8'), 'launched')
+ } else {
+ assert.notEqual(result.status, 0, 'invalid selector must fail before any test invocation')
+ assert.throws(() => readFileSync(marker), 'npm must never launch for invalid selection')
+ }
+ } finally {
+ rmSync(fixture, { recursive: true, force: true })
+ }
+ })
+ }
+}