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>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-11-25 12:08:54 -06:00
1 parent 2d06567795
commit 2538dce415
12 files changed
+109 -52

No files matched your search

+21 -3
View File
@@ -164,10 +164,28 @@
"measuredMs": 223420
},
{
"path": "server/src/__tests__/heartbeat-process-recovery.test.ts",
"path": "server/src/__tests__/heartbeat-process-recovery-part-1.test.ts",
"category": "recovery-idle-maintenance-soak",
"reason": "Heavy serialized heartbeat process-crash recovery soak (285 cases, 344s); core heartbeat/recovery.test.ts stays on PRs",
"measuredMs": 344017
"reason": "Heavy serialized heartbeat process-crash recovery soak (part 1/4, 116 cases); core heartbeat/recovery.test.ts stays on PRs",
"measuredMs": 88511
},
{
"path": "server/src/__tests__/heartbeat-process-recovery-part-2.test.ts",
"category": "recovery-idle-maintenance-soak",
"reason": "Heavy serialized heartbeat process-crash recovery soak (part 2/4, 103 cases); core heartbeat/recovery.test.ts stays on PRs",
"measuredMs": 102168
},
{
"path": "server/src/__tests__/heartbeat-process-recovery-part-3.test.ts",
"category": "recovery-idle-maintenance-soak",
"reason": "Heavy serialized heartbeat process-crash recovery soak (part 3/4, 87 cases); core heartbeat/recovery.test.ts stays on PRs",
"measuredMs": 72141
},
{
"path": "server/src/__tests__/heartbeat-process-recovery-part-4.test.ts",
"category": "recovery-idle-maintenance-soak",
"reason": "Heavy serialized heartbeat process-crash recovery soak (part 4/4, 160 cases); core heartbeat/recovery.test.ts stays on PRs",
"measuredMs": 81197
},
{
"path": "server/src/__tests__/heartbeat-retry-scheduling.test.ts",
@@ -234,7 +234,7 @@ test("mixed audited documentation stays graph eligible and large complete source
});
test("refineTestPlan applies nightly exclusions before partitioning while keeping full inventory validation", () => {
const nightlySuite = "server/src/__tests__/heartbeat-process-recovery.test.ts";
const nightlySuite = "server/src/__tests__/heartbeat-process-recovery-part-1.test.ts";
const fastSuite = "server/src/__tests__/issues-service.test.ts";
const entries = [0, 1].map((shard_index) => ({
group: "general-server-without-chat",
+4 -1
View File
@@ -66,7 +66,10 @@ const additionalSerializedServerTests = new Set([
"server/src/__tests__/health.test.ts",
"server/src/__tests__/heartbeat-dependency-scheduling.test.ts",
"server/src/__tests__/heartbeat-issue-liveness-escalation.test.ts",
"server/src/__tests__/heartbeat-process-recovery.test.ts",
"server/src/__tests__/heartbeat-process-recovery-part-1.test.ts",
"server/src/__tests__/heartbeat-process-recovery-part-2.test.ts",
"server/src/__tests__/heartbeat-process-recovery-part-3.test.ts",
"server/src/__tests__/heartbeat-process-recovery-part-4.test.ts",
"server/src/__tests__/invite-accept-existing-member.test.ts",
"server/src/__tests__/invite-accept-gateway-defaults.test.ts",
"server/src/__tests__/invite-accept-replay.test.ts",
+4 -1
View File
@@ -86,7 +86,10 @@
"server/src/__tests__/health.test.ts": 5679,
"server/src/__tests__/heartbeat-dependency-scheduling.test.ts": 78007,
"server/src/__tests__/heartbeat-issue-liveness-escalation.test.ts": 54768,
"server/src/__tests__/heartbeat-process-recovery.test.ts": 344017,
"server/src/__tests__/heartbeat-process-recovery-part-1.test.ts": 88511,
"server/src/__tests__/heartbeat-process-recovery-part-2.test.ts": 102168,
"server/src/__tests__/heartbeat-process-recovery-part-3.test.ts": 72141,
"server/src/__tests__/heartbeat-process-recovery-part-4.test.ts": 81197,
"server/src/__tests__/heartbeat-run-privacy-routes.test.ts": 28486,
"server/src/__tests__/inbox-agent-policy-routes.test.ts": 6628,
"server/src/__tests__/inbox-archive-routes.test.ts": 11396,