Files
PaperClipAI/server/src/services/system-recovery-state.ts
T
DottaandClaude Opus 5.5 57b787d3d2 fix(retry): continue from recorded work when saved files cannot be recovered (#21363)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - When a run finishes but copying its files out of the sandbox fails,
Paperclip holds the task and tries to recover the saved files. When
recovery gives up, the task offers Retry.
> - Some saved files can never be recovered: the sandbox that held them
was destroyed, or Paperclip cannot prove which runs used a shared
sandbox. Each Retry ran the same check again, failed again, and parked
the Retry in a wait that never ends.
> - The task told the person to press Retry again or to wait for a
Paperclip update. That breaks the rule that recovery must work and that
a Retry that is shown must work.
> - This pull request makes Retry continue the task in a fresh session
and a new workspace from the work that is recorded, when the saved files
are provably unrecoverable or cannot be proven safe. The task says
clearly that the unsaved files were not recovered.
> - The benefit is that an offered Retry starts a run, and nobody waits
for a fix that another click cannot bring.

## Linked Issues or Issue Description

Refs #21315, #21295, #21267

**What happened?**

On hosted staging, two blocked tasks offered Retry (`canRetry: true`).
Each Retry was accepted, and within about 3 seconds it was parked in a
wait. No run started. Every later Retry did the same.

- Task A: the hold cause was
`native_workspace_sync_out_retry_exhausted`. Recovery ended with
`source_unavailable` (`use_alternative_strategy`). The sandbox that held
the files had a signed absence proof and a `destroyed` termination
receipt. Retry was parked with `saved_work_recovery_failed`: "Saving the
agent's files failed. Retry to try again".
- Task B: the same hold cause. Recovery ended with
`allocation_ownership_ambiguous` (`service_required`), because the
sandbox was a reusable sandbox that other runs also used. Each Retry
opened a new recovery generation, ran the same check, and was parked
with `saved_work_recovery_refused`: "Retry runs the same check again and
succeeds only after Paperclip is updated."
- In both tasks, the agent's turn had finished and its result was
accepted. Its work was recorded outside the sandbox: a plan document and
screenshot attachments for task A, and a pushed branch with an open pull
request and an implementation document for task B.

Root cause: admission had a branch for an accepted result whose files
were not yet saved. When the recovery budget was spent, the branch
always returned a `saved_work_recovery_*` wait. It did not check whether
the files could ever be recovered, so the fresh-workspace path that
admission already has was never reached. The automatic retained-source
fallback did not help either, because it handles only the remote
workspace v1 reference, and these runs use the native workspace sync v3
reference. Also, Retry opened a new recovery generation for an ownership
refusal, which only repeated the same check.

**Expected behavior**

When the saved files are provably unrecoverable or cannot be proven
safe, Retry continues the task in a fresh session and a new workspace
from the recorded work. The old files are never applied and the source
sandbox is not changed. No provider turn is replayed. The task says that
the unsaved files could not be recovered. The Retry offer and admission
agree.

**Steps to reproduce**

1. Let a native run finish with an accepted result, and let its
workspace copy-back fail (`native_workspace_sync_out_retry_exhausted`).
2. Let saved-work recovery end with `source_unavailable` (sandbox
destroyed) or with `allocation_ownership_ambiguous` (shared reusable
sandbox).
3. Press Retry.
4. Observe that the Retry receipt waits with
`saved_work_recovery_failed` or `saved_work_recovery_refused`, and no
run starts. Press Retry again and observe the same result.

**Paperclip version or commit**

Staging on `origin/master` after #21315 (`bbafa78fe2`).

**Deployment mode**

Hosted cloud (staging), remote Daytona sandbox runner.

**Agent adapter(s) involved**

`paperclip_runner` (native runtime runs).

## What Changed

- `savedFilesUnrecoverable` and `unrecoverableSavedFilesFailure`
(`system-recovery-state.ts`) are the one rule for saved files that no
recovery can apply. The rule is true for a spent recovery whose failure
is a permanent source refusal: `source_unavailable`,
`allocation_ownership_ambiguous` or `historical_source_missing`. It is
false for `source_binding_invalid`, because a new recovery generation
can still verify that source. It is false for `archive_unsafe` and
`snapshot_verification_failed`, because a fresh attempt still imports
earlier saved snapshots and would fail before the agent starts. It is
also false after a fresh attempt is recorded.
- Admission (`explicit-native-continuation.ts`) no longer parks a Retry
of an accepted result in `saved_work_recovery_*` when every live
recovery of the run is unrecoverable. The Retry takes the existing
fresh-workspace path (`fresh_isolated_workspace`). That path keeps all
stop proofs, leaves the source sandbox and workspace untouched, and
starts a fresh session.
- When such a Retry starts, the task gets one system comment. The
comment says that Paperclip could not recover the unsaved files, why,
and that the task continues from its recorded work (comments, documents,
attachments and pushed commits). The settled hold records the same text.
- Retry (`task-retry.ts`) binds to an unrecoverable recovery generation.
It does not open a new generation that repeats the same check.
- The blocker text for unrecoverable files says that Retry continues the
task in a new workspace from its recorded work. It no longer says that
Retry succeeds only after an update.
- `canAdoptNativeSourceRetention` and the permanent source-refusal lists
moved into `system-recovery-state.ts`, so that admission, Retry and
messages share them. The old modules re-export them.

## Verification

- Red/green: `cd server && npx vitest run
src/services/unrecoverable-saved-work-retry.test.ts`. The tests fail on
`origin/master` sources (or on the earlier head for the snapshot case)
and pass with this change. They are built from the two staging shapes
(destroyed sandbox with `source_unavailable`, and a shared reusable
sandbox with `allocation_ownership_ambiguous`):
- offers a Retry that continues the task (blocker and task view agree,
and the text names the fresh workspace)
- starts a fresh run from the recorded work: the Retry receipt has no
wait and a run, the strategy is `fresh_isolated_workspace`, the hold is
settled with the fresh attempt, one system comment explains the lost
files with no raw IDs, the source lease is unchanged, and no new
recovery generation opens
- keeps a Retry out of a fresh attempt that would import a succeeded
snapshot whose archive is unsafe
- `workspace-recovery-warm-handoff.test.ts` › "wakes physical
preservation from HTTP Retry before passive history without replaying
the provider" failed on an earlier head of this PR, which also treated
`source_binding_invalid` as unrecoverable. It passes unchanged now.
- Updated tests that pinned the old repeat-the-check behavior:
`workspace-recovery-preparation-gates`, `task-retry`,
`system-recovery-state`, `workspace-recovery-retry-copyback`.
- Related suites pass: `system-recovery-state`,
`workspace-recovery-preparation-gates`,
`workspace-recovery-retry-copyback`, `workspace-recovery-warm-handoff`,
`task-retry`, `saved-work-retry-eligibility`,
`workspace-recovery-fallback`, `explicit-native-continuation`,
`workspace-recovery-admission`, `task-interruption-query`,
`native-workspace-sync-retention`.
- `cd server && node scripts/typecheck-layers.mjs` passes (source and
test layers).

## Risks

- Medium-low. A Retry of an unrecoverable hold now starts a new agent
turn in a new workspace instead of waiting. The turn starts only through
the existing fresh-workspace admission, which keeps every stop and
cleanup proof.
- Unsaved files of the old run are not applied. That was already true;
the change is that the task continues and says so.
- `source_binding_invalid`, `snapshot_verification_failed` and
`archive_unsafe` keep today's path.

> 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

- 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>
2026-11-13 06:23:23 -06:00

262 lines
16 KiB
TypeScript

import { createHash, randomUUID } from "node:crypto";
import { z } from "zod";
import { ENVIRONMENT_LEASE_POLICIES, WORKSPACE_SOURCE_VERIFICATION_REASONS,
type WorkspaceSourceVerificationFailure } from "@paperclipai/shared";
import { REMOTE_WORKSPACE_CAPTURE_POLICY_VERSION } from "./remote-workspace-snapshot-archive.js";
export const SYSTEM_RECOVERY_POLICY_VERSION = 1;
export const SYSTEM_RECOVERY_MAX_RETRIES = 5;
export const SYSTEM_RECOVERY_WINDOW_MS = 30 * 60_000;
export function infrastructureRetryDelayMs(retryNumber: number, sample: number) {
return Math.round(30_000 * 2 ** (retryNumber - 1) * (0.8 + Math.min(1, Math.max(0, sample)) * 0.4));
}
/** Assumed provider limit cooldown when the provider reports no reset time. */
export const PROVIDER_LIMIT_DEFAULT_COOLDOWN_MS = 60 * 60_000;
export const recoveryFailureCodes = [
"historical_source_missing", "source_binding_invalid", "allocation_ownership_ambiguous",
"agent_stop_unconfirmed", "copyback_stop_unconfirmed", "workspace_writer_active",
"provider_unavailable", "export_interrupted", "archive_unsafe", "snapshot_verification_failed",
"source_unavailable", "effect_unresolved",
] as const;
export type RecoveryFailureCode = typeof recoveryFailureCodes[number];
export const recoveryRetryClasses = [
"retry_transient", "recheck_evidence", "use_alternative_strategy", "service_required", "user_action_required",
] as const;
export type RecoveryRetryClass = typeof recoveryRetryClasses[number];
export class SystemRecoveryFailure extends Error {
constructor(readonly code: RecoveryFailureCode, readonly retryClass: RecoveryRetryClass, message = code,
readonly sourceVerification?: WorkspaceSourceVerificationFailure) {
super(message);
}
}
export const workspaceSourceVerificationFailureSchema = z.object({
reason: z.enum(WORKSPACE_SOURCE_VERIFICATION_REASONS),
observedLeasePolicy: z.enum([...ENVIRONMENT_LEASE_POLICIES, "unrecognized"]).optional(),
});
/** Why an attempt failed, in closed labels only. Provider text never appears. */
export const recoveryFailureCauseSchema = z.object({
label: z.string().regex(/^[a-z][a-z0-9_]{0,47}$/),
code: z.string().regex(/^[A-Z][A-Z0-9_]{1,31}$/).nullable(),
status: z.number().int().min(100).max(599).nullable(),
});
export type RecoveryFailureCause = z.infer<typeof recoveryFailureCauseSchema>;
export const systemRecoverySchema = z.object({
schema: z.literal("paperclip.system-recovery.v1"),
policyVersion: z.literal(SYSTEM_RECOVERY_POLICY_VERSION),
sourceRunId: z.string().uuid(),
revision: z.number().int().nonnegative(),
generationId: z.string().uuid(),
intentId: z.string().uuid().nullable(),
phase: z.enum(["verify_execution", "preserve_files", "reconcile_effects", "settle_result_or_dispatch"]),
state: z.enum(["scheduled", "running", "awaiting_evidence", "exhausted", "complete"]),
attemptId: z.string().uuid().nullable(),
attempts: z.number().int().nonnegative(),
retriesUsed: z.number().int().min(0).max(SYSTEM_RECOVERY_MAX_RETRIES),
firstFailureAt: z.number().nullable(),
nextAttemptAt: z.number().nullable(),
deadlineAt: z.number().nullable(),
providerCooldownAt: z.number().nullable().default(null),
failure: z.object({
code: z.enum(recoveryFailureCodes),
retryClass: z.enum(recoveryRetryClasses),
evidenceFingerprint: z.string(),
sourceVerification: workspaceSourceVerificationFailureSchema.optional(),
cause: recoveryFailureCauseSchema.optional(),
}).nullable(),
preservationOperationIds: z.array(z.string().uuid()),
freshAttemptRunId: z.string().uuid().nullable(),
/** The workspace capture policy this generation saves with. Absent on
* generations written before the field existed; those used version 1. */
capturePolicyVersion: z.number().int().positive().optional(),
});
export type SystemRecoveryState = z.infer<typeof systemRecoverySchema>;
type RecoveryFailure = NonNullable<SystemRecoveryState["failure"]>;
export function readSystemRecovery(evidence: Record<string, unknown> | null | undefined): SystemRecoveryState | null {
const parsed = systemRecoverySchema.safeParse(evidence?.systemRecovery);
return parsed.success ? parsed.data : null;
}
/** New generations require new intent or one-time policy adoption, never a sweep. */
export function createSystemRecovery(sourceRunId: string, intentId: string | null = null): SystemRecoveryState {
return {
schema: "paperclip.system-recovery.v1", policyVersion: SYSTEM_RECOVERY_POLICY_VERSION,
sourceRunId, revision: 0, generationId: intentId ?? randomUUID(), intentId,
phase: "verify_execution", state: "scheduled", attemptId: null, attempts: 0, retriesUsed: 0,
firstFailureAt: null, nextAttemptAt: null, deadlineAt: null, providerCooldownAt: null, failure: null,
preservationOperationIds: [], freshAttemptRunId: null,
capturePolicyVersion: REMOTE_WORKSPACE_CAPTURE_POLICY_VERSION,
};
}
export function reserveSystemRecoveryAttempt(state: SystemRecoveryState, now = Date.now()): SystemRecoveryState | null {
if (state.state === "complete" || state.state === "exhausted" ||
(state.nextAttemptAt !== null && state.nextAttemptAt > now)) return null;
// A reclaimed physical owner first reconciles the same interrupted attempt.
// Starting another call is not evidence that the prior call failed.
if (state.state === "running" && state.attemptId) return { ...state, revision: state.revision + 1 };
if ((state.deadlineAt !== null && now >= state.deadlineAt) ||
(state.attempts > 0 && state.retriesUsed >= SYSTEM_RECOVERY_MAX_RETRIES)) return null;
return { ...state, revision: state.revision + 1, state: "running", attemptId: randomUUID(),
attempts: state.attempts + 1, retriesUsed: state.retriesUsed + (state.attempts > 0 ? 1 : 0), nextAttemptAt: null };
}
/** The caller persists this timestamp. A restart must not recalculate jitter. */
export function failSystemRecovery(
state: SystemRecoveryState, failure: SystemRecoveryFailure,
options: { now?: number; retryAfterAt?: number; evidenceFingerprint?: string; cause?: RecoveryFailureCause } = {},
): SystemRecoveryState {
const now = options.now ?? Date.now();
const firstFailureAt = state.firstFailureAt ?? now;
const deadlineAt = state.deadlineAt ?? firstFailureAt + SYSTEM_RECOVERY_WINDOW_MS;
const retryNumber = state.retriesUsed + 1;
const entropy = createHash("sha256").update(`${state.generationId}:${retryNumber}`).digest().readUInt32BE(0) / 0xffffffff;
const delay = infrastructureRetryDelayMs(retryNumber, entropy);
const nextAttemptAt = Math.max(now + delay, options.retryAfterAt ?? 0);
const retryable = ["retry_transient", "recheck_evidence"].includes(failure.retryClass);
const retry = retryable && retryNumber <= SYSTEM_RECOVERY_MAX_RETRIES && nextAttemptAt < deadlineAt;
const sourceVerification = workspaceSourceVerificationFailureSchema.safeParse(failure.sourceVerification);
const cause = recoveryFailureCauseSchema.safeParse(options.cause);
return { ...state, revision: state.revision + 1, firstFailureAt, deadlineAt,
providerCooldownAt: options.retryAfterAt ?? null,
state: retry ? failure.retryClass === "recheck_evidence" ? "awaiting_evidence" : "scheduled" : "exhausted",
nextAttemptAt: retry ? nextAttemptAt : null,
failure: { code: failure.code, retryClass: failure.retryClass,
...(sourceVerification.success ? { sourceVerification: sourceVerification.data } : {}),
...(cause.success ? { cause: cause.data } : {}),
evidenceFingerprint: options.evidenceFingerprint ?? createHash("sha256").update(`${state.sourceRunId}:${failure.code}`).digest("hex") },
};
}
/**
* A save that failed while preserving files under an older workspace capture
* policy. The current policy may accept what the older one refused (for
* example a workspace with a symlink out of it), so recovery retries it once
* under the current policy (workspace-recovery-capture-policy). The new
* generation carries the current version, so the retry is bounded per policy.
*/
export const CAPTURE_POLICY_RECOVERY_KEY = "capturePolicyRecovery";
export const CAPTURE_POLICY_RECOVERY_SCHEMA = "paperclip.capture-policy-recovery.v1";
// Capture refusals surface as export_interrupted. archive_unsafe names a restore
// refusal, which the capture policy does not change, so it is not re-armed.
export const CAPTURE_POLICY_REARM_CODES = ["export_interrupted"] as const;
export function isCapturePolicyRearmable(state: Pick<SystemRecoveryState, "state" | "phase" | "failure" | "capturePolicyVersion"> | null | undefined) {
return state?.state === "exhausted" && state.phase === "preserve_files"
&& (CAPTURE_POLICY_REARM_CODES as readonly string[]).includes(state.failure?.code ?? "")
&& (state.capturePolicyVersion ?? 1) < REMOTE_WORKSPACE_CAPTURE_POLICY_VERSION;
}
/**
* An exhausted save whose last failure was an unproven agent stop is not a
* permanent refusal: once the source run has ended, a later attempt can prove
* the stop. Recovery re-arms it a bounded number of times on a backoff
* (workspace-recovery-stop-proof), then an export hold continues from the last
* save with the unsaved files attached, like a refused source.
*/
export const STOP_PROOF_RECOVERY_KEY = "stopProofRecovery";
export const STOP_PROOF_RECOVERY_SCHEMA = "paperclip.stop-proof-recovery.v1";
export const STOP_PROOF_MAX_REARMS = 4;
export const STOP_PROOF_WAIT_CODE = "agent_stop_unconfirmed";
/** Coordinator phases after which no finalizer or provider work runs under the coordinator. */
export const FINISHED_COORDINATOR_PHASES = ["committed", "terminal_failure", "applied"] as const;
export function readStopProofRecovery(evidence: Record<string, unknown> | null | undefined): { rearms: number; nextRearmAt: number | null } | null {
const marker = evidence?.[STOP_PROOF_RECOVERY_KEY] as Record<string, unknown> | undefined;
if (!marker || marker.schema !== STOP_PROOF_RECOVERY_SCHEMA || typeof marker.rearms !== "number") return null;
return { rearms: marker.rearms, nextRearmAt: typeof marker.nextRearmAt === "number" ? marker.nextRearmAt : null };
}
export function isExhaustedStopProofWait(state: Pick<SystemRecoveryState, "state" | "failure"> | null | undefined) {
return state?.state === "exhausted" && state.failure?.code === STOP_PROOF_WAIT_CODE
&& state.failure.retryClass === "recheck_evidence";
}
/** Every bounded re-arm of an unproven stop is spent. */
export function stopProofRearmsSpent(evidence: Record<string, unknown> | null | undefined) {
return (readStopProofRecovery(evidence)?.rearms ?? 0) >= STOP_PROOF_MAX_REARMS;
}
/** User-facing text for a spent recovery budget. It names what happens next and
* never asks a person to inspect a sandbox or environment. The code stays for support. */
export function exhaustedSystemRecoveryAction(state: SystemRecoveryState, evidence?: Record<string, unknown> | null): string {
// Another Retry cannot release a copyback owner that stopped without reporting.
if (state.failure?.code === "copyback_stop_unconfirmed")
return "Recovery of saved work is waiting for the previous server's file copy to stop. "
+ "Recovery resumes once Paperclip can confirm that it stopped. No provider turn is submitted.";
// An unproven agent stop is re-proven automatically once the run is over
// (workspace-recovery-stop-proof), while a bounded re-arm remains.
if (evidence !== undefined && isExhaustedStopProofWait(state) && !stopProofRearmsSpent(evidence))
return "Recovery of saved work is waiting to confirm that the previous run stopped. "
+ "Paperclip tries again automatically, and the agent will not repeat its work.";
if (state.failure?.cause?.label === "sandbox_disk_full")
return "Saving the agent's files stopped because the sandbox disk is full. Paperclip deletes only inactive tool "
+ "caches it can prove safe, and that did not free enough space. Automatic recovery does not repeat a save that fails the same way. "
+ "Retry saves the files again. The agent's result is kept, and the agent will not repeat its work.";
const lostFiles = unrecoverableSavedFilesFailure(state);
if (lostFiles)
return `Paperclip cannot recover the unsaved files from the previous run: ${unrecoverableSavedFilesReason(lostFiles)}. `
+ "Retry continues the task in a new workspace from its recorded work, without those files. The agent will not repeat its completed actions.";
if (isDeterministicRecoveryRefusal(state)) {
const code = state.failure!.code;
// Never promise a release. A retained-file hold the fallback settles
// (workspace-recovery-fallback) replaces this text with its own outcome.
return `Paperclip refused to recover the saved files: ${recoveryRefusalReasons[code] ?? "a safety check on the saved files did not pass"}. `
+ "Automatic recovery does not repeat this check, because the same saved state gives the same result. "
+ "Retry runs the check again. The agent's result is saved, and the agent will not repeat its work.";
}
const tries = state.attempts > 1 ? ` after ${state.attempts} tries` : "";
return `Paperclip could not recover the agent's saved files${tries}. `
+ "Press Retry to try again; the agent will not repeat its work.";
}
export const UNVERIFIABLE_SOURCE_CODES = ["allocation_ownership_ambiguous", "source_binding_invalid", "source_unavailable", "historical_source_missing"] as const;
export const PERMANENT_SOURCE_RETRY_CLASSES = ["service_required", "use_alternative_strategy"] as const;
const UNRECOVERABLE_SOURCE_CODES = ["allocation_ownership_ambiguous", "source_unavailable", "historical_source_missing"] as const;
export function canAdoptNativeSourceRetention(state: SystemRecoveryState) {
return state.state === "exhausted" && state.phase === "verify_execution" && state.attempts === 1
&& state.retriesUsed === 0 && state.failure?.code === "source_binding_invalid"
&& (!state.failure.sourceVerification || state.failure.sourceVerification.reason === "lease_policy_not_retained")
&& state.preservationOperationIds.length === 0 && !state.freshAttemptRunId;
}
export function unrecoverableSavedFilesFailure(state: SystemRecoveryState | null | undefined): RecoveryFailure | null {
const failure = state?.failure;
if (!state || !failure || state.state !== "exhausted" || state.freshAttemptRunId || canAdoptNativeSourceRetention(state)) return null;
return (UNRECOVERABLE_SOURCE_CODES as readonly string[]).includes(failure.code)
&& (PERMANENT_SOURCE_RETRY_CLASSES as readonly string[]).includes(failure.retryClass) ? failure : null;
}
export function savedFilesUnrecoverable(state: SystemRecoveryState | null | undefined) {
return unrecoverableSavedFilesFailure(state) !== null;
}
function unrecoverableSavedFilesReason(failure: RecoveryFailure) {
return recoveryRefusalReasons[failure.code] ?? "a safety check on the saved files did not pass";
}
export function unrecoverableSavedFilesNotice(failure: RecoveryFailure) {
return `Paperclip could not recover the unsaved files from the previous run: ${unrecoverableSavedFilesReason(failure)}. `
+ "Retry continued this task in a new workspace from its recorded work: comments, documents, attachments and pushed commits. "
+ "Files that run did not save or push are not included. Its completed actions stay recorded and are not repeated.";
}
export function isDeterministicRecoveryRefusal(state: Pick<SystemRecoveryState, "state" | "failure"> | null | undefined) {
return state?.state === "exhausted" && state.failure?.retryClass === "service_required";
}
const recoveryRefusalReasons: Partial<Record<RecoveryFailureCode, string>> = {
allocation_ownership_ambiguous: "Paperclip cannot prove which runs used the sandbox that holds the saved files",
source_binding_invalid: "the recorded source of the saved files does not match the run that saved them",
snapshot_verification_failed: "the saved snapshot of the files did not pass verification",
archive_unsafe: "the saved file archive contains entries that are not safe to apply",
source_unavailable: "the saved files are no longer available where the run recorded them",
historical_source_missing: "Paperclip has no record of where the run kept the saved files",
};