mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-06 10:48:12 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Paperclip Cloud consumes versioned readiness markers for each merged source commit. > - Those markers can be published only after the required checks and artifacts pass. > - The marker jobs currently wait for the same AWS runner capacity as builds and tests. > - A busy builder pool can delay readiness after all required work has finished. > - This PR moves the small readiness jobs to GitHub-hosted runners while retaining every dependency gate. ## Linked Issues or Issue Description Refs #13326 and #13328. **What existing behavior does this improve?** Time from completed Cloud verification to a deployable marker, and AWS capacity occupied by artifact polling. **Current behavior** In [Cloud readiness run 34711557083](https://github.com/paperclipai/paperclip/actions/runs/34711557083), all builds and tests finished at 18:43:05 UTC. The source marker did not start until 18:44:21, and the deployable marker did not start until 18:44:37. Merge-to-deployable was 11m33s, although the prerequisite work finished in 9m44s. **Proposed behavior** Run the artifact wait and both versioned marker jobs on `ubuntu-latest`. Keep the compute jobs on the approved post-merge AWS fleet. **Reason and benefit** Avoid builder-pool queue delays after verification finishes. This also removes the long artifact-wait job from AWS capacity. Expected savings depend on queue depth: the observed run had over 90 seconds of avoidable marker waiting. The marker commands themselves take only seconds. **Breaking changes** Runner placement changes for three bookkeeping jobs. Marker names, exact-source artifact checks, required verification, and image verification stay the same. **Additional context** Searched the related runner and Cloud readiness work. This addresses queue time observed after the parallel verification change. ## What Changed - Place the artifact wait, source-verification marker, and deployable marker on GitHub-hosted runners. - Keep all existing job dependencies, source guards, permissions, and commands. - Extend routing regressions to enforce this placement and retain fail-closed readiness gates. - Document why readiness bookkeeping uses separate runner capacity. ## Verification - Passed 433 workflow, routing, source-verification, and Cloud readiness tests with `node --test .github/scripts/tests/*.test.mjs scripts/cloud-source-verification.test.mjs scripts/cloud-readiness.test.mjs scripts/__tests__/release-verify-workflow.test.mjs`. - Passed `actionlint` and `git diff --check`. - Passed all latest-head CI gates in [run 34712624340, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/34712624340), including typecheck, build, browser, Runner, and all general/serialized tests. - Attempt 1 had one localhost readiness timeout in an unchanged test. A single targeted retry passed all 166 files (3,225 tests passed, one existing skip), including all seven tests in that file. No timeout, assertion, or application source was changed; the retry is documented in the PR comment. - Local full-suite verification is limited by local disk exhaustion; the focused checks above pass. - Fresh Greptile review is 5/5 with no unresolved findings. ## Risks - GitHub-hosted capacity can also queue, but these jobs no longer compete with AWS build/test demand. The change does not reserve instances or change box sizes. - Readiness must still fail if any prerequisite fails. The existing `needs` relationships and success-only execution are preserved and tested. ## Model Used OpenAI GPT-6 through Codex, with reasoning, repository tools, and code execution. The exact serving model ID and context window are not exposed by this environment. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
108 lines
6.1 KiB
JavaScript
108 lines
6.1 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { runInNewContext } from "node:vm";
|
|
|
|
const fleet = "runs-on/fleet=paperclip-post-merge-x64/env=public-ci";
|
|
const sha = "a".repeat(40);
|
|
const base = {
|
|
repository: "paperclipai/paperclip", repository_id: "1170821064",
|
|
ref: "refs/heads/master", event_name: "push", sha,
|
|
};
|
|
const expectedJobs = {
|
|
"cloud-readiness.yml": [],
|
|
"cloud-artifacts.yml": ["dispatch_migrator"],
|
|
"release-verify.yml": ["typecheck", "general_tests", "serialized_tests", "runner_workflow_evals", "verify_paperclip_runner", "build"],
|
|
"runner-chaos-evals.yml": ["chaos_and_recovery"],
|
|
"release.yml": ["plan_preview", "package_preview"],
|
|
};
|
|
for (const [file, expectedNames] of Object.entries(expectedJobs)) {
|
|
const workflow = readFileSync(new URL(`../../workflows/${file}`, import.meta.url), "utf8");
|
|
const jobs = [...workflow.matchAll(/^ ([a-z_]+):\n([\s\S]*?)(?=^ [a-z_]+:\n|(?![\s\S]))/gm)];
|
|
const routed = jobs.filter(([, , body]) => body.includes(fleet));
|
|
test(`${file}: all intended jobs carry the post-merge guard`, () => {
|
|
assert.deepEqual(routed.map(([, name]) => name).sort(), [...expectedNames].sort());
|
|
});
|
|
for (const [, job, body] of routed) {
|
|
const expression = body.match(/^ runs-on: \$\{\{ (.+) \}\}$/m)?.[1];
|
|
assert.ok(expression, `${file}/${job} must use an explicit runner expression`);
|
|
const release = file === "release.yml";
|
|
const checkRef = release || file === "release-verify.yml" || file === "runner-chaos-evals.yml";
|
|
const inputs = { ref: sha, source_ref: sha, channel: "cloud-migrator" };
|
|
const defaultContext = { ...base, event_name: release ? "workflow_dispatch" : "push" };
|
|
const cases = [
|
|
{ name: "exact master source", expected: fleet },
|
|
{ name: "manual exact master source", github: { event_name: "workflow_dispatch" }, expected: fleet },
|
|
{ name: "switch disabled", enabled: "false" },
|
|
{ name: "switch absent", enabled: "" },
|
|
{ name: "malformed switch", enabled: "yes" },
|
|
{ name: "fork", github: { repository: "someone/paperclip", repository_id: "123" } },
|
|
{ name: "repository renamed or transferred", github: { repository_id: "123" } },
|
|
{ name: "unapproved PR", github: { event_name: "pull_request", ref: "refs/pull/1/merge" } },
|
|
{ name: "PR event even with master ref", github: { event_name: "pull_request" } },
|
|
{ name: "privileged PR event", github: { event_name: "pull_request_target" } },
|
|
{ name: "workflow completion event", github: { event_name: "workflow_run" } },
|
|
{ name: "repository dispatch", github: { event_name: "repository_dispatch" } },
|
|
{ name: "scheduled caller", github: { event_name: "schedule" } },
|
|
{ name: "branch workflow", github: { ref: "refs/heads/feature" } },
|
|
{ name: "release tag", github: { ref: "refs/tags/v2026.911.0" } },
|
|
];
|
|
if (checkRef) {
|
|
const key = release ? "source_ref" : "ref";
|
|
for (const value of ["b".repeat(40), "refs/pull/1/head", "master", "feature", "v1.0.0", ""]) {
|
|
cases.push({ name: `unverified source ${value || "(empty)"}`, inputs: { [key]: value } });
|
|
}
|
|
cases.push({ name: "missing source identity", github: { sha: "" }, inputs: { [key]: "" } });
|
|
}
|
|
if (release) {
|
|
cases.push({ name: "preview of master", inputs: { channel: "preview" } });
|
|
cases.push({ name: "stable release", inputs: { channel: "stable" } });
|
|
}
|
|
for (const { name, github = {}, inputs: overrides = {}, enabled = "true", expected = "ubuntu-latest" } of cases) {
|
|
test(`${file}/${job}: ${name}`, () => {
|
|
const context = { github: { ...defaultContext, ...github }, inputs: { ...inputs, ...overrides }, vars: { AWS_POST_MERGE_CI_ENABLED: enabled } };
|
|
// These canonical contexts use boolean operators and string comparisons
|
|
// whose results match GitHub's expression evaluation.
|
|
assert.equal(runInNewContext(expression, context), expected);
|
|
const timeout = body.match(/^ timeout-minutes: (.+)$/m)?.[1];
|
|
assert.ok(timeout, "AWS jobs need a timeout below the 45-minute instance lifetime");
|
|
const minutes = timeout.startsWith("${{") ? runInNewContext(timeout.slice(3, -2), context) : Number(timeout);
|
|
if (expected === fleet) assert.ok(minutes > 0 && minutes < 45);
|
|
if (release && job === "plan_preview") assert.equal(minutes, expected === fleet ? 10 : 360);
|
|
});
|
|
}
|
|
}
|
|
if (file === "release.yml") {
|
|
test("npm publisher always uses a GitHub-hosted runner", () => {
|
|
const publisher = jobs.find(([ , job]) => job === "publish_preview")?.[2];
|
|
assert.match(publisher, /^ runs-on: ubuntu-latest$/m);
|
|
assert.match(publisher, /^ environment: npm-canary$/m);
|
|
assert.match(publisher, /^ id-token: write$/m);
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
test("Cloud readiness bookkeeping never waits for the AWS verification fleet", () => {
|
|
const workflow = readFileSync(new URL("../../workflows/cloud-readiness.yml", import.meta.url), "utf8");
|
|
const bodies = new Map();
|
|
for (const [name, needs] of [
|
|
["artifacts", null],
|
|
["source_verified", "[verify]"],
|
|
["ready", "[verify, image, artifacts]"],
|
|
]) {
|
|
const body = workflow.match(new RegExp(`^ ${name}:\\n([\\s\\S]*?)(?=^ [a-z_]+:|(?![\\s\\S]))`, "m"))?.[1];
|
|
assert.ok(body, `missing ${name} job`);
|
|
bodies.set(name, body);
|
|
assert.match(body, /^ runs-on: ubuntu-latest$/m);
|
|
assert.doesNotMatch(body, /^ +continue-on-error:|^ +if:.*always\(\)/m);
|
|
assert.match(body, /^ if: github.repository == 'paperclipai\/paperclip' && github.ref == 'refs\/heads\/master'$/m);
|
|
assert.match(body, /^ +SOURCE_SHA: \$\{\{ github.sha \}\}$/m);
|
|
assert.equal(body.match(/^ needs: (.+)$/m)?.[1] ?? null, needs, `${name} prerequisites`);
|
|
}
|
|
assert.match(bodies.get("artifacts"), /^ run: node scripts\/cloud-readiness.mjs "\$SOURCE_SHA"$/m);
|
|
assert.match(bodies.get("source_verified"), /^ run: node --test scripts\/cloud-source-verification.test.mjs$/m);
|
|
assert.match(bodies.get("source_verified"), /echo "Cloud source verified v1: \$SOURCE_SHA"/);
|
|
assert.match(bodies.get("ready"), /echo "Cloud deployable v1: \$SOURCE_SHA"/);
|
|
});
|