From d258f478fc3ae7caa12a81af9befb645d7107653 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:50:54 -0600 Subject: [PATCH 1/5] test(ci): stop the live-run census hanging server shards, and name any stalled test file (#21941) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - PR CI splits the server tests across 12 shards; `ci / verify` fails when any shard fails > - Since 2026-11-16 the server shards were cancelled at their 20-minute job limit with no output (shard 2/12 five times, plus shards 1, 3 and 9), which blocked unrelated pull requests until reruns > - Turbo prints a task's output only when it ends, so a cancelled shard never names the stuck file > - Recomputing each cancelled shard's file list at its own merge commit put `issue-recovery-live-run-agent-census.test.ts` in 12 of 14 of them; it is also the slowest file in passing shards (235-300 s) > - That census started 9-14 real agent runs per file while `setTimeout` was faked, waited on them with no bound, and had 30-minute test timeouts, so a stuck wait could never fail inside the job > - This pull request stops the census from starting real runs, bounds every wait, and adds a CI reporter that fails a run naming any file that stops making progress > - The benefit is that this file cannot hang a shard, and the next stuck file fails in minutes with its name and step in the log ## Linked Issues or Issue Description Refs #21867 (the same fix for the sibling agent-row census), #21831 (the behavior this census guards) **What happened?** `ci / General tests (server (2/12))` was cancelled at 20m16s in actions runs 43865258195, 43926799428, 43932238377, 43934278368, 43944290677 and 43935722497 (both attempts), and other server shards hit the same limit (for example 43901003914 shard 1, 43945768035 shard 3, 43845343831 shard 9). The hung jobs show CPU near 0 for the last 9 minutes and printed nothing after `Running //#test:run:general`. Shard membership changes with every merge commit. To compare the shards, I recomputed each job's file list at its exact merge commit with `GITHUB_WORKFLOW=PR` (the PR workflow removes the native-runner suites from these shards, so a local dry run without it gives a different list). `server/src/__tests__/issue-recovery-live-run-agent-census.test.ts` was in 12 of the 14 hung shards. Why that file: - During its 10-minute fake-timer warm-up, the "live" task was `in_progress` with no run. That is real assigned work, so recovery woke its agent and a real `process`-adapter run started while `setTimeout` was faked. The run lost its lease ("Legacy controller lease lost"), recovery retried, and a local run of the file showed 13 real run executions. - No wait in the file had a bound, and each test had a 30-minute timeout, so a delivery pass waiting on a faked timer or a run holding a lock never failed inside the 20-minute job. - Under local CPU contention, 3 of 4 copies of the old file failed the census assertion (39 settled checks, caused by the stray runs), and each copy took about 270 s with 9-14 real runs. Fixing the runs exposed a second problem in the fixture: the seeded tasks were stamped "now". The first 5-minute backstop after the live run's first hint re-checks rows changed within 5 minutes before the last full pass, so it re-checked all 860 seeded tasks. The old file passed only because the stray runs happened to trigger that backstop during the warm-up. **Expected behavior** The census never starts a real run, every wait has a bound that names what it waited for, and a CI test file that stops making progress fails the job quickly with its name. ## What Changed - `issue-recovery-live-run-agent-census.test.ts` - The live task is a settled review until its run starts; `startLiveRun` now writes the checkout (`in_progress` + `executionRunId`) the way execution start does. - Population agents and the held agent take no on-demand wakes (`wakeOnDemand: false`), so a recovery check cannot dispatch a run. The census counts queue checks, so this does not change what it measures. - The seeded population is backdated 2 hours ("settled long before the window", as the file's comment already said). - Each step (seed, worker start, run start, run-event tick, fake-timer advance, pass settlement, direct writes) has a real 20-second bound captured before the timers are faked, with a message naming the step. Test timeout is 4 minutes instead of 30. - New `scripts/ci/stalled-file-reporter.mjs`, enabled in GitHub Actions from the root `vitest.config.ts`: when a running file starts no test or hook and reports no result for 8 minutes (`PAPERCLIP_VITEST_FILE_STALL_MS` overrides), it prints a `::error file=...` annotation naming the file and the step it was in, cancels the run and exits 1. The slowest healthy server file runs about 5 minutes in total, so 8 minutes without any progress means a stuck file. Tests: `scripts/ci/stalled-file-reporter.test.mjs` (added to `test:release-registry`). ## Verification - Census, red: the old file runs 13 real agent runs locally (`heartbeat execution setup failed`, `LegacyControllerLeaseLostError`); with 4 copies under CPU contention, 3 failed with 39 settled checks at about 270 s each. - Census, green: 4/4 tests pass, 0 real runs, about 80 s locally. - Census still guards #21831: with the `ag.status <> 'running'` line removed from `changed-tasks.ts`, the first test fails with 534 settled checks and 540 backstop checks, the numbers #21831 recorded. - Reporter, red/green: the real-Vitest case (a file awaiting a promise that never settles, with a 10-minute test timeout) is still running when the 20-second test bound ends without the reporter; with the reporter it exits 1 in about 8 s and prints the annotation naming the file and the test. - Reporter on a real server file: `PAPERCLIP_VITEST_FILE_STALL_MS=3000` on `issue-recovery-recorded-decision-idle.test.ts` prints the annotation naming the file and step and exits 1. - `node --test scripts/ci/stalled-file-reporter.test.mjs`: 5/5 pass. ## Risks - Test and CI-tooling change only. No product code changed. - The census's agents no longer take on-demand wakes. The census measures recovery queue checks, not dispatch, and still fails without the #21831 fix. - The reporter stops the whole CI run when one file stalls for 8 minutes. A legitimate single test or hook that runs more than 8 minutes with no other progress in its file would now fail; none exists today (the slowest whole file is about 5 minutes). The limit is configurable. - Other fake-timer recovery files still have long test timeouts and unbounded pass waits (for example `issue-recovery-activity-hints`, 30 minutes). The reporter now caps any of them at 8 minutes without progress and names the file; bounding them is follow-up work. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use and code execution in Claude Code. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- package.json | 2 +- scripts/ci/stalled-file-reporter.mjs | 146 ++++++++++++++++++ scripts/ci/stalled-file-reporter.test.mjs | 114 ++++++++++++++ ...sue-recovery-live-run-agent-census.test.ts | 84 +++++++--- .../runner-e2e/source-sdk-public-inputs.json | 2 +- vitest.config.ts | 5 +- 6 files changed, 325 insertions(+), 28 deletions(-) create mode 100644 scripts/ci/stalled-file-reporter.mjs create mode 100644 scripts/ci/stalled-file-reporter.test.mjs diff --git a/package.json b/package.json index b6a185b015b..2213c21acb7 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "smoke:notion-generic-live": "node scripts/smoke/notion-generic-live.mjs", "smoke:posthog-live": "node scripts/smoke/posthog-live.mjs", "smoke:terminal-bench-loop-skill": "node scripts/smoke/terminal-bench-loop-skill-smoke.mjs", - "test:release-registry": "node scripts/ci-profile/node-test.mjs scripts/ci-profile/reporters.test.mjs scripts/ci/retry-reporter.test.mjs scripts/__tests__/runner-vitest-package-lanes.test.mjs scripts/__tests__/canary-startup-playwright.test.mjs scripts/__tests__/cursor-public-install-sandbox.test.mjs scripts/__tests__/grok-public-install-sandbox.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/public-install-registry.test.mjs scripts/__tests__/prefetch-child.test.mjs scripts/__tests__/stage-bundled-packages.test.mjs scripts/__tests__/pack-staged-packages.test.mjs scripts/__tests__/retain-runner-qualification-packages.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/runner-debug-crate-cache.test.mjs scripts/__tests__/agent-build-cache.test.mjs scripts/__tests__/agent-preflight.test.mjs scripts/__tests__/vitest-worker-isolation.test.mjs scripts/verify-release-registry-state.test.mjs scripts/release-package-map.test.mjs scripts/check-release-package-bootstrap.test.mjs scripts/check-no-git-push.test.mjs scripts/release-lib.test.mjs scripts/draft-stable-notes.test.mjs scripts/release-registry-versions.test.mjs scripts/link-plugin-dev-sdk.test.js scripts/acpx-patch-packaging.test.mjs scripts/service-onboard-smoke.test.mjs scripts/docker-onboard-smoke.test.mjs scripts/preview-artifacts.test.mjs scripts/cloud-migrator-artifacts.test.mjs scripts/typecheck-test-programs.test.mjs scripts/__tests__/local-verify.test.mjs scripts/test-sandbox-providers.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/scale-ramp/scale-ramp.test.ts scripts/scale-ramp/scale-ramp-spend.test.ts", + "test:release-registry": "node scripts/ci-profile/node-test.mjs scripts/ci-profile/reporters.test.mjs scripts/ci/retry-reporter.test.mjs scripts/ci/stalled-file-reporter.test.mjs scripts/__tests__/runner-vitest-package-lanes.test.mjs scripts/__tests__/canary-startup-playwright.test.mjs scripts/__tests__/cursor-public-install-sandbox.test.mjs scripts/__tests__/grok-public-install-sandbox.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/public-install-registry.test.mjs scripts/__tests__/prefetch-child.test.mjs scripts/__tests__/stage-bundled-packages.test.mjs scripts/__tests__/pack-staged-packages.test.mjs scripts/__tests__/retain-runner-qualification-packages.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/runner-debug-crate-cache.test.mjs scripts/__tests__/agent-build-cache.test.mjs scripts/__tests__/agent-preflight.test.mjs scripts/__tests__/vitest-worker-isolation.test.mjs scripts/verify-release-registry-state.test.mjs scripts/release-package-map.test.mjs scripts/check-release-package-bootstrap.test.mjs scripts/check-no-git-push.test.mjs scripts/release-lib.test.mjs scripts/draft-stable-notes.test.mjs scripts/release-registry-versions.test.mjs scripts/link-plugin-dev-sdk.test.js scripts/acpx-patch-packaging.test.mjs scripts/service-onboard-smoke.test.mjs scripts/docker-onboard-smoke.test.mjs scripts/preview-artifacts.test.mjs scripts/cloud-migrator-artifacts.test.mjs scripts/typecheck-test-programs.test.mjs scripts/__tests__/local-verify.test.mjs scripts/test-sandbox-providers.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/scale-ramp/scale-ramp.test.ts scripts/scale-ramp/scale-ramp-spend.test.ts", "storybook-visual:baseline": "node scripts/storybook-visual-baseline.mjs", "test:storybook-visual": "node scripts/storybook-visual-baseline.mjs download && node scripts/storybook-visual-baseline.mjs verify && pnpm build-storybook && npx playwright test --config tests/storybook-visual/playwright.config.ts", "test:storybook-visual:update": "node scripts/storybook-visual-baseline.mjs download && pnpm build-storybook && npx playwright test --config tests/storybook-visual/playwright.config.ts --update-snapshots && node scripts/storybook-visual-baseline.mjs pack", diff --git a/scripts/ci/stalled-file-reporter.mjs b/scripts/ci/stalled-file-reporter.mjs new file mode 100644 index 00000000000..82412feb5c8 --- /dev/null +++ b/scripts/ci/stalled-file-reporter.mjs @@ -0,0 +1,146 @@ +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +// A test file that stops making progress otherwise holds its CI job silently +// until the job's time limit cancels it. Turbo prints a task's output only +// when the task ends, so a cancelled job never names the stuck file (server +// shard 2/12 on 2026-11-16: five cancellations at 20m16s, no file named). +// +// This reporter watches every running file. When one starts no test, hook or +// result for the stall limit, it prints a GitHub error annotation naming the +// file and the step it was in, then ends the run with a failure, so the job +// fails minutes earlier with the file and step in its log. +export const stallEnvName = "PAPERCLIP_VITEST_FILE_STALL_MS"; +// The slowest healthy server files ran about 5 minutes in total +// (issue-recovery-live-run-agent-census, 235-300 s in PR shards), and no +// single test or hook in a healthy run goes this long without progress. +export const defaultStallMs = 8 * 60_000; +// How long a cancelled run may take to stop before the process exits anyway. +export const exitGraceMs = 30_000; +const repoRoot = fileURLToPath(new URL("../../", import.meta.url)); + +export function stallLimitMs(env = process.env) { + const configured = env[stallEnvName]?.trim(); + if (!configured) return defaultStallMs; + const parsed = Number(configured); + if (!Number.isInteger(parsed) || parsed <= 0) { + throw new Error(`${stallEnvName} must be a positive integer of milliseconds. Received "${configured}".`); + } + return parsed; +} + +// Watching is for CI, where a stuck file costs a whole job; a local run can be +// stopped by hand. The variable turns it on anywhere, for example to reproduce. +export function stalledFileReporterEnabled(env = process.env) { + return env.GITHUB_ACTIONS === "true" || Boolean(env[stallEnvName]?.trim()); +} + +function escapeData(value) { + return String(value).replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A"); +} + +function escapeProperty(value) { + return escapeData(value).replaceAll(":", "%3A").replaceAll(",", "%2C"); +} + +export function stallAnnotation(entry, now) { + const minutes = ((now - entry.progressAt) / 60_000).toFixed(1); + const properties = [`file=${escapeProperty(entry.file)}`, `title=${escapeProperty("Test file stopped making progress")}`]; + return `::error ${properties.join(",")}::${escapeData( + `${entry.file} made no progress for ${minutes} min while in: ${entry.step}. ` + + "The run was stopped so this job fails with the file's name instead of reaching its time limit.")}`; +} + +export default class StalledFileReporter { + constructor(options = {}) { + this.limitMs = options.limitMs ?? stallLimitMs(); + this.now = options.now ?? Date.now; + this.exit = options.exit ?? (code => process.exit(code)); + this.write = options.write ?? (line => process.stderr.write(`${line}\n`)); + this.root = options.root ?? repoRoot; + this.graceMs = options.graceMs ?? exitGraceMs; + this.intervalMs = options.intervalMs ?? Math.min(15_000, Math.max(250, Math.floor(this.limitMs / 4))); + this.files = new Map(); + this.timer = null; + this.stopped = false; + } + + onInit(vitest) { + this.vitest = vitest; + } + + onTestRunStart() { + this.stopped = false; + if (this.timer) return; + // The reporter runs in the main Vitest process, whose timers tests never + // fake. The interval must not keep a finished run alive. + this.timer = setInterval(() => this.check(), this.intervalMs); + this.timer.unref?.(); + } + + progress(moduleId, step) { + const entry = this.files.get(moduleId); + if (!entry) return; + entry.progressAt = this.now(); + entry.step = step; + } + + // Queued fires before the file is imported, so a file that never finishes + // loading (a top-level await or a blocking setup import) is watched too. + onTestModuleQueued(testModule) { + const file = path.relative(this.root, testModule.moduleId).split(path.sep).join("/"); + this.files.set(testModule.moduleId, { file, progressAt: this.now(), step: "loading the file" }); + } + + onTestModuleStart(testModule) { + if (!this.files.has(testModule.moduleId)) this.onTestModuleQueued(testModule); + this.progress(testModule.moduleId, "starting the file's tests"); + } + + onHookStart(hook) { + const moduleId = hook.entity?.module?.moduleId ?? hook.entity?.moduleId; + const owner = hook.entity?.fullName ?? hook.entity?.name; + this.progress(moduleId, owner ? `${hook.name} of ${owner}` : hook.name); + } + + onHookEnd(hook) { + this.onHookStart({ ...hook, name: `after ${hook.name}` }); + } + + onTestCaseReady(testCase) { + this.progress(testCase.module.moduleId, `test "${testCase.fullName}"`); + } + + onTestCaseResult(testCase) { + this.progress(testCase.module.moduleId, `after test "${testCase.fullName}"`); + } + + onTestModuleEnd(testModule) { + this.files.delete(testModule.moduleId); + } + + onTestRunEnd() { + this.files.clear(); + if (this.timer) clearInterval(this.timer); + this.timer = null; + // A cancelled run can report its finished files as passed. It still failed: + // exit once the other reporters have printed their summaries. + if (this.stopped) setTimeout(() => this.exit(1), 1000); + } + + check() { + if (this.stopped) return; + const now = this.now(); + const stalled = [...this.files.values()].filter(entry => now - entry.progressAt >= this.limitMs); + if (stalled.length === 0) return; + this.stopped = true; + for (const entry of stalled) this.write(stallAnnotation(entry, now)); + const running = [...this.files.values()].map(entry => entry.file).sort(); + this.write(`[stalled-file-reporter] stopping the run; files still running: ${running.join(", ")}`); + process.exitCode = 1; + // A stalled worker may never answer a cancel, so exit after a grace period + // either way. This timer is kept referenced on purpose. + setTimeout(() => this.exit(1), this.graceMs); + void Promise.resolve(this.vitest?.cancelCurrentRun("stalled-file")).catch(() => undefined); + } +} diff --git a/scripts/ci/stalled-file-reporter.test.mjs b/scripts/ci/stalled-file-reporter.test.mjs new file mode 100644 index 00000000000..840cf6d5e6f --- /dev/null +++ b/scripts/ci/stalled-file-reporter.test.mjs @@ -0,0 +1,114 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import test from "node:test"; +import StalledFileReporter, { defaultStallMs, stallAnnotation, stalledFileReporterEnabled, stallLimitMs } + from "./stalled-file-reporter.mjs"; + +const root = fileURLToPath(new URL("../../", import.meta.url)); +const reporterPath = fileURLToPath(new URL("./stalled-file-reporter.mjs", import.meta.url)); + +test("the stall limit defaults to eight minutes and accepts a positive override", () => { + assert.equal(stallLimitMs({}), defaultStallMs); + assert.equal(defaultStallMs, 8 * 60_000); + assert.equal(stallLimitMs({ PAPERCLIP_VITEST_FILE_STALL_MS: " 1500 " }), 1500); + assert.equal(stallLimitMs({ PAPERCLIP_VITEST_FILE_STALL_MS: "" }), defaultStallMs); + for (const value of ["0", "-5", "1.5", "soon"]) { + assert.throws(() => stallLimitMs({ PAPERCLIP_VITEST_FILE_STALL_MS: value }), /positive integer/, value); + } +}); + +test("the reporter watches in GitHub Actions, or wherever the limit is set", () => { + assert.equal(stalledFileReporterEnabled({}), false); + assert.equal(stalledFileReporterEnabled({ GITHUB_ACTIONS: "true" }), true); + assert.equal(stalledFileReporterEnabled({ PAPERCLIP_VITEST_FILE_STALL_MS: "1000" }), true); +}); + +test("a file stops the run only once it makes no progress for the whole limit", () => { + let now = 0; + const lines = [], exits = []; + const cancels = []; + const reporter = new StalledFileReporter({ limitMs: 1000, now: () => now, write: line => lines.push(line), + exit: code => exits.push(code), root: "/repo", graceMs: 0 }); + reporter.onInit({ cancelCurrentRun: reason => { cancels.push(reason); return Promise.resolve(); } }); + const moduleId = "/repo/server/src/stuck.test.ts"; + const testCase = { fullName: "suite > waits forever", module: { moduleId } }; + reporter.onTestModuleStart({ moduleId }); + reporter.onTestModuleStart({ moduleId: "/repo/server/src/healthy.test.ts" }); + now = 900; reporter.onTestCaseReady(testCase); + now = 1800; reporter.onTestCaseResult({ fullName: "ok", module: { moduleId: "/repo/server/src/healthy.test.ts" } }); + reporter.check(); + assert.deepEqual(lines, [], "progress 900 ms ago is not a stall"); + now = 1900; reporter.check(); + assert.equal(lines.length, 2); + assert.match(lines[0], /^::error file=server\/src\/stuck\.test\.ts,title=Test file stopped making progress::/); + assert.match(lines[0], /while in: test "suite > waits forever"/); + assert.equal(lines[1], "[stalled-file-reporter] stopping the run; files still running: server/src/healthy.test.ts, server/src/stuck.test.ts"); + assert.deepEqual(cancels, ["stalled-file"]); + reporter.check(); + assert.equal(lines.length, 2, "a stopped run reports once"); + process.exitCode = 0; +}); + +test("finished files and hooks count as progress", () => { + let now = 0; + const lines = []; + const reporter = new StalledFileReporter({ limitMs: 1000, now: () => now, write: line => lines.push(line), exit: () => {}, root: "/repo" }); + const moduleId = "/repo/a.test.ts"; + reporter.onTestModuleStart({ moduleId }); + now = 800; reporter.onHookStart({ name: "beforeAll", entity: { moduleId } }); + now = 1600; reporter.check(); + assert.deepEqual(lines, []); + reporter.onTestModuleEnd({ moduleId }); + now = 10_000; reporter.check(); + assert.deepEqual(lines, []); + assert.equal(stallAnnotation({ file: "a,b:c.test.ts", progressAt: 0, step: "x\ny" }, 90_000), + "::error file=a%2Cb%3Ac.test.ts,title=Test file stopped making progress::a,b:c.test.ts made no progress for 1.5 min while in: x%0Ay." + + " The run was stopped so this job fails with the file's name instead of reaching its time limit."); +}); + +test("a file that never finishes loading is named from the moment it is queued", () => { + let now = 0; + const lines = []; + const reporter = new StalledFileReporter({ limitMs: 1000, now: () => now, write: line => lines.push(line), exit: () => {}, root: "/repo" }); + reporter.onTestModuleQueued({ moduleId: "/repo/server/src/top-level-await.test.ts" }); + now = 1000; reporter.check(); + assert.match(lines[0] ?? "", /^::error file=server\/src\/top-level-await\.test\.ts,.*while in: loading the file\./); + process.exitCode = 0; +}); + +// The failure this guards: a test awaiting a promise that never settles, with +// a test timeout longer than the CI job, holds Vitest until the job is +// cancelled and never prints the file's name. +for (const [label, body, step] of [ + ["a test that never settles", 'import { test } from "vitest";\ntest("waits forever", () => new Promise(() => {}), 600_000);\n', 'test "waits forever"'], + ["a top-level await that never settles", 'import { test } from "vitest";\nawait new Promise(() => {});\ntest("never collected", () => {});\n', "loading the file"], +]) test(`a real Vitest run with ${label} fails fast and names the file`, () => { + const directory = realpathSync(mkdtempSync(path.join(tmpdir(), "stalled-file-reporter-"))); + try { + writeFileSync(path.join(directory, "stuck.test.mjs"), body); + writeFileSync(path.join(directory, "quick.test.mjs"), `import { test } from "vitest"; +test("passes", () => {}); +`); + const configFile = path.join(directory, "vitest.config.mjs"); + writeFileSync(configFile, `export default ${JSON.stringify({ test: { include: ["*.test.mjs"], + reporters: ["default", [reporterPath, { limitMs: 1500, graceMs: 5000, root: directory }]] } })};`); + const started = Date.now(); + const result = spawnSync(process.execPath, [path.join(root, "node_modules/vitest/vitest.mjs"), "run", + "--config", configFile, "--root", directory], { + cwd: directory, encoding: "utf8", timeout: 60_000, + env: { ...process.env, GITHUB_ACTIONS: "", PAPERCLIP_VITEST_FILE_STALL_MS: "" }, + }); + const output = `${result.stdout}\n${result.stderr}`; + assert.equal(result.signal, null, `Vitest was still running after 60 s:\n${output}`); + assert.notEqual(result.status, 0, output); + assert.ok(Date.now() - started < 30_000, `took ${Date.now() - started} ms:\n${output}`); + assert.match(output, /::error file=stuck\.test\.mjs,title=Test file stopped making progress::stuck\.test\.mjs made no progress/); + assert.ok(output.includes(`while in: ${step}.`), output); + } finally { + rmSync(directory, { recursive: true, force: true }); + } +}); diff --git a/server/src/__tests__/issue-recovery-live-run-agent-census.test.ts b/server/src/__tests__/issue-recovery-live-run-agent-census.test.ts index 94032f7f2e8..1d0a90dd36a 100644 --- a/server/src/__tests__/issue-recovery-live-run-agent-census.test.ts +++ b/server/src/__tests__/issue-recovery-live-run-agent-census.test.ts @@ -11,9 +11,23 @@ import { seedRecoveryPopulation } from "./helpers/recovery-population.js"; vi.hoisted(() => { process.env.PAPERCLIP_DEBUG_WORK_SIGNALS = "stranded-assignments:1,assigned-work-invariant:1"; }); const MINUTE = 60_000; +const TEST_TIMEOUT_MS = 240_000; +const STEP_TIMEOUT_MS = 20_000; const TOPICS = new Set(["stranded-assignments", "assigned-work-invariant"]); +const realSetTimeout = globalThis.setTimeout; +const realClearTimeout = globalThis.clearTimeout; type Recorded = { at: number; topic: string; name: string; fields: Record }; +/** Bounds one step with the real clock, captured before the timers are faked, + * so a wait that cannot finish fails in seconds and names what it waited for. */ +function bounded(work: Promise, waitingFor: () => string): Promise { + let timer: ReturnType | undefined; + const expired = new Promise((_, reject) => { + timer = realSetTimeout(() => reject(new Error(`Timed out after ${STEP_TIMEOUT_MS} ms waiting for ${waitingFor()}`)), STEP_TIMEOUT_MS); + }); + return Promise.race([work, expired]).finally(() => realClearTimeout(timer)); +} + /** * Staging shape: about 860 settled assigned tasks, most of them held by the * same few agents, and one agent whose native run stays live for the whole @@ -27,9 +41,14 @@ describeIssueRecovery("stranded-task checks beside one long live run (census)", const until = Date.now() + ms; let nextTick = Date.now(); while (Date.now() < until) { - if (onTick && Date.now() >= nextTick) { await onTick(); nextTick = Date.now() + 10_000; } - await vi.advanceTimersByTimeAsync(Math.min(1000, until - Date.now())); - await Promise.allSettled([...state.passes]); await immediate(); + const at = new Date(Date.now()).toISOString(); + if (onTick && Date.now() >= nextTick) { + await bounded(onTick(), () => `the run event at simulated ${at} to commit`); + nextTick = Date.now() + 10_000; + } + await bounded(vi.advanceTimersByTimeAsync(Math.min(1000, until - Date.now())), () => `simulated time to advance past ${at}`); + await bounded(Promise.allSettled([...state.passes]), () => `${state.passes.size} delivery passes started by simulated ${at} to settle`); + await immediate(); } } @@ -56,38 +75,52 @@ describeIssueRecovery("stranded-task checks beside one long live run (census)", async function seed() { const f = await state.fixture(); // 12 agents leave 3 workers, so each holds about 266 of the settled reviews. - const population = await seedRecoveryPopulation(state.db, f.companyId, { agents: 12, inReview: 800, inProgress: 30, todo: 30 }); + // No agent takes on-demand wakes: a check that repairs a task would start a + // real run while setTimeout is faked, and that run can wait forever. The + // census counts queue checks, not runs. + const population = await seedRecoveryPopulation(state.db, f.companyId, + { agents: 12, inReview: 800, inProgress: 30, todo: 30, wakeOnDemand: false }); + // Settled long before the window, as on staging. Rows stamped now count as + // changed for the first backstop after the warm-up, which would re-check + // every seeded task once. + const settledAt = new Date(Date.now() - 2 * 60 * MINUTE); + await state.db.update(issues).set({ createdAt: settledAt, updatedAt: settledAt }).where(eq(issues.companyId, f.companyId)); + await state.db.update(heartbeatRuns).set({ updatedAt: settledAt }).where(eq(heartbeatRuns.companyId, f.companyId)); + await state.db.update(agents).set({ createdAt: settledAt, updatedAt: settledAt }).where(eq(agents.companyId, f.companyId)); const liveAgentId = population.agentIds[7]!; - const [liveTask] = await state.db.insert(issues).values({ companyId: f.companyId, title: "Live native task", status: "in_progress", + // A settled review until its run starts. An in-progress task with no run + // is real assigned work, so recovery would start a real run for it while + // setTimeout is faked, and that run can wait forever. + const [liveTask] = await state.db.insert(issues).values({ companyId: f.companyId, title: "Live native task", status: "in_review", assigneeAgentId: liveAgentId }).returning({ id: issues.id }); // A paused agent with one waiting task, both settled long before the window. - const old = new Date(Date.now() - 2 * 60 * MINUTE); + // It takes no on-demand wakes, so resuming it never starts a real run. const [held] = await state.db.insert(agents).values({ companyId: f.companyId, name: "Held worker", role: "engineer", status: "paused", - lifecycleHolds: ["manual"], adapterType: "process", reportsTo: population.agentIds[1], createdAt: old, updatedAt: old, + lifecycleHolds: ["manual"], adapterType: "process", reportsTo: population.agentIds[1], createdAt: settledAt, updatedAt: settledAt, adapterConfig: { command: process.execPath, args: ["-e", "0"], cwd: process.cwd() }, - runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: true } } }).returning({ id: agents.id }); + runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: false } } }).returning({ id: agents.id }); const [waiting] = await state.db.insert(issues).values({ companyId: f.companyId, title: "Waits for its agent", status: "todo", - assigneeAgentId: held!.id, createdAt: old, updatedAt: old }).returning({ id: issues.id }); + assigneeAgentId: held!.id, createdAt: settledAt, updatedAt: settledAt }).returning({ id: issues.id }); return { ...f, population, liveAgentId, liveTaskId: liveTask!.id, heldAgentId: held!.id, waitingTaskId: waiting!.id }; } async function boot() { - const f = await seed(); + const f = await bounded(seed(), () => "the fixture to be seeded"); const events = record(); vi.useFakeTimers({ toFake: ["Date", "setTimeout", "clearTimeout"] }); - await state.start({}); + await bounded(state.start({}), () => "the recovery workers to start"); await advance(10 * MINUTE); events.length = 0; return { ...f, events }; } - /** What execution start writes (heartbeat.ts): the run, then the agent's - * status flip to running without a heartbeat time. */ + /** What execution start writes (heartbeat.ts): the run, the task's checkout, + * then the agent's status flip to running without a heartbeat time. */ async function startLiveRun(f: Awaited>) { const [run] = await state.db.insert(heartbeatRuns).values({ companyId: f.companyId, agentId: f.liveAgentId, status: "running", runtimeMode: "native", startedAt: new Date(), contextSnapshot: { issueId: f.liveTaskId }, nativeIssueId: f.liveTaskId }) .returning({ id: heartbeatRuns.id }); - await state.db.update(issues).set({ executionRunId: run!.id }).where(eq(issues.id, f.liveTaskId)); + await state.db.update(issues).set({ status: "in_progress", executionRunId: run!.id }).where(eq(issues.id, f.liveTaskId)); await state.db.update(agents).set({ status: "running", updatedAt: new Date() }).where(eq(agents.id, f.liveAgentId)); const runId = run!.id; return { @@ -102,7 +135,7 @@ describeIssueRecovery("stranded-task checks beside one long live run (census)", it("does not re-check the live agent's settled tasks while its run stays live", async () => { const f = await boot(); - const live = await startLiveRun(f); + const live = await bounded(startLiveRun(f), () => "the live run to start"); let ticks = 0; const before = state.meter.read(); await advance(30 * MINUTE, () => { ticks += 1; return live.tick(); }); @@ -121,11 +154,11 @@ describeIssueRecovery("stranded-task checks beside one long live run (census)", expect(result.strandedByWake.hint ?? 0).toBeLessThanOrEqual(ticks + 10); expect(result.assignedWork).toBeLessThanOrEqual(10); expect(result.signalsBeyondRunEvents).toBe(0); - }, 1_800_000); + }, TEST_TIMEOUT_MS); it("still checks a task of the live agent within the backstop bound when its own rows change without a hint", async () => { const f = await boot(); - const live = await startLiveRun(f); + const live = await bounded(startLiveRun(f), () => "the live run to start"); await advance(6 * MINUTE, live.tick); f.events.length = 0; const target = f.population.inReview.find((_, index) => index % 3 === 0)!; @@ -133,31 +166,32 @@ describeIssueRecovery("stranded-task checks beside one long live run (census)", expect(current!.assignee).toBe(f.liveAgentId); const changedAt = Date.now(); // A direct write that sends no hint (for example an edit by an older server). - await state.db.update(issues).set({ status: "todo", updatedAt: new Date() }).where(eq(issues.id, target)); + await bounded(state.db.update(issues).set({ status: "todo", updatedAt: new Date() }).where(eq(issues.id, target)), + () => "the direct task write"); await advance(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE, live.tick); const checked = f.events.find(event => event.topic === "stranded-assignments" && event.name === "check" && event.fields.issueId === target); expect(checked).toBeDefined(); expect(checked!.at - changedAt).toBeLessThanOrEqual(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE); - }, 1_800_000); + }, TEST_TIMEOUT_MS); it("still checks a resumed agent's task within the backstop bound when the resume sends no hint", async () => { const f = await boot(); - const live = await startLiveRun(f); + const live = await bounded(startLiveRun(f), () => "the live run to start"); await advance(6 * MINUTE, live.tick); f.events.length = 0; const waiting = f.waitingTaskId; const changedAt = Date.now(); - await state.db.update(agents).set({ status: "idle", lifecycleHolds: [], updatedAt: new Date() }) - .where(eq(agents.id, f.heldAgentId)); + await bounded(state.db.update(agents).set({ status: "idle", lifecycleHolds: [], updatedAt: new Date() }) + .where(eq(agents.id, f.heldAgentId)), () => "the agent resume write"); await advance(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE, live.tick); const checked = f.events.find(event => event.topic === "stranded-assignments" && event.name === "check" && event.fields.issueId === waiting); expect(checked).toBeDefined(); expect(checked!.at - changedAt).toBeLessThanOrEqual(ISSUE_RECOVERY_BACKSTOP_MS + 2 * MINUTE); - }, 1_800_000); + }, TEST_TIMEOUT_MS); it("still re-checks every settled task in the hourly full pass", async () => { const f = await boot(); - const live = await startLiveRun(f); + const live = await bounded(startLiveRun(f), () => "the live run to start"); await advance(ISSUE_RECOVERY_FULL_BACKSTOP_MS + 5 * MINUTE, live.tick); const checked = new Set(checksOf(f.events, "stranded-assignments").map(event => String(event.fields.issueId))); const missing = f.population.inReview.filter(id => !checked.has(id)); @@ -165,5 +199,5 @@ describeIssueRecovery("stranded-task checks beside one long live run (census)", const runs = await state.db.select({ id: heartbeatRuns.id }).from(heartbeatRuns) .where(and(eq(heartbeatRuns.companyId, f.companyId), sql`${heartbeatRuns.status} = 'running'`)); expect(runs.map(run => run.id)).toContain(live.runId); - }, 1_800_000); + }, TEST_TIMEOUT_MS); }); diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index 6d024d3da2b..b1a79860e2e 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -1,6 +1,6 @@ { "inputs": { - "package.json": "b6a185b015b2ec9ffc80564f0970916b65b7d6ba", + "package.json": "2213c21acb7ce340b07aa114c69974a266a0bad8", "packages/plugins/sdk/package.json": "b7a4936e2803fd0d3b32dd7f17fc1ea86609ead0", "packages/plugins/sdk/src/bundlers.ts": "883bf3d9f2bd42877cfc0c3707cd882a6f6248d0", "packages/plugins/sdk/src/define-plugin.ts": "a99e07ce77ef72fcf1df1347346aacb8ba12e284", diff --git a/vitest.config.ts b/vitest.config.ts index 4961fc0eef7..1beb791259a 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,5 +1,6 @@ import { configDefaults, defineConfig } from "vitest/config"; import { retryReporterEnabled } from "./scripts/ci/vitest-retry.mjs"; +import { stalledFileReporterEnabled } from "./scripts/ci/stalled-file-reporter.mjs"; export default defineConfig({ test: { @@ -8,7 +9,9 @@ export default defineConfig({ ? ["./scripts/ci/test-timing-reporter.mjs", "./scripts/ci/oversized-test-files.mjs"] : []), ...(process.env.PAPERCLIP_CI_PROFILE === "true" ? ["./scripts/ci-profile/vitest-reporter.mjs"] : []), // PR lanes pass --retry from scripts/run-vitest-stable.mjs; see scripts/ci/vitest-retry.mjs. - ...(retryReporterEnabled() ? ["./scripts/ci/retry-reporter.mjs"] : [])], + ...(retryReporterEnabled() ? ["./scripts/ci/retry-reporter.mjs"] : []), + // Fails a CI run whose file stops making progress, naming the file; see the reporter. + ...(stalledFileReporterEnabled() ? ["./scripts/ci/stalled-file-reporter.mjs"] : [])], projects: [ "packages/shared", "packages/skills-catalog", From 784bc06276d93c608ea7ee082e2f5cb5e8e8fe26 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:56:57 -0600 Subject: [PATCH 2/5] perf(runner): reuse the sandbox's identical runnerd instead of uploading it on every cold boot (#21949) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Remote agent runs start `paperclip-runnerd` inside a sandbox, such as a Daytona sandbox > - Agent boot time is a measured product constraint, and cold boot on Daytona grew from about 11 s to 25–75 s in restart-chaos waves > - The span that grew is `runner.artifact.prepare`: the controller uploaded its 31 MB `paperclip-runnerd` to every new sandbox > - The controller uploads this file whenever `PAPERCLIP_RUNNER_REMOTE_BINARY_PATH` is set, even when the sandbox image already has the same bytes > - The upload time depends on the sandbox file-upload throughput. That throughput changed from about 1 s to 5–48 s for the same 31 MB, on the same image and with no runner change > - This pull request makes the controller use the image's `paperclip-runnerd` when its SHA-256 equals the configured artifact > - The benefit is a cold boot that does not depend on sandbox upload throughput: about 9–11 s instead of 33–45 s in the same hour ## Linked Issues or Issue Description No issue exists. This describes the bug, following `.github/ISSUE_TEMPLATE/bug_report.yml`. **What happened?** Cold `agent_boot` on Daytona became 2–7 times slower. In restart-chaos waves on master `c5218f5ec4`, the cold boot p50 was about 11 s for claude, about 10 s for codex and 15–25 s for OpenCode. On master `3452639a81` it was 25 s, then 55 s, then 70–78 s for claude and codex over five waves. OpenCode reached 238–265 s. The run spans show that the extra time for every adapter is in `runner.artifact.prepare` (codex example: 42.7 s, before it was 1.2 s). In this span the controller uploads its own 31 MB `paperclip-runnerd` to the new sandbox. `PAPERCLIP_RUNNER_REMOTE_BINARY_PATH` is set, so `mayUsePreinstalledRunnerArtifact` returned `false` and the controller never used the identical `paperclip-runnerd` in the sandbox image. The upload time follows the sandbox upload throughput, which changes over time. None of the 17 commits between the two masters changed this path. **Expected behavior** When the sandbox already has a `paperclip-runnerd` with the same SHA-256 as the configured artifact, the controller links it and does not upload it. Cold boot does not depend on upload throughput. **Steps to reproduce** 1. Set `PAPERCLIP_RUNNER_REMOTE_BINARY_PATH` to the `paperclip-runnerd` from the Daytona runner image. 2. Start a cold agent run in a new Daytona sandbox from that image. 3. Look at the run spans. `runner.artifact.prepare` holds a full upload of the runner (5–48 s in our waves), and there is no `runner.artifact.discover` span. **Paperclip version or commit** `3452639a81` (also current master `6205b24d54`). Image `ghcr.io/paperclipai/paperclip-daytona-runner@sha256:710deab7375a…`. **Agent adapter(s) involved** All remote adapters: claude, codex and OpenCode. ## What Changed - `mayUsePreinstalledRunnerArtifact` accepts a preinstalled `paperclip-runnerd` when an artifact is configured and the controller has that artifact on disk. - In that case the existing SHA-256 check (`runner_remote_preinstalled_artifact_mismatch`) is mandatory. A different, missing, or unreadable image copy still falls back to the upload. - When an artifact is configured, a failed discovery probe counts as "no preinstalled runnerd", so the controller uploads the configured file as before. - Tests: a unit case for the gate, and three cases in the runner wiring test: identical configured artifact (no `syncIn`), mismatched configured artifact (upload), and failed discovery with a configured artifact (upload). - `docs/deploy/environment-variables.md` describes the new behavior. ## Verification - Red/green: `cd server && npx vitest run src/services/native-runtime/native-session-executor.test.ts -t "server-owned replacement artifact|contract-compatible runnerd|configured artifact the controller holds"`. Without the fix 3 tests fail. With the fix 27 pass. - `pnpm verify` passes. - Restart-chaos waves on Daytona, image `710deab7375a`, 6 tasks (2 claude, 2 codex, 2 opencode), A1/K0, run back to back in one hour: | Wave | Fix | claude cold boot p50 | codex | opencode | `runner.artifact.prepare` | | --- | --- | --- | --- | --- | --- | | w-20261117T005138 | no | 38.4 s | 33.2 s | 36.0 s | not recorded | | w-20261117T005627 | yes | 9.5 s | 8.8 s | 10.6 s | 0.5–0.6 s, all runs use the image copy | | w-20261117T005956 | no | 44.1 s | 13.1 s (max 47.1 s) | 45.5 s | 4.9–37.8 s upload | All 18 tasks passed. ## Risks - Low risk. The controller uses the image copy only when its SHA-256 equals the configured artifact, so the runner bytes do not change. Every other case keeps the current upload. - One extra `command -v` probe and one `sha256sum` probe run when an artifact is configured. Each takes about 0.1 s. - Saved run state is not changed. A run saved by the previous release resumes with the same runner identity, because the bytes are the same. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, via Claude Code with tool use (shell, file edit) and extended reasoning. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- docs/deploy/environment-variables.md | 2 +- .../native-runtime/native-session-executor.test.ts | 12 +++++++++--- .../native-runtime/native-session-executor.ts | 13 +++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/deploy/environment-variables.md b/docs/deploy/environment-variables.md index 70d804fc346..2489a0bd880 100644 --- a/docs/deploy/environment-variables.md +++ b/docs/deploy/environment-variables.md @@ -22,7 +22,7 @@ All environment variables that Paperclip uses for server configuration. | `PAPERCLIP_CHAT_WEBHOOK_PUBLIC_URL` | (board public origin) | Optional HTTPS origin for native chat provider webhooks when ingress and the board use different hosts. Must have no credentials, path, query, or fragment; invalid configuration refuses startup. Used only for provider callback URLs, not board links, authentication, trusted hosts, or identity confirmation. In `authenticated` mode with `private` exposure, also add the ingress hostname to `PAPERCLIP_ALLOWED_HOSTNAMES`. Otherwise the private-hostname guard rejects provider callbacks with 403 before they reach the webhook route. The guard reads `X-Forwarded-Host` before `Host`, so a reverse proxy that rewrites `Host` but forwards the original `X-Forwarded-Host` still gets 403. | | `PAPERCLIP_RUNNER_PUBLIC_URL` | (unset) | Explicit `wss://` base URL used only when a remote `paperclip_runner` target dials Paperclip directly. Paperclip appends `/api/runner/v1/connect/`; the reverse proxy must forward WebSocket upgrades for that route. This value is never inferred from request headers. Daytona ignores it and uses provider ingress. | | `PAPERCLIP_RUNNER_CA_BUNDLE_PATH` | (unset) | Optional PEM CA bundle for direct runner WSS. Platform roots remain enabled. There is no insecure TLS bypass. | -| `PAPERCLIP_RUNNER_REMOTE_BINARY_PATH` | (host build) | Host-local path to a `paperclip-runnerd` artifact built for the remote target OS and architecture. Required when Paperclip and the remote sandbox do not share a compatible platform; build metadata and the required transport mode are verified before launch. | +| `PAPERCLIP_RUNNER_REMOTE_BINARY_PATH` | (host build) | Host-local path to a `paperclip-runnerd` artifact built for the remote target OS and architecture. Required when Paperclip and the remote sandbox do not share a compatible platform; build metadata and the required transport mode are verified before launch. When the sandbox image already has a `paperclip-runnerd` with the same SHA-256, Paperclip uses that copy and does not upload this file. | | `PAPERCLIP_RUNNER_REMOTE_CODEX_PATH` | (unset) | Optional host-local path to a Codex executable built for the remote target OS and architecture. For remote Codex-backed runners, Paperclip stages and verifies this executable beside `paperclip-runnerd`. | | `PAPERCLIP_RUNNER_REMOTE_CODEX_NPM_SPEC` | (unset) | Optional pinned npm package spec (for example, `@openai/codex@0.160.0`) installed inside each fresh remote lease when its Codex harness is not baked into the sandbox image. Mutually exclusive with `PAPERCLIP_RUNNER_REMOTE_CODEX_PATH`; Paperclip verifies the installed executable before starting `runnerd`. | | `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` | `/opt/paperclip-runner/provider-pack` in Docker; otherwise unset | Host-local path to the immutable provider pack built by `pnpm --filter @paperclipai/paperclip-runner build:provider-pack`. Stamped standard Docker images include the pack; downstream compositions and the `cloud` target inherit it. Unstamped local Docker builds skip pack generation. The pack includes its target-built Node 24.11+ runtime, locked production dependencies, OpenCode proxy/executable, and ACPX sidecar. Remote OpenCode and ACPX fail closed without it. A preinstalled pack is accepted only when its complete digested manifest matches this build-owned pack; otherwise Paperclip stages this pack into the sandbox. | diff --git a/server/src/services/native-runtime/native-session-executor.test.ts b/server/src/services/native-runtime/native-session-executor.test.ts index 13fb4614f48..0dd70c67740 100644 --- a/server/src/services/native-runtime/native-session-executor.test.ts +++ b/server/src/services/native-runtime/native-session-executor.test.ts @@ -5400,6 +5400,11 @@ describe("remote preinstalled executable discovery", () => { expect(mayUsePreinstalledRunnerArtifact(" ")).toBe(true); expect(mayUsePreinstalledRunnerArtifact(undefined)).toBe(true); }); + + it("checks a preinstalled runnerd against a configured artifact the controller holds", () => { + expect(mayUsePreinstalledRunnerArtifact("/artifacts/paperclip-runnerd", true)).toBe(true); + expect(mayUsePreinstalledRunnerArtifact("/artifacts/paperclip-runnerd", false)).toBe(false); + }); }); describe("remote runner build metadata", () => { @@ -23175,7 +23180,7 @@ describe("runnerd provider runtime wiring", () => { }); it.each([ - ...["current", "preinstalled-exact", "preinstalled-mismatch", "preinstalled-error", "preinstalled-timeout", "stale", "missing", "retained", "retained-mismatch", "retained-error", "retained-timeout", "retained-explicit"] + ...["current", "preinstalled-exact", "preinstalled-mismatch", "preinstalled-error", "preinstalled-timeout", "preinstalled-explicit", "preinstalled-explicit-mismatch", "preinstalled-explicit-discover-fails", "stale", "missing", "retained", "retained-mismatch", "retained-error", "retained-timeout", "retained-explicit"] .map((image) => ({ image, version: "0.160.0" })), ...["0.149.0", "0.149.1", "0.153.4", "0.156.0", "0.160.1"] .map((version) => ({ image: "current", version })), @@ -23184,7 +23189,7 @@ describe("runnerd provider runtime wiring", () => { ])("uses shared Codex and the server-owned replacement artifact (image=$image, Codex=$version)", async ({ image, version }) => { const retained = image.startsWith("retained"); const exactRetained = image === "retained" || image === "retained-explicit"; - const needsReplacement = image !== "current" && image !== "preinstalled-exact" && !exactRetained; + const needsReplacement = image !== "current" && image !== "preinstalled-exact" && image !== "preinstalled-explicit" && !exactRetained; // The mocked remote executes metadata probes; artifact staging only needs bytes. // Keep this regression independent of a locally compiled Rust runner binary. const controllerArtifact = join(isolatedStateDirectory, "paperclip-runnerd"); @@ -23225,6 +23230,7 @@ describe("runnerd provider runtime wiring", () => { } else if (script === "uname -s; uname -m") { stdout = `${process.platform === "darwin" ? "Darwin" : "Linux"}\n${process.arch === "arm64" ? "arm64" : "x86_64"}\n`; } else if (script.includes("command -v paperclip-runnerd")) { + if (image === "preinstalled-explicit-discover-fails") throw new Error("sandbox provider unavailable"); stdout = image === "missing" ? "" : "/usr/local/bin/paperclip-runnerd\n"; } else if (script.includes("command -v codex")) { stdout = script.includes("/opt/paperclip-runner/bin/codex") @@ -23250,7 +23256,7 @@ describe("runnerd provider runtime wiring", () => { execution, runnerInstanceId: "runner-image-runtime", onLog, - ...(image === "retained-explicit" ? { runnerRemoteBinaryPath: controllerArtifact } : {}), + ...(image.includes("explicit") ? { runnerRemoteBinaryPath: controllerArtifact } : {}), runnerIngressAuthorized: true, runnerExecutionTarget: { kind: "remote", diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index c4a80912ee2..bee52eec15b 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -14239,8 +14239,9 @@ export function buildRemoteCodexLauncherCommand( export function mayUsePreinstalledRunnerArtifact( configuredRemoteBinaryPath: string | null | undefined, + configuredArtifactAvailable = false, ): boolean { - return !configuredRemoteBinaryPath?.trim(); + return !configuredRemoteBinaryPath?.trim() || configuredArtifactAvailable; } const RUNNERD_BUILD_METADATA_SCHEMA = @@ -19306,11 +19307,15 @@ export function createRemoteNativeArtifactPreparation(input: { ); } const explicitRemoteBinary = input.runnerRemoteBinaryPath?.trim() || null; - if (!runnerArtifactPrepared && mayUsePreinstalledRunnerArtifact(explicitRemoteBinary)) { + const controllerArtifactAvailable = existsSync(controllerRunnerBinary); + if (!runnerArtifactPrepared && + mayUsePreinstalledRunnerArtifact(explicitRemoteBinary, controllerArtifactAvailable)) { const preinstalledRunner = await measureNativeRunnerSpan( input.trace, "runner.artifact.discover", - () => discoverPreinstalledExecutable("paperclip-runnerd"), + () => explicitRemoteBinary + ? discoverPreinstalledExecutable("paperclip-runnerd").catch(() => null) + : discoverPreinstalledExecutable("paperclip-runnerd"), ); if (preinstalledRunner) { try { @@ -19319,7 +19324,7 @@ export function createRemoteNativeArtifactPreparation(input: { "runner.artifact.verify_preinstalled", () => verifyRemoteRunner(requiredMode, preinstalledRunner), ); - if (existsSync(controllerRunnerBinary) && + if (controllerArtifactAvailable && !await matchesControllerRunnerArtifact(preinstalledRunner)) { throw new Error("runner_remote_preinstalled_artifact_mismatch"); } From b2b2c1e60b6293d2bf9e591498bfd4f1c05137a6 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:59:48 -0600 Subject: [PATCH 3/5] fix(issues): release a done blocker whose ended run already finalized (#21948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A parent task can wait for its subtasks through "blocks" relations. When the last blocker is done, the parent wakes with `issue_children_completed` or `issue_blockers_resolved` > - A done blocker with workspace work also passes a workspace-finalize barrier. The barrier holds dependents until the blocker's run saves its workspace > - The barrier reads the blocker's latest workspace operation. A save that starts inside the run's finalize and ends after it, or any operation that the same run records after its finalize, makes the barrier look unsaved > - That run has ended, so it records no further finalize. Nothing clears the barrier, every wake for the parent becomes a skipped `issue_dependencies_blocked` wait, and the periodic backstop also sees the blocker as unresolved > - This pull request treats a settled operation as saved when its run has ended and that run recorded a successful finalize for the blocker issue > - The benefit is that the parent gets its children-completed run, and parents that are stuck now are released by the existing dependency backstop with no manual step ## Linked Issues or Issue Description Refs #19219, #17206, #18665. #19219 releases the barrier when a terminal run recorded no finalize at all. This change is narrower: the run must have recorded a successful finalize for the blocker issue. A failed finalize with no later success still holds the gate (#17206 owns that recovery). **What happened?** A parent task created two subtasks. Subtask 1 finished and its run saved the workspace. Then the parent run bound both subtasks as blockers and moved the parent to `blocked` (`durable_dependency_blocker_bound`). Subtask 2 finished 30 seconds later. The `issue_children_completed` wake for the parent was skipped and recorded as `issue_dependencies_blocked` with `unresolvedBlockerIssueIds` set to subtask 1, which had been done for 2.5 minutes. The parent showed `pendingFinalizeBlockerIssueIds: [subtask 1]` and `canRetry: false`. No later wake came. The parent stayed blocked until a person changed it by hand. **Expected behavior** When every blocker is done and each blocker's run has finished with a successful workspace finalize, the parent gets one children-completed run. **Steps to reproduce** 1. Create a parent with two subtasks on separate execution workspaces. 2. Finish subtask 1. Its run records a successful `workspace_finalize`, and a `remote_workspace_snapshot` of the same run ends after the finalize ends. The incident run had a failed copy-back that was retried during a restart overlap. 3. Bind both subtasks as blockers of the parent, then block the parent. 4. Finish subtask 2 and dispatch the native `issue_children_completed` intent. 5. Before this change, the wake is skipped as `issue_dependencies_blocked` and no run starts. **Paperclip version or commit** master `6205b24d54`. ## What Changed - `pendingFinalizeBlockerCondition` (`server/src/services/issues.ts`) has one more release rule. The latest blocker operation is settled (`succeeded`, `failed` or `skipped`). Its heartbeat run is terminal. That run recorded a successful `workspace_finalize` for the blocker issue on the same workspace (or with no workspace id). Readiness, the queue dependency gate, blocker attention and the periodic backstop all read this condition. - Live runs keep the old behavior. A save that ends after its finalize, or an operation that starts after it, still holds dependents while the run is running. - Foreign-run operations, unfinished operations and failed finalizes with no success still hold dependents. ## Verification - New regression test `heartbeat-dependency-scheduling.test.ts` › "runs the parent's children-completed wake when a child it bound after completion saved after its finalize". It replays the incident order: child 1 done and finalized, its snapshot ends after the finalize, the parent binds both children and blocks, child 2 finishes, the native children-completed intent dispatches. Red before the fix (no run starts; the wake becomes `issue_dependencies_blocked`). Green after the fix (a run starts with the intent's context, and no dependency wait is recorded). - `issues-service.test.ts` nested-snapshot matrix: `late-finish` and `later-operation` now run with a live owner run (still pending) and with a terminal owner run (released). `covered`, `foreign-run`, `unfinished` and `failed-finalize` stay as before. - `cd server && npx vitest run src/__tests__/heartbeat-dependency-scheduling.test.ts src/__tests__/issues-service.test.ts` passes (207 tests). - `pnpm verify` and `tsc --noEmit` for `server` pass locally. ## Risks - Low risk. The change only releases a barrier for a run that has already ended after a successful finalize for the issue. That run cannot write another finalize, so the old rule held dependents forever with no path to release them. - An operation that a terminal run recorded after its finalize is no longer a reason to hold dependents. Such work can never be saved by that run. Holding the parent forever does not protect it. - No schema, API or UI contract change. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edits, test execution) and extended reasoning. ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 --- .../heartbeat-dependency-scheduling.test.ts | 85 +++++++++++++++++++ server/src/__tests__/issues-service.test.ts | 21 +++-- server/src/services/issues.ts | 18 ++++ 3 files changed, 118 insertions(+), 6 deletions(-) diff --git a/server/src/__tests__/heartbeat-dependency-scheduling.test.ts b/server/src/__tests__/heartbeat-dependency-scheduling.test.ts index 134ce9cc8cc..e7d912cf9b9 100644 --- a/server/src/__tests__/heartbeat-dependency-scheduling.test.ts +++ b/server/src/__tests__/heartbeat-dependency-scheduling.test.ts @@ -277,6 +277,91 @@ describeEmbeddedPostgres("heartbeat dependency-aware queued run selection", () = } }, 45_000); + it("runs the parent's children-completed wake when a child it bound after completion saved after its finalize", async () => { + const companyId = randomUUID(); + const agentId = randomUUID(); + const parentId = randomUUID(); + const firstChildId = randomUUID(); + const secondChildId = randomUUID(); + const firstWorkspaceId = randomUUID(); + const secondWorkspaceId = randomUUID(); + const firstRunId = randomUUID(); + const secondRunId = randomUUID(); + const decisionId = randomUUID(); + await db.insert(companies).values({ id: companyId, name: "Child completion", + issuePrefix: `C${companyId.replace(/-/g, "").slice(0, 6).toUpperCase()}`, + requireBoardApprovalForNewAgents: false, defaultResponsibleUserId: "responsible-user" }); + await db.insert(companyMemberships).values({ companyId, principalType: "user", principalId: "responsible-user", status: "active", membershipRole: "member" }); + await db.insert(agents).values({ id: agentId, companyId, name: "Parent", role: "engineer", + status: "active", adapterType: "codex_local", adapterConfig: {}, permissions: {}, + runtimeConfig: { heartbeat: { wakeOnDemand: true, maxConcurrentRuns: 1 } } }); + await db.insert(executionWorkspaces).values([firstWorkspaceId, secondWorkspaceId].map((id) => ({ + id, companyId, mode: "shared_workspace", strategyType: "project_primary", name: "Child workspace", status: "active", + }))); + await db.insert(issues).values([ + { id: parentId, companyId, title: "Parent", status: "in_progress", + assigneeAgentId: agentId, responsibleUserId: "responsible-user" }, + { id: firstChildId, companyId, parentId, title: "First child", status: "done", + assigneeAgentId: agentId, executionWorkspaceId: firstWorkspaceId, responsibleUserId: "responsible-user", + completedAt: new Date("2026-11-16T23:33:00.000Z") }, + { id: secondChildId, companyId, parentId, title: "Second child", status: "in_progress", + assigneeAgentId: agentId, executionWorkspaceId: secondWorkspaceId, responsibleUserId: "responsible-user" }, + ]); + await db.insert(heartbeatRuns).values([ + { id: firstRunId, companyId, agentId, issueId: firstChildId, status: "succeeded", + startedAt: new Date("2026-11-16T23:28:28.000Z"), finishedAt: new Date("2026-11-16T23:32:59.430Z") }, + { id: secondRunId, companyId, agentId, issueId: secondChildId, status: "running", + startedAt: new Date("2026-11-16T23:31:17.000Z") }, + ]); + await db.insert(workspaceOperations).values([ + { companyId, executionWorkspaceId: firstWorkspaceId, issueId: firstChildId, heartbeatRunId: firstRunId, + phase: "workspace_finalize", status: "succeeded", + startedAt: new Date("2026-11-16T23:32:57.000Z"), finishedAt: new Date("2026-11-16T23:32:59.000Z") }, + { companyId, executionWorkspaceId: firstWorkspaceId, issueId: firstChildId, heartbeatRunId: firstRunId, + phase: "remote_workspace_snapshot", status: "succeeded", + startedAt: new Date("2026-11-16T23:32:58.000Z"), finishedAt: new Date("2026-11-16T23:32:59.200Z") }, + ]); + await db.insert(issueRelations).values([firstChildId, secondChildId].map((blockerId) => ({ + companyId, issueId: blockerId, relatedIssueId: parentId, type: "blocks" as const, createdByAgentId: agentId, + }))); + await db.update(issues).set({ status: "blocked", blockedTransitionAt: new Date("2026-11-16T23:34:52.374Z") }) + .where(eq(issues.id, parentId)); + await db.insert(workspaceOperations).values({ companyId, executionWorkspaceId: secondWorkspaceId, + issueId: secondChildId, heartbeatRunId: secondRunId, phase: "workspace_finalize", status: "succeeded", + startedAt: new Date("2026-11-16T23:35:20.000Z"), finishedAt: new Date("2026-11-16T23:35:22.000Z") }); + await db.update(heartbeatRuns).set({ status: "succeeded", finishedAt: new Date("2026-11-16T23:35:23.250Z") }) + .where(eq(heartbeatRuns.id, secondRunId)); + await db.update(issues).set({ status: "done", completedAt: new Date("2026-11-16T23:35:23.218Z") }) + .where(eq(issues.id, secondChildId)); + const [intent] = await db.insert(agentWakeupRequests).values({ companyId, agentId, + source: "automation", triggerDetail: "system", reason: "issue_children_completed", + requestedByActorType: "system", requestedByActorId: "native-status-committer", + idempotencyKey: `issue_children_completed:${parentId}:${secondChildId}:${decisionId}`, + payload: { issueId: parentId, taskId: parentId, _paperclipWakeContext: { + issueId: parentId, taskId: parentId, source: "native_status_decision", + nativeChildCompletionDecisionId: decisionId, completedChildIssueId: secondChildId, + childIssueIds: [firstChildId, secondChildId], + } }, + }).returning(); + + await heartbeat.dispatchPendingNativeStatusWakeups({ companyId }); + expect(await waitForCondition(async () => mockAdapterExecute.mock.calls.length === 1, 10_000)).toBe(true); + await heartbeat.drainActiveRunExecutions(); + + const dependencyWaits = await db.select().from(agentWakeupRequests).where(and( + eq(agentWakeupRequests.companyId, companyId), eq(agentWakeupRequests.reason, "issue_dependencies_blocked"), + )); + expect(dependencyWaits).toEqual([]); + const parentRuns = await db.select().from(heartbeatRuns).where(and( + eq(heartbeatRuns.companyId, companyId), sql`${heartbeatRuns.contextSnapshot}->>'issueId' = ${parentId}`, + )); + const childrenCompletedRun = parentRuns.find((run) => run.contextSnapshot?.nativeStatusWakeIntentId === intent!.id); + expect(childrenCompletedRun?.contextSnapshot).toMatchObject({ + wakeReason: "issue_children_completed", nativeStatusWakeIntentId: intent!.id, + completedChildIssueId: secondChildId, + }); + }, 45_000); + it("keeps a saved native continuation behind its active predecessor without retagging that run", async () => { const companyId = randomUUID(), agentId = randomUUID(), issueId = randomUUID(); let finishPredecessor!: () => void; diff --git a/server/src/__tests__/issues-service.test.ts b/server/src/__tests__/issues-service.test.ts index 75aa6921574..bde1ad87d66 100644 --- a/server/src/__tests__/issues-service.test.ts +++ b/server/src/__tests__/issues-service.test.ts @@ -4773,13 +4773,23 @@ const dependencyTestDatabaseUrl = resolveExternalTestDatabaseUrl("PAPERCLIP_ISSU }); }); - it.each(["covered", "foreign-run", "unfinished", "failed-finalize", "late-finish", "later-operation"])( - "requires a successful owning finalize to cover a nested snapshot: %s", async kind => { + it.each([ + ["covered", "succeeded", true], + ["foreign-run", "succeeded", false], + ["unfinished", "succeeded", false], + ["failed-finalize", "succeeded", false], + ["late-finish", "running", false], + ["later-operation", "running", false], + ["late-finish", "succeeded", true], + ["later-operation", "succeeded", true], + ] as const)( + "requires a successful owning finalize to cover a nested snapshot: %s (run %s)", async (kind, runStatus, ready) => { const f = await seedSharedWorkspaceDependency(); const runId = randomUUID(), foreignRunId = randomUUID(); - await db.insert(heartbeatRuns).values([runId, foreignRunId].map(id => ({ - id, companyId: f.companyId, agentId: f.assigneeAgentId, status: "succeeded", - }))); + await db.insert(heartbeatRuns).values([ + { id: runId, companyId: f.companyId, agentId: f.assigneeAgentId, status: runStatus }, + { id: foreignRunId, companyId: f.companyId, agentId: f.assigneeAgentId, status: "succeeded" }, + ]); const started = new Date("2026-05-23T22:00:00.000Z"); const finished = new Date("2026-05-23T22:00:02.000Z"); await db.insert(workspaceOperations).values([ @@ -4797,7 +4807,6 @@ const dependencyTestDatabaseUrl = resolveExternalTestDatabaseUrl("PAPERCLIP_ISSU startedAt: new Date(finished.getTime() + 100), finishedAt: new Date(finished.getTime() + 200), }] : []), ]); - const ready = kind === "covered"; expect((await svc.listWakeableBlockedDependents(f.blockerId)).map(issue => issue.id)) .toEqual(ready ? [f.dependentId] : []); await expect(svc.getDependencyReadiness(f.dependentId)).resolves.toMatchObject({ diff --git a/server/src/services/issues.ts b/server/src/services/issues.ts index 0bdcf07c2af..3d14f402788 100644 --- a/server/src/services/issues.ts +++ b/server/src/services/issues.ts @@ -2625,6 +2625,24 @@ function pendingFinalizeBlockerCondition(companyId: string, issueId: SQL, worksp and recovery_finalize.started_at >= coalesce(latest_blocker_operation.finished_at, latest_blocker_operation.started_at) ) ) + and not ( + latest_blocker_operation.status in ('succeeded', 'failed', 'skipped') + and exists ( + select 1 from heartbeat_runs settled_owner_run + where settled_owner_run.company_id = ${companyId}::uuid + and settled_owner_run.id = latest_blocker_operation.heartbeat_run_id + and settled_owner_run.status in (${sql.join([...TERMINAL_HEARTBEAT_RUN_STATUSES].map(status => sql`${status}`), sql`, `)}) + ) + and exists ( + select 1 from workspace_operations settled_run_finalize + where settled_run_finalize.company_id = ${companyId}::uuid + and settled_run_finalize.issue_id = ${issueId} + and settled_run_finalize.heartbeat_run_id = latest_blocker_operation.heartbeat_run_id + and settled_run_finalize.phase = 'workspace_finalize' and settled_run_finalize.status = 'succeeded' + and (settled_run_finalize.execution_workspace_id is null + or settled_run_finalize.execution_workspace_id = ${workspaceId}) + ) + ) )`; } From 6d117998c83b95fa612f3b252f6d3b68fc0f4f6b Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Mon, 16 Nov 2026 18:03:41 -0800 Subject: [PATCH 4/5] fix(ci): skip reviewed-lock checks for a pending Dependabot lock in the Runner support suite (#21942) ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Dependabot pull requests that change `pnpm-lock.yaml` are the only way, other than the lockfile refresh, that lock content changes > - #19356 let a verified Dependabot lockfile pass CI. The server's reporting-lock policy test skips when `PAPERCLIP_CI_PR_AUTHOR` is `dependabot[bot]`, and the lockfile refresh renews the proof after the merge > - #19537 then made the Runner support suite a required check. That job does not set `PAPERCLIP_CI_PR_AUTHOR`, and the suite's own reviewed-lock checks have no Dependabot skip > - So every Dependabot lockfile pull request fails `ci / Runner support suite` and `ci / verify`. The last one that merged, #17364, merged before #19537 > - This pull request gives the support suite the same Dependabot skip as the server test > - The benefit is that Dependabot dependency updates can merge again, with the same lock trust rules as before ## Linked Issues or Issue Description Refs #19356, #19537, #19614, #17172, #19575. Rebased onto `master` after #21943, which fixed the unrelated `qualify_test_selection` failure that a CI file change triggers. **What happened?** Dependabot pull request #17172 changes `pnpm-lock.yaml`. `ci / Runner support suite` fails in four test files, and `ci / verify` fails because of it: - `prepare-report-lock.test.ts` > installs only the reviewed dependency correction (4 cases): the committed lock hash is not in `report-lock.json`. - `source-sdk-public-type.test.ts`: the shared setup throws "Committed SDK reference lock is not reviewed". - `source-sdk-evidence.test.ts` > seals a normal producer-certified reviewed-reference SDK: the same error. - `source-sdk-public-inputs.test.mjs` > the committed SDK public source pins match this checkout's committed tree: `pnpm-lock.yaml` is stale in `source-sdk-public-inputs.json`. A Dependabot pull request may not change `report-lock.json`, `report-lock.patch` or the SDK pins. `lockfile-trust.mjs` rejects that change, and `refresh-lockfile.yml` renews those files after the merge. So the pull request can never pass. **Expected behavior** A verified Dependabot lockfile passes the Runner support suite, as it already passes the server's reporting-lock policy test. Other authors keep every check. **Steps to reproduce** 1. Open a Dependabot pull request that changes `pnpm-lock.yaml`, such as #17172. 2. Let CI run. `ci / Runner support suite` fails in the four files above. ## What Changed - `.github/workflows/pr-trusted.yml`: the `verify_runner_e2e_support` job sets `PAPERCLIP_CI_PR_AUTHOR` from the pull request author, like the general test job. - `tests/runner-e2e/prepare-report-lock.test.ts`, `source-sdk-evidence.test.ts`, `source-sdk-public-inputs.test.mjs`: the test cases that need a reviewed committed lock skip when `PAPERCLIP_CI_PR_AUTHOR` is `dependabot[bot]`. This uses the same check as `server/scripts/reporting-lock-policy.test.mjs`. The other cases in these files still run. - `tests/runner-e2e/vitest.config.ts`: on a Dependabot pull request, the suite excludes `source-sdk-public-type.test.ts`. Its shared `beforeAll` prepares the reviewed SDK reference, so every case in the file needs a reviewed lock. - `tests/runner-e2e/source-sdk-public-type.ts`: the installed TypeScript, Babel parser and Zod package hash checks move into an exported `verifySdkProofPackages`, which `verifySdkPublicSource` calls. The lockfile refresh renews the lock and source pins after a merge, but keeps these package hashes. - `tests/runner-e2e/source-sdk-proof-packages.test.ts` (new): runs `verifySdkProofPackages` against the installed packages on every pull request, including Dependabot ones, and checks that a changed package pin is rejected. So a Dependabot update of one of those packages still fails until its pins are reviewed. ## Verification - Red, then green, with a real Dependabot lock: I committed the `pnpm-lock.yaml` and `package.json` changes of #17172 on top of this branch in a local commit (not pushed). Then I ran `node node_modules/vitest/vitest.mjs run --config tests/runner-e2e/vitest.config.ts` on the four files: - Without `PAPERCLIP_CI_PR_AUTHOR`: 4 files failed and the same 6 tests failed as in CI. - With `PAPERCLIP_CI_PR_AUTHOR=dependabot[bot]`: 3 files passed, 33 tests passed and 6 skipped. `source-sdk-public-type.test.ts` was excluded. - On this branch with master's lock: `pnpm test:e2e:runner:unit` passed (Vitest: 687 files, 11640 tests; node tests passed). - `node --test .github/scripts/tests/*.test.mjs`: 808 passed. - After the package check change: the five affected files (`source-sdk-proof-packages`, `source-sdk-public-type`, `source-sdk-evidence`, `source-sdk-public-inputs`, `prepare-report-lock`) pass, 71 tests. `tsc --noEmit -p tests/runner-e2e/tsconfig.json` passes. - `pr.yml` calls `pr-trusted.yml@master`, so this pull request's own CI does not use the new job variable. The first Dependabot pull request after the merge checks it. ## Risks - A Dependabot update of TypeScript, the Babel parser or Zod still fails the suite until a maintainer reviews the new package pins. That is deliberate. - On a Dependabot pull request, the suite no longer checks the committed lock against the reviewed proof. The policy job still requires that the lock comes from a verified Dependabot commit (`lockfile-trust.mjs pr`), and the lockfile refresh still admits the lock and renews the proof and the SDK pins after the merge. That is the same trust as #19356. - `PAPERCLIP_CI_PR_AUTHOR` is the pull request author from the GitHub event. A contributor cannot set it to `dependabot[bot]`. Other commits pushed to a Dependabot branch are still checked by the policy job. - No runtime code changes. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use and code execution. ## 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 - [ ] All Paperclip CI gates are green - [ ] 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 --- .github/workflows/pr-trusted.yml | 1 + tests/runner-e2e/prepare-report-lock.test.ts | 4 +++- tests/runner-e2e/source-sdk-evidence.test.ts | 3 ++- .../source-sdk-proof-packages.test.ts | 16 +++++++++++++++ .../source-sdk-public-inputs.test.mjs | 3 ++- tests/runner-e2e/source-sdk-public-type.ts | 20 +++++++++++++------ tests/runner-e2e/vitest.config.ts | 5 ++++- 7 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 tests/runner-e2e/source-sdk-proof-packages.test.ts diff --git a/.github/workflows/pr-trusted.yml b/.github/workflows/pr-trusted.yml index e66b7cee4b6..f749fd6af75 100644 --- a/.github/workflows/pr-trusted.yml +++ b/.github/workflows/pr-trusted.yml @@ -756,6 +756,7 @@ jobs: env: PAPERCLIP_CI_PROFILE: ${{ needs.gate.outputs.profile_ci }} PAPERCLIP_CI_PROFILE_JOB: Runner support suite + PAPERCLIP_CI_PR_AUTHOR: ${{ github.event.pull_request.user.login }} # The paid Runner workflows depend on this suite: workflow security # policy, evidence oracles, cost receipts and controller recovery. It diff --git a/tests/runner-e2e/prepare-report-lock.test.ts b/tests/runner-e2e/prepare-report-lock.test.ts index 6098e9d393f..22b2a96c112 100644 --- a/tests/runner-e2e/prepare-report-lock.test.ts +++ b/tests/runner-e2e/prepare-report-lock.test.ts @@ -7,7 +7,9 @@ import { expect, it } from 'vitest'; import { parse } from 'yaml'; import { prepareReportLock, refreshReportLock } from './prepare-report-lock.mjs'; -it.each(['valid', 'unknown-lock', 'changed-patch', 'wrong-output'])( +const pendingDependabotLock = process.env.PAPERCLIP_CI_PR_AUTHOR === 'dependabot[bot]'; + +it.skipIf(pendingDependabotLock).each(['valid', 'unknown-lock', 'changed-patch', 'wrong-output'])( 'installs only the reviewed dependency correction: %s', async variant => { const root = await mkdtemp(path.join(tmpdir(), 'eval-report-lock-test-')); const here = import.meta.dirname, relative = path.join(root, 'tests/runner-e2e'); diff --git a/tests/runner-e2e/source-sdk-evidence.test.ts b/tests/runner-e2e/source-sdk-evidence.test.ts index 99803867d83..33d820a14c2 100644 --- a/tests/runner-e2e/source-sdk-evidence.test.ts +++ b/tests/runner-e2e/source-sdk-evidence.test.ts @@ -18,6 +18,7 @@ import { MANUAL_PRIVATE_EXECUTIONS, MANUAL_PRIVATE_PROTOCOL } from "./manual-pri const roots: string[] = [], executionId = "chat-features.runner-opencode.local.plugins.install-plugin", sourceRevision = "a".repeat(40); const hash = (bytes: Buffer | string) => createHash("sha256").update(bytes).digest("hex"); +const pendingDependabotLock = process.env.PAPERCLIP_CI_PR_AUTHOR === "dependabot[bot]"; afterEach(async () => { await Promise.all(roots.splice(0).map(root => rm(root, { recursive: true, force: true }))); }); async function fixture(secrets: string[] = []) { const root = await realpath(await mkdtemp(path.join(os.tmpdir(), "source-sdk-synthetic-unit-"))); roots.push(root); @@ -116,7 +117,7 @@ it("retains declarations and source maps under names the private result sealer a // CI lock can be regenerated for unrelated PR patches and must not be relabeled reviewed. const builtSdk = ["packages/shared/dist", "packages/plugins/sdk/dist"].every(target => existsSync(new URL(`../../${target}/.paperclip-build-complete`, import.meta.url))); -it("seals a normal producer-certified reviewed-reference SDK, keeping key-shaped declarations out", async () => { +it.skipIf(pendingDependabotLock)("seals a normal producer-certified reviewed-reference SDK, keeping key-shaped declarations out", async () => { const originalRoot=await realpath(path.resolve(import.meta.dirname,"../..")); const repositoryRoot=await realpath(await mkdtemp(path.join(os.tmpdir(),"source-sdk-reviewed-build-")));roots.push(repositoryRoot); await prepareReviewedSdkReference(originalRoot,repositoryRoot); diff --git a/tests/runner-e2e/source-sdk-proof-packages.test.ts b/tests/runner-e2e/source-sdk-proof-packages.test.ts new file mode 100644 index 00000000000..f9104f1c05a --- /dev/null +++ b/tests/runner-e2e/source-sdk-proof-packages.test.ts @@ -0,0 +1,16 @@ +import { realpath } from "node:fs/promises"; +import path from "node:path"; +import { expect, it } from "vitest"; +import pins from "./source-sdk-public-inputs.json" with { type: "json" }; +import { verifySdkProofPackages } from "./source-sdk-public-type.js"; + +const repositoryRoot = path.resolve(import.meta.dirname, "../.."); + +it("installed TypeScript, parser and Zod packages match the reviewed SDK proof pins", async () => { + await expect(verifySdkProofPackages(await realpath(repositoryRoot))).resolves.toBeTruthy(); +}); + +it("rejects an installed proof package that differs from its pin", async () => { + await expect(verifySdkProofPackages(await realpath(repositoryRoot), { ...pins, zodPackageSha256: "0".repeat(64) })) + .rejects.toThrow("SDK public source proof unavailable"); +}); diff --git a/tests/runner-e2e/source-sdk-public-inputs.test.mjs b/tests/runner-e2e/source-sdk-public-inputs.test.mjs index 9ca1a501bfc..0ed0b7300ac 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.test.mjs +++ b/tests/runner-e2e/source-sdk-public-inputs.test.mjs @@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url"; import { isSdkPublicInput, staleSdkPublicInputs, staleSdkPublicInputsInWorkingTree, staleSdkPublicInputsMessage, synchronizeSdkPublicInputs } from "./source-sdk-public-inputs.mjs"; const registry = "tests/runner-e2e/source-sdk-public-inputs.json"; +const pendingDependabotLock = process.env.PAPERCLIP_CI_PR_AUTHOR === "dependabot[bot]"; const reportLock = "tests/runner-e2e/report-lock.json"; const reportPolicy = (inputSha256, outputSha256) => `${JSON.stringify({ inputSha256, outputSha256, patchSha256: "0".repeat(64), basis: "synthetic" }, null, 2)}\n`; const commit = (root, message) => { git(root, "add", "-A"); git(root, "-c", "user.name=Synthetic unit", "-c", "user.email=synthetic@example.invalid", "commit", "-qm", message); return git(root, "rev-parse", "HEAD").trim(); }; @@ -113,7 +114,7 @@ test("refuses a committed lock that the report-lock policy does not review", asy // source. A PR that edits packages/shared/src (or another pinned input) without // refreshing them breaks every SDK-dependent Runner cell before its server // starts, so fail here, cheaply, with the inputs and the fix command. -test("the committed SDK public source pins match this checkout's committed tree", async () => { +test.skipIf(pendingDependabotLock)("the committed SDK public source pins match this checkout's committed tree", async () => { const root = fileURLToPath(new URL("../..", import.meta.url)); const stale = await staleSdkPublicInputs(root); assert.deepEqual(stale, [], staleSdkPublicInputsMessage(stale)); diff --git a/tests/runner-e2e/source-sdk-public-type.ts b/tests/runner-e2e/source-sdk-public-type.ts index d77d7284915..7a460bea1c8 100644 --- a/tests/runner-e2e/source-sdk-public-type.ts +++ b/tests/runner-e2e/source-sdk-public-type.ts @@ -15,6 +15,19 @@ interface PublicSource { inputs: SdkPublicInputs; identity: { inputs: number; manifestSha256: string; lockSha256: string; compilerPackageSha256: string; parserPackageSha256: string; parserEntrySha256: string; zodPackageSha256: string; zodEntrySha256: string; zodTypeGraphSha256: string }; } const verified = new WeakSet(); +const matches = async (file: string, expected: string) => { if (hash(await readFile(file)) !== expected) throw new Error("SDK public source proof unavailable"); }; +export async function verifySdkProofPackages(root: string, inputs: SdkPublicInputs = defaultInputs) { + await matches(path.join(root, "node_modules/typescript/package.json"), inputs.compilerPackageSha256); + const parserRoot = path.join(root, "node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser"); + await matches(path.join(parserRoot, "package.json"), inputs.parserPackageSha256); await matches(path.join(parserRoot, "lib/index.js"), inputs.parserEntrySha256); + const require = createRequire(path.join(root, "packages/shared/package.json")), zodPackage = require.resolve("zod/package.json"), zodEntry = require.resolve("zod"); + await matches(zodPackage, inputs.zodPackageSha256); await matches(zodEntry, inputs.zodEntrySha256); + for (const [relative, expected] of Object.entries(inputs.zodTypeFiles)) { + if (!/^[A-Za-z0-9._/-]+$/.test(relative) || relative.split("/").includes("..")) throw new Error("SDK public source proof unavailable"); + await matches(path.join(path.dirname(zodPackage), relative), expected); + } + return { parserRoot, require, zodPackage }; +} export async function verifySdkPublicSource(root: string, expectations?: SdkPublicInputs): Promise { const supplied = expectations ?? defaultInputs; const inputs: SdkPublicInputs = Object.freeze({ ...supplied, inputs: Object.freeze({ ...supplied.inputs }), zodTypeFiles: Object.freeze({ ...supplied.zodTypeFiles }) }); @@ -39,13 +52,8 @@ export async function verifySdkPublicSource(root: string, expectations?: SdkPubl for (const directory of ["packages/shared/src", "packages/plugins/sdk/src"]) await collect(directory); const expectedSources = Object.keys(inputs.inputs).filter(file => file.startsWith("packages/shared/src/") || file.startsWith("packages/plugins/sdk/src/")); if (JSON.stringify(actualSources.sort()) !== JSON.stringify(expectedSources.sort())) throw new Error("SDK public source proof unavailable"); - const matches = async (file: string, expected: string) => { if (hash(await readFile(file)) !== expected) throw new Error("SDK public source proof unavailable"); }; await matches(path.join(root, "pnpm-lock.yaml"), inputs.lockSha256); - await matches(path.join(root, "node_modules/typescript/package.json"), inputs.compilerPackageSha256); - const parserRoot = path.join(root, "node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser"); - await matches(path.join(parserRoot, "package.json"), inputs.parserPackageSha256); await matches(path.join(parserRoot, "lib/index.js"), inputs.parserEntrySha256); - const require = createRequire(path.join(root, "packages/shared/package.json")), zodPackage = require.resolve("zod/package.json"), zodEntry = require.resolve("zod"); - await matches(zodPackage, inputs.zodPackageSha256); await matches(zodEntry, inputs.zodEntrySha256); + const { parserRoot, require, zodPackage } = await verifySdkProofPackages(root, inputs); const parser = createRequire(path.join(parserRoot, "package.json"))("./lib/index.js"); const publicTypes = new Map(); for (const [relative, expected] of Object.entries(inputs.zodTypeFiles)) { diff --git a/tests/runner-e2e/vitest.config.ts b/tests/runner-e2e/vitest.config.ts index 45178ceb703..b23653c84be 100644 --- a/tests/runner-e2e/vitest.config.ts +++ b/tests/runner-e2e/vitest.config.ts @@ -1,6 +1,8 @@ import { fileURLToPath } from "node:url"; import { configDefaults, defineConfig } from "vitest/config"; +const pendingDependabotLock = process.env.PAPERCLIP_CI_PR_AUTHOR === "dependabot[bot]"; + export default defineConfig({ root: import.meta.dirname, test: { @@ -12,7 +14,8 @@ export default defineConfig({ globalSetup: ["./verified-provider-bundles.setup.mjs"], include: ["**/*.test.ts", "**/*.test.mjs"], // These use node:test and run separately in test:e2e:runner:unit. - exclude: [...configDefaults.exclude, "product-regression-testops.test.mjs", "reliability-testops.test.mjs", "native-completion-{checks,git-source,source-contract}.test.mjs", "artifact-budget.test.mjs", "chat-feature-testops-api.test.mjs", "chat-feature-testops-cli.test.mjs", "chat-feature-testops-results.test.mjs", "testops-chat-reporter.test.mjs", "chat-completion-testops-{api,contract}.test.mjs", "chat-full-catalog-testops-*.test.mjs", "chat-catalog-testops-streaming.test.mjs"], + exclude: [...configDefaults.exclude, "product-regression-testops.test.mjs", "reliability-testops.test.mjs", "native-completion-{checks,git-source,source-contract}.test.mjs", "artifact-budget.test.mjs", "chat-feature-testops-api.test.mjs", "chat-feature-testops-cli.test.mjs", "chat-feature-testops-results.test.mjs", "testops-chat-reporter.test.mjs", "chat-completion-testops-{api,contract}.test.mjs", "chat-full-catalog-testops-*.test.mjs", "chat-catalog-testops-streaming.test.mjs", + ...(pendingDependabotLock ? ["source-sdk-public-type.test.ts"] : [])], testTimeout: 30_000, }, }); From 7b8df907d36628d6cc6056c9e7a9a7d227a5e466 Mon Sep 17 00:00:00 2001 From: Michael Nguyen <13559011+nguyenm7@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:21:00 -0800 Subject: [PATCH 5/5] test(runner): copy a standalone sleep binary where /bin/sleep is a multicall binary (#21726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Each pull request runs the Paperclip CI gates. A pull request from a fork runs them on GitHub-hosted `ubuntu-latest` runners. > - GitHub now routes some `ubuntu-latest` jobs to the `ubuntu-26.04` image. On that image `ci / Verify Paperclip Runner (static checks)` fails for each pull request, with no relation to the change under test. > - The cause is a test fixture. Two tests copy `/bin/sleep` as a stand-in for the daemon. On that image `/bin/sleep` is a multicall binary that does not run from a copy with another name. > - #21787 starts the copy with the process name `sleep`. The copy still exits with status 1 on that image, so the two tests still fail there. > - This pull request makes the two tests copy a standalone `sleep` binary on such an image. > - The benefit is that `ci / verify` shows the state of the change again on each runner image. ## Linked Issues or Issue Description Refs #21787 and #21792. #21792 fixed the sandbox test that failed on the same image, so this pull request no longer changes that test. #21787 changed the runner staging tests, but two of them still fail on the `ubuntu-26.04` image. Refs #21688 and #21692, which show the failure. **What happened?** `ci / Verify Paperclip Runner (static checks)` fails when the job runs on the `ubuntu-26.04` runner image. Two tests in `packages/paperclip-runner/scripts/stage-runner-binary.test.mjs` fail: "atomically publishes while the previous executable is running" and "a source rebuild selects fresh dev bytes while preserving release binaries and their manifest". The same job passes on the `ubuntu-24.04` image and on the self-hosted fleet. **Expected behavior** The check gives the same result on each runner image. **Steps to reproduce** 1. Start an `ubuntu:26.04` container. 2. Run `cmp /bin/sleep /bin/echo`. The files are the same. Each is the Rust coreutils multicall binary. 3. Run `cp /bin/sleep /tmp/paperclip-runnerd && /tmp/paperclip-runnerd 30`. The output is `coreutils: unknown program 'paperclip-runnerd'` and the status is 1. 4. Run the test file from `master` in that container with Node 24. The two tests fail. **Operating system** The `ubuntu-26.04` GitHub-hosted runner image, version 20261111.196.1. ## What Changed - `packages/paperclip-runner/scripts/stage-runner-binary.test.mjs`: add `standaloneSleep`. On Linux, when `/bin/sleep` and `/bin/echo` have the same bytes, the two tests copy `/usr/bin/gnusleep` as the stand-in for the daemon. On each other system the tests use `/bin/sleep` as before. No product code changes. No workflow file changes. The branch no longer changes `runner-bridge-tools.test.ts`. ## Verification Tested revision: the head commit of this branch. - `node --test scripts/stage-runner-binary.test.mjs` in `packages/paperclip-runner`, in an `ubuntu:26.04` container with Node 24: the version from `master` fails the two tests. This version passes them. - The same command in an `ubuntu:24.04` container with Node 24: the two tests pass. - The same command on macOS: 9 of 9 tests passed. - In the two containers one other test, "a build without release daemons still compiles the Runner binary", fails because `pnpm` is not installed there. It passes on macOS. - An earlier revision of this branch, before the merge with `master`, passed `ci / Verify Paperclip Runner (static checks)` on the `ubuntu-26.04` image. ## Risks - Low risk. The change is in one test file. - The tests use `/usr/bin/gnusleep` only when the standard file is a multicall binary. If an image has a multicall binary and does not have the GNU file, the two tests fail with a missing file error, which names the cause. ## Model Used - Claude Fable 5.2 (`claude-fable-5-2`), through Claude Code, with tool use and code execution. ## 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 - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5.2 --- .../scripts/stage-runner-binary.test.mjs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/paperclip-runner/scripts/stage-runner-binary.test.mjs b/packages/paperclip-runner/scripts/stage-runner-binary.test.mjs index 2127a9d1842..2ee6166fecb 100644 --- a/packages/paperclip-runner/scripts/stage-runner-binary.test.mjs +++ b/packages/paperclip-runner/scripts/stage-runner-binary.test.mjs @@ -84,6 +84,12 @@ test("release metadata rejects incompatible native, harness and protocol contrac } }); +async function standaloneSleep() { + if (process.platform !== "linux") return "/bin/sleep"; + const multicall = (await readFile("/bin/sleep")).equals(await readFile("/bin/echo")); + return multicall ? "/usr/bin/gnusleep" : "/bin/sleep"; +} + async function withOwnedChildren(root, action) { const owned = []; const start = (command, args, argv0) => { @@ -112,12 +118,13 @@ async function withOwnedChildren(root, action) { test("atomically publishes while the previous executable is running", { skip: process.platform === "win32", timeout: 15_000 }, async () => { const root = await mkdtemp(path.join(tmpdir(), "runnerd-stage-test-")); const destination = path.join(root, "paperclip-runnerd"); + const sleep = await standaloneSleep(); await withOwnedChildren(root, async start => { - await stageRunnerBinary("/bin/sleep", destination); + await stageRunnerBinary(sleep, destination); const previous = await stat(destination); const old = start(destination, ["30"], "sleep"); await old.spawned; - await stageRunnerBinary("/bin/sleep", destination); + await stageRunnerBinary(sleep, destination); const published = await stat(destination); assert.notEqual(published.ino, previous.ino); assert.equal(published.mode & 0o777, 0o755); @@ -152,7 +159,7 @@ test("a source rebuild selects fresh dev bytes while preserving release binaries await mkdir(path.dirname(built), { recursive: true }); await copyHostFixture("/bin/sh", built); const previousBuild = path.join(root, "previous-build"); - await copyHostFixture("/bin/sleep", previousBuild); + await copyHostFixture(await standaloneSleep(), previousBuild); await stageRunnerBinary(previousBuild, hostTarget); await stageRunnerBinary(built, path.join(binaryRoot, "paperclip-runnerd")); const platforms = {}, releaseBytes = new Map();