Files
PaperClipAI/tests
DottaandClaude Opus 5.5 9715b3d210 test(restart-chaos): do not grade a recovery that a back-to-back fault interrupted (#20243)
## Thinking Path

- #20183 split restart recovery so the speed budget judges Paperclip's
own share (`restart_recovery_control_plane`).
- In Phase 3's local mixed wave (`w-20261109T104527-s9901`, master
3963d38560), Claude's control-plane recovery was p50 1.4 s but p95 24.2
s (n=19). That suggested an occasional 20 s wait on Paperclip's side.
- The kept database shows otherwise. The slow samples all come from
back-to-back faults on one run (`566c07b4`):
- f07 was ready at 10:56:45.39; the run requested its runner at 45.70;
f08 (K6) killed the server at 45.78.
  - f09 started 0.69 s after f08 was ready.
- So each "sample" spans the next fault's outage plus a repeated
recovery. Outage time is removed, but the repeated claim, prepare and
launch work and the partial attempt are still charged. Paperclip has no
wait to fix; the grader mismeasures overlapping faults.

## Linked Issues or Issue Description

Refs #20183

**What happened?**
A recovery sample that a later fault interrupted before its next
provider event was graded as if it were one long recovery. That inflated
the control-plane p95 (Claude, 24.2 s) in fault storms.

**Steps to reproduce**
1. Run a chaos wave with back-to-back faults (for example the mixed wave
seed 9901: f07 K4 → f08 K6 0.4 s after ready → f09 K6 0.7 s after
ready).
2. Look at `restart_recovery_control_plane` for runs in flight across
those faults.

**Expected behavior**
Only uninterrupted recoveries are graded. Interrupted ones are counted
and reported.

## What Changed

- `tests/restart-chaos/ttft-baseline-stats.ts`:
  - `BaselineFault` gains `startedAt`.
- When a later fault starts inside a sample's window (after ready,
before the next provider event), `recoverySamples` marks the sample
`interruptedByFault` and nulls its latencies. The later fault's own
sample measures that run.
- `tests/restart-chaos/wave-speed.ts`:
  - `faultRuns` passes `startedAt`.
- `WaveSpeed` reports `recoveryInterruptedByFault`, which no longer
counts as "no provider event".
  - The speed summary prints it.
- Tests:
- A new back-to-back case: the interrupted sample is skipped and the
later fault's 1.5 s recovery is graded. It's red without the change and
green with it.
  - The `faultRuns` expectation includes `startedAt`.

## Verification

- `npx vitest run --config tests/restart-chaos/vitest.config.ts
tests/restart-chaos/wave-speed.test.ts
tests/restart-chaos/ttft-baseline-stats.test.ts`: 32 passed.
- Against the wave: the two samples behind the tail (f07 → f08, f08 →
f09) are exactly the interrupted ones. The next slowest Claude sample
(f10, 15.6 s) includes a 9.4 s `provider.session.load`, so its
control-plane share is about 6 s.

## Risks

- **Harness grading only; no product change.** Fault storms produce
fewer graded samples, and the count is reported, so a wave that is
mostly interrupted is visible.
- **A real Paperclip wait** that happened to straddle a later fault
would be hidden in that sample. It would show up in uninterrupted
samples.

## Model Used

Claude Opus 5.5 (`claude-opus-5-5`, Anthropic), 1M context window, tool
use and code execution, via 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>
2026-11-09 05:32:59 -06:00
..