test(native): exited-remote-runner budget case follows provider-work attempt charging (#19963)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Two restart-recovery PRs merged independently: #19951 lets a remote
runner that exited before provider work bootstrap again, and #19948
charges a restart attempt only when the provider accepted a turn.
> - Together they change one of #19951's test expectations: at the last
attempt, the exited runner is no longer charged, so it bootstraps again
instead of hitting the budget.
> - That test now fails on master in `Verify Paperclip Runner (vitest
native server)`, which blocks other PRs.
> - This pull request updates the test to the combined behavior. Product
code does not change.
> - The benefit is a green master, with the generation-cap bound on
repeated exits still under test.

## Linked Issues or Issue Description

Refs #19951, #19948, #19950 (blocked by this failure).

**What happened?**
On master, the test "keeps an exited remote runner's retry held when the
bootstrap budget is spent" receives `bootstrap_incomplete` with
`chargesProviderAttempt: false` instead of `blocked /
execution_recovery_budget_exhausted`.

**What did you expect?**
The test should match the combined behavior: uncharged at the last
attempt, and blocked once the controller generation cap is reached.

**Steps to reproduce**
1. `cd server && npx vitest run
src/services/native-runtime/native-runner-restart-recovery.integration.test.ts
-t "exited remote runner"` on master fails.

## What Changed

- Removed the stale budget row from the exited-runner counter-cases.
- Added two cases. An exited runner at attempt 3 bootstraps without
being charged. At `NATIVE_PROGRESS_CREDIT_GENERATION_LIMIT` it blocks
with `execution_recovery_budget_exhausted`. These mirror #19948's own
cases.

## Verification

- `cd server && npx vitest run
src/services/native-runtime/native-runner-restart-recovery.integration.test.ts
-t "exited remote runner|relaunched remote runner|generation cap"`: 11
pass.

## Risks

- Low. Test-only change. Repeated runner exits before provider work stay
bounded by the generation cap, which the new case covers.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with
tool use (shell, file edits).

## 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
- [ ] 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>
This commit is contained in:
DottaandClaude Opus 5.5 authored and GitHub committed 2026-11-07 21:52:54 -06:00
1 parent f6cb3e43f4
commit ca34bed257
1 file changed
+19 -1
@@ -2707,6 +2707,25 @@ process.on("SIGTERM", () => child.kill("SIGTERM"));
expect(run).toMatchObject({ status: "running", errorCode: null });
});
it("bootstraps an exited remote runner at its last attempt without charging it (no provider work)", async () => {
// #19948: only a turn the provider accepted is charged; a runner that
// exited before provider work keeps the attempt.
const fixture = await seedExitedRemoteRunner("EXITED-LAST-ATTEMPT", {}, 3);
expect(await claimNativeRestartRecoveries({ db: fixture.db, controller: successor,
restartKind: "hard", runIds: [fixture.runId] })).toEqual([expect.objectContaining({
kind: "bootstrap_incomplete", runId: fixture.runId, providerAttempt: 3, chargesProviderAttempt: false })]);
});
it("blocks an exited remote runner at its last attempt once the controller generation cap is reached", async () => {
// Repeated exits before provider work stay bounded by the generation cap.
const fixture = await seedExitedRemoteRunner("EXITED-GEN-CAP", {}, 3);
await fixture.db.update(nativeRunFinalizations).set({ controllerGeneration: NATIVE_PROGRESS_CREDIT_GENERATION_LIMIT })
.where(eq(nativeRunFinalizations.runId, fixture.runId));
expect(await claimNativeRestartRecoveries({ db: fixture.db, controller: successor,
restartKind: "hard", runIds: [fixture.runId] })).toEqual([expect.objectContaining({
kind: "blocked", runId: fixture.runId, reason: "execution_recovery_budget_exhausted" })]);
});
it.each(["a provider event committed after the failure", "a session checkpoint saved after the failure"])(
"keeps an exited remote runner's retry held when %s contradicts the saved failure", async (label) => {
// The saved failure still says no provider work; fresh evidence wins.
@@ -2729,7 +2748,6 @@ process.on("SIGTERM", () => child.kill("SIGTERM"));
["the provider session was established", { providerSessionEstablished: true }, 2, "ambiguous_remote_recovery_evidence"],
["provider events exist", { providerEventsExist: true }, 2, "ambiguous_remote_recovery_evidence"],
["a checkpoint exists", { checkpointExists: true }, 2, "ambiguous_remote_recovery_evidence"],
["the bootstrap budget is spent", {}, 3, "execution_recovery_budget_exhausted"],
])("keeps an exited remote runner's retry held when %s", async (label, failure, attempt, reason) => {
const fixture = await seedExitedRemoteRunner(`EXITED-${label.replace(/\W+/g, "-")}`, failure, attempt);
expect(await claimNativeRestartRecoveries({ db: fixture.db, controller: successor,