mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 18:26:40 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The recovery service restores execution when a task loses its live path. > - The service retries the original agent for a limited number of attempts. > - The old fallback could select a manager or an executive and wake that agent. > - That fallback changed the effective recovery owner without a board decision. > - This pull request keeps the source owner and gives the exhausted recovery decision to the board. > - The benefit is a clear ownership rule with no automatic task takeover. ## Linked Issues or Issue Description Refs: #11807 Refs: #11817 **What existing behavior does this improve?** This improves stranded-task recovery in the server and the recovery action card in the board UI. **Subsystem affected** Cross-cutting: server recovery orchestration, recovery observability, board UI, and execution documentation. **Current behavior** Paperclip retries the original agent for a limited number of attempts. After the retry limit, it can select a manager, task creator, CTO, or CEO as a recovery owner. It can then wake that substitute agent. The source task keeps its assignee, but the automatic substitute wake creates an implicit takeover path. **Proposed behavior** Paperclip keeps the limited retry path for the original agent. If recovery is exhausted or unsafe, Paperclip creates one board-owned source recovery action. It keeps both source assignee fields. It does not wake a substitute agent. The board can repair, retry the original owner, explicitly reassign, or resolve the task. **Reason and benefit** Source task ownership must remain stable until a person or an approved policy changes it. The new rule removes implicit manager and executive takeover. It also gives operators clear evidence through the `board_escalation_no_takeover_v1` routing marker. **Breaking changes** Automatic recovery no longer wakes a manager or executive after the original-agent retry limit. Existing active agent-owned recovery actions remain visible and can resolve. Paperclip does not schedule a new takeover wake for those legacy actions. ## What Changed - Route exhausted and unsafe stranded recovery to a board-owned source action. - Preserve agent and user assignee fields during automatic escalation. - Keep limited same-agent continuity repair and provider quota monitoring. - Stop new manager, creator, CTO, and CEO recovery wakes. - Keep legacy agent-owned recovery actions readable and resolvable. - Add the routing marker to new board escalation evidence and observability. - Update recovery notices, the board UI card, tests, and execution documentation. ## Verification - Run `pnpm -r typecheck`. - Run `pnpm build`. - Run `pnpm check:token-gates`. - Run `pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-process-recovery.test.ts`. - Run `pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-workspace-branch-containment.test.ts`. - Run the focused recovery and UI Vitest files changed by this pull request. - Confirm that a paused or over-budget source owner creates one board action, keeps the source assignee, and creates no substitute wake. ## Risks - Operators must now make the final recovery decision after the original-agent limit. - Legacy agent-owned actions use their stored contract. This avoids a rollout-time ownership rewrite. - No database migration or API response shape changes are included. - The tests cover concurrent escalation, paused and over-budget owners, legacy actions, provider quota monitoring, and UI presentation. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used OpenAI Codex with GPT-5. The hosted exact model revision and context window are not exposed. Reasoning, tool use, and code execution were enabled. ## 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>
54 lines
2.4 KiB
TypeScript
54 lines
2.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { ISSUE_RECOVERY_ACTION_KINDS } from "@paperclipai/shared";
|
|
import { classifyContinuationFailure } from "../services/recovery/service.ts";
|
|
import {
|
|
DISPOSITION_REPAIR_BASE_DELAYS_MS,
|
|
DISPOSITION_REPAIR_MAX_ATTEMPTS,
|
|
dispositionRepairDelayMs,
|
|
} from "../services/recovery/disposition-repair.ts";
|
|
|
|
const deliberateWaitRun = {
|
|
id: "run-1",
|
|
agentId: "agent-1",
|
|
status: "cancelled" as const,
|
|
error: "Continuation parked",
|
|
errorCode: "issue_continuation_waiting_on_review",
|
|
contextSnapshot: {},
|
|
livenessState: null,
|
|
startedAt: new Date("2026-08-11T00:00:00.000Z"),
|
|
createdAt: new Date("2026-08-11T00:00:00.000Z"),
|
|
};
|
|
|
|
describe("owner-sticky disposition repair", () => {
|
|
it("classifies a deliberate wait without a target into its dedicated bounded lane", () => {
|
|
expect(ISSUE_RECOVERY_ACTION_KINDS).toContain("deliberate_wait_without_target");
|
|
expect(classifyContinuationFailure(deliberateWaitRun)).toEqual({
|
|
kind: "deliberate_wait_without_target",
|
|
maxAttempts: 5,
|
|
baseBackoffMs: 60_000,
|
|
errorCode: "issue_continuation_waiting_on_review",
|
|
});
|
|
});
|
|
|
|
it("uses the persisted five-attempt owner-sticky schedule with bounded deterministic jitter", () => {
|
|
const fingerprint = "disposition_repair:v1:example";
|
|
const timings = [1, 2, 3, 4, 5].map((attempt) => dispositionRepairDelayMs(attempt, fingerprint));
|
|
|
|
expect(DISPOSITION_REPAIR_MAX_ATTEMPTS).toBe(5);
|
|
expect(DISPOSITION_REPAIR_BASE_DELAYS_MS).toEqual([0, 60_000, 120_000, 240_000, 480_000]);
|
|
expect(timings[0]).toEqual({ baseDelayMs: 0, jitterMs: 0, delayMs: 0 });
|
|
expect(timings[1]?.baseDelayMs).toBe(60_000);
|
|
expect(timings[1]?.jitterMs).toBeGreaterThanOrEqual(0);
|
|
expect(timings[1]?.jitterMs).toBeLessThanOrEqual(6_000);
|
|
expect(timings[2]?.baseDelayMs).toBe(120_000);
|
|
expect(timings[2]?.jitterMs).toBeGreaterThanOrEqual(0);
|
|
expect(timings[2]?.jitterMs).toBeLessThanOrEqual(12_000);
|
|
expect(timings[3]?.baseDelayMs).toBe(240_000);
|
|
expect(timings[3]?.jitterMs).toBeLessThanOrEqual(24_000);
|
|
expect(timings[4]?.baseDelayMs).toBe(480_000);
|
|
expect(timings[4]?.jitterMs).toBeLessThanOrEqual(48_000);
|
|
expect(dispositionRepairDelayMs(2, fingerprint)).toEqual(timings[1]);
|
|
expect(() => dispositionRepairDelayMs(6, fingerprint)).toThrow(/Invalid disposition repair attempt/);
|
|
});
|
|
});
|