Files
PaperClipAI/tests
DottaandClaude Sonnet 5.5 54f8068df4 fix(chaos): confirm a task that rests just before its deadline (#21979)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The restart-chaos harness grades whether tasks come to rest after
faults
> - The task observer must see rest for REST_CONFIRM_MS before it
records rest
> - The deadline check ran on the same poll and timed the task out first
> - A task that went done shortly before its deadline got graded R1 fail
"no_rest_within_budget"
> - This pull request gives such a task up to REST_CONFIRM_MS more to
confirm
> - The benefit is that the harness no longer reports false R1 failures

## Linked Issues or Issue Description

**What happened?**

A task that reaches a resting status (for example done) shortly before
its deadline is graded R1 fail "no_rest_within_budget (last status
done)". The observer needs REST_CONFIRM_MS of confirmed rest before it
calls onRest. The deadline check right after it fires on the same poll
and sets timedOut. Example: wave w-20261117T061432-s7106, task t025 went
done at 06:59:32.8Z and task_timed_out was logged at 06:59:34.1Z.

**Expected behavior**

The task is graded as rested, with restAt set to the time rest started.

**Steps to reproduce**

Run a wave where a task goes done less than REST_CONFIRM_MS before its
deadline. The new observer unit test reproduces it without the fix.

## What Changed

- `TaskObserver.poll` now skips the deadline timeout while a rest
candidate began at or before the deadline and has not yet had
REST_CONFIRM_MS.
- Added three tests in `observer.test.ts`: rest just before the deadline
passes, a running task times out, and a task that starts resting after
the deadline times out.

## Verification

- `pnpm exec vitest run --config tests/restart-chaos/vitest.config.ts
tests/restart-chaos/observer.test.ts
tests/restart-chaos/governance.test.ts` passes (49 tests).
- The new "rest just before the deadline" test fails without the fix and
passes with it.
- `pnpm verify` exits 2 because the harness test change needs broader CI
coverage. CI supplies it.

## Risks

- Low risk. Only a task already resting before its deadline gets up to
REST_CONFIRM_MS (12 s) extra. Real timeouts are unchanged.

## Model Used

- Claude Sonnet 5.5 (Anthropic), model ID claude-sonnet-5-5, 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)
- [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 Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 02:25:51 -06:00
..