mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
ecef06d24673d1d08cb8cd03151bc4b558f0f7a1
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cffd17e78a |
perf(ci): Phase 3 PR CI under 3m — 4x Runner support, 12x E2E, incremental TS 7 cache, pure-Node postinstall, and rebalanced shards (#22804)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Pull request CI verifies every change before merge across build, typecheck, server tests, Runner tests, and Playwright E2E shards. > - After Phase 1 (#22679) and Phase 2 (#22729), full-fanout PR CI still takes 9m45s wall-clock on 4-core AWS runners because of five bottlenecks: an unsharded 7m22s `Runner support suite`, stale server/chat/Runner shard duration manifests plus newly landed SSH/soak whales, 28s of `pnpm -r run postinstall` replay on every job, cold server/UI typecheck and single-build overhead, and 3 oversized (>180s) Playwright E2E specs across 8 shards with double-start Postgres template boot. > - Docs-only prose edits under `doc/**` and `docs/**` also fanned out to 66 CI jobs because only three doc paths bypassed global dependencies. > - This pull request shards `Runner support suite` 4 ways with `pool: "threads"`, shards E2E 12 ways after splitting the 3 oversized specs and removing double-start Postgres boot, adds pure-Node workspace postinstall replay, adds read-only master-warmed incremental TS 7 and Runner dist caches, rebalances all server/chat/Runner duration manifests, demotes 48 new non-invariant soak whales to nightly, and routes audited prose docs without triggering 66-job storms. > - The benefit is driving ordinary PR CI toward under 3 minutes wall-clock while preserving every invariant check, cache boundary, and full master/nightly test coverage. ## Linked Issues or Issue Description Refs #22679 Refs #22729 **What existing behavior does this improve?** Pull request CI wall-clock latency across `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`, `.github/actions/setup-ci-dependencies/action.yml`, typecheck orchestration, Vitest/Runner lanes, and Playwright E2E shards. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Full-fanout PR CI takes 9m45s on 4-core runners (run `45440355579`), dominated by `Runner support suite` (7m22s), `e2e shards` (5m02s–6m24s), `General tests (server/chat)` (5m37s–6m01s), `Verify Paperclip Runner (vitest package)` (6m25s on stale manifests), `Typecheck` (4m13s–6m30s), `Build` (~4m), and 28s of `pnpm -r postinstall` per job. Prose edits under `doc/**` trigger 66 jobs. **Proposed behavior** Shard `Runner support suite` (4x) and `e2e_shards` (12x), split the 3 oversized E2E specs, boot disposable E2E Postgres in a single non-durable start, replay workspace `postinstall` in pure Node (<1s), cache prebuilt Runner dist and TS 7 `.tsbuildinfo` from canonical `master` pushes (read-only in PRs), use emit-only server compile in ordinary PR `Build`, rebalance all shard duration manifests, demote 48 new non-invariant soak whales to nightly, and route audited prose docs cleanly. ## What Changed - **Pure-Node postinstall replay (`scripts/replay-workspace-postinstall.mjs`, `.github/actions/setup-ci-dependencies/action.yml`):** Replaces the 28s `pnpm -r --if-present run postinstall && pnpm run postinstall` call on every CI job with a pure-Node parallel runner (~0.84s locally) with fallback for older checkouts. - **4-way sharded `Runner support suite` + `threads` pool (`.github/ci-task-matrix.json`, `.github/workflows/pr-trusted.yml`, `tests/runner-e2e/run-unit.mjs`, `tests/runner-e2e/vitest.config.ts`):** Shards Vitest and `node:test` suites 4 ways (`--shard-index 0..3 --shard-count 4`) and switches `tests/runner-e2e` to `pool: "threads"` with CPU-aware `maxWorkers` while preserving `isolate: true`. - **12-way E2E shards, single-start E2E Postgres boot, and 3 oversized spec splits (`tests/e2e/start-e2e-server.ts`, `tests/e2e/*.spec.ts`, `tests/e2e/playwright.config.ts`, `scripts/e2e-shard.mjs`, `scripts/e2e-shard-durations.json`, `.github/ci-task-matrix.json`):** Boots cold ephemeral E2E Postgres in one `initdb --no-sync` + non-durable `postgresql.conf` start overlapped with server module import; splits `agent-chat-projects`, `chat-adapters-ui-providers`, and `chat-adapters-ui-messaging` cleanly with zero tests removed; balances all 54 specs across 12 shards (6.8s spread). - **Incremental TS 7 typecheck & Runner dist caching (`server/scripts/typecheck-layers.mjs`, `scripts/ci-typecheck-lane.mjs`, `scripts/typecheck-test-programs.mjs`, `scripts/typecheck-test-projects.mjs`, `.github/workflows/pr-trusted.yml`, `.github/workflows/release-verify.yml`):** Preserves portable `.tsbuildinfo`/`.d.ts` with `layer-map.json` invalidation and stale-declaration pruning, wires read-only `runner-dist-v1` and `typecheck-incremental-v1` restores in `pr-trusted.yml` (zero `actions/cache/save`) paired with canonical-`master`-only guarded writers in `release-verify.yml`, skips redundant Runner Rust `cargo check` on TS-only shared PRs, and uses LPT scheduling with concurrency 3 (4-core) / 4 (8-core). - **Emit-only PR `Build` & audited prose doc routing (`.github/workflows/pr-trusted.yml`, `.github/scripts/ci-inputs.mjs`):** Passes `PAPERCLIP_TSC_EMIT_ONLY=1` on ordinary PR `Build` jobs (full `pnpm build` on `full-ci` / `master`), and classifies audited prose Markdown under `doc/**` and `docs/**` as `guidance` / `historical` while keeping `docs/api/**`, JSON/TS fixtures, `maps/**`, and unknown files fail-closed. - **Rebalanced shard manifests & new soak demotions (`scripts/ci/nightly-only-suites.json`, `scripts/*-shard-durations.json`, `packages/paperclip-runner/scripts/vitest-lane-durations.json`, `packages/paperclip-runner/vitest.config.ts`, `packages/paperclip-runner/scripts/vitest-sequencer.mjs`):** Demotes 48 newly landed/grown non-invariant soak suites (including 4 real-SSH integration suites) to nightly, refreshes all 4 timing manifests from live CI measurements (0.1s–0.6s LPT skew), and scales Runner package Vitest CI `maxWorkers` to 3 on 4-core / 6 on 8-core. ## Verification - `node --test .github/scripts/tests/*.test.mjs scripts/__tests__/runner-release-crate-cache.test.mjs scripts/__tests__/public-install-closure.test.mjs scripts/__tests__/merge-queue-checks-workflow.test.mjs scripts/__tests__/e2e-shard.test.mjs scripts/__tests__/ci-typecheck-lane.test.mjs scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/__tests__/run-vitest-stable-pr-mode.test.mjs scripts/__tests__/runner-vitest-package-lanes.test.mjs scripts/typecheck-test-programs.test.mjs scripts/check-test-budget.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/test-selection-timings.test.mjs` — **973/973 PASS** - `node scripts/check-test-budget.mjs --base origin/master` — **PASS** (`609` nightly suites validated, zero protected invariants demoted) - `node scripts/check-maps.mjs` — **PASS** - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/source-sdk-public-inputs.test.mjs tests/runner-e2e/unit-launcher.test.mjs` — **PASS** - `pnpm --filter @paperclipai/paperclip-runner exec vitest run scripts/vitest-sequencer.test.mjs` — **PASS** - `cd server && node ../node_modules/vitest/vitest.mjs run scripts/typecheck-layers.test.mjs scripts/typecheck-layers-incremental.test.mjs` — **56/56 PASS** (real TS 7.0.2 incremental soundness tests) - `node scripts/run-tsc.mjs -p tests/e2e/tsconfig.json --noEmit && node scripts/run-tsc.mjs -p tests/tsconfig.playwright.json --noEmit && pnpm run test:e2e:runner:typecheck` — **0 errors** - Live Playwright smoke passed across all 6 split E2E spec files on the cold non-durable Postgres boot path (`PAPERCLIP_TEST_POSTGRES_TEMPLATE=0`). - Live sharded `tests/runner-e2e` runs passed under `pool: "threads", maxWorkers: 4` (shard `1/4` 172/172 PASS; shard `2/4` all Vitest + 65/65 `node:test` PASS). ## Risks - **Cache invalidation on incremental typecheck / Runner dist:** Mitigated by exact-key hashing (including `packages/{shared,adapter-utils,plugins/sdk}/src/**` and `packages/paperclip-runner/spec/**`) with no `restore-keys:` on `runner-dist-v1`, SHA-256 self-validation inside `prepare-runner-vendor.mjs`, `layer-map.json` invalidation + stale `.d.ts` pruning in `typecheck-layers.mjs`, and read-only PR restores (only canonical `master` pushes save caches). - **Shard rebalancing & soak demotions:** All demoted suites remain in `nightly-only-suites.json` and run on `full-ci` / `master` / nightly; `check-test-budget.mjs` enforces zero protected invariants are demoted. - **Workflow security boundaries:** `ci-routing.yml`, `pr.yml`, `CODEOWNERS`, and all `runs-on:` expressions are unchanged; `pr-trusted.yml` performs zero `actions/cache/save` calls. ## Model Used - Google Gemini (Antigravity agent swarm) with extended reasoning, tool use, and local code/test execution across 6 parallel worker roles (`ci-pipeline`, `vitest-runner`, `server-prune`, `e2e-opt`, `typecheck-opt`, `verifier`). ## 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 |
||
|
|
0d832a02d3 |
perf(ci): shorten the general server and chat test lanes (#21393)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Every pull request runs the `PR` CI workflow before it can merge > - The `General tests (server (N/12))` and `General tests (chat (N/3))` jobs finish last, so they set the wall-clock time of CI > - Before this change, server shards took 9.5 to 11.7 minutes and chat shards took 6.4 to 9.6 minutes; the target is 7 minutes or less > - Measurement shows that the chat lane was unbalanced and that the server lane is limited by CPU on the 4-vCPU runners > - This pull request balances the chat lane by recorded test time, runs three chat partitions per job, and takes general server weights from PR runs > - The benefit is a chat lane under 7 minutes and measured evidence for the shard count that the server lane needs ## Linked Issues or Issue Description **What existing behavior does this improve?** The PR CI general server and chat test jobs. They are the slowest jobs of every pull request. **Subsystem affected** CI test scheduling: `scripts/run-vitest-stable.mjs`, `scripts/test-line-shard.mjs` and `scripts/ci/refresh-test-durations.mjs`. **Current behavior** Baseline: green `PR` runs [43437558012](https://github.com/paperclipai/paperclip/actions/runs/43437558012) and [43441184316](https://github.com/paperclipai/paperclip/actions/runs/43441184316), all on m7i-flex.xlarge (4 vCPU, 16 GB). - Server shards: 9.5 to 11.7 job minutes, 502 to 654 s test step, effective file concurrency 2.5 to 2.9 of 3 workers. Vitest reports `tests 61-68%, import 25-31%, transform 6-7%, setup 1%`. Each shard sums 1,410 to 1,765 s of file time. The longest file is 303 s (`deferred-execution-receipt-work.test.ts`), so the floor is total work divided by workers, not one file. - Chat shards: 9.3 to 9.6, 7.6 to 7.8 and 6.4 to 6.5 job minutes. Each job ran two partitions of `chat-channels.integration.test.ts`. The partitions were balanced by collected-case count, but one `it.each` line can run many cases. One of six partitions recorded 532 s of test time against a 377 s mean. **Proposed behavior** - Chat partitions keep each source line whole and balance by recorded time per collected entry. - Each chat job runs three partitions in place of two. - General server weights come from the server jobs of merged PR runs, which run files with the same concurrency as the lane they place. **Reason and benefit** The slowest job sets the CI wall-clock time for every pull request. The chat lane goes from a 9.3-9.6 minute maximum to 6.5-6.8 minutes. ## What Changed - `scripts/test-line-shard.mjs`: `partitionTestLines` takes optional recorded durations. With durations, it balances source lines by recorded time; entries without a record take the median. Without durations, the behavior is unchanged. - `scripts/chat-shard-durations.json` (new): recorded time per collected chat entry, from the CI profile records of PR run [43444854171](https://github.com/paperclipai/paperclip/actions/runs/43444854171). 926 of 928 collected entries are measured; the other two are the bogus collection entries that the launcher already drops. - `scripts/ci/refresh-chat-shard-durations.mjs` (new): builds that manifest from downloaded `ci-profile-*` artifacts. Each executed case maps to the collected `it`/`it.each` entry that registers it. A case without an entry fails the refresh. - `scripts/run-vitest-stable.mjs`: a sharded chat job runs three partitions in place of two, and the chat launcher passes the recorded durations. A chat job collects the suite once with `vitest list` in place of once per partition, and the per-partition filter checks run at the same time. Before, each partition ran two blocking collections of the 86,000-line file one after another. The server worker count stays at three. - `scripts/ci/refresh-test-durations.mjs` and `scripts/ci/pr-run-durations.mjs`: the weekly refresh reads general server weights from the two newest merged-PR runs. Each run must have the full server shard count from `.github/ci-task-matrix.json` and cover at least 90% of the lane. Serialized weights still come from master Cloud readiness runs. - `scripts/general-server-shard-durations.json`: refreshed with the new source (PR runs 43439145752 and 43439279537). - Tests: `scripts/__tests__/run-vitest-stable-shard.test.mjs`, `scripts/ci/test-selection-pr-timings.test.mjs` and `server/src/__tests__/vitest-chat-shards.test.ts` cover the weighted partition, the entry mapping, the manifest format, the PR-run collection rules and the three-partition chat launcher. - `doc/DEVELOPING.md`: describes the three chat partitions, the chat weights and how to refresh them, and the new source of the server weights. ## Verification Experiments ran in this PR's own CI with a temporary resource sampler (removed before review). | Setting (run) | Server step vs. same shard's baseline | CPU busy | Max memory used | Result | |---|---|---|---|---| | 3 workers (43444854171, shards 1-4) | +8% (profiling overhead) | 62-73% | 6.8 GB | 1 flaky retry | | 4 workers (43444854171, shards 5-8) | -4% | 82-86% | 8.2 GB | clean | | 5 workers (43444854171, shards 9-12) | -10% | 70-93% | 9.5 GB | 1 hard failure: `decision-models.test.ts` timed out at 15 s twice | | 4 workers (43450469416) | mixed m5a/m5n/m6i runners | 78-89% | 7.7 GB | 1 hard failure: `workspace-recovery-warm-handoff.test.ts` timed out at 30 s on m5a | The server lane is CPU bound: at four workers the CPU is 82-89% busy and wall time improves by only about 10%. Five workers fail tests. Memory is not the limit (no swap, no memory pressure, at least 6 GB free). Node's compile cache and Postgres `fsync=off` showed no attributable gain (import share stayed 29-34%; `fsync=off` cut iowait from 2-4% to 0.2-0.7% of CPU time), so neither is in this PR. Final configuration (server: 3 workers with refreshed weights; chat: 3 weighted partitions per job), job minutes / test-step seconds / effective concurrency: | Shard | Baseline 43437558012 | Baseline 43441184316 | A: 43465156503 attempt 1 | B: attempt 2 | C: attempt 3 | |---|---|---|---|---|---| | server 1/12 | 11.0 / 609 / 2.81 | 10.2 / 562 / 2.82 | 10.1 / 535 / 2.88 | 11.6 / 615 / 2.86 | 11.3 / 600 / 2.86 | | server 2/12 | 10.2 / 567 / 2.71 | 10.9 / 607 / 2.79 | 9.7 / 510 / 2.85 | 8.9 / 466 / 2.86 | 11.9 / 635 / 2.83 | | server 3/12 | 10.9 / 609 / 2.88 | 10.9 / 601 / 2.86 | 9.4 / 498 / 2.81 | 11.7 / 623 / 2.80 | 20.3 / 1109 / 0.00 | | server 4/12 | 11.0 / 613 / 2.77 | 11.2 / 622 / 2.84 | 11.3 / 602 / 2.84 | 9.3 / 487 / 2.83 | 12.5 / 676 / 2.84 | | server 5/12 | 10.1 / 555 / 2.83 | 9.9 / 544 / 2.84 | 10.2 / 542 / 2.85 | 11.6 / 618 / 2.82 | 11.9 / 640 / 2.84 | | server 6/12 | 9.9 / 551 / 2.85 | 10.4 / 579 / 2.85 | 9.8 / 516 / 2.69 | 9.1 / 480 / 2.68 | 9.2 / 480 / 2.67 | | server 7/12 | 10.8 / 596 / 2.84 | 10.1 / 558 / 2.86 | 10.8 / 575 / 2.80 | 11.8 / 631 / 2.80 | 20.8 / 1129 / 2.69 | | server 8/12 | 11.7 / 654 / 2.62 | 11.2 / 624 / 2.56 | 9.8 / 513 / 2.83 | 11.2 / 589 / 2.82 | 19.4 / 1059 / 2.40 | | server 9/12 | 9.7 / 533 / 2.85 | 9.7 / 533 / 2.84 | 11.5 / 615 / 2.68 | 9.8 / 515 / 2.66 | 13.0 / 703 / 2.68 | | server 10/12 | 9.8 / 540 / 2.79 | 9.5 / 502 / 2.81 | 10.6 / 561 / 2.84 | 11.8 / 625 / 2.83 | 9.3 / 488 / 2.83 | | server 11/12 | 10.9 / 605 / 2.83 | 11.3 / 627 / 2.75 | 10.3 / 545 / 2.75 | 9.5 / 498 / 2.72 | 20.3 / 1107 / 0.00 | | server 12/12 | 10.6 / 592 / 2.50 | 11.7 / 645 / 2.53 | 9.6 / 503 / 2.81 | 8.9 / 468 / 2.82 | 19.7 / 1065 / 2.70 | | chat 1/3 | 9.6 / 528 / 1.56 | 9.3 / 511 / 1.58 | 6.6 / 310 / 2.69 | 5.7 / 272 / 2.65 | 6.8 / 331 / 2.69 | | chat 2/3 | 7.8 / 418 / 1.74 | 7.6 / 408 / 1.75 | 6.3 / 305 / 2.57 | 6.5 / 311 / 2.58 | 5.5 / 260 / 2.58 | | chat 3/3 | 6.5 / 337 / 1.74 | 6.4 / 333 / 1.73 | 6.0 / 285 / 2.65 | 5.4 / 258 / 2.68 | 5.8 / 262 / 2.69 | Summary: chat maximum 9.3-9.6 min before, 6.6 / 6.5 / 6.8 min in A / B / C. Server maximum 11.7 min before, 11.5 / 11.8 min in A / B; the server worker setting is unchanged, so its run-to-run spread is mostly runner type (m8i.xlarge shards took 8.9-9.8 min, m6a.xlarge 11.9-13.0 min). Runners: A all m7i.xlarge; B m8i/m6i; C m6a/m6in/m8i/m5a. In C, the five server shards on m5a.xlarge summed 2,545-3,037 s of file time against about 1,700 s elsewhere; three reached the 20-minute job limit and two failed tests on 15 s timeouts. The server lane settings in this PR are the same as master's, so this is a fleet finding: m5a.xlarge cannot run a server shard inside the job limit (follow-up for the fleet configuration, outside this PR). Flakiness of the final setting: the nine chat jobs in A, B and C had no failure and no retried test. Server shards in A and B had no failure and no retried test. Before the last commit (single chat collection), three runs of 43456289623 had chat at 6.7-7.5 min with no chat retries; server retries there (2 in one run, 1 in another) were on the unchanged three-worker server setting. Local checks (correctness only): - `node --test scripts/__tests__/run-vitest-stable-shard.test.mjs scripts/ci/test-selection-pr-timings.test.mjs scripts/ci/test-selection-timings.test.mjs`: 68 passed. - `pnpm exec vitest run --project @paperclipai/server server/src/__tests__/vitest-chat-shards.test.ts`: passed. - `pnpm verify` exits 2 (global CI input changed), so the required CI checks supply the broad coverage. ## Risks - Three chat partitions per job use more memory: the peak was 11.4 GB of 16 GB, with at least 4.2 GB free and no memory pressure. CPU was 55-63% busy. - Stale chat weights only change balance, never which tests run. Shard membership is still checked with `vitest list` before each run. - The weekly refresh now downloads general server logs from merged-PR runs. Runs that selected a subset of files are skipped before download because their shard count is smaller. - The server lane is still above 7 minutes. See the remaining floor below. **Remaining floor and shard-count recommendation (for a follow-up under `.github/`)** A server shard sums about 1,600 s of file time, and 3 workers on 4 vCPUs give at most about 2.8 effective concurrency, so the test step is about 560-640 s. Job overhead is about 50 s. A job of 7 minutes needs a test step of about 360 s, so about 1,000 s of file time per shard. The current 19,200 s of general server file time therefore needs about 19-20 shards of 4 vCPUs at 3 workers. More workers on the same runners do not help, because the CPU is already the limit. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, with tool use (shell, GitHub CLI) 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 <noreply@anthropic.com> |