test: add PI release proof harness
This commit is contained in:
122
scripts/smoke-pi-real.mjs
Normal file
122
scripts/smoke-pi-real.mjs
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn } from 'node:child_process';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { arch, platform } from 'node:os';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
import { verifyPiProductArtifact } from './lib/pi-product-artifact.mjs';
|
||||
import { runLocalProviderContracts } from './probe-pi-provider-contracts.mjs';
|
||||
import { parsePiArtifactVerifierArgs } from './verify-pi-product-artifact.mjs';
|
||||
import { runProbe } from './probe-pi-runtime.mjs';
|
||||
|
||||
function runExtensionSmoke(projectRoot, artifact) {
|
||||
return new Promise((resolvePromise, reject) => {
|
||||
const child = spawn(process.execPath, [
|
||||
resolve(projectRoot, 'scripts', 'run-pi-subagent-packaged-smoke.mjs'),
|
||||
'--runtime-root', artifact.artifact.runtimeRoot,
|
||||
'--electron-executable', artifact.artifact.executable,
|
||||
], {
|
||||
cwd: projectRoot,
|
||||
stdio: 'inherit',
|
||||
windowsHide: true,
|
||||
});
|
||||
child.once('error', reject);
|
||||
child.once('exit', (code, signal) => {
|
||||
if (code === 0) resolvePromise({ result: 'pass' });
|
||||
else reject(new Error(
|
||||
`Final product extension/subagent smoke failed with code ${code ?? 'null'} signal ${signal ?? 'none'}`,
|
||||
));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function runRealPiSmoke(options) {
|
||||
const artifact = await verifyPiProductArtifact(options);
|
||||
const common = {
|
||||
samples: options.samples,
|
||||
timeoutMs: options.timeoutMs,
|
||||
stage: false,
|
||||
keepStage: false,
|
||||
reportPath: undefined,
|
||||
providerFixturePath: undefined,
|
||||
imagePath: undefined,
|
||||
electronExecutablePath: artifact.artifact.executable,
|
||||
cliPath: artifact.artifact.cliPath,
|
||||
artifactLabel: 'final-makelore-product-artifact',
|
||||
};
|
||||
const runtime = await runProbe(common, options.projectRoot);
|
||||
if (runtime.result === 'fail') throw new Error('Final product Pi runtime lifecycle smoke failed');
|
||||
const providerContracts = await runLocalProviderContracts(common, options.projectRoot);
|
||||
const extensionAndSubagent = await runExtensionSmoke(options.projectRoot, artifact);
|
||||
const report = {
|
||||
schemaVersion: 1,
|
||||
generatedAt: new Date().toISOString(),
|
||||
commit: process.env.MAKELORE_BUILD_COMMIT ?? null,
|
||||
platform: { platform: platform(), arch: arch() },
|
||||
scope: {
|
||||
finalProductArtifact: true,
|
||||
actualPackagedPiProcess: true,
|
||||
providerEndpoint: 'controlled-127.0.0.1-provider-shaped',
|
||||
realProvider: false,
|
||||
realTurnVerified: false,
|
||||
realProviderDecision: 'explicitly-waived-accepted-risk',
|
||||
},
|
||||
artifact,
|
||||
runtime,
|
||||
providerContracts,
|
||||
extensionAndSubagent,
|
||||
coverage: {
|
||||
session: runtime.session.sessionIdPreserved,
|
||||
prompt: runtime.session.promptAccepted,
|
||||
tool: runtime.session.shellOutputMatched,
|
||||
abort: runtime.localIsolation.abortIsolated,
|
||||
settled: runtime.session.agentSettled,
|
||||
reopen: runtime.session.sessionIdPreserved,
|
||||
twoWorkerOverlap: providerContracts.protocols.every(
|
||||
({ qualification }) => qualification.overlapMs > 0,
|
||||
),
|
||||
twoWorkerIsolation: providerContracts.protocols.every(
|
||||
({ qualification }) => qualification.distinctSessionIds,
|
||||
),
|
||||
providerAbortIsolation: providerContracts.protocols.every(
|
||||
({ qualification }) => qualification.abortIsolation.passed,
|
||||
),
|
||||
subagent: extensionAndSubagent.result === 'pass',
|
||||
shutdown: runtime.performance.exitModes.every((mode) => mode === 'stdin-close'),
|
||||
},
|
||||
result: 'pass',
|
||||
crossPlatformReleaseReady: false,
|
||||
releaseBlockers: [
|
||||
'macOS x64 and macOS arm64 PI-150 final-artifact/runtime/resource/performance validation was skipped by explicit user direction',
|
||||
],
|
||||
};
|
||||
if (Object.values(report.coverage).some((value) => value !== true)) {
|
||||
throw new Error(`Final product Pi smoke coverage failed: ${JSON.stringify(report.coverage)}`);
|
||||
}
|
||||
if (options.reportPath) {
|
||||
await mkdir(dirname(options.reportPath), { recursive: true });
|
||||
await writeFile(options.reportPath, `${JSON.stringify(report, null, 2)}\n`);
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const options = parsePiArtifactVerifierArgs(process.argv.slice(2));
|
||||
if (options.help) {
|
||||
process.stdout.write('Usage: node scripts/smoke-pi-real.mjs [--app-exe path] [--samples count] [--timeout-ms ms] [--report path]\n');
|
||||
return;
|
||||
}
|
||||
const report = await runRealPiSmoke(options);
|
||||
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
||||
}
|
||||
|
||||
const isMain = process.argv[1]
|
||||
&& pathToFileURL(resolve(process.argv[1])).href === import.meta.url;
|
||||
if (isMain) {
|
||||
main().catch((error) => {
|
||||
process.stderr.write(`${error.stack ?? error.message}\n`);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user