Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: align local PostgreSQL gate with validated suite inventory
Alfredo Lopez40e94910b86c
diff --git a/docs/testing/minikube-t2-runbook.md b/docs/testing/minikube-t2-runbook.mdindex 97103dfb3..8c9e29327 100644--- a/docs/testing/minikube-t2-runbook.md+++ b/docs/testing/minikube-t2-runbook.md@@ -393,6 +393,11 @@ non-T2 scope guard.`testResults[].name` set must exactly equal the selected physical files, andthe Vitest process must also exit zero; a green reporter cannot hideteardown, worker, OOM, signal, or partial-selection failure.+ Control API selection uses the same validated `publicPostgres` census as CI+ in `tests/contracts/password-recovery-suites.json`. Both private producer+ suites must still exist, but their execution is a separate+ [private PostgreSQL lane](password-recovery-private-postgres.md), reported as+ `NOT_RUN` by T1. A T1 pass does not verify Member Registration integration.* **T2** — the final exact-head preflight inside `make minikube-t2` (or`make minikube-t2-runtime`): the marker matches this worktree/`HEAD`, theimage manifest is current, PostgreSQL and required namespaces/Services arediff --git a/scripts/ci/password-recovery-suite-contract.mjs b/scripts/ci/password-recovery-suite-contract.mjsindex 1e81f8b06..c1f3d2e4c 100644--- a/scripts/ci/password-recovery-suite-contract.mjs+++ b/scripts/ci/password-recovery-suite-contract.mjs@@ -102,6 +102,8 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)console.log(`Recovery suite contract: ${manifest.publicPostgres.length} public PostgreSQL suites; 2 private exclusions`)+ else if (command === 'public' && !lane && !path)+ console.log(manifest.publicPostgres.join('\n'))else if (command === 'private' && ['local', 'configured', 'all'].includes(lane) && !path)console.log((lane === 'all'@@ -117,7 +119,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)console.log(`Recovery ${lane} report: complete and passing`)} elsethrow new Error(- 'Usage: password-recovery-suite-contract.mjs verify | private local/configured/all | report lane report.json'+ 'Usage: password-recovery-suite-contract.mjs verify | public | private local/configured/all | report lane report.json')} catch (error) {console.error(error.message)diff --git a/scripts/e2e/minikube-real-postgres.sh b/scripts/e2e/minikube-real-postgres.shindex 580dc0a2b..89c8a53a4 100755--- a/scripts/e2e/minikube-real-postgres.sh+++ b/scripts/e2e/minikube-real-postgres.sh@@ -318,7 +318,16 @@ PY}list_real_pg_files() {- local package="$1"+ local package="$1" file+ if [ "$package" = control-api ]; then+ # Reuse CI's validated census. Private producer suites require a separate+ # authorized service/database lane, documented in the private PG runbook.+ node "$PROJECT_DIR/scripts/ci/password-recovery-suite-contract.mjs" public |+ while IFS= read -r file; do+ printf '%s/%s\n' "$PROJECT_DIR" "$file"+ done+ return+ fifind "$PROJECT_DIR/$package" -type f -name '*realPostgres*.test.ts' \! -name 'realPostgres.requirement.ts' -print | sort}@@ -443,10 +452,15 @@ PYrun_suite() {local package="$1" lane="$2" admin_url="$3"- local expected_files=0 reported_files=0 file log_file json_file stats+ local expected_files=0 reported_files=0 file log_file json_file stats selectionlocal suite_started_seconds="$SECONDS" suite_duration_seconds=0local -a files=() vitest_filters=()+ if ! selection="$(list_real_pg_files "$package")"; then+ T1_NEXT_COMMAND='restore the exact PostgreSQL suite manifest and its files, then re-run T1'+ die_t1 REAL_PG_REPORT_INCOMPLETE "PostgreSQL suite inventory could not be validated for $package"+ return 1+ fiwhile IFS= read -r file; do[ -z "$file" ] && continueif [ "$package" = control-api ]; then@@ -460,7 +474,7 @@ run_suite() {fifiles+=("$file")vitest_filters+=("${file#"$PROJECT_DIR/$package/"}")- done < <(list_real_pg_files "$package")+ done <<< "$selection"expected_files="${#files[@]}"if ! [[ "$expected_files" =~ ^[1-9][0-9]*$ ]]; then@@ -472,6 +486,10 @@ run_suite() {die_t1 REAL_PG_REQUIRED_BUT_UNAVAILABLE "Real PostgreSQL $lane DSN is empty for $package"fi+ if [ "$package" = control-api ]; then+ printf '[minikube-t1] private producer PostgreSQL lanes: NOT_RUN; see docs/testing/password-recovery-private-postgres.md\n'+ t2_evidence_write private-producer NOT_RUN 'Member Registration producer suites require the separate private PostgreSQL lane'+ filog_file="$T1_TMP_DIR/$(printf '%s' "$package-$lane" | tr / _).log"json_file="$T1_TMP_DIR/$(printf '%s' "$package-$lane" | tr / _).json"printf '[minikube-t1] running %s %s Real PostgreSQL suites (%s files)\n' \diff --git a/scripts/tests/password-recovery-suite-contract.test.mjs b/scripts/tests/password-recovery-suite-contract.test.mjsindex 1cc4f4094..2f602f2d9 100644--- a/scripts/tests/password-recovery-suite-contract.test.mjs+++ b/scripts/tests/password-recovery-suite-contract.test.mjs@@ -3,7 +3,7 @@ import { spawnSync } from 'node:child_process'import fs from 'node:fs'import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'import { syncBuiltinESMExports } from 'node:module'-import { join } from 'node:path'+import { dirname, join } from 'node:path'import test from 'node:test'import { fileURLToPath } from 'node:url'import { reportViolations, verifySuiteManifest } from '../ci/password-recovery-suite-contract.mjs'@@ -176,6 +176,97 @@ for (const [label, mutate] of [test('unknown report lane rejects', () =>assert.notDeepEqual(reportViolations(root, manifest, 'unknown', green()), []))+function withMinikubeSelectionFixture(run) {+ const scratchRoot = process.env.CODEX_SCRATCH_ROOT+ assert.ok(scratchRoot, 'CODEX_SCRATCH_ROOT is required for selection fixtures')+ mkdirSync(scratchRoot, { recursive: true })+ const fixture = mkdtempSync(join(scratchRoot, 'minikube-pg-selection-'))+ try {+ for (const directory of ['scripts/ci', 'tests/contracts', 'gfs-controller/test'])+ mkdirSync(join(fixture, directory), { recursive: true })+ for (const file of [+ 'scripts/ci/password-recovery-suite-contract.mjs',+ 'scripts/ci/assert-pinned-vitest-suites.mjs',+ 'tests/contracts/password-recovery-suites.json',+ ])+ copyFileSync(join(root, file), join(fixture, file))+ // Only inventory discovery runs here; these synthetic files are never executed.+ for (const file of [+ ...manifest.publicPostgres,+ ...Object.values(manifest.privatePostgres),+ ...manifest.composedContract,+ ...manifest.consumer,+ 'gfs-controller/test/public.realPostgres.test.ts',+ ]) {+ mkdirSync(dirname(join(fixture, file)), { recursive: true })+ writeFileSync(join(fixture, file), '// synthetic suite inventory entry\n')+ }+ run(fixture)+ } finally {+ rmSync(fixture, { recursive: true, force: true })+ }+}++function minikubeSelection(fixture, packageName = 'control-api', runSuite = false) {+ return spawnSync(+ '/bin/bash',+ [+ '-c',+ `source "$TASK_T1_SOURCE"+trap - EXIT INT TERM+PROJECT_DIR="$TASK_SELECTION_ROOT"+if [ "$TASK_RUN_SUITE" = true ]; then+ t2_evidence_write() { :; }+ npm() { printf launched > "$TASK_SELECTION_ROOT/npm-launched"; return 97; }+ T1_TMP_DIR="$TASK_SELECTION_ROOT"+ run_suite control-api isolated synthetic-inventory-only+else+ list_real_pg_files "$TASK_SELECTION_PACKAGE"+fi`,+ ],+ {+ encoding: 'utf8',+ timeout: 5000,+ env: {+ ...process.env,+ TASK_T1_SOURCE: join(root, 'scripts/e2e/minikube-real-postgres.sh'),+ TASK_SELECTION_ROOT: fixture,+ TASK_SELECTION_PACKAGE: packageName,+ TASK_RUN_SUITE: String(runSuite),+ },+ }+ )+}++test('Minikube T1 selects the exact public inventory and preserves GFS discovery', () => {+ withMinikubeSelectionFixture(fixture => {+ const control = minikubeSelection(fixture)+ assert.equal(control.status, 0, control.stderr)+ assert.deepEqual(+ control.stdout.trim().split('\n').sort(),+ manifest.publicPostgres.map(file => join(fixture, file)).sort()+ )+ const gfs = minikubeSelection(fixture, 'gfs-controller')+ assert.equal(gfs.status, 0, gfs.stderr)+ assert.equal(gfs.stdout.trim(), join(fixture, 'gfs-controller/test/public.realPostgres.test.ts'))+ })+})++for (const fault of ['missing-private-suite', 'unregistered-suite']) {+ test(`Minikube T1 rejects ${fault} before launching npm`, () => {+ withMinikubeSelectionFixture(fixture => {+ if (fault === 'missing-private-suite') rmSync(join(fixture, manifest.privatePostgres.local))+ else writeFileSync(join(fixture, 'control-api/test/unregistered.realPostgres.test.ts'), '// fixture\n')+ const selection = minikubeSelection(fixture)+ assert.notEqual(selection.status, 0, 'invalid census must fail selection')+ const execution = minikubeSelection(fixture, 'control-api', true)+ assert.notEqual(execution.status, 0)+ assert.match(execution.stderr, /REAL_PG_REPORT_INCOMPLETE/)+ assert.equal(fs.existsSync(join(fixture, 'npm-launched')), false)+ })+ })+}+// 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']) {diff --git a/scripts/tests/test-minikube-t1-reporter-report.sh b/scripts/tests/test-minikube-t1-reporter-report.shindex 21e818c14..77cea2c3f 100755--- a/scripts/tests/test-minikube-t1-reporter-report.sh+++ b/scripts/tests/test-minikube-t1-reporter-report.sh@@ -347,6 +347,9 @@ PYPROJECT_DIR="$RUN_PROJECT"T1_TMP_DIR="$RUN_TMP"T1_REDACT_PASSWORD="$RUN_PASSWORD"+ # This fixture tests reporter failures; inventory validation has its own+ # real-selector contract in password-recovery-suite-contract.test.mjs.+ list_real_pg_files() { printf "%s\n" "$RUN_FILE"; }run_suite control-api isolated "$1"' bash "$dsn_scheme://isolated" >"$TEST_DIR/run-suite.out" 2>"$run_err"run_status=$?diff --git a/scripts/tests/test-minikube-t2-contract.sh b/scripts/tests/test-minikube-t2-contract.shindex b115e8dac..8621c7871 100755--- a/scripts/tests/test-minikube-t2-contract.sh+++ b/scripts/tests/test-minikube-t2-contract.sh@@ -62,6 +62,7 @@ done"$ROOT/scripts/tests/test-minikube-t1-port-forward-owner.sh""$ROOT/scripts/tests/test-minikube-t2-process-owner.sh""$ROOT/scripts/tests/test-minikube-t1-reporter-report.sh"+CODEX_SCRATCH_ROOT="$TMP_ROOT" node --test "$ROOT/scripts/tests/password-recovery-suite-contract.test.mjs""$ROOT/scripts/tests/test-minikube-explicit-context.sh""$ROOT/scripts/tests/test-minikube-t2-evidence.sh""$ROOT/scripts/tests/test-minikube-targeted-health.sh"