Skip to content

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

TypeScript

test(llm): audit dedicated journey discovery from the selected root

Alfredo Lopez4f24f74160ec
diff --git a/scripts/tests/lib/subscription-t0-discovery.mjs b/scripts/tests/lib/subscription-t0-discovery.mjs
index d6f8a14ca..703cba470 100644
--- a/scripts/tests/lib/subscription-t0-discovery.mjs
+++ b/scripts/tests/lib/subscription-t0-discovery.mjs
@@ -4,7 +4,7 @@ import { pathToFileURL } from 'node:url'
export const namedRoots = [
'control-api', 'mcp-host', 'workflow-recipes', 'host-context-controller',
- 'control-ui', 'desktop-app', 'tests/e2e', 'scripts/e2e',
+ 'control-ui', 'desktop-app', 'tests/e2e', 'scripts/e2e', 'scripts/tests',
]
const excludedDirectories = new Set([
'node_modules', 'dist', '.next', 'coverage', '.git', 'test-results',
@@ -19,6 +19,7 @@ function realPgLane(file) {
}
export function isSubscriptionCandidate(file, provider) {
+ if (calibrationSuites.has(file)) return true
const name = path.posix.basename(file).toLowerCase()
const other = provider === 'codex' ? 'grok' : 'codex'
return name.includes(provider) ||
@@ -55,10 +56,16 @@ const otherLaneSuites = new Map([
['mcp-host/src/core/tools/__tests__/attachmentRead.test.ts', 'general-ci:mcp-host'],
['desktop-app/ui/src/lib/__tests__/chatMessageAttachments.test.ts', 'general-ci:desktop-app'],
])
+const calibrationSuites = new Map([
+ ['scripts/tests/measure-control-api-authorize-memory.test.mjs', 'calibration:control-api-memory'],
+])
const runtimeSuites = new Map([
['desktop-app/test/e2e-playwright/subscription-image-input.spec.ts', 'desktop-app/test/e2e-playwright/playwright.subscription-image.config.ts'],
['desktop-app/test/e2e-playwright/codex-image-input.spec.ts', 'desktop-app/test/e2e-playwright/playwright.codex-image.config.ts'],
['desktop-app/test/e2e-playwright/plugin-workload-sdk-codex-fallback.spec.ts', 'desktop-app/test/e2e-playwright/playwright.config.ts'],
+ ['desktop-app/test/e2e-playwright/subscription-tool-screenshot.spec.ts', 'desktop-app/test/e2e-playwright/playwright.subscription-tool-screenshot.config.ts'],
+ ['desktop-app/test/e2e-playwright/subscription-gfs-image.spec.ts', 'desktop-app/test/e2e-playwright/playwright.subscription-gfs-image.config.ts'],
+ ['desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts', 'desktop-app/test/e2e-playwright/playwright.subscription-admission-recovery.config.ts'],
['tests/e2e/playwright/control-ui/codex-subscription-admission.spec.ts', 'tests/e2e/playwright/playwright.subscription-admission.config.ts'],
['tests/e2e/playwright/control-ui/codex-subscription-host-workflow.spec.ts', 'tests/e2e/playwright/playwright.codex-subscription.config.ts'],
['tests/e2e/playwright/control-ui/codex-subscription-workflow-recipe.spec.ts', 'tests/e2e/playwright/playwright.codex-subscription.config.ts'],
@@ -157,6 +164,16 @@ function projectBlocks(source) {
}
function playwrightCollectsFile(source, configDirectory, file) {
+ if (source.includes('subscriptionRemainingJourneyConfig')) {
+ const delegatedRemainingConfig = /remainingJourneyConfig\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/.exec(source)
+ if (!delegatedRemainingConfig) return false
+ const helper = readFileSync(path.join(configDirectory, 'subscriptionRemainingJourneyConfig.ts'), 'utf8')
+ return path.posix.basename(file) === delegatedRemainingConfig[2] &&
+ /return\s+defineConfig\s*\(/.test(helper) &&
+ helper.includes('testMatch: `**/${specFile}`') &&
+ /=\s*requireSubscriptionImageRun\s*\(/.test(helper) &&
+ /(?:^|\n)\s*requireRemainingJourney\s*\(/.test(helper)
+ }
if (!source.includes('defineConfig')) return false
const relative = path.posix.relative(configDirectory, file)
const testDirectory = /(?:^|[{,\n]\s*)testDir:\s*['"](.+)['"]/.exec(source)?.[1]
@@ -201,7 +218,8 @@ export function verifyRuntimeConsumer(root, file, consumer) {
}
const source = readFileSync(path.join(root, consumer), 'utf8')
- if (!playwrightCollectsFile(source, path.posix.dirname(consumer), file)) return undefined
+ const configDirectory = path.join(root, path.posix.dirname(consumer))
+ if (!playwrightCollectsFile(source, configDirectory, path.join(root, file))) return undefined
return `${consumer} (collection-verified registry entry)`
}
@@ -229,6 +247,17 @@ function verifyOtherConsumer(root, file, lane) {
return `${ciPath}#test (${service}); ${configPath}`
}
+function verifyCalibrationConsumer(root, file, lane) {
+ if (lane !== 'calibration:control-api-memory') return undefined
+ const driver = 'scripts/tests/measure-control-api-authorize-memory.mjs'
+ if (!regularFile(root, file) || !regularFile(root, driver)) return undefined
+ const makefile = regularFile(root, 'Makefile')
+ ? readFileSync(path.join(root, 'Makefile'), 'utf8')
+ : ''
+ if (!makefile.includes('minikube-control-api-authorize-memory:')) return undefined
+ return `Makefile#minikube-control-api-authorize-memory (physical calibration only); ${driver}`
+}
+
export function auditSubscriptionDiscovery(provider, root, registered) {
if (!['grok', 'codex'].includes(provider)) throw new Error('provider must be grok or codex')
const suiteRoots = provider === 'grok'
@@ -258,6 +287,8 @@ export function auditSubscriptionDiscovery(provider, root, registered) {
const pgLane = realPgLane(file)
const pgRegistered = Boolean(pgLane) &&
registeredSet.has(file) && otherLaneSuites.get(file) === pgLane
+ const calibrationLane = calibrationSuites.get(file)
+ const calibrationRegistered = registeredSet.has(file) && calibrationLane !== undefined
if (runtimeSuites.has(file)) {
lane = 'runtime-opt-in'
if (registeredSet.has(file)) {
@@ -271,6 +302,11 @@ export function auditSubscriptionDiscovery(provider, root, registered) {
consumer = verifyOtherConsumer(root, file, pgLane)
if (!consumer) violations.push(`unverified ${pgLane} consumer for ${file}`)
else violations.push(`real-PG suite cannot be registered as a T0 unit ${file}`)
+ } else if (calibrationRegistered) {
+ lane = calibrationLane
+ consumer = verifyCalibrationConsumer(root, file, calibrationLane)
+ if (!consumer) violations.push(`unverified ${calibrationLane} consumer for ${file}`)
+ else violations.push(`calibration suite cannot be registered as a T0 unit ${file}`)
} else if (registeredSet.has(file)) {
lane = 'T0'
consumer = 'physical T0 group; separate producer/reporter required'
@@ -278,6 +314,10 @@ export function auditSubscriptionDiscovery(provider, root, registered) {
lane = pgLane
consumer = verifyOtherConsumer(root, file, lane)
if (!consumer) violations.push(`unverified ${lane} consumer for ${file}`)
+ } else if (calibrationLane !== undefined) {
+ lane = calibrationLane
+ consumer = verifyCalibrationConsumer(root, file, lane)
+ if (!consumer) violations.push(`unverified ${lane} consumer for ${file}`)
} else if (otherLaneSuites.has(file)) {
lane = otherLaneSuites.get(file)
consumer = verifyOtherConsumer(root, file, lane)
diff --git a/scripts/tests/subscription-t0-discovery.test.mjs b/scripts/tests/subscription-t0-discovery.test.mjs
index 313199621..819981a3d 100644
--- a/scripts/tests/subscription-t0-discovery.test.mjs
+++ b/scripts/tests/subscription-t0-discovery.test.mjs
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict'
-import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import path from 'node:path'
import test from 'node:test'
@@ -65,7 +65,7 @@ test('admits the three formerly omitted roots through their physical file entrie
assert.deepEqual(result.violations, [])
const lanes = new Map(result.candidates.map(entry => [entry.file, entry.lane]))
for (const file of [desktop, host, e2e, scripts]) assert.equal(lanes.get(file), 'T0')
- for (const root of ['desktop-app', 'tests/e2e', 'scripts/e2e']) {
+ for (const root of ['desktop-app', 'tests/e2e', 'scripts/e2e', 'scripts/tests']) {
assert.ok(result.roots.includes(root))
}
})
@@ -309,3 +309,111 @@ export default defineConfig({
result.violations.includes(`runtime suite cannot be registered as a T0 unit ${spec}`),
)
})
+
+test('visible remaining journeys use delegated collection and explicit opt-in gates', t => {
+ const fixture = makeFixture(t)
+ createFile(
+ fixture.root,
+ 'desktop-app/test/e2e-playwright/subscriptionRemainingJourneyConfig.ts',
+ `import { defineConfig } from '@playwright/test'
+export function remainingJourneyConfig(suite, specFile) {
+ const run = requireSubscriptionImageRun()
+ requireRemainingJourney(suite, run)
+ return defineConfig({ testMatch: \`**/\${specFile}\` })
+}
+`,
+ )
+ const suites = [
+ ['tool-screenshot', 'subscription-tool-screenshot.spec.ts'],
+ ['gfs-image', 'subscription-gfs-image.spec.ts'],
+ ['admission-recovery', 'subscription-admission-recovery.spec.ts'],
+ ]
+ for (const [suite, specName] of suites) {
+ const spec = `desktop-app/test/e2e-playwright/${specName}`
+ const config = `desktop-app/test/e2e-playwright/playwright.subscription-${suite}.config.ts`
+ createFile(fixture.root, spec)
+ createFile(
+ fixture.root,
+ config,
+ `import { remainingJourneyConfig } from './subscriptionRemainingJourneyConfig.js'
+export default remainingJourneyConfig('${suite}', '${specName}')
+`,
+ )
+ }
+
+ const result = auditSubscriptionDiscovery('codex', fixture.root, fixture.registered)
+ assert.deepEqual(result.violations, [])
+ const entries = new Map(result.candidates.map(entry => [entry.file, entry]))
+ for (const [, specName] of suites) {
+ const file = `desktop-app/test/e2e-playwright/${specName}`
+ assert.equal(entries.get(file)?.lane, 'runtime-opt-in')
+ assert.match(String(entries.get(file)?.consumer), /collection-verified registry entry/)
+ }
+
+ const admissionConfig = 'desktop-app/test/e2e-playwright/playwright.subscription-admission-recovery.config.ts'
+ const admissionSource = readFileSync(path.join(fixture.root, admissionConfig), 'utf8')
+ const ungated = admissionSource.replace(/\bremainingJourneyConfig\s*\(/, 'void(')
+ writeFileSync(path.join(fixture.root, admissionConfig), ungated)
+ assert.equal(
+ verifyRuntimeConsumer(
+ fixture.root,
+ 'desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts',
+ admissionConfig,
+ ),
+ undefined,
+ )
+ const negative = auditSubscriptionDiscovery('codex', fixture.root, fixture.registered)
+ assert.ok(
+ negative.violations.includes(
+ 'runtime consumer does not collect desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts',
+ ),
+ )
+
+ const helperPath = path.join(fixture.root, 'desktop-app/test/e2e-playwright/subscriptionRemainingJourneyConfig.ts')
+ const ungatedHelper = readFileSync(helperPath, 'utf8')
+ .replace(/=\s*requireSubscriptionImageRun\s*\(/, '= void(')
+ writeFileSync(helperPath, ungatedHelper)
+ writeFileSync(path.join(fixture.root, admissionConfig), admissionSource)
+ assert.deepEqual(
+ auditSubscriptionDiscovery('codex', fixture.root, fixture.registered).violations,
+ [
+ 'runtime consumer does not collect desktop-app/test/e2e-playwright/subscription-admission-recovery.spec.ts',
+ 'runtime consumer does not collect desktop-app/test/e2e-playwright/subscription-gfs-image.spec.ts',
+ 'runtime consumer does not collect desktop-app/test/e2e-playwright/subscription-tool-screenshot.spec.ts',
+ ],
+ )
+
+ const wrongSelector = readFileSync(helperPath, 'utf8')
+ .replace(/=\s*void\(/, '= requireSubscriptionImageRun(')
+ .replace('testMatch: `**/${specFile}`', 'testMatch: `**/*.spec.ts`')
+ writeFileSync(helperPath, wrongSelector)
+ assert.ok(
+ auditSubscriptionDiscovery('codex', fixture.root, fixture.registered).violations.includes(
+ 'runtime consumer does not collect desktop-app/test/e2e-playwright/subscription-gfs-image.spec.ts',
+ ),
+ )
+})
+
+test('memory calibration owns a dedicated lane and cannot enter T0', t => {
+ const fixture = makeFixture(t)
+ const testFile = 'scripts/tests/measure-control-api-authorize-memory.test.mjs'
+ const driver = 'scripts/tests/measure-control-api-authorize-memory.mjs'
+ createFile(fixture.root, testFile)
+ createFile(fixture.root, driver)
+ createFile(fixture.root, 'Makefile', 'minikube-control-api-authorize-memory:\n\t@true\n')
+
+ const result = auditSubscriptionDiscovery('codex', fixture.root, fixture.registered)
+ assert.deepEqual(result.violations, [])
+ const entry = result.candidates.find(candidate => candidate.file === testFile)
+ assert.equal(entry?.lane, 'calibration:control-api-memory')
+ assert.match(String(entry?.consumer), /physical calibration only/)
+
+ const registered = auditSubscriptionDiscovery(
+ 'codex',
+ fixture.root,
+ [...fixture.registered, testFile],
+ )
+ assert.ok(
+ registered.violations.includes(`calibration suite cannot be registered as a T0 unit ${testFile}`),
+ )
+})
diff --git a/scripts/tests/test-codex-subscription-t0.sh b/scripts/tests/test-codex-subscription-t0.sh
index 289c00547..4c99dd776 100755
--- a/scripts/tests/test-codex-subscription-t0.sh
+++ b/scripts/tests/test-codex-subscription-t0.sh
@@ -239,6 +239,7 @@ run_group "codex-upstream-contract-freeze" "tests/e2e" "integration/codex-subscr
run_node_group "approved-tools-fixtures-and-runner" \
"scripts/tests/subscription-t0-discovery.test.mjs" \
+ "scripts/tests/subscription-image-runner.test.mjs" \
"scripts/e2e/fixtures/subscription-image-provider.test.mjs" \
"scripts/tests/run-node-test-files.test.mjs" \
"tests/e2e/fixtures/codex-subscription/approved-tools/server.test.mjs" \
@@ -422,6 +423,8 @@ else
"test/subscriptionImageChallenge.test.ts" \
"test/subscriptionImageRunContract.test.ts" \
"test/subscriptionAdmissionGuard.test.ts" \
+ "test/subscriptionRemainingJourneyData.test.ts" \
+ "test/subscriptionRemainingJourneysContract.test.ts" \
"test/codexImageChallenge.test.ts" \
"ui/src/constants/__tests__/attachments.test.ts" \
"ui/src/hooks/__tests__/useHostModels.test.tsx" \
diff --git a/scripts/tests/test-grok-subscription-t0.sh b/scripts/tests/test-grok-subscription-t0.sh
index a38db7e3b..c1f3c3678 100755
--- a/scripts/tests/test-grok-subscription-t0.sh
+++ b/scripts/tests/test-grok-subscription-t0.sh
@@ -237,6 +237,7 @@ echo "Grok subscription T0 aggregator"
run_node_group "subscription-discovery-and-offline-image-provider" \
"scripts/tests/subscription-t0-discovery.test.mjs" \
+ "scripts/tests/subscription-image-runner.test.mjs" \
"scripts/e2e/fixtures/subscription-image-provider.test.mjs"
require_ci_matrix_entry "grok-llm-proxy"
@@ -412,6 +413,8 @@ else
"test/subscriptionImageChallenge.test.ts" \
"test/subscriptionImageRunContract.test.ts" \
"test/subscriptionAdmissionGuard.test.ts" \
+ "test/subscriptionRemainingJourneyData.test.ts" \
+ "test/subscriptionRemainingJourneysContract.test.ts" \
"ui/src/constants/__tests__/attachments.test.ts" \
"ui/src/components/agents/__tests__/ComposerPanel.test.tsx"
fi