Files
PaperClipAI/tests
DottaandClaude Opus 5.5 c1cf43e666 test(restart-chaos): count staging-mix completions only from DONE, and attribute runs after DONE (#21226)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The restart chaos harness grades staging-mix tasks across server
swaps, and reports duplicated side effects separately from completion
> - `completion_once` counted every comment that mentions `DONE-<nonce>`
as a completion
> - In wave `w-20261112T223803-s7101`, task t001's blocked run fcc55827
wrote that it "will … post `DONE-<nonce>`" later, and the harness
counted that as a second completion next to the real one from run
37724b59
> - Runs that start after a task is done are also hard to attribute
without a manual trace through the wake evidence
> - This pull request counts only real completions, and lists each run
started after DONE with its wake reason and actor

## Linked Issues or Issue Description

Refs #21168, #21173.

**What existing behavior does this improve?**
The staging-mix `completion_once` check and the wave summary.

**Subsystem affected**
Test harness only: `tests/restart-chaos/`. No product code changes.

**Current behavior**
Any agent comment that mentions the DONE marker counts as a completion.
A blocked or progress comment that promises to post the marker later
becomes a false "duplicate completion". The summary does not say why a
run started after the task was done.

**Proposed behavior**
A run completes the task only when it posts the bare `DONE-<nonce>`
comment (the rule `isDoneComment` already uses), or posts a comment that
mentions the marker at or after the first DONE comment. The summary gets
a "Runs started after the task's DONE" section. It lists each such run
with its wake reason, source, trigger and requesting actor, taken from
the saved wake evidence.

**Reason and benefit**
The duplicate count stays honest, and extra turns can be attributed
straight from the wave results.

## What Changed

- `staging-mix.ts`:
  - Comments keep their creation time.
- The new `completionRunIds` counts a run as completing the task when it
posts the bare DONE comment, or posts a later comment that mentions the
marker.
  - `done_comment_posted` and `done_comment_once` are unchanged.
- `staging-mix-retry.ts`:
- `firstDoneAt` anchors DONE on the first bare DONE comment, else on the
issue's completion time.
- `runsAfterDone` joins each later run to its wake row in
`wake-evidence/<task>.json`.
- The results JSON gains `extraTurns`, and the summary prints one line
per run, for example `run 91f0c3d2 started … after DONE; wake
issue_recovery_action_restored (automation/system) by system sweep`.
- Runs after DONE are filtered by when they started, not when they were
queued. A run queued after DONE that never started is listed separately
as "queued after DONE, never started" (`queuedAfterDone`).
- `wake-evidence.ts` keeps only issue status transitions: `issue.*`
entries whose status is an issue status. In t001 of
`w-20261112T223803-s7101`, a `runner.api_called` entry with HTTP status
201 was being listed as a status change.
- README: the `completion_once` row, the results paragraph and the
wake-evidence status note.

## Verification

- `pnpm exec vitest run --config tests/restart-chaos/vitest.config.ts`:
68 files, 774 tests pass.
- `node scripts/typecheck-test-projects.mjs tests/restart-chaos`:
passes.
- A regression test copies t001's shape from `w-20261112T223803-s7101`:
the blocked comment from run fcc55827 at 22:56 mentions the marker as a
future step, and the bare DONE comment comes from run 37724b59 at 23:12.
The test checks `completion_once` passes with `runs=1`. It fails on
master, which reports two runs.
- The earlier duplicate case still fails `completion_once`: a different
run's completion summary posted after the DONE comment.
- Tests cover the run-after-DONE join, the DONE anchor, and the summary
line.

## Risks

- Low risk. Test harness only.
- A comment from a run that was cut off before it could post the bare
marker, but that mentioned the marker before the first DONE comment, is
no longer counted as a completion. That is the intended change.
- Known master CI failures, not touched here: the storage S3 multipart
throttle test and the Runner native-distribution-integrity test. Recent
cancelled-runner CI failures ("The runner has received a shutdown
signal") are infrastructure, not tests.
- `ci / General tests (server (11/12))` failed on head 94c4751803 with a
real server test failure that this harness-only diff cannot reach:
`server/src/services/fresh-continuation-fallback.test.ts >
fresh-continuation fallback > keeps the continuation pending while the
agent's daily run limit declines it, then delivers it` (`expected [ {
…(81) } ] to have a length of +0 but got 1`). It failed on another PR at
the same time.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, through Claude Code
with tool use (shell, file edits). Extended reasoning was available.

## 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-12 19:50:02 -06:00
..