mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path > - The execution-semantics spec gives `deliberate_wait_without_target` recovery five disposition-repair attempts, with delays 0, 60, 120, 240, and 480 seconds. > - The disposition-repair module implements that schedule. A separate legacy-episode helper also exists, to protect pre-upgrade episodes that already spent attempts under an older, tighter allowance. > - The helper never answered "not a legacy episode". A run with an entirely empty context snapshot — clearly not a pre-upgrade episode — still got a legacy episode capped at 2 attempts (1 for handoff and old-recovery runs). > - The common continuation path passes that episode unconditionally, so the documented five-attempt fallback next to it was dead code for every non-native run. > - The fix makes the helper return no episode when a run has no legacy markers and has consumed no attempts. Marked or partly spent pre-upgrade runs keep the legacy cap, so no spent budget is resurrected. ## Linked Issues Fixes #15776 ## What Changed - `server/src/services/recovery/legacy-continuation.ts`: `legacyDispositionEpisode` now gives a run with no legacy markers (no persisted episode record, no handoff or old-recovery markers, no repair fingerprint, no liveness-continuation source) and no consumed attempts the documented budget, `DISPOSITION_REPAIR_MAX_ATTEMPTS` (5), instead of the legacy cap. The episode object still exists for every run, so repair dispatch keeps its persisted binding, issue state guard, and source-identity semantics. Marked or partly spent runs still derive their capped episodes, unchanged. - `server/src/services/recovery/legacy-continuation.ts`: the persisted-record branch no longer clamps every episode to the legacy cap. A record keeps the budget it was written with: records written under the legacy scheme carry at most the legacy cap and keep it, and records written under the documented scheme keep theirs. Without this, a new episode was re-capped at 2 from its second attempt on. - Tests in `legacy-continuation.test.ts`: marker-less runs derive the five-attempt budget; persisted records keep their written budget (2 stays 2, 5 stays 5); fingerprinted, liveness-sourced, and partly spent runs still derive their capped episodes. - Test updates in `legacy-continuation-authority.test.ts` and `heartbeat-process-recovery.test.ts`: expectations that pinned the old cap for marker-less runs now expect `maxAttempts: 5`; the exhaustion tests (ACCT-02, ACCT-04, and the bounded-episode test) stamp a genuine pre-upgrade episode on their source runs so they keep pinning the legacy bound. No production behavior outside the budget derivation changed for those tests. ## Verification - `vitest run server/src/services/recovery/legacy-continuation.test.ts` — 28 of 28 pass, including the existing "does not resurrect an exhausted pre-upgrade budget" cases. - CI on the final head: all checks pass (55 of 55), including the suites that pin the surrounding semantics — `legacy-continuation-authority`, `heartbeat-process-recovery`, `heartbeat-stale-queue-invalidation`, `heartbeat-slack-invitation`, `heartbeat-issue-liveness-escalation`, and the chat integration suites. - An earlier revision of this PR returned `undefined` for marker-less runs; CI showed that episode presence also drives the state guard and dispatch identity checks, so the fix was reworked to change only the budget derivation. The PR comments carry the full history. ## Risks - A run whose only history is a positive generic continuation counter stays on the legacy cap. That matches this repo's existing test expectation that a run with `continuationAttempt: 2` is an exhausted pre-upgrade episode; the counters cannot distinguish schemes, so the conservative reading wins. - Note for sequencing: open PR #15658 also touches the recovery area (owner continuation after partial work) but does not change the attempt cap, so the two changes are independent. ## Model Used - **Provider / Model ID:** Meta, Muse Spark 1.3 - **Context window:** 1M+ tokens (exact limit not disclosed); large-repository tasks with long tool transcripts - **Capabilities:** agentic coding with tool use — file editing, shell execution, test execution, browser and API access, multi-step planning ## 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) - [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 - [ ] 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 --------- Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local> Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>