mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 06:03:51 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Issue routes can wake an assigned agent in the background. > - The structured issue parity suite uses those real routes and a temporary database. > - It could stop that database while route-triggered work was still active. > - The resulting unhandled database error failed source verification after test assertions passed. > - This pull request drains that work after each test and checks quiescence. > - Database teardown now starts only after the suite's background work settles. ## Linked Issues or Issue Description **What happened?** [Cloud readiness run 47456696780, attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47456696780/job/145473729239) reported 1,562 tests passed and three skipped in server shard 13/20, then failed on an unhandled PostgreSQL `read ECONNRESET`. The error came from type discovery and was reported while `canonical-issue-structured-parity.test.ts` was running. This cancelled [image run 47456696824](https://github.com/paperclipai/paperclip/actions/runs/47456696824). **Expected behavior** The fixture must settle route-triggered wakeups and executions before it resets data or stops PostgreSQL. **Steps to reproduce** On master `83f10b968dba1cb0300f216cabce3a5924f5d3c8`, add the quiescence assertion from this diff without the drain. Run `PAPERCLIP_VITEST_RETRY=0 pnpm exec vitest run server/src/__tests__/canonical-issue-structured-parity.test.ts --maxWorkers=1`. The assertion failed locally with three active executions and one pending wake. The old teardown also logged queries against a closed connection. ## What Changed - Await the existing heartbeat drain after each test. - Assert zero active executions and pending wakes before the fixture can continue or stop its database. - Keep the route, channel isolation, schema validation, and authorization checks in place. ## Verification - Red: the cleanup assertion failed with `activeRuns: 3`, `pendingWakes: 1`, and `quiescent: false`. - Green: both tests passed after the drain, with retries disabled and no unhandled errors. - Test budget and `git diff --check` passed. - Final PR head `f4679f12c299ff7718112f5d368fce907d1d0f3a`: 64 checks passed, seven skipped, no pending or failed checks; GitHub reports no merge conflicts. [Greptile rated it 5/5](https://github.com/paperclipai/paperclip/pull/23813#issuecomment-7429108337), with no review threads or follow-ups. - The first server typecheck found stale local Plugin SDK declarations that omitted `runtime_updating`. The value already exists in SDK source. Rebuilt the Plugin SDK and shared package; the final server typecheck passed, and both focused tests passed again with retries disabled. - `pnpm verify --explain` conservatively retained 2,009 of 2,372 test files. Required CI will provide that broad coverage. - Recovery: [exact-source verification attempt 3](https://github.com/paperclipai/paperclip/actions/runs/47456696780/job/145482927885) passed for master `83f10b968dba1cb0300f216cabce3a5924f5d3c8`. [Image attempt 2](https://github.com/paperclipai/paperclip/actions/runs/47456696824/job/145483491486) then published the AMD64/ARM64 manifest as `ghcr.io/paperclipai/paperclip:sha-83f10b9`, digest `sha256:9c23177cbe9744eded163c56bc88904aa0901442fe9932b6ea5cf329f143c66e`. All publication gates remained in place. This establishes operational recovery; resolving the cleanup race requires this change. ## Risks - Low risk. Only test fixture cleanup changes. Production code and database behavior stay as they are. - The drain can settle work that the route started before the HTTP response. A future unfinished execution fails the quiescence assertion instead of leaking into database teardown. - No documentation change is needed because the application contract does not change. ## Model Used - OpenAI `gpt-6.1-sol`, through the Codex harness in T3 Code, with xhigh reasoning effort and shell tools. The context window size is not exposed. ## 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>