mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 11:59:26 +01:00
> [!NOTE] > Opened by Prospector's automated issue-fix pipeline. A maintainer reviews and decides; nothing here merges on its own. ## Thinking Path - Issue #16728 reports a defect in paperclipai/paperclip. - Root cause, as the fixing agent read it: PostgreSQL could evaluate both result_json predicates before publication filtering, detoasting already-published runs. The regression test also passed transaction handles to helpers typed for full database handles. - This pull request: Defer chat milestone result reads and fix regression test transaction typing ## What Changed - `server/src/services/chat-run-publications.ts`: Retain publication-dependent guards around both result JSON predicates in the shared milestone query. - `server/src/__tests__/chat-run-milestone-toast.test.ts`: Use the neighboring tests' transaction cast convention. Confirmed both cases fail without the guards and pass with them; all seven selected milestone test files and typecheck passed. ## Verification - Reproducing test(s), added in this PR: `server/src/__tests__/chat-run-milestone-candidates.test.ts`, `server/src/__tests__/chat-run-milestone-toast.test.ts` - They fail on the base commit and pass with the fix, each twice in a fresh sandbox. - The repository's compile command passes with the fix applied. - 8 existing test file(s) near the change failed, and fail on the base too, so they cannot show whether the change breaks them. - The full test suite passes except for the 15 file(s) that already fail on the base commit. ## Risks - Written by an automated pipeline, not a person: review it as you would an outside contribution. - Risk tier of the touched paths: 2. ## Model Used - opus (Anthropic Claude, via Claude Code), writing and checking the change in an isolated sandbox. - opus (Anthropic Claude, via Claude Code), reviewing it independently. ## Linked Issues Fixes #16728 The reviewer found the base already handles: - Milestone projection still runs on a one-second cadence. (server/src/services/chat-run-milestone-work.ts:12 describes and implements discovery on startup/committed changes with retries for failures or unfinished batches; server/src/app.ts:1269 registers this work owner. This code exists independently of the proposed predicate change.) Other pull requests that name #16728: - #18686 (open): perf(runs): read result_json once per run in run lists and index agent runs by created_at ## 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) - [ ] 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) - [ ] 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 - [ ] 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 - [ ] I will address all Greptile and reviewer comments before requesting merge <!-- prospector:issue-fix v1 issue=16728 base=d1ee25d0f722 report=5924b3e8dd6d2fe4 --> --------- Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>