Files
PaperClipAI/doc
DottaandPaperclip 3a283fbc9b fix(runtime): preserve failed sources with older warm supervisors (#19024)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - A volume-free web server needs durable recovery data for retained
sessions.
> - An old failed follow-up can retain its snapshot while the warm
supervisor still holds the preceding successful turn.
> - The migration refuses to treat those different snapshots as the same
execution authority.
> - That refusal also blocks the tenant even when the failed source can
be preserved as an archive.
> - This pull request archives that narrow case after it verifies the
older successful snapshot and all scope bindings.
> - The failed run keeps its history and files while valid controller
recovery keeps its existing proof requirements.

## Linked Issues or Issue Description

Refs #18959, which added the existing failed-controller archive path. No
duplicate PR for this case was found.

**What happened?**

Offline controller migration stops with `stale_supervisor_snapshot` for
an old failed warm follow-up. Its local supervisor still contains the
prior successful turn. Read-only checks found the same database snapshot
and supervisor bytes in the live source and the isolated copy. The
mismatch predates the rehearsal.

**Expected behavior**

Preserve the failed run's database state and available local files in
the existing durable archive. Only archive when the older supervisor
matches a completed successful run in the same company, agent, task,
native session and Runner instance. Keep current execution and
controller authority checks intact.

**Steps to reproduce**

Create a successful native turn and a later failed warm follow-up. Keep
the successful snapshot in the supervisor file and the failed snapshot
in the database. Give the failed source local controller bytes but no
durable controller checkpoint. Run the offline migration. The new
regression fails with `stale_supervisor_snapshot` before this change.

## What Changed

- Verify the older supervisor against scoped successful history and the
same provider thread.
- Use the existing encrypted archive owner for that failed legacy
source.
- Preserve snapshots, run status, ownership, queued work and the
session's last-run pointer.
- Keep foreign, changed, active, successful and already-durable sources
outside this path.
- Document the preservation and recovery boundary.

## Verification

- New positive regression: red on the original owner, green after the
change.
- Native migration and controller recovery: 27 checks passed. Final
migration checks also cover refusal to replace a durable checkpoint.
- Storage failure blocks publication. Repeated migration is safe. The
archive restores the exact controller and supervisor bytes after the old
home is deleted.
- The archived failed source does not gain executable recovery
authority.
- Local server typecheck is blocked by reused workspace declarations for
accounting, bootstrap and ingress contracts. No diagnostic names either
modified owner or test file. Full local typecheck, repo-wide tests and
build are not claimed; clean CI is required before merge. The exact-head
CI has now passed typecheck, build, policy, Runner checks, browser E2E,
and all server test shards.
- Rehearsal verification against the copied historical source remains
required. Full tenant migration and hosted deployment qualification
remain separate gates.

## Risks

The archive preserves evidence for an already failed source. It does not
certify that source as resumable. A prior snapshot must match exactly,
and the normal archive owner checks the terminal failed binding before
it publishes. Existing durable checkpoints remain authoritative. A
missing or changed proof still blocks migration.

## Model Used

OpenAI Codex, exact model ID `gpt-6.1-sol`, with reasoning, tool use and
code execution. The host does not expose context-window size.

## 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 described the issue in-PR following the bug template
- [x] I have not referenced internal or instance-local Paperclip issues
or links
- [x] My branch name describes the change and contains no internal
ticket id or instance-derived details
- [x] I have run the relevant tests locally; retained failures and
limits are listed 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 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:40:53 -06:00
..
2026-02-16 14:25:00 -06:00