mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-21 02:43:25 +01:00
ae2afd525b52aa73d329c4ef454a7e4f2dc1362a
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
87ef7097b6 |
refactor(wake-queue): own blocked admission deferral (#22332)
## Thinking Path > - Paperclip runs agents in response to work on a task. > - A person can leave a comment while execution recovery holds that task. > - Wake-queue checks the recovery gate under the task lock. Heartbeat used to choose how to save the blocked input. > - The deferred-work worker later retries the saved receipt by ID. > - This change gives wake-queue responsibility for saving the input before it confirms deferral. ## Linked Issues or Issue Description **Current behavior** The gate and the write that makes a blocked wake recoverable have different owners. Heartbeat also reports an admitted deferral when an update to an existing receipt matches no row. **Proposed behavior** Let the recovery admission operation save the first receipt or update the existing one in the same transaction. Confirm admission only when the write succeeds. Keep replaceable automatic signals on their existing diagnostic path. **Reason and benefit** Changes to recovery admission can now be checked against one rule. A blocked comment must have a durable receipt and remain recoverable across delivery attempts. Related changes include [#22292](https://github.com/paperclipai/paperclip/pull/22292) and [#22290](https://github.com/paperclipai/paperclip/pull/22290). ## What Changed - Added a transaction-bound deferral operation to wake-queue recovery. It handles existing receipts, saved input, and replaceable system signals. - Scoped retry updates to the company, issue, agent, deferred status, and receipt ID. A stale receipt cannot confirm admission or cause a new receipt to be inserted. - Kept case refusals and issue state callbacks in heartbeat. A saved comment uses the existing delivery worker and post-commit effects. ## Verification - Retried a saved comment by receipt ID through the real heartbeat and run-control entry points. While the hold remained, no run started. After the hold cleared, repeated retry delivered the comment to exactly one run. - Forced a rollback after the wake-queue Postgres adapter saved a receipt. The test observed the receipt within the transaction and confirmed its absence after rollback. Tested missing receipts and receipts for another issue or agent. The admission application test covers error propagation and post-commit effects when the transaction fails. - The test-only revision `9f443f9e6b` passed 9 focused PostgreSQL and recovery checks and all 15 issue-wake admission application tests. - The preceding production revision `eb37328472` passed the server TypeScript check, the module boundary check, and 498 tests across five queue and recovery suites. Twelve pairs of ordinary comments issued the same SQL before and after that production change (42 statements for a fresh wake and 35 for a join). - Both updated test files passed in full (249 tests). [CI attempt 3](https://github.com/paperclipai/paperclip/actions/runs/44572369812/attempts/3) passed on `9f443f9e6b` after retrying interrupted jobs. [Standard Greptile review](https://github.com/paperclipai/paperclip/pull/22332#issuecomment-7014835241) scored the same commit 5/5 with no open findings. ## Risks The affected path handles blocked admissions that may race a retry or a reassignment. Existing recovery gates, saved comment IDs, receipt identity, and notifications must survive that race. This change has no migration or new worker. The healthy admission path is expected to issue the same SQL. ## Model Used OpenAI Codex with GPT-6.2 Sol for implementation and verification. Codex directed and reviewed the change. ## 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> |
||
|
|
c6c7a61e2c |
fix(retry): release a Retry held on a resolved decision (#21267)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - When an agent run fails, the task shows a Retry button. Admission can hold an accepted Retry while a person must answer a pending approval or question (`decision_pending`). > - The hold is saved on the deferred Retry receipt. Nothing cleared that saved reason when the person answered, so the task kept saying "Retry is waiting for a pending approval or question" when nothing was left to answer. > - The deferred-receipt worker drops a refused receipt from its schedule. No producer hinted it when the decision resolved, so the held Retry did not start until some unrelated event rescanned the company. > - A Retry was also held by a confirmation that was already open when the failed turn was admitted. That turn had already run past the confirmation, so the Retry added a gate that the original turn did not have. > - A person's comment on the task started a continuation, but the held Retry receipt stayed deferred next to it. > - This pull request makes a resolved decision release the held Retry at once, keeps the projection from showing a resolved decision as the wait, stops holding a Retry on a decision that predates the failed turn, and settles a held Retry when a comment or answer continues the same failed run. > - The benefit is that Retry always works: a person never waits on a decision that is already resolved. ## Linked Issues or Issue Description **What happened?** A board user pressed Retry on blocked tasks. No run started. The task said "Retry is waiting for a pending approval or question to be resolved. Your message is saved." In one task, the only interaction was a `request_confirmation` that the previous successful run created. The user's later comment started the turn that failed. The confirmation stayed pending, so every Retry attached to the same held receipt. After the user rejected the confirmation and sent a new comment, the task still showed the same wait. No run started until a server restart rescanned the deferred receipts about three minutes later. The task projection said `canRetry: true` with the `decision_pending` wait. **Expected behavior** An accepted Retry is never held on a decision that is already resolved. Accepting or rejecting the decision releases a held Retry right away. A person's comment on the blocked task starts work, and the held Retry is settled. The task projection never shows a resolved decision as the Retry wait. **Steps to reproduce** 1. Let an agent run on a remote runner create a `request_confirmation` for the task. 2. Let the runner be lost so the run fails with `native_continuation_requires_reconciliation`, and let saved work recovery complete. 3. Press Retry. The Retry receipt is saved with `executionWait.reason = decision_pending`. 4. Reject or accept the confirmation. 5. Observe that the receipt keeps `decision_pending`, the task keeps showing the wait, and the Retry does not start until an unrelated rescan. **Paperclip version or commit** Staging Core `57aeda190b`. Fixed on top of `origin/master` `53608bd1d6`. **Deployment mode** Hosted cloud (staging), remote sandbox runner. **Agent adapter(s) involved** `paperclip_runner` (native runtime). ## What Changed - `hasPendingContinuationDecision` (`explicit-native-continuation.ts`) is now the single check for a decision that holds a person's continuation. Admission and the task projection both use it. - For a Retry, a pending interaction that was created before the failed source run was created does not hold the Retry. That turn was already admitted while the decision was open. Decisions that the failed run created (for example a plan review) still hold the Retry. - `releaseDecisionHeldExecution` (`deferred-execution-wait.ts`) removes the saved `decision_pending` wait from deferred receipts on the task and hints each receipt to the deferred-receipt worker. It runs in the resolution transaction of every interaction resolution path (through `notifyChatConfirmationResolution`) and in question answers. - The task projection reads the live decision state. A saved `decision_pending` wait whose decision is resolved is not shown. This also repairs receipts saved before this change. - When a comment or an interaction answer continues a failed run, `retireTaskRetriesContinuedBy` (`task-retry.ts`) settles held Retry receipts for the same source run as `task_retry_superseded`. ## Verification - Red/green: `cd server && npx vitest run src/services/governed-wait-runner-loss.test.ts`. The five new tests fail on `origin/master` sources and pass with this change (17/17 pass): - releases the held Retry as soon as the person chooses accept - releases the held Retry as soon as the person chooses reject - never shows a resolved confirmation as the Retry's wait, and both projections offer the same Retry - a person's comment starts work and settles the held Retry once nothing is left to answer - starts a Retry at once when the confirmation was already open before the failed turn started - The existing tests that keep a Retry or a message on hold while a plan review, governed tool action, secret proposal, or connection authorization is pending still pass. - Related suites: deferred execution wait, explicit native continuation, interaction resolution and service, task interruption presentation and query, task retry, deferred receipt work, interaction routes. ## Risks - Medium-low. A Retry now starts when the only pending interaction is older than the failed run. That turn already ran with the interaction open, so the Retry gets no new authority. Governed tool actions still need their own approval before the tool runs. - Interaction resolution now also updates deferred receipts on the same task. The update is limited to receipts with a saved `decision_pending` wait. A receipt that is still blocked by another pending decision is held again on its next admission. - Issue-linked approvals (`approvals` table) do not yet hint the held receipt when they resolve. The projection no longer shows them as the wait after they resolve. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edit, browser for read-only staging API reads). ## 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 - [x] 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> |
||
|
|
93f7c3b5d3 |
fix(tasks): keep a budget-held Retry's failure visible and refresh the open task (#20338)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - When a task's automatic recovery stops, the person's Retry rechecks
the task's gates. If a gate refuses, for example a budget hard stop, the
Retry is saved and starts by itself once the gate allows it
> - After a person pressed Retry under a budget hold, the task page went
blank: no failure, no notice and no Retry. A person had no way to see
why nothing started
> - Two gaps caused it. The task notice drew only system-owned states,
and a budget hold presents as a person-owned state with no card of its
own. Also, admission saved the wait reason without publishing anything
that an open page listens to
> - This pull request keeps the failure visible and names the budget
wait, and it refreshes an open task when admission records why a Retry
waits
> - The benefit is that "failure remains visible if the new attempt
cannot start" holds without the person reloading the page
> - These two commits were pushed to #20306 after it was squash-merged,
so they are not on master
## Linked Issues or Issue Description
Refs #20306 (merged without these two commits) and #20270.
**What happened?**
In the chat eval
`chat-features.runner-opencode.local.recovery.retry-exhausted`, a person
pressed Retry on a task whose native recovery was exhausted while the
agent's budget was held. The Retry was accepted (`POST
/api/issues/{id}/retry` returned 202). The task page then stayed blank
for more than 60 seconds on the open page.
**Expected behavior**
The task keeps the failure visible and says that it is waiting for the
budget. Once the budget allows new work, the saved Retry starts once by
itself.
**Steps to reproduce**
1. Let a task's run fail, and put the assignee over a budget hard stop.
2. Open the task and press Retry.
3. The page shows nothing about the failure or the wait.
**Paperclip version or commit**
master at
|
||
|
|
3ee4c5b613 |
Make saved execution receipt recovery react to durable work (#18409)
Reviewed and verified at
|