Files
PaperClipAI/server
DottaandPaperclip e401ed006b test(inbox): wait for snapshot completion before fresh reads (#18798)
## Thinking Path

> - Paperclip helps people manage AI agents and inspect their work.
> - Mine combines task and run data behind the issue-read admission
limit.
> - Its cancellation test aborts a request while the server still owns
its snapshot computation.
> - The test waited for seven separate list requests and assumed the
snapshot had also finished.
> - CI can return those list requests first, so the next snapshot read
correctly shares the existing computation.
> - This pull request completes a snapshot read before it checks that a
fresh read starts new work.
> - The regression keeps its admission-limit checks without depending on
database read order.

## Linked Issues or Issue Description

**What happened?**

Full [CI run
41671193176](https://github.com/paperclipai/paperclip/actions/runs/41671193176/job/126041533414)
failed `retains admission until aborted snapshot work settles (coalesced
reader: false)`. It expected nine computation starts but saw eight. The
aborted snapshot was still running after the seven list requests
returned. A follow-up snapshot request could share that work.

**Expected behavior**

The test must retain the occupied slot while the aborted work runs. It
must wait for snapshot completion before it expects a new computation.

**Steps to reproduce**

Run the full serialized CI shard containing
`server/src/__tests__/inbox-mine-routes.test.ts`. The assertion depends
on read order and can pass in isolation. The unchanged focused
cancellation cases passed locally after the CI failure. The test does
not await the aborted server computation, which explains the race.

**Paperclip version or commit**

CI failure: `1859d17b3ada7865c0ad4c5835eda23c32e33a48`, based on
`f7ad1dc7cacedf7153a45e854ddfdd544aa87abd`. This branch now includes
master at `adb49a4434`.

**Deployment mode**

Source checkout; real HTTP requests and disposable PostgreSQL.

Refs #18790, which introduced the snapshot test. The user-reported [run
41665098924](https://github.com/paperclipai/paperclip/actions/runs/41665098924)
also had three UI fixture failures and several runner shutdowns. All
three UI failures reproduced locally. This PR first repaired them;
concurrent #18799 merged the same repair while CI ran. The branch
preserves that upstream repair, so the remaining diff is this inbox
test. No duplicate inbox completion repair was found.

## What Changed

- Complete a snapshot request as a barrier for any remaining aborted
snapshot work.
- Then assert that a fresh snapshot request is a cache miss and starts
exactly one new computation.
- Retain the eight-slot limit, rejected ninth request, and
coalesced-reader assertions.

## Verification

- The first full CI matrix exposed the eight-versus-nine assertion
failure linked above. Both UI shards passed after the fixture
correction.
- All six real-database inbox route cases pass with the completion
barrier. Server typecheck also passes after that repair.
- Before the master merge, both affected UI suites and the
account-scoped access reader passed 30 tests. The reader still rejects
another account's response. Token gates pass.
- On final merged head `f93d1e309a1c76bb6ded57f76efe08b876afa164`, the
combined 36 focused tests, `pnpm -r typecheck`, and `pnpm build` all
pass.
- The local `pnpm test:run` completed four chat shards with 1,279
passing tests. It was stopped during shard five when master advanced. It
is not reported as a full-suite pass. The final full CI matrix verifies
the current head.
- Full [CI run
41674890115](https://github.com/paperclipai/paperclip/actions/runs/41674890115)
passed on final head `f93d1e309a1c76bb6ded57f76efe08b876afa164`: 48 jobs
passed and one optional selection job was skipped. All PR checks are
green with none pending.
- Greptile and Paperclip Review are both 5/5 on that same head. Greptile
added zero comments, and no review threads are open.

## Risks

Low risk. The diff changes test synchronization only. It uses actual
request completion and adds no timing delay. Production behavior,
permissions, schemas, and API contracts do not change. No operator
documentation change is needed.

## Model Used

OpenAI Codex, GPT-6 family, with reasoning, tool use, and code
execution. The exact serving model ID and context-window size are not
exposed in this session.

## 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: Paperclip <noreply@paperclip.ing>
2026-11-03 10:46:13 -06:00
..