Files
gstack/test/helpers/cso-qualified-cli.ts
T
Garry Tan 5885157a90 v1.91.29.0 fix(cso): native runtime qualification passes for Node, Bun, Python and Rails (#3044)
* fix(cso): unblock native runtime qualification (v1.91.28.0)

Fixes the qualify-native failures from main run 37345275258:
- re-bind promotion evidence for staged runtimes in cold-start tests
- give npm a distinct empty global config (npm 11 refuses double-loading)
- export /archives and /work through tmpfs-backed local volumes (docker cp
  cannot read tmpfs), with exec on /work
- keep the offline seed process alive
- end broker/forwarder tunnels explicitly under Bun
- batch gem fetch per platform
- wait for run-app's source copy before Rails db:prepare and tests
- fix the Python cold fixture and add bin/rails to the Rails cold fixture

* fix(cso): bounded 900 s ceiling for preparation dependency commands

- PREPARATION_COMMAND_TIMEOUT_MS (900 s) applies only to acquisition and
  offline dependency commands; everything else keeps COMMAND_TIMEOUT_MS
  (300 s), and both are cut to the journey deadline
- prepared-tree export refusals fail with PREPARED_EXPORT_REJECTED and the
  helper's fixed reason or errno, never target paths, with no retry
- free tests pin the ceiling, its callers, and the rejection parser

* Take v1.91.29.0 (1.91.28.0 is claimed by #3032 and #3033)

* cso-diff-mode accepts every correct name for the unauthenticated webhook finding
2026-10-06 10:32:19 -07:00

52 lines
2.2 KiB
TypeScript

import * as fs from 'node:fs';
import * as path from 'node:path';
import { dispatchCsoCommand, type CsoCliDependencies } from '../../lib/cso/cli';
import { validateRuntimeCatalog, type QualifiedRuntime, type RuntimeCatalog, type RuntimePlatform } from '../../lib/cso/runtime-catalog';
import { completeRuntimeCatalogFixture, installStagedRuntime } from './cso-runtime-catalog';
export interface QualifiedCsoCli {
readonly catalog: RuntimeCatalog;
readonly runtime: QualifiedRuntime;
command<T = unknown>(args: string[]): Promise<T>;
}
/** Bind a staged Node image to the real command dispatcher without adding a production override. */
export function qualifiedNodeCli(options: {
image: string;
versions: Record<string, string>;
watchdogPath: string;
platform: RuntimePlatform;
}): QualifiedCsoCli {
if (!path.isAbsolute(options.watchdogPath) || !fs.statSync(options.watchdogPath).isFile()) {
throw new Error('Node lifecycle qualification requires an absolute compiled watchdog path');
}
for (const key of ['node', 'npm', 'cso-preparation']) {
if (!/^\d+\.\d+\.\d+$/.test(options.versions[key] ?? '')) {
throw new Error(`Node lifecycle qualification requires exact ${key} version metadata`);
}
}
if (options.versions['cso-preparation'] !== '1.0.0') {
throw new Error('Node lifecycle qualification requires cso-preparation 1.0.0');
}
const catalog = completeRuntimeCatalogFixture('node-lifecycle-fixture');
const fixture = catalog.runtimes.find(item => item.stack === 'node' && item.platform === options.platform);
if (!fixture) throw new Error('Node lifecycle catalog fixture is incomplete');
const runtime = installStagedRuntime(catalog, { ...fixture, image: options.image, versions: options.versions });
validateRuntimeCatalog(catalog);
const dependencies: CsoCliDependencies = Object.freeze({
runtimeCatalog: catalog,
watchdogPath: () => options.watchdogPath,
});
return Object.freeze({
catalog,
runtime,
async command<T = unknown>(args: string[]): Promise<T> {
const [command, ...commandArgs] = args;
if (!command) throw new Error('CSO qualification command is required');
return await dispatchCsoCommand(command, commandArgs, dependencies) as T;
},
});
}