135 lines
5.0 KiB
JavaScript
135 lines
5.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { execFile } from 'node:child_process';
|
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
import { arch, platform, release } 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';
|
|
import { runPackagedProductProof } from './run-pi-subagent-packaged-smoke.mjs';
|
|
|
|
function runGit(projectRoot, args) {
|
|
return new Promise((resolvePromise, reject) => {
|
|
execFile('git', args, { cwd: projectRoot, windowsHide: true }, (error, stdout) => {
|
|
if (error) reject(error);
|
|
else resolvePromise(stdout.trim());
|
|
});
|
|
});
|
|
}
|
|
|
|
async function gitEvidence(projectRoot) {
|
|
const [commit, status] = await Promise.all([
|
|
runGit(projectRoot, ['rev-parse', 'HEAD']),
|
|
runGit(projectRoot, ['status', '--porcelain']),
|
|
]);
|
|
return { commit, dirty: Boolean(status) };
|
|
}
|
|
|
|
async function runExtensionSmoke(projectRoot, artifact) {
|
|
return await runPackagedProductProof({
|
|
projectRoot,
|
|
runtimeRoot: artifact.artifact.runtimeRoot,
|
|
electronExecutable: artifact.artifact.executable,
|
|
reportPath: undefined,
|
|
verifyCleanupFailure: true,
|
|
});
|
|
}
|
|
|
|
export async function runRealPiSmoke(options) {
|
|
const git = await gitEvidence(options.projectRoot);
|
|
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: git.commit,
|
|
git,
|
|
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: platform() === 'linux' && !release().toLowerCase().includes('microsoft')
|
|
? []
|
|
: ['Native non-WSL Linux desktop/compositor PI-150 evidence is not established by this report'],
|
|
deferredToPi160: [
|
|
'macOS x64 and macOS arm64 final release validation was skipped by explicit user direction and remains Not Pass',
|
|
],
|
|
};
|
|
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;
|
|
});
|
|
}
|