Files
PaperClipAI/server
DottaandPaperclip 25b5a072cc fix(recovery): let messages continue recovered preparation (#19026)
## Thinking Path

> - Paperclip must preserve work while allowing people to continue
failed tasks.
> - A preparation failure can retain an ID from an earlier provider
session.
> - Workspace recovery and host settlement already prove that the failed
attempt never dispatched a provider.
> - The preparation classifier also required that inherited session ID
to be absent.
> - That extra condition kept new messages, saved messages, and Retry
behind a resolved recovery hold.
> - Classify execution from the existing execution evidence and admit
one fresh turn through normal gates.

## Linked Issues or Issue Description

Refs #18908, #19004, and #19021. The latter two address historical Retry
ancestry and empty object logs. This repair addresses a current source
with an inherited session and ordinary user messages; it needs neither
ancestry nor an object log. ROADMAP.md and related open PRs were
checked.

**What happened?**

Sending a message to a failed task saved it in the queue, but did not
start another run. The failed native preparation had recovered files and
durable host settlement, plus `sessionIdBefore` from prior work. The
classifier treated that input as execution evidence and kept the
recovery hold.

**Expected behavior**

Admit the new user turn once the existing saved-work and stop checks
pass. Preserve previous failures and files. Show the current run instead
of the old error, and consume messages when execution starts.

**Steps to reproduce**

Fail Runner preparation before runtime selection. Preserve its remote
workspace. Retain an inherited `sessionIdBefore`. Send an ordinary
message or click Retry. The three new HTTP regressions accept the
request but admit zero successors before the repair.

**Paperclip version or commit**

Base `3bd52a9fa0`.

**Deployment mode**

Authenticated hosted Runner. Regression verification uses macOS arm64,
Node 26.4.0, real PostgreSQL, HTTP routes, and real temporary workspace
archives. The external sandbox transport and native provider boundary
are controlled in the execution fixture.

## What Changed

- Stop requiring the inherited session input to be absent from otherwise
verified failed preparation.
- Cover new messages, previously saved messages, Retry, request replay,
one successor, recovered files, and current task presentation.
- Exercise the existing preparation safety controls with inherited
context, including a new output-session refusal.
- Exercise native execution and finalization with the inherited session
input.
- Document the continuation rule.

## Verification

- RED: all three new HTTP cases admitted zero successors before the
production change.
- All three final HTTP cases pass. The 41 preparation safety cases,
including the new output-session refusal, pass with inherited context.
- The native execution fixture passes with inherited context. It reads
restored files, writes the continuation result, runs one provider turn,
persists the accepted result, empties the queue, and resolves the
notice.
- Initial positive assertions expected an empty queue while the fixture
deliberately held the agent's slot, then expected a null optional wait
field. The final assertions use the actual queue contract and retain
execution and presentation checks.
- `pnpm build`, `node scripts/typecheck-low-memory.mjs`, module
boundaries, and `git diff --check` pass locally. The final rebased head
`56d2ef26` passes the four HTTP/native journey cases. All 634 tests in
the four complete owning recovery, Retry and continuation suites pass.
Current-head full CI passes: 53 successful checks and three expected
skips, with no failed or pending checks. The full local command has the
documented timeout below.
- The full local command passed its first three chat shards, then
stopped in shard four on a 15-second timeout in `answers each finding
thread in its own run instead of one unattestable batch` (267 other
shard cases passed). The exact unchanged test passes alone (about nine
seconds of test work) and all three full CI chat groups pass on this
head. It uses a custom adapter, so the changed native-preparation proof
is inapplicable. The timeout cause remains unknown; the full local
command is not claimed green and its later groups were not reached.
- Initial CI attempt: all other checks passed, but server shard 2/12
failed on the unchanged `idle-completed-history.test.ts` owned HTTP
runtime test. The ten-second readiness probe returned ECONNREFUSED. The
source and runtime have no diff from the base and this test does not use
failed-preparation admission. The exact local case passes; the
underlying readiness cause remains unknown. Logs and annotations are
retained at [the failed
job](https://github.com/paperclipai/paperclip/actions/runs/41897539206/job/126811385017).
The single failed-job retry passed on the same head, including the
dependent verify aggregate. This proves recovery of that check; the
original readiness cause remains unknown.
- Greptile reviewed the exact head `56d2ef26` at 5/5 with no actionable
findings and zero unresolved threads. Hosted recovery remains unverified
until the repair reaches the serving revision.

## Risks

The risk is mistaking earlier context for a stopped current execution.
Current provider session, process, controller, native
input/result/output, accounting, exact lease stop, workspace
epoch/generation/writer, actor, assignment, pause and approval checks
remain enforced. No migration, new polling, API, credentials or
execution policy is added.

## Model Used

OpenAI GPT-6 through Codex, using reasoning, code editing, shell tools,
and browser diagnostics. The exact serving snapshot and context window
are not exposed in this session.

## 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 (634 owning-suite cases and
final-head journey cases; full-local timeout is documented above)
- [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>
2026-11-04 13:54:38 -06:00
..