mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-13 23:39:21 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Native execution needs a compatible installed daemon and provider dependency. > - The Codex-default work found missing platform packages and clean-install startup failures. > - Release builds also repeat dependency compilation and run preparation serially. > - This prerequisite packages four daemon targets and verifies installed native startup. > - It also caches hosted Cargo dependencies and overlaps JavaScript preparation with compilation. > - Agent creation defaults and experimental gates stay at the current master behavior. ## Linked Issues or Issue Description Refs #15683. Refs #15555. Refs #15422. Refs #15926. Refs #15932. Extract runtime and installation support from #15683. This prerequisite has 65 changed files. Creation, onboarding, imports, UI runner selection and graduation remain in the dependent PR. Feature/access maps and the Storybook source catalog stay synchronized. Existing agents keep their execution choices. ## What Changed - Correct the existing runner test fixtures. Reserve owned credential quorum listeners through the existing bounded fixture helper. Keep foreign listeners intact, run actual credential staging once, and preserve its rejection and unchanged-auth assertions. Reuse the durable-resume outer-limit correction. Wait for actual warm-completion and held-authorization callback entry under the existing recovery deadline and surface early request errors. Preserve every semantic assertion. - Retain bounded installation failure diagnostics through the existing qualification receipt upload. Keep the original error, 10-minute deadline and all success checks. - Keep startup ownership until credential preparation and registration drain. Reject duplicate and post-close startup/resume work. Observe shutdown during normal and adopted authentication readiness. Preserve the primary failure and retain private state when cleanup is unconfirmed. - Package Linux x64/ARM64 and macOS Apple Silicon/Intel daemons. Verify target headers, source identities, manifests, and hashes before assembly and installation. - Reuse the existing release producer/consumer workflows. Cache Cargo dependencies by target, OS, compiler, lockfile, and contract inputs. Rebuild workspace binaries. Permit trusted cache writes only for canonical exact-source master pushes. - Overlap JavaScript preparation with native compilation. Join both commands and failure/cancellation cleanup before artifact verification. - Preserve shell positional arguments in the shared SSH runner and apply environment assignments correctly. Reject environment option keys. Six before/after controls and two real SSH subprocess paths pass with zero provider calls; this fix lands before both Codex and Claude defaults. - Admit verified suspended SSH backups during cold controller continuation, using the same full-scope, integrity and lifecycle checks as sandbox targets. Two positive SSH cases fail before; all 14 positive/negative matrix cases pass afterward. Active ownership and corrupt/malformed/nonempty state remain rejected. - Record measured sandbox platform facts through the existing explicit environment probe. Bind facts to the company, effective provider configuration, immutable OCI image and actual captured image binding. Check the returned cleanup receipt. Reject client-authored proof and stale or named boot identities. Creation and discovery allocate nothing. Preserve connection-only behavior. - Resolve the actual remote Codex target and preserve same-host development overrides. Preserve runtime artifact verification. Use actual protocol/model compatibility rather than a numerical CLI version fence. - Resolve the installed Codex login dependency on 64-bit Linux and Mac independently of the daemon libc baseline. Preserve account homes and safe errors. - Fix actual clean-install TOML table comparison. Preserve strict semantic checks, comments, private writes, and malformed-input rejection. Preserve primary startup failures and bounded cleanup. - Document GNU libc 2.39+ and stock Ubuntu sandbox prerequisites. Qualify ARM startup with a scoped distribution profile and unchanged global restrictions. Preserve Windows and Alpine deferral. - Preserve selected and saved native Codex reasoning effort in the existing UI builder, while excluding it from other providers. This small shared correction prevents import edits higher in the stack from dropping effort. - Reuse existing installed-package checks and assertions. Paperclip tarballs contain no Codex native payloads. Official npm dependencies supply the consumer's Codex binaries. All Docker and native builds stay remote. ## Verification Candidate: `271d434c170e74bdedde65d0b13059a55419c943`. It includes current master `e168512f7bdbb6af6ea01954c6d7ed80b91e903e` and preserves prior candidates through ordinary commits. Current [full CI](https://github.com/paperclipai/paperclip/actions/runs/38346601686) is successful on attempt 2. GitHub reports 54 successful checks and four conditional skips, including required verify and browser aggregates, workspace typecheck/tests/build, Linux DB controls, both runner shards and [isolated native compilation](https://github.com/paperclipai/paperclip/actions/runs/38346601609). Fresh current-head Greptile is 5/5 with all four threads resolved. The passing build's clean Grok/Codex report records CI merge source `7a82a37438e6e448abc7cc5caa60dc2519a97be0`, 18 installed packages, omitted Codex payloads, official host-only npm dependencies and zero provider calls. Pi setup and its no-prompt lease verification also pass. The first attempt's single 60-second Node archive download timeout remains retained; its DNS/TLS/download cause remains unknown. One unchanged-source retry was requested through the normal Build-job dialog with debug logging disabled. GitHub's attempt 2 graph reports the other CI jobs as well; no second retry or source/deadline relaxation was made. The [final exact-source package campaign](https://github.com/paperclipai/paperclip/actions/runs/38347027535) is successful on literal `271d434c170e74bdedde65d0b13059a55419c943`. It passes all four native producers, public Linux package assembly and clean installed consumers on Apple Silicon, Intel Mac and Linux ARM64. The nine qualification-mode skips are intentional; full CI above covers their ordinary gates. Native builds and Docker assembly ran remotely. The predecessor [`dae808` package campaign](https://github.com/paperclipai/paperclip/actions/runs/38342104102) remains literal historical evidence. Only tests and the dated record differ from that source; runtime, package and workflow code is unchanged. The reused credential fixture correction passes all 42 canonical Node 24 controls with synthetic data and independent matching-source review, and the current hosted runner shard passes. Production credential behavior is unchanged. **Merge hold:** current-source CI, fresh 5/5 review and exact-source package qualification pass. Actual code-owner approval and normal protected merge remain pending. No slice has merged or deployed. GitHub CLI authentication needs refresh; the normal signed-in embedded GitHub UI provided this status without credential workarounds. - The master merge preserves both Storybook source-review appendices and the guarded test-home cleanup. All six existing cleanup controls pass without skips. Master's isolated-home helper/test/setup are byte-identical. The two existing whitespace lines in master's unrelated privacy test remain outside this PR's diff. - Canonical Node 24 passes all 24 existing public-install helper tests. Three narrow added cases prove bounded/redacted failure metadata, symlink exclusions, original exception identity, failed diagnostic writes and no false failure on success. The Mac installer now uses `--timing`; at most two 16 KiB tails and 32 structured entries per tail enter the existing receipt upload. Raw argv, URLs, environment, error text and stacks are omitted. A failed receipt explicitly remains FAILED/unqualified/runtime-not-attempted. The 600,000 ms install deadline and every real package/hash/payload/lock/lifecycle/runtime oracle are unchanged. - Canonical Node 24 reproduces the durable-resume outer timeout under controlled fake latency. Only its outer test limit changes to 15 seconds; internal 500 ms/5 second deadlines and usage/effect assertions remain. Controlled warm-recovery and before-bootstrap authorization scheduling delays reproduce their callback polling failures, while the explicit entry signals pass. Early recovery errors surface unchanged. Independent review is clear. Historical mock binaries support the fixture controls; fresh full hosted CI remains decisive. The original hosted callback failure cause is inconclusive. - The composed runner/surfaces/server/E2E TypeScript checks pass. Map checks pass 35 areas/171 capability IDs. Token gates pass. The existing Storybook catalog passes 223 files/2,210 stories; story IDs and classifications remain intact. The current master had 25 inherited stale fingerprints from three changed map recipes. Only those guarded fingerprints and a source-only review note change; all 92 non-map story/component/fixture inputs remain unchanged. Existing classifications are retained. This proves source structure, not visual or live acceptance. - The 65-file contribution audit has no code file crossing from below 1,000 lines to above the limit. Earlier comment cleanup preserves executable emissions, parsed workflows and action pins. Independent cleanup/catalog and three-file reporting reviews are clear. No new workflow, suite, grader or local native/Docker build was added. **Prior `dae808` gate evidence:** fresh Greptile is 5/5 with four resolved threads, isolated native compilation and the browser aggregate pass. Its first runner shard passes the previous two corrections but fails a different held-authorization cell at the implicit one-second polling deadline. It records 1,672 passes/one failure/three skips. This candidate applies the verified entry-signal correction without changing production deadlines or any semantic assertions. Its original hosted cause remains inconclusive until fresh CI. **Previous-source evidence, kept literal:** the [exact `16a532` package campaign](https://github.com/paperclipai/paperclip/actions/runs/38338806076) passes all four native producers, public Linux package assembly, Apple Silicon, Intel Mac and Linux ARM64 installed consumers. Its fresh review is 5/5 with all four threads resolved. Full CI records 52 successful checks, four conditional skips and the two fixture failures corrected here. This is not a green full-CI candidate or proof for the new source. `64c074fb8da1b31f8d6042c4fef48dc4164e759b` passed [full CI](https://github.com/paperclipai/paperclip/actions/runs/38332726938), 54 checks/four conditional skips, [isolated native compilation](https://github.com/paperclipai/paperclip/actions/runs/38332726787/job/115085895328), and fresh Greptile 5/5/all four resolved threads. The hosted transport suite passed 246 tests and startup trust passed 22, closing that source's local fake-binary limitation. These are historical after reconciliation. The [previous exact-source package campaign](https://github.com/paperclipai/paperclip/actions/runs/38332921463) built all four platform daemons and passed public Linux package assembly plus Apple Silicon and Linux ARM64 installed consumers. **Intel Mac failed:** its initial scripts-disabled npm install timed out before lifecycle/runtime assertions. The underlying download/resolution/host cause is unknown because the old helper deleted the npm logs. This is the concrete baseline for the diagnostic change. The failed campaign remains failed; no all-platform signoff or automatic retry is claimed. The earlier `a200495` [four-target campaign](https://github.com/paperclipai/paperclip/actions/runs/38283695248) and [scoped ARM qualification](https://github.com/paperclipai/paperclip/actions/runs/38291535914) remain component evidence. Cargo restores were cold misses; no warm-cache speedup is claimed. Paperclip tarballs contain no Codex payloads. Official npm dependencies supply Codex on the user's platform. Current-source full workspace typecheck/tests/build, Linux DB controls, static/Rust/native tests, all browser shards and exact-source package consumers must pass. New-agent defaults and final managed onboarding belong to #15683. Actual private Cloud composition, warm/cold signup, task/follow-up and rollback compatibility remain later release gates. Source audits found that ordinary managed onboarding does not run the saved platform probe and Cloud distributes named snapshots without a verified final boot-image binding. These dependent release blockers remain open; prequalified E2E fixtures do not close them. Master adds task-workspace migrations; the final image/migrator and previous-image checks must include them. ARM paid task/follow-up and ordinary OS APT installation are not proven. ## Risks - Multi-target packages require source and header agreement. Missing or mismatched artifacts fail explicitly. Existing execution choices remain unchanged. - Linux requires GNU libc 2.39+ and compatible sandbox prerequisites. The scoped hosted ARM preparation does not qualify arbitrary containers or kernels. Windows, 32-bit ARM, and Alpine remain deferred. - Only dependency crates are cached. Preview jobs cannot write trusted caches. Concurrent command cleanup must preserve the primary failure. - Native-free Paperclip packaging retains official Codex npm dependencies. No Codex payload bundling, schema migration, automatic agent migration, or production deployment is included. ## Model Used OpenAI Codex, GPT-6 family, with reasoning, repository tools, code execution, and parallel agents. The exact serving model snapshot and context-window size are not exposed. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
455 lines
35 KiB
JavaScript
455 lines
35 KiB
JavaScript
#!/usr/bin/env node
|
|
// Run on a disposable Linux verification host after pnpm build. No publication,
|
|
// credentials, inference, or changes to release versions. Native provisioning is
|
|
// explicit and separate from npm installation, and is removed in finally.
|
|
import assert from 'node:assert/strict';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { chmodSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
import { createHash } from 'node:crypto';
|
|
import { createServer } from 'node:net';
|
|
import { tmpdir } from 'node:os';
|
|
import { stripTypeScriptTypes } from 'node:module';
|
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { packConcurrency, packStagedPackages, packTimings } from './pack-staged-packages.mjs';
|
|
import { materializePublishManifest } from './prepare-bundled-package.mjs';
|
|
import { GROK_PUBLIC_INSTALL_IMAGE, GROK_PUBLIC_INSTALL_LIFECYCLE, assertInstalledNativeConsumerContinuity, assertNoBundledCodexPayloads, grokConsumerDockerArgs, installedCodexProbeSource, installedDaemonProbeSource, macNodeHeadersDirectory, macPublicInstallLifecycleProfile, macInstalledStartupProbeSource, runMacInitialInstallWithDiagnostics } from './grok-public-install-sandbox.mjs';
|
|
import { startPrefetch, stopPrefetches } from './prefetch-child.mjs';
|
|
import { retainRunnerQualificationPackages } from './retain-runner-qualification-packages.mjs';
|
|
import { bundledInstallTimings, startBundledInstalls } from './stage-bundled-packages.mjs';
|
|
const repo = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
async function verifyMacConsumer(packageDirectory, sourceRevision, receiptPath) {
|
|
assert.equal(process.env.GITHUB_ACTIONS, 'true', 'Mac clean consumers run only on disposable hosted CI');
|
|
assert.equal(process.platform, 'darwin');
|
|
assert.ok(['arm64', 'x64'].includes(process.arch));
|
|
assert.match(sourceRevision, /^[a-f0-9]{40}$/);
|
|
const packages = realpathSync(packageDirectory);
|
|
const manifest = JSON.parse(readFileSync(join(packages, 'manifest.json'), 'utf8'));
|
|
assert.equal(manifest.schema, 'paperclip.runner.public-packages/v1');
|
|
assert.equal(manifest.sourceRevision, sourceRevision);
|
|
assert.ok(manifest.archives.some(entry => entry.name === '@paperclipai/server'));
|
|
assert.ok(manifest.archives.some(entry => entry.name === 'paperclipai'));
|
|
assert.equal(new Set(manifest.archives.map(entry => entry.name)).size, manifest.archives.length);
|
|
const root = realpathSync(mkdtempSync(join(tmpdir(), 'paperclip-mac-public-install-')));
|
|
try {
|
|
const consumer = join(root, 'consumer'), home = join(root, 'home'), tools = join(root, 'tools');
|
|
for (const directory of [consumer, home, tools, join(root, 'tmp'), join(root, 'cache')]) mkdirSync(directory);
|
|
const npmCli = realpathSync(execFileSync('/usr/bin/which', ['npm'], { encoding: 'utf8' }).trim());
|
|
symlinkSync(process.execPath, join(tools, 'node'));
|
|
const env = { PATH: `${tools}:/usr/bin:/bin:/usr/sbin:/sbin`, HOME: home, TMPDIR: join(root, 'tmp'),
|
|
npm_config_cache: join(root, 'cache'), npm_config_audit: 'false', npm_config_fund: 'false' };
|
|
const run = (command, args, cwd = consumer, runEnv = env) => execFileSync(command, args, { cwd, env: runEnv,
|
|
timeout: 10 * 60_000, maxBuffer: 32 * 1024 * 1024, encoding: 'utf8' });
|
|
const tarballs = manifest.archives.map(entry => {
|
|
assert.match(entry.file, /^[A-Za-z0-9._-]+\.tgz$/); assert.match(entry.sha256, /^[a-f0-9]{64}$/);
|
|
const path = join(packages, entry.file);
|
|
assert.equal(realpathSync(path), path);
|
|
assert.equal(createHash('sha256').update(readFileSync(path)).digest('hex'), entry.sha256);
|
|
assertNoBundledCodexPayloads(run('/usr/bin/tar', ['-tzf', path]).trim().split('\n'));
|
|
return path;
|
|
});
|
|
writeFileSync(join(consumer, 'package.json'), JSON.stringify({ private: true, type: 'module' }));
|
|
const sentinelSource = join(root, 'lifecycle-sentinel'); mkdirSync(sentinelSource);
|
|
writeFileSync(join(sentinelSource, 'package.json'), JSON.stringify({ name: 'paperclip-verification-lifecycle-sentinel', version: '1.0.0',
|
|
scripts: { postinstall: 'node -e "require(\'node:fs\').writeFileSync(\'lifecycle-ran\', \'ok\')"' } }));
|
|
run(process.execPath, [npmCli, 'pack', '--ignore-scripts', '--pack-destination', root], sentinelSource);
|
|
const sentinelTar = join(root, readdirSync(root).find(name => name.endsWith('.tgz')));
|
|
runMacInitialInstallWithDiagnostics(() => run(process.execPath, [npmCli, 'install', '--ignore-scripts', '--omit=dev', '--timing', ...tarballs, sentinelTar]),
|
|
{ sourceRevision, platform: process.platform, architecture: process.arch, cacheDirectory: join(root, 'cache'), receiptPath });
|
|
const sentinel = join(consumer, 'node_modules/paperclip-verification-lifecycle-sentinel/lifecycle-ran');
|
|
assert.equal(existsSync(sentinel), false);
|
|
const lock = readFileSync(join(consumer, 'package-lock.json'), 'utf8');
|
|
const profile = join(root, 'lifecycle.sb'); writeFileSync(profile, macPublicInstallLifecycleProfile(root));
|
|
const listener = createServer(socket => socket.end());
|
|
await new Promise((resolve, reject) => { listener.once('error', reject); listener.listen(0, '127.0.0.1', resolve); });
|
|
try {
|
|
const port = listener.address().port;
|
|
const networkProbe = `import assert from 'node:assert/strict'; import net from 'node:net';
|
|
const socket = net.connect({host:'127.0.0.1',port:${port}}); socket.setTimeout(3000,()=>process.exit(2));
|
|
socket.once('connect',()=>{socket.destroy(); ${"process.argv[1] === 'denied' ? process.exit(3) : process.exit(0)"};});
|
|
socket.once('error',error=>{assert.equal(process.argv[1],'denied'); assert.equal(error.code,'EPERM');});`;
|
|
run(process.execPath, ['--input-type=module', '-e', networkProbe, 'allowed']);
|
|
run('/usr/bin/sandbox-exec', ['-f', profile, process.execPath, '--input-type=module', '-e', networkProbe, 'denied']);
|
|
} finally { await new Promise(resolve => listener.close(resolve)); }
|
|
const nodeHeaders = macNodeHeadersDirectory(process.execPath, process.versions.node);
|
|
run('/usr/bin/sandbox-exec', ['-f', profile, process.execPath, npmCli, 'rebuild', '--offline', '--ignore-scripts=false', '--dangerously-allow-all-scripts', '--foreground-scripts'],
|
|
consumer, { ...env, npm_config_nodedir: nodeHeaders });
|
|
assert.equal(readFileSync(sentinel, 'utf8'), 'ok');
|
|
assert.equal(readFileSync(join(consumer, 'package-lock.json'), 'utf8'), lock);
|
|
for (const entry of manifest.archives) {
|
|
assert.equal(JSON.parse(readFileSync(join(consumer, 'node_modules', entry.name, 'package.json'))).version, manifest.releaseVersion);
|
|
}
|
|
const server = join(consumer, 'node_modules/@paperclipai/server'), installed = join(server, 'dist/vendor/paperclip-runner');
|
|
const probe = (name, source) => { const file = join(root, name); writeFileSync(file, source); return JSON.parse(run(process.execPath, [file]).trim()); };
|
|
const daemon = probe('daemon-probe.mjs', installedDaemonProbeSource(installed, consumer, sourceRevision));
|
|
const codex = probe('codex-probe.mjs', installedCodexProbeSource(join(installed, 'index.js'), consumer, undefined, { nativeCodex: true }));
|
|
const startupScript = macInstalledStartupProbeSource(consumer, server, daemon.sha256, join(repo, 'tests/runner-e2e/installed-cli.ts'));
|
|
const startupFile = join(root, 'startup-probe.mts'); writeFileSync(startupFile, startupScript);
|
|
const startup = JSON.parse(run(process.execPath, ['--import', 'tsx', startupFile], join(repo, 'server')).trim());
|
|
const receipt = { schema: 'paperclip.runner.mac-public-install.v1', sourceRevision, platform: process.platform, architecture: process.arch,
|
|
cleanNpmInstall: true, packageCount: manifest.archives.length, codexPackedPayloadsOmitted: true,
|
|
consumerLockPreserved: true, lifecycleSentinelVerified: true, lifecycleNodeHeadersVerified: true, lifecycleNodeVersion: process.versions.node,
|
|
lifecycleNetwork: 'sandbox-exec denied (loopback negative control)',
|
|
...daemon, ...codex, startup, providerCalls: 0 };
|
|
writeFileSync(receiptPath, JSON.stringify(receipt, null, 2) + '\n');
|
|
console.log(JSON.stringify(receipt));
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
}
|
|
async function verifyLinuxArmConsumer(packageDirectory, sourceRevision, receiptPath) {
|
|
assert.equal(process.env.GITHUB_ACTIONS, 'true', 'Native clean consumers run only on disposable hosted CI');
|
|
assert.equal(process.platform + '-' + process.arch, 'linux-arm64', 'ARM qualification requires a native ARM host');
|
|
assert.equal(process.versions.node.split('.')[0], '24', 'ARM host startup requires the qualified Node24 runtime');
|
|
assert.match(sourceRevision, /^[a-f0-9]{40}$/);
|
|
const packages = realpathSync(packageDirectory);
|
|
const manifest = JSON.parse(readFileSync(join(packages, 'manifest.json'), 'utf8'));
|
|
assert.equal(manifest.schema, 'paperclip.runner.public-packages/v1');
|
|
assert.equal(manifest.sourceRevision, sourceRevision);
|
|
assert.ok(manifest.archives.some(entry => entry.name === '@paperclipai/server'));
|
|
assert.ok(manifest.archives.some(entry => entry.name === 'paperclipai'));
|
|
assert.equal(new Set(manifest.archives.map(entry => entry.name)).size, manifest.archives.length);
|
|
const root = realpathSync(mkdtempSync(join(tmpdir(), 'paperclip-arm-public-install-')));
|
|
try {
|
|
const assets = join(root, 'assets'), consumer = join(root, 'consumer'), cache = join(root, 'cache');
|
|
for (const directory of [assets, consumer, cache]) mkdirSync(directory);
|
|
const run = (command, args, cwd = root) => execFileSync(command, args, { cwd,
|
|
env: { PATH: process.env.PATH, HOME: root, TMPDIR: root }, timeout: 10 * 60_000,
|
|
maxBuffer: 32 * 1024 * 1024, encoding: 'utf8' });
|
|
const platform = 'linux/arm64';
|
|
run('docker', ['pull', '--platform', platform, GROK_PUBLIC_INSTALL_IMAGE]);
|
|
const isolated = (command, options = {}) => run('docker', grokConsumerDockerArgs({ assets, consumer, cache,
|
|
uid: process.getuid(), gid: process.getgid(), platform, command, ...options }));
|
|
for (const entry of manifest.archives) {
|
|
assert.match(entry.file, /^[A-Za-z0-9._-]+\.tgz$/); assert.match(entry.sha256, /^[a-f0-9]{64}$/);
|
|
const tarball = join(packages, entry.file);
|
|
assert.equal(realpathSync(tarball), tarball);
|
|
assert.equal(createHash('sha256').update(readFileSync(tarball)).digest('hex'), entry.sha256);
|
|
assertNoBundledCodexPayloads(run('tar', ['-tzf', tarball]).trim().split('\n'));
|
|
cpSync(tarball, join(assets, entry.file)); chmodSync(join(assets, entry.file), 0o644);
|
|
}
|
|
writeFileSync(join(consumer, 'package.json'), JSON.stringify({ private: true, type: 'module' }));
|
|
const sentinelSource = join(root, 'lifecycle-sentinel'); mkdirSync(sentinelSource);
|
|
writeFileSync(join(sentinelSource, 'package.json'), JSON.stringify({ name: 'paperclip-verification-lifecycle-sentinel', version: '1.0.0',
|
|
scripts: { postinstall: 'node -e "require(\'node:fs\').writeFileSync(\'lifecycle-ran\', \'ok\')"' } }));
|
|
run('npm', ['pack', '--ignore-scripts', '--pack-destination', assets], sentinelSource);
|
|
isolated(['npm', 'install', '--ignore-scripts', '--omit=dev', ...readdirSync(assets).filter(file => file.endsWith('.tgz')).map(file => `/packages/${file}`)], { download: true });
|
|
const sentinel = join(consumer, 'node_modules/paperclip-verification-lifecycle-sentinel/lifecycle-ran');
|
|
assert.equal(existsSync(sentinel), false);
|
|
const lock = readFileSync(join(consumer, 'package-lock.json'), 'utf8');
|
|
isolated(GROK_PUBLIC_INSTALL_LIFECYCLE);
|
|
assert.equal(readFileSync(sentinel, 'utf8'), 'ok');
|
|
assert.equal(readFileSync(join(consumer, 'package-lock.json'), 'utf8'), lock);
|
|
for (const entry of manifest.archives) {
|
|
assert.equal(JSON.parse(readFileSync(join(consumer, 'node_modules', entry.name, 'package.json'))).version, manifest.releaseVersion);
|
|
}
|
|
const server = '/consumer/node_modules/@paperclipai/server', installed = server + '/dist/vendor/paperclip-runner';
|
|
const probe = (name, source, options = {}) => { writeFileSync(join(assets, name), source); return JSON.parse(isolated(['node', '/packages/' + name], options).trim()); };
|
|
const daemon = probe('daemon-probe.mjs', installedDaemonProbeSource(installed, '/consumer', sourceRevision));
|
|
assert.equal(daemon.target, 'linux-arm64');
|
|
const codex = probe('codex-probe.mjs', installedCodexProbeSource(installed + '/index.js', '/consumer', undefined, { nativeCodex: true }));
|
|
cpSync(join(repo, 'tests/runner-e2e/installed-cli.ts'), join(assets, 'installed-cli.ts'));
|
|
writeFileSync(join(assets, 'types.js'), stripTypeScriptTypes(readFileSync(join(repo, 'tests/runner-e2e/types.ts'), 'utf8')));
|
|
const home = join(root, 'host-home'), hostTmp = join(root, 'host-tmp');
|
|
for (const directory of [home, hostTmp]) mkdirSync(directory, { mode: 0o700 });
|
|
const hostEnv = { PATH: `${dirname(process.execPath)}:/usr/bin:/bin:/usr/sbin:/sbin`, HOME: home, TMPDIR: hostTmp, LC_ALL: 'C', TZ: 'UTC' };
|
|
const hostProbe = (name, source) => {
|
|
const file = join(assets, name); writeFileSync(file, source);
|
|
return JSON.parse(execFileSync(process.execPath, [file], { cwd: consumer, env: hostEnv,
|
|
timeout: 120_000, maxBuffer: 1024 * 1024, encoding: 'utf8' }).trim());
|
|
};
|
|
const hostServer = join(consumer, 'node_modules/@paperclipai/server'), hostInstalled = join(hostServer, 'dist/vendor/paperclip-runner');
|
|
const hostDaemon = () => hostProbe('host-daemon-probe.mjs', installedDaemonProbeSource(hostInstalled, consumer, sourceRevision));
|
|
const hostCodex = () => hostProbe('host-codex-probe.mjs', installedCodexProbeSource(join(hostInstalled, 'index.js'), consumer, undefined, { nativeCodex: true }));
|
|
const digest = value => createHash('sha256').update(value).digest('hex');
|
|
const beforeCodex = hostCodex();
|
|
const before = { lockSha256: digest(lock), runnerSha256: hostDaemon().sha256.slice(7), codexCommandSha256: beforeCodex.codexCommandSha256, codexNativeExecutableSha256: beforeCodex.codexNativeExecutableSha256 };
|
|
assert.equal(before.runnerSha256, daemon.sha256.slice(7), 'Docker and host must select the same packaged daemon bytes');
|
|
assert.equal(before.codexCommandSha256, codex.codexCommandSha256, 'Docker and host must select the same official Codex command bytes');
|
|
assert.equal(before.codexNativeExecutableSha256, codex.codexNativeExecutableSha256, 'Docker and host must select the same official native Codex payload bytes');
|
|
const hostHeader = process.report.getReport().header;
|
|
assert.match(hostHeader.glibcVersionRuntime || '', /^\d+\.\d+$/, 'Native host startup must report its actual GNU libc ABI');
|
|
const startup = hostProbe('host-startup-probe.mjs', macInstalledStartupProbeSource(consumer, hostServer, daemon.sha256, join(assets, 'installed-cli.ts')));
|
|
const afterCodex = hostCodex();
|
|
const after = { lockSha256: digest(readFileSync(join(consumer, 'package-lock.json'))), runnerSha256: hostDaemon().sha256.slice(7), codexCommandSha256: afterCodex.codexCommandSha256, codexNativeExecutableSha256: afterCodex.codexNativeExecutableSha256 };
|
|
assertInstalledNativeConsumerContinuity(before, after);
|
|
assert.equal(startup.runnerSha256, before.runnerSha256);
|
|
assert.equal(startup.codexSha256, before.codexCommandSha256);
|
|
const receipt = { schema: 'paperclip.runner.linux-arm64-public-install.v1', sourceRevision, platform: process.platform, architecture: process.arch,
|
|
cleanNpmInstall: true, packageCount: manifest.archives.length, codexPackedPayloadsOmitted: true,
|
|
consumerImage: GROK_PUBLIC_INSTALL_IMAGE, consumerImagePlatform: platform,
|
|
consumerLockPreserved: true, lifecycleSentinelVerified: true, lifecycleNetwork: 'none',
|
|
startupEnvironment: 'native host, same installed graph, isolated empty homes',
|
|
startupHost: { nodeVersion: process.versions.node, nodeModulesAbi: process.versions.modules, glibcVersionRuntime: hostHeader.glibcVersionRuntime, kernelRelease: hostHeader.osRelease },
|
|
installedIdentityBefore: before, installedIdentityAfter: after,
|
|
...daemon, ...codex, startup, providerCalls: 0 };
|
|
writeFileSync(receiptPath, JSON.stringify(receipt, null, 2) + '\n');
|
|
console.log(JSON.stringify(receipt));
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
}
|
|
if (process.argv[2] === '--linux-arm64-consumer') {
|
|
assert.equal(process.argv.length, 6, 'Usage: --linux-arm64-consumer PACKAGE_DIRECTORY SOURCE_SHA RECEIPT_PATH');
|
|
await verifyLinuxArmConsumer(process.argv[3], process.argv[4], process.argv[5]);
|
|
} else if (process.argv[2] === '--mac-consumer') {
|
|
assert.equal(process.argv.length, 6, 'Usage: --mac-consumer PACKAGE_DIRECTORY SOURCE_SHA RECEIPT_PATH');
|
|
await verifyMacConsumer(process.argv[3], process.argv[4], process.argv[5]);
|
|
} else {
|
|
assert.equal(process.platform, 'linux', 'Run this verification on disposable EC2 Linux, not a developer host');
|
|
const root = mkdtempSync(join(tmpdir(), 'paperclip-grok-public-install-'));
|
|
const prerequisite = join(root, 'native/grok');
|
|
const env = { ...process.env, NODE_PATH: '', PAPERCLIP_RELEASE_REUSE_UI_DIST: '1', npm_config_ignore_scripts: 'false', npm_config_audit: 'false', npm_config_fund: 'false' };
|
|
const run = (cmd, args, cwd = root) => execFileSync(cmd, args, { cwd, env, stdio: 'pipe', maxBuffer: 32 * 1024 * 1024 });
|
|
const sourceRevision = run('git', ['rev-parse', 'HEAD'], repo).toString().trim();
|
|
const releaseVersion = `0.0.0-grok-verify.${sourceRevision.slice(0, 12)}`;
|
|
// The two network downloads the probes need do not depend on anything packed
|
|
// below, so they overlap the CPU-bound staging instead of running after it.
|
|
// The consumer image is pinned by digest and the Grok binary is checked against
|
|
// its pinned sha256 by the provisioning script, so an early start changes no
|
|
// verified property. Neither touches the consumer, the assets, nor the
|
|
// `native/grok` path that the post-install assertion inspects.
|
|
const prefetched = join(root, 'prefetch'); mkdirSync(prefetched);
|
|
const stagedGrok = join(prefetched, 'grok');
|
|
// Every background child, downloads and bundled-dependency installs alike, is
|
|
// stopped in `finally`; `downloads` is the subset the timing line reports as
|
|
// prefetches.
|
|
const prefetches = [];
|
|
const downloads = [];
|
|
const timing = {};
|
|
// A prefetch failure surfaces where its result is awaited, never as an
|
|
// unhandled rejection that would mask an earlier staging error.
|
|
const prefetch = (name, cmd, args) => {
|
|
const handle = startPrefetch({ name, cmd, args, cwd: root, env, logPath: join(prefetched, `${name}.log`) });
|
|
prefetches.push(handle);
|
|
downloads.push(handle);
|
|
return handle.done;
|
|
};
|
|
let phaseStarted = performance.now();
|
|
const phase = name => { const now = performance.now(); timing[`${name}_ms`] = Math.round(now - phaseStarted); phaseStarted = now; };
|
|
const awaited = async (name, promise) => { const started = performance.now(); await promise; timing[`${name}_wait_ms`] = Math.round(performance.now() - started); };
|
|
try {
|
|
const imageReady = prefetch('image', 'docker', ['pull', '--platform', 'linux/amd64', GROK_PUBLIC_INSTALL_IMAGE]);
|
|
// Provision as the unprivileged verification user, never into the host's /opt.
|
|
// Only the positive probe sees this file at the canonical sandbox path.
|
|
const grokReady = prefetch('grok', process.execPath, [join(repo, 'packages/paperclip-runner/scripts/provision-grok.mjs'), stagedGrok]);
|
|
const listing = run(process.execPath, [join(repo, 'scripts/release-package-map.mjs'), 'list'], repo).toString().trim().split('\n').map(line => line.split('\t'));
|
|
const packages = new Map(listing.map(([dir, name]) => [name, { dir, manifest: JSON.parse(readFileSync(join(repo, dir, 'package.json'), 'utf8')) }]));
|
|
const needed = new Set();
|
|
function visit(name) {
|
|
if (needed.has(name)) return;
|
|
const entry = packages.get(name); assert.ok(entry, `Missing public workspace dependency ${name}`); needed.add(name);
|
|
for (const [dep, spec] of Object.entries({ ...entry.manifest.dependencies, ...entry.manifest.optionalDependencies })) {
|
|
if (spec.startsWith('workspace:')) visit(dep);
|
|
}
|
|
}
|
|
visit('@paperclipai/server');
|
|
visit('paperclipai');
|
|
// release.sh also builds the standalone public packages (the sandbox-provider
|
|
// plugins outside the pnpm workspace) before it stages anything, because it
|
|
// publishes them. Nothing staged here reaches them: `needed` is closed under
|
|
// `workspace:` specs, so every package staged below is a workspace package
|
|
// that `pnpm build` already built, and that build would only cost one
|
|
// network install and compile per plugin whose output no tarball reads.
|
|
// Canary Dry Run still runs it through release.sh. The one path that does
|
|
// read a standalone build is qualification-package retention at the end:
|
|
// it packs the Daytona plugin from its `dist`, which only this build
|
|
// produces, so the build runs when retention is requested and nowhere else.
|
|
const retainQualificationPackages = Boolean(process.env.PAPERCLIP_RUNNER_QUALIFICATION_PACKAGES_DIR);
|
|
if (retainQualificationPackages) {
|
|
const standaloneStarted = performance.now();
|
|
run(process.execPath, [join(repo, 'scripts/build-standalone-public-packages.mjs')], repo);
|
|
timing.stage_standalone_build_ms = Math.round(performance.now() - standaloneStarted);
|
|
}
|
|
// The server's `ui-dist` payload is prepared here; with the reuse flag set
|
|
// above, that copies the `ui/dist` that `pnpm build` produced instead of
|
|
// building the UI again.
|
|
const uiDistStarted = performance.now();
|
|
run('bash', [join(repo, 'scripts/prepare-server-ui-dist.sh')], repo);
|
|
timing.stage_ui_dist_ms = Math.round(performance.now() - uiDistStarted);
|
|
// Match release.sh's unified versioning in temporary staging directories.
|
|
// Source manifests remain untouched, including independently versioned SDKs.
|
|
// Each package's published files are staged into `source-<index>` and its
|
|
// pack input into `package-<index>`, with <index> in dependency order so the
|
|
// tarball list keeps matching `needed`. The packages that bundle dependencies
|
|
// each need a host-side `npm install` of their bundled closure; those installs
|
|
// write only their own `package-<index>` and read nothing another package
|
|
// produces, so they start first and run together while the other packages
|
|
// are copied, instead of one after another inside one loop. Packing is a
|
|
// Node start-up plus CPU-bound gzip per package that reads only the package's
|
|
// own directory, so the packs also run together, each into its own
|
|
// `pack-<index>`, and the tarballs are checked in order once all are made.
|
|
const entries = [...needed].map((name, index) => {
|
|
const { dir, manifest } = packages.get(name);
|
|
const bundled = (manifest.bundleDependencies ?? manifest.bundledDependencies ?? []).length > 0;
|
|
return { name, index, dir, manifest, bundled, target: join(root, `package-${index}`), stagedSource: join(root, `source-${index}`), destination: join(root, `pack-${index}`) };
|
|
});
|
|
const stageSource = ({ dir, manifest, stagedSource }) => {
|
|
mkdirSync(stagedSource);
|
|
for (const file of manifest.files ?? ['dist']) {
|
|
// release.sh stages runtime skills into these public packages before pack.
|
|
const releaseSkills = file === 'skills' && ['server', 'packages/adapters/claude-local', 'packages/adapters/codex-local'].includes(dir);
|
|
// Other adapters declare an optional skills directory that npm pack omits
|
|
// when absent. Do not fabricate extra release payloads for those adapters.
|
|
if (file === 'skills' && !releaseSkills && !existsSync(join(repo, dir, file))) continue;
|
|
cpSync(releaseSkills ? join(repo, 'skills') : join(repo, dir, file), join(stagedSource, file), { recursive: true });
|
|
}
|
|
const releaseManifest = { ...manifest, version: releaseVersion };
|
|
writeFileSync(join(stagedSource, 'package.json'), JSON.stringify(releaseManifest));
|
|
return releaseManifest;
|
|
};
|
|
const sourcesStarted = performance.now();
|
|
for (const entry of entries.filter(entry => entry.bundled)) stageSource(entry);
|
|
const installsStarted = performance.now();
|
|
const installs = startBundledInstalls(entries.filter(entry => entry.bundled), { logDir: prefetched, cwd: repo });
|
|
prefetches.push(...installs.map(({ handle }) => handle));
|
|
for (const entry of entries.filter(entry => !entry.bundled)) {
|
|
const releaseManifest = stageSource(entry);
|
|
mkdirSync(entry.target);
|
|
cpSync(entry.stagedSource, entry.target, { recursive: true });
|
|
writeFileSync(join(entry.target, 'package.json'), JSON.stringify(materializePublishManifest(releaseManifest)));
|
|
}
|
|
timing.stage_sources_ms = Math.round(performance.now() - sourcesStarted);
|
|
await awaited('bundled', Promise.all(installs.map(({ handle }) => handle.done)));
|
|
timing.stage_bundled_ms = Math.round(performance.now() - installsStarted);
|
|
const packStarted = performance.now();
|
|
// The bundled packages make the largest tarballs, so they are launched first
|
|
// and the short packs fill the remaining slots behind them. Each pack is
|
|
// registered for cleanup as it starts, so a failure stops the ones still
|
|
// running before the scratch root is removed. The results are put back into
|
|
// dependency order before the tarballs are checked and copied.
|
|
const concurrency = packConcurrency();
|
|
const packs = await packStagedPackages([...entries].sort((a, b) => Number(b.bundled) - Number(a.bundled)), { logDir: prefetched, env, concurrency, register: handle => prefetches.push(handle) });
|
|
packs.sort((a, b) => a.index - b.index);
|
|
const checksStarted = performance.now();
|
|
const tarballs = packs.map(({ tarball }) => tarball);
|
|
for (const tarball of tarballs) assertNoBundledCodexPayloads(run('tar', ['-tzf', tarball]).toString().trim().split('\n'));
|
|
timing.stage_pack_check_ms = Math.round(performance.now() - checksStarted);
|
|
timing.stage_pack_ms = Math.round(performance.now() - packStarted);
|
|
Object.assign(timing, packTimings(packs, concurrency));
|
|
|
|
if (process.env.PAPERCLIP_RUNNER_PUBLIC_PACKS_DIR) {
|
|
const output = resolve(process.env.PAPERCLIP_RUNNER_PUBLIC_PACKS_DIR);
|
|
assert.equal(JSON.parse(readFileSync(join(repo, 'server/dist/build-info.json'))).commit, sourceRevision);
|
|
assert.ok(!existsSync(output), 'Never replace retained public packages');
|
|
mkdirSync(output, { recursive: true });
|
|
const archives = [...needed].map((name, index) => {
|
|
const file = basename(tarballs[index]); cpSync(tarballs[index], join(output, file));
|
|
return { name, file, sha256: createHash('sha256').update(readFileSync(tarballs[index])).digest('hex') };
|
|
});
|
|
writeFileSync(join(output, 'manifest.json'), JSON.stringify({
|
|
schema: 'paperclip.runner.public-packages/v1', sourceRevision, releaseVersion,
|
|
publicInstallationVerified: false, providerCalls: 0, archives,
|
|
}, null, 2) + '\n');
|
|
}
|
|
const assets = join(root, 'assets'); mkdirSync(assets, { mode: 0o755 });
|
|
const consumer = join(root, 'consumer'); mkdirSync(consumer);
|
|
const cache = join(root, 'cache'); mkdirSync(cache);
|
|
writeFileSync(join(consumer, 'package.json'), JSON.stringify({ private: true, type: 'module' }));
|
|
for (const tarball of tarballs) {
|
|
const destination = join(assets, basename(tarball)); cpSync(tarball, destination); chmodSync(destination, 0o644);
|
|
}
|
|
// Prove lifecycle execution is real even if npm changes its script defaults.
|
|
const sentinelSource = join(root, 'lifecycle-sentinel'); mkdirSync(sentinelSource);
|
|
writeFileSync(join(sentinelSource, 'package.json'), JSON.stringify({
|
|
name: 'paperclip-verification-lifecycle-sentinel', version: '1.0.0', private: true,
|
|
scripts: { postinstall: 'node -e "require(\'node:fs\').writeFileSync(\'lifecycle-ran\', \'ok\')"' },
|
|
}));
|
|
run('npm', ['pack', '--ignore-scripts', '--pack-destination', assets], sentinelSource);
|
|
const sentinel = join(consumer, 'node_modules/paperclip-verification-lifecycle-sentinel/lifecycle-ran');
|
|
const consumerUid = process.getuid();
|
|
const isolated = (command, options = {}) => run('docker', grokConsumerDockerArgs({ assets, consumer, cache, uid: consumerUid, gid: process.getgid(), command, ...options }));
|
|
phase('stage_packages');
|
|
await awaited('image', imageReady);
|
|
// npm resolution is intentionally the public consumer graph, not the pnpm
|
|
// workspace graph. Freeze that result before any lifecycle script can run.
|
|
isolated(['npm', 'install', '--ignore-scripts', '--omit=dev', ...readdirSync(assets).filter(file => file.endsWith('.tgz')).map(file => `/packages/${file}`)], { download: true });
|
|
phase('consumer_install');
|
|
assert.equal(existsSync(sentinel), false, 'Dependency download must not run lifecycle scripts');
|
|
const consumerLock = readFileSync(join(consumer, 'package-lock.json'), 'utf8');
|
|
// npm ci rejects bundled optional platform dependencies absent from its own
|
|
// generated lock. Rebuild runs the deferred install hooks on the installed
|
|
// graph without re-resolving it; network isolation and lock checks still hold.
|
|
isolated(GROK_PUBLIC_INSTALL_LIFECYCLE);
|
|
assert.equal(readFileSync(sentinel, 'utf8'), 'ok', 'Offline lifecycle scripts must actually execute');
|
|
assert.equal(readFileSync(join(consumer, 'package-lock.json'), 'utf8'), consumerLock, 'Lifecycle execution must preserve the resolved consumer lock');
|
|
phase('lifecycle_rebuild');
|
|
for (const name of needed) {
|
|
const installedManifest = JSON.parse(readFileSync(join(consumer, 'node_modules', name, 'package.json'), 'utf8'));
|
|
assert.equal(installedManifest.version, releaseVersion, `Installed release version for ${name}`);
|
|
}
|
|
assert.equal(existsSync(prerequisite), false, 'npm must not provision Grok');
|
|
const server = join(consumer, 'node_modules/@paperclipai/server');
|
|
const installed = join(server, 'dist/vendor/paperclip-runner');
|
|
const codexVersion = JSON.parse(readFileSync(join(repo, 'packages/paperclip-runner/acpx-profiles.json'), 'utf8')).profiles.codex.agentRuntimeVersion;
|
|
assert.match(codexVersion, /^\d+\.\d+\.\d+$/);
|
|
writeFileSync(join(assets, 'codex-probe.mjs'), installedCodexProbeSource(
|
|
'/consumer/node_modules/@paperclipai/server/dist/vendor/paperclip-runner/index.js', '/consumer', codexVersion), { mode: 0o644 });
|
|
const codex = JSON.parse(isolated(['node', '/packages/codex-probe.mjs']).toString().trim());
|
|
phase('codex_probe');
|
|
assert.equal(codex.codexConsumerHostOnly, true);
|
|
assert.equal(codex.codexPlatformPackageSource, 'official npm');
|
|
assert.ok(existsSync(join(installed, 'providers/grok/launcher.cjs')));
|
|
assert.equal(existsSync(join(consumer, 'node_modules/@paperclipai/grok-acp')), false);
|
|
assert.equal(existsSync(join(installed, 'providers/grok/bin')), false);
|
|
// Use real installed compiled code and its actual npm dependency graph. A
|
|
// separate process prevents module resolution from borrowing this checkout.
|
|
const probe = `
|
|
import assert from 'node:assert/strict';
|
|
import { verifyQualifiedAcpxInstallation } from '/consumer/node_modules/@paperclipai/server/dist/vendor/paperclip-runner/drivers/acpx/installation-integrity.js';
|
|
import { resolveQualifiedAcpxProfile } from '/consumer/node_modules/@paperclipai/server/dist/vendor/paperclip-runner/drivers/acpx/qualified-profiles.js';
|
|
const profile = resolveQualifiedAcpxProfile('grok', 'grok-4.7');
|
|
const inspect = () => verifyQualifiedAcpxInstallation(profile, () => { throw new Error('Grok must not resolve an npm package'); });
|
|
if (process.argv[2] === 'missing') await assert.rejects(inspect, /prerequisite missing/);
|
|
else { const installation = await inspect(); assert.equal(installation.agentServerPackageJsonPath, null); assert.equal(installation.agentRuntimePackageJsonPath, null); await (await installation.openCommand()).close(); }
|
|
`;
|
|
writeFileSync(join(assets, 'probe.mjs'), probe, { mode: 0o644 });
|
|
isolated(['node', '/packages/probe.mjs', 'missing']);
|
|
// The binary was provisioned outside `native/grok` while the packages were
|
|
// staged, so the assertion above still proves npm put nothing there. It moves
|
|
// into place only now, so only the positive probe sees it.
|
|
await awaited('grok', grokReady);
|
|
mkdirSync(dirname(prerequisite), { recursive: true });
|
|
renameSync(stagedGrok, prerequisite);
|
|
isolated(['node', '/packages/probe.mjs', 'present'], { prerequisite });
|
|
phase('grok_probes');
|
|
console.log(JSON.stringify({ schema: 'paperclip.grok.public-npm-install.v1', sourceRevision, releaseVersion, lifecycleScriptsEnabled: true, lifecycleSentinelVerified: true, lifecycleNetwork: 'none', consumerImage: GROK_PUBLIC_INSTALL_IMAGE, consumerUid, consumerLockPreserved: true, cleanNpmInstall: true, packageCount: needed.size, codexPackedPayloadsOmitted: true, codexPackedPackagesChecked: tarballs.length, ...codex, builtinLauncherPresent: true, separateGrokPackage: false, npmProvisionedBinary: false, missingPrerequisiteRejected: true, provisionedBinaryVerified: true, commandLeaseVerified: true, providerCalls: 0 }));
|
|
// Exercise Pi's public CLI and installed server, never a private workspace
|
|
// package or binary override. Public dependency downloads are explicit and
|
|
// isolated; the actual admission probe runs without a network or credentials.
|
|
const piProbe = join(assets, 'pi-public-install-probe.mjs');
|
|
cpSync(join(repo, 'scripts/pi-public-install-probe.mjs'), piProbe); chmodSync(piProbe, 0o644);
|
|
// Pi assembles a bundled runtime in scratch space before atomic publication.
|
|
// Keep the existing sandbox and memory bound; only this download needs more
|
|
// temporary capacity than the smaller offline lifecycle probes.
|
|
const setup = isolated(['node', '/consumer/node_modules/paperclipai/dist/index.js', 'runtime', 'setup', 'pi'], { download: true, temporarySizeMiB: 2048 }).toString();
|
|
const receipt = JSON.parse(setup.trim());
|
|
phase('pi_setup');
|
|
assert.equal(receipt.status, 'installed_verified');
|
|
assert.equal(receipt.target, 'linux-x64');
|
|
assert.equal(readFileSync(join(consumer, 'package-lock.json'), 'utf8'), consumerLock, 'Pi setup must preserve the consumer dependency graph');
|
|
// Verified launch leases also materialize the runtime in private scratch.
|
|
// Docker defaults tmpfs to noexec. The offline admission probe must execute
|
|
// its verified private snapshot while keeping lifecycle/download scratch noexec.
|
|
console.log(isolated(['node', '/packages/pi-public-install-probe.mjs', '/consumer/node_modules/@paperclipai/server'], { temporarySizeMiB: 2048, temporaryExecutable: true }).toString().trim());
|
|
phase('pi_probe');
|
|
// Wall time per phase, so the slow part of this step is visible in the CI log
|
|
// without re-running it. `*_prefetch_ms` runs from a download's start to its
|
|
// last output, and `*_wait_ms` is how long the main flow waited for a
|
|
// prefetch that had not finished yet; zero means the overlap hid it entirely.
|
|
// `stage_ui_dist_ms`, `stage_sources_ms`, `stage_bundled_ms` and
|
|
// `stage_pack_ms` split the staging phase, and `stage_bundled_<package>_ms`
|
|
// is each concurrent install. `stage_standalone_build_ms` appears only when
|
|
// qualification-package retention made the standalone build necessary.
|
|
const downloaded = Object.fromEntries(downloads.map(({ name, durationMs }) => [`${name}_prefetch_ms`, durationMs]));
|
|
console.log(JSON.stringify({ schema: 'paperclip.public-npm-install.timing.v1', ...timing, ...downloaded, ...bundledInstallTimings(installs) }));
|
|
if (retainQualificationPackages) {
|
|
const retained = retainRunnerQualificationPackages({ repo, output: process.env.PAPERCLIP_RUNNER_QUALIFICATION_PACKAGES_DIR, sourceRevision, releaseVersion, env,
|
|
publicArchives: [...needed].map((name, index) => ({ name, file: tarballs[index] })),
|
|
});
|
|
console.log(JSON.stringify(retained));
|
|
}
|
|
} finally {
|
|
// An earlier failure must not leave a prefetch running, and scratch is
|
|
// removed only once both children have stopped writing into it.
|
|
await stopPrefetches(prefetches);
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
}
|