mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 06:50:43 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Post-merge `Cloud readiness` runs the full server test suite with `--retry=0` before publishing new Core Docker images. > - Five consecutive `Cloud readiness` runs on `master` failed over 22 hours because two test timeout patterns surfaced under multi-worker CI shards. > - First, `issue-activity-events-routes.test.ts` and `issue-comment-attribution-audit-routes.test.ts` dynamically import `server/src/routes/issues.ts` inside the first `it()` block, crossing the 15s `testTimeout` when 5 fork workers simultaneously hit Vite's transform server. > - Second, `native-status-arbiter-corpus.test.ts` seeds 103 rows sequentially in its multi-page drain tests, crossing 60s under 7-worker shared-Postgres load and causing `afterEach` to time out before restoring real timers. > - This pull request moves those module imports into `beforeAll`, aligns `server/vitest.config.ts` `testTimeout` with `hookTimeout` (30s), batches the 103-row fixture seeding with bounded concurrency, and guards timer restoration in `try/finally`. > - The benefit is green, deterministic post-merge `Cloud readiness` builds without weakening any test assertion or retry policy. ## Linked Issues or Issue Description **What happened?** Five consecutive `Cloud readiness` workflow runs on `master` failed and cancelled over a 22-hour window, blocking new Core image publication: - Three runs failed with `Test timed out in 15000ms` on the first test of `server/src/__tests__/issue-activity-events-routes.test.ts` (twice) and `server/src/__tests__/issue-comment-attribution-audit-routes.test.ts` (once) while dynamically importing `server/src/routes/issues.ts` under 5-worker parallel serialized shards. - Two runs failed in `server/src/__tests__/native-status-arbiter-corpus.test.ts` when `drains more than one reconstruction page without replaying settled reviews` timed out at `60000ms` during 103 sequential `seedReview()` calls, which also timed out `afterEach` (`30000ms`) before restoring `vi.useRealTimers()`. **Expected behavior** All server route and native status arbiter tests pass reliably on post-merge `Cloud readiness` (`--retry=0`) without cold-transform timeouts or leaked fake timers. **Steps to reproduce** 1. Run `Cloud readiness` (`release-verify.yml`) on `master` with `--retry=0` on 8-core runners (`maxWorkers=5` serialized shards, `maxWorkers=7` general-server shards). 2. Observe cold dynamic imports of `routes/issues.ts` inside `it()` crossing `15000ms` and the 103-row sequential seed test in `native-status-arbiter-corpus.test.ts` crossing `60000ms`. **Paperclip version or commit** `c57471459f` (`master`) ## What Changed - **`server/src/__tests__/issue-activity-events-routes.test.ts`**: Register module mocks and import `routes/issues.js` and `middleware/index.js` once in `beforeAll` (30s timeout) instead of calling `vi.resetModules()` and re-importing on every test; keep full `vi.clearAllMocks()` and mock defaults reset in `beforeEach`. - **`server/src/__tests__/issue-comment-attribution-audit-routes.test.ts`**: Pre-import `routes/activity.js` and `routes/issues.js` in `beforeAll` alongside embedded Postgres startup (30s timeout) instead of lazily importing inside `createApp()` on the first test. - **`server/vitest.config.ts`**: Increase `testTimeout` from `15000` to `30000` (matching `hookTimeout` and `teardownTimeout`) so parallel cold Vite transforms on 5-worker CI shards do not flake the first test in sibling route suites. - **`server/src/__tests__/native-status-arbiter-corpus.test.ts`**: Seed the 103 fixtures in both multi-page drain tests in bounded concurrent batches of 8, parallelize the final status assertions, allow `30_000ms` for multi-page `flush()`, and wrap `coordinator?.stop()` in `try/finally` in both `afterEach` hooks so `vi.useRealTimers()` and `vi.restoreAllMocks()` always run. ## Verification - `pnpm --filter @paperclipai/server typecheck` — passed - `pnpm exec vitest run --project @paperclipai/server server/src/__tests__/issue-activity-events-routes.test.ts server/src/__tests__/issue-comment-attribution-audit-routes.test.ts server/src/__tests__/native-status-arbiter-corpus.test.ts` — passed (`3/3` files, `189/189` tests; `issue-activity-events-routes.test.ts` ran in `3.95s` total and test 1 of `issue-comment-attribution-audit-routes.test.ts` ran in `445ms`) ## Risks - Low risk: test-only and Vitest timeout configuration changes. No production server behavior, schema, or API contracts are changed, and no test assertions or retry policies are weakened. ## Model Used - Google DeepMind Antigravity (Gemini 3.1 Pro, agentic tool use with shell verification) ## 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)