mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 05:47:10 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Hosted stacks move from a volume to volume-free storage, offline in
maintenance or online with no outage
> - A stack moves only when no local native harness backup obligation
remains
> - A selected session can carry a backup stamp whose files are no
longer on the volume
> - Offline and online both refuse that stack forever, because nothing
can copy files that are gone
> - This pull request records "backup source was gone" for that session,
the same way offline and online, after a locked recheck
> - The benefit is that the stack moves, and the gone backup is recorded
instead of silently forgotten
## Linked Issues or Issue Description
**What happened?**
An online durable-data pass reports
`native_harness:selected_source_absent` on every pass for a stack. The
selected session has a v2 backup stamp, but `failover-backups/current`
for that scope is not on disk. The offline maintenance path also fails:
`native_harness_backups_require_migration` stays true because
`migrateNativeHarnessBackups` only visits sources on disk. The stack can
never move.
**Expected behavior**
When the backup files are already gone and the session is settled, both
paths record that the backup source was gone and stop counting it as an
obligation. A session that is still active, or a backup that the
expiration service is rotating, stays blocked with a name.
**Steps to reproduce**
1. Create a selected `paperclip_runner` session whose last run is
settled and whose environment lease has a v2 backup stamp.
2. Remove `<state base>/<scope digest>`.
3. Run `prestageNativeHarnessBackups` or `migrateNativeHarnessBackups`.
4. Before this change, `selected_source_absent` repeats and
`hasLocalNativeHarnessObligations` stays true.
**Paperclip version or commit**
master at b2a12fab49.
## What Changed
- Add `recordNativeHarnessBackupSourceAbsence`. In one transaction it
locks the selected session row, the run's finalization advisory lock,
the last run row and the finalization row. It requires a settled run
(terminal, no controller lease, no live execution control, no
finalization owner, no lease owner or scheduled retry on the
coordinator), no queued or running turn on the task or session, no
current durable backup for the scope, and stamped leases for the scope.
Then it rechecks the disk. If `current` is back, it records nothing. If
a `.retiring-*` backup exists, it returns `selected_source_retiring`. If
any other entry remains (for example `previous` from an interrupted
publish), it returns `selected_source_unsettled`. Only a scope with no
entries besides `.expired-*` trash counts as gone. Otherwise it writes
`nativeHarnessBackupSourceAbsent` on the last run (scope digest to
stamped manifest digests) and logs
`native_harness_backup_source_gone_recorded`.
- A lock timeout during the recheck returns `selected_source_busy` for
this pass instead of failing the harness phase.
- The obligation query excludes a scope only when the selected session's
last run records that exact scope and that exact stamped manifest
digest. A new turn changes the last run, and a new stamp changes the
manifest, so the obligation comes back.
- The online pass (`prestageNativeHarnessBackups`) and the offline pass
(`migrateNativeHarnessBackups`) both call the same recorder for the
obligations they could not copy. The online pass counts
`nativeHarnessBackupSourcesGone` and does not defer it.
- Previous-release story: the new key is additive run state. No resume
path reads it. A session behaves after the move exactly as it does on
the volume today without its backup. A previous release ignores the key
and still reports the obligation.
## Verification
- Red: the new tests fail on master. Online still reports
`selected_source_absent`, offline still has an obligation (`expected
true to be false`), and the retiring case is not named.
- Green: `npx vitest run
src/services/native-runtime/native-harness-online-preservation.integration.test.ts
src/services/native-runtime/native-harness-backup-obligations.integration.test.ts
src/services/online-durable-data-migration.test.ts` (62 passed,
including busy-row and previous-backup cases).
- Neighbors: `ephemeral-server-startup-run-state`,
`ephemeral-server-runtime-skill-startup`,
`native-harness-prestage(-runtime)`,
`native-harness-filesystem-independence`,
`native-harness-backup-storage` (218 passed).
- `pnpm typecheck` in `server` passes.
## Risks
- Medium. A gone backup stops blocking the move. The recorder writes
only after a locked recheck that the run is settled, no turn is active,
and the files are still absent. A backup that is rotating stays blocked.
- The record changes the last run's `runnerProfileJson`.
Filesystem-independence facts include that profile. The recorder writes
only when no valid independence receipt exists, so no existing receipt
changes.
- No schema migration.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), Claude Code agent with tool use
and code execution.
## 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>