Files
PaperClipAI/tests
ceabc3bc88 fix(e2e): wait on the server's own deferral signal in the signoff wakeup helper (#15345)
## Thinking Path

> - Paperclip coordinates work for AI agents through server-managed
tasks and heartbeats
> - Signoff policy tests exercise stage transitions that wake the next
participant
> - A stage transition can defer a wake while the previous run still
holds the issue execution lock
> - The test helper used a fixed wait and could fail before the server
released that lock
> - This pull request waits on the server deferral signal and verifies
the returned run identity
> - The benefit is a stable test with clear failure details and no
repeated wake request

## Linked Issues or Issue Description

**What happened?**

The signoff policy end-to-end spec failed intermittently with `No
issue-bound heartbeat run became available for agent <id>`. The server
had deferred the wake while another run held the issue execution lock.

**Expected behavior**

The test helper waits for the named blocking run to finish, then reads
and verifies the new run for the requested agent and issue.

**Steps to reproduce**

1. Run `npx playwright test --config tests/e2e/playwright.config.ts
tests/e2e/signoff-policy.spec.ts`.
2. Exercise a signoff stage transition while the previous stage run
still holds the issue execution lock.
3. Confirm that the helper waits on the server deferral signal and
returns only a matching run.

This change relates to [PR
#11299](https://github.com/paperclipai/paperclip/pull/11299), which also
touches the signoff policy end-to-end spec.

## What Changed

- Call the wakeup endpoint that reports the server deferral reason.
- Wait for the named blocking run instead of using a fixed delay.
- Verify that each returned run belongs to the requested agent and
issue.
- Bound read and wait loops and report the last server signal and lock
fields on failure.
- Keep one wakeup request per helper call.

## Verification

- `npx playwright test --config tests/e2e/playwright.config.ts
tests/e2e/signoff-policy.spec.ts` passed locally.
- All five signoff policy cases passed locally.
- The spec keeps all 60 assertions.
- The diff contains only `tests/e2e/signoff-policy.spec.ts`.
- The full CI end-to-end shards must pass before merge.

## Risks

- The helper now depends on the wakeup endpoint's deferral fields.
- A server change to those fields can fail the test with a named
diagnostic.
- The change affects end-to-end test behavior only.

## Model Used

OpenAI GPT-5 Codex, exact runtime model `gpt-5-codex`, with tool use and
code review assistance. The runtime does not expose a separate
context-window value.

## 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
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: nickyleach <331803+nickyleach@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-10-07 08:57:56 -07:00
..