Files
PaperClipAI/packages/paperclip-runner/spec
DottaandPaperclip 2538dce415 Split heartbeat-process-recovery.test.ts into 4 balanced serialized suites (#22955)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Release and master verification run serialized server integration
suites across sharded CI jobs (`release-verify.yml`)
> - `server/src/__tests__/heartbeat-process-recovery.test.ts` (17,926
lines, 466 expanded tests) takes ~6m 28s in a single file, so Vitest
cannot shard it across runners even with 9 serialized shards (#22946)
> - Because one file sets a hard floor on the serialized verification
lane, release readiness stays slower than necessary after every merge
> - This pull request moves the shared suite body into
`server/src/__tests__/heartbeat-process-recovery.helper.ts` with four
disjoint `part` slices and adds four thin test entrypoints
(`heartbeat-process-recovery-part-{1..4}.test.ts`)
> - The benefit is balanced shard distribution across serialized
runners, cutting the single-file serialized ceiling by ~4.5 minutes
while keeping all 466 test cases intact

## Linked Issues or Issue Description

Refs #22946

**Area**
CI / Test Infrastructure

**Current Behavior**
`server/src/__tests__/heartbeat-process-recovery.test.ts` runs as a
single 17,926-line Vitest file (~344s recorded, ~388s in recent release
runs), bounding `Serialized tests` even across 9 shards.

**Proposed Improvement**
Partition the suite into four thin entrypoint files
(`heartbeat-process-recovery-part-{1..4}.test.ts`) backed by a shared
`heartbeat-process-recovery.helper.ts`, with measured proportional shard
weights in `scripts/serialized-shard-durations.json` and
`scripts/ci/nightly-only-suites.json`.

**Motivation / Use Case**
Shorten master and release verification wall-clock latency without
dropping or weakening any recovery test coverage.

## What Changed

- Renamed `server/src/__tests__/heartbeat-process-recovery.test.ts` to
`server/src/__tests__/heartbeat-process-recovery.helper.ts` exporting
`registerHeartbeatProcessRecoverySuite(part: 1 | 2 | 3 | 4)`, hoisting
`withTempPaperclipHome` to shared scope, making `beforeAll`'s
`authUsers` seed `.onConflictDoNothing()` for shared
`PAPERCLIP_TEST_DATABASE_URL` safety, routing dynamic `run-dispatch`
imports through `../modules/run-dispatch/index.js`, and updating the two
stack-trace file-name assertions to `.helper.ts`.
- Added four 3-line entrypoints:
`server/src/__tests__/heartbeat-process-recovery-part-{1,2,3,4}.test.ts`.
- Updated `scripts/run-vitest-stable.mjs`,
`scripts/serialized-shard-durations.json`, and
`scripts/ci/nightly-only-suites.json` with the four part paths and
measured proportional shard weights (`88511`, `102168`, `72141`, `81197`
ms; sum `344017` ms).
- Updated `.github/workflows/runner-chaos-evals.yml` (with
`--no-file-parallelism` to preserve serial execution in that job),
`maps/feature-map/recovery.md`,
`packages/paperclip-runner/spec/evals/stress-workflow-traceability.json`,
and `scripts/ci/test-selection.integration.test.mjs`.

## Verification

- Executed all four split suites locally via Vitest against embedded
Postgres — **466/466 tests passed** (0 failed, 0 skipped):
- `heartbeat-process-recovery-part-1.test.ts`: 116/116 passed (199.67s
under 4-way local contention)
- `heartbeat-process-recovery-part-2.test.ts`: 103/103 passed (230.48s)
  - `heartbeat-process-recovery-part-3.test.ts`: 87/87 passed (162.74s)
- `heartbeat-process-recovery-part-4.test.ts`: 160/160 passed (183.17s)
- Verified brace-depth exhaustiveness across
`heartbeat-process-recovery.helper.ts`: 0 top-level
`it`/`it.each`/`describe` blocks outside `if (part === N)` guards.
- `node scripts/check-module-boundaries.mjs` — passed.
- `node scripts/check-maps.mjs` — passed.
- `node scripts/check-test-budget.mjs --base origin/master` — passed.
- `node --test scripts/check-test-budget.test.mjs
scripts/__tests__/run-vitest-stable-shard.test.mjs
scripts/__tests__/run-vitest-stable-pr-mode.test.mjs
scripts/ci/test-selection.integration.test.mjs` — passed.

## Risks

- Low risk: test-only partition; zero production runtime files changed.
- Adding a future test to `heartbeat-process-recovery.helper.ts` outside
an `if (part === N)` guard would not register in any part; documented
the placement rule directly on `registerHeartbeatProcessRecoverySuite`.

## Model Used

- Google Gemini (Antigravity agent 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)

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-25 12:08:54 -06:00
..