mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-19 07:42:38 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - A GitHub review bot reviews each PR in a task. Each push sends a new review request to that task as a chat message. > - A push that arrives during a review waits as a deferred chat wake. That wake starts a new turn. The turn binds its tools to the newest pushed commit. > - #21959 and #22140 continue a run that reports a blocker in a fresh session. That continuation keeps the source binding of the blocked run. It also holds the task, so the waiting push request does not run. > - On staging, a push during a review made the publication fail with "requested for an older pull request head". The agent reported a blocker. Paperclip then continued twice with the old binding. Each continuation finished the review and could not publish it. > - A second failure mode: a complete re-review that listed only the files changed since the prior review got a short rejection. The rejection named no files, and a small model stopped instead of correcting the submission. > - This pull request lets a queued chat request take the next turn instead of a blocker continuation. It also names the missing files in the coverage rejection. > - The benefit is that reviews publish for the newest push without a person, and agents can correct incomplete coverage on the next call. ## Linked Issues or Issue Description **What happened?** On staging, automatic GitHub reviews stopped publishing. The bots posted "Publication is currently blocked" and "Paperclip must authorize the review for <newest commit>". The run history showed this sequence: a review run started for the first commit. Two pushes arrived during the run. Steering into the active run was rejected for both pushes, so they waited as deferred chat wakes. The run reported a blocker. Paperclip then started two `native_environment_blocker` continuations. Each continuation had no message of its own, so its GitHub tools resolved to the first commit's request and refused the current head. The waiting push requests did not run until a later push. **What did you expect?** A push request that waits behind a run starts the next turn, bound to that push. The agent then reviews and publishes for the current head. **Steps to reproduce** 1. Start an automatic review on a PR. 2. Push a new commit while the review runs, so the review request waits as a deferred chat wake. 3. Let the run report a blocker (for example after the stale-head publication refusal). 4. See that a fresh-session retry starts with the old binding and the push request stays deferred. Refs #21959, #22140, #22066 ## What Changed - `status-arbiter.ts`: new rule before the blocker continuation lanes. When a blocked run has a queued chat request for the same task and agent, the decision is `preserve` with only `release_checkout` (reason `native_blocker_superseded_by_queued_request`). The normal release drain then starts the queued request. A pause hold or a board-owned blocker keeps the existing behavior. - `native-runtime/queued-chat-request.ts`: new `hasQueuedChatRequest` query. It uses the same chat-wake test that keeps chat wakes out of first turns (`chatConversationId` or `externalChatProvider`). - `native-run-finalizer.ts`: supplies `hasQueuedChatRequest` to the arbiter, only for a blocked report. - `chat-github-review-policy.ts` / `chat-github-reviews.ts`: `githubCompleteCoverageGap` replaces the inline check. The rejection now names the missing files (up to 20), says that a complete review covers all changed files, and gives the two corrections (add them to `reviewedPaths`, or submit `complete: false` with `omittedPaths`). ## Verification - Red/green: `cd server && npx vitest run src/services/native-runtime/native-environment-blocker.integration.test.ts`. The new case failed before the fix with reason `native_environment_blocker` and one scheduled retry, as on staging. After the fix it passes: no retry, the task stays `in_progress`, and the chat wake stays deferred for the release drain. - Red/green: `npx vitest run src/services/native-runtime/status-arbiter.test.ts -t "queued chat request"`. - Red/green: `npx vitest run src/services/chat-github-review-policy.test.ts -t githubCompleteCoverageGap`. - `native-agent-blocker.integration.test.ts` and the full arbiter and review-policy suites pass. - `cd server && npx tsc --noEmit -p .` passes. - `pnpm verify` on the changed files (results in the CI checks below). ## Risks - Low to medium. The new rule changes only blocked reports that would otherwise auto-continue while a chat request waits behind the run. Without a waiting chat request, the behavior does not change. - The waiting request now starts the next turn instead of the continuation. If the blocker is real, that turn can report it again, and the existing lanes apply. - The finalizer does one more indexed read, only for blocked reports. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code with tool use: code search, editing, shell, test runs, and staging run inspection through the browser. ## 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 - [ ] I will address all Greptile and reviewer comments before requesting merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>