Skip to content

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

TypeScript

fix: use native module identity for the suite policy CLI

Alfredo Lopez83ae4683a374
diff --git a/scripts/ci/password-recovery-suite-contract.mjs b/scripts/ci/password-recovery-suite-contract.mjs
index c1f3d2e4c..14aaf69e6 100644
--- a/scripts/ci/password-recovery-suite-contract.mjs
+++ b/scripts/ci/password-recovery-suite-contract.mjs
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { closeSync, constants, fstatSync, openSync, readFileSync, readdirSync } from 'node:fs'
import { dirname, relative, resolve } from 'node:path'
-import { fileURLToPath, pathToFileURL } from 'node:url'
+import { fileURLToPath } from 'node:url'
import { pinnedSuiteViolations } from './assert-pinned-vitest-suites.mjs'
export function verifySuiteManifest(root, manifest) {
@@ -88,7 +88,7 @@ export function reportViolations(root, manifest, lane, report) {
return violations
}
-if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
+if (import.meta.main) {
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
try {
const manifest = verifySuiteManifest(
diff --git a/scripts/tests/password-recovery-suite-contract.test.mjs b/scripts/tests/password-recovery-suite-contract.test.mjs
index 2f602f2d9..c741681d7 100644
--- a/scripts/tests/password-recovery-suite-contract.test.mjs
+++ b/scripts/tests/password-recovery-suite-contract.test.mjs
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import fs from 'node:fs'
-import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
+import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
import { syncBuiltinESMExports } from 'node:module'
import { dirname, join } from 'node:path'
import test from 'node:test'
@@ -252,6 +252,21 @@ test('Minikube T1 selects the exact public inventory and preserves GFS discovery
})
})
+test('suite CLI validates the census through a symlinked entry point', () => {
+ withMinikubeSelectionFixture(fixture => {
+ const alias = join(fixture, 'suite-cli.mjs')
+ symlinkSync(join(fixture, 'scripts/ci/password-recovery-suite-contract.mjs'), alias)
+ const selected = spawnSync(process.execPath, [alias, 'public'], { encoding: 'utf8' })
+ assert.equal(selected.status, 0, selected.stderr)
+ assert.deepEqual(selected.stdout.trim().split('\n'), manifest.publicPostgres)
+
+ rmSync(join(fixture, manifest.privatePostgres.local))
+ const rejected = spawnSync(process.execPath, [alias, 'verify'], { encoding: 'utf8' })
+ assert.notEqual(rejected.status, 0, 'a symlinked CLI must still validate every declared suite')
+ assert.match(rejected.stderr, /ENOENT|Missing or empty recovery suite/)
+ })
+})
+
for (const fault of ['missing-private-suite', 'unregistered-suite']) {
test(`Minikube T1 rejects ${fault} before launching npm`, () => {
withMinikubeSelectionFixture(fixture => {