Files
PaperClipAI/server/src/services/native-runtime
DottaandClaude Opus 5.5 fd6317de23 fix(cloud): name a retained runtime skill run whose bundle left the disk and keep saving the runs after it (#22648)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A hosted server copies the runtime skill bundles that retained runs
still need to shared storage before it moves to a volume-free shape
> - The online pass copies them a page at a time with
`migrateRuntimeSkillAssets`
> - The page fails at the first run whose bundle is no longer on the
disk, so the later runs on that page are never saved and the pass names
only the first failure
> - The offline migration continues past such a run, collects it as
unsaved, and refuses at the end
> - This pull request gives the online page the same behavior and names
each unsaved run
> - The benefit is that the pass saves every bundle it can and reports
each one it cannot

## Linked Issues or Issue Description

Refs #22190, #22294, #22641

**What happened?**
On staging, one stack reports `runtime_skill_assets_require_migration`.
Its passes showed
`runtime_skill_assets:runtime_skill_source_absent:missing` as a
whole-page failure: the runs after the first missing bundle were not
visited.

**Expected behavior**
The page saves every run whose bundle is on the disk and names each run
whose bundle is gone.

**Steps to reproduce**
1. Keep two retained native runs with unversioned skill bundles. Remove
the bundle of the first run from the disk.
2. Run `migrateRuntimeSkillAssets` with `apply`.
3. See that it throws `runtime_skill_source_absent:missing` and does not
save the second run.

**Additional context**
#22641 already makes every blocker in the pass result carry a code. This
pull request was reduced to the runtime skill page after #22641 merged.

## What Changed

- `migrateRuntimeSkillAssets` returns `{ status: "unsaved", code:
"runtime_skill_source_absent:<reason>" }` for a run whose bundle is not
on this disk, and continues. Other errors still stop the page, as in the
offline migration.
- The result type is a discriminated union, so `unsaved` always carries
a code.
- The online pass reports each unsaved run as
`runtime_skill_assets:<code>`.
- `migrate-skill-packages --phase=runtime-assets` prints the unsaved
rows and exits 1 when any run stays unsaved.

## Verification

- Red: `cd server && npx vitest run
src/services/online-durable-data-migration.test.ts
src/__tests__/runtime-skill-preservation.test.ts` failed 2 new tests:
the real page (embedded PostgreSQL, real bundle files) threw
`runtime_skill_source_absent:missing` before it saved the next run, and
the pass had no code for unsaved runs.
- Green: the same files and
`online-durable-data-migration-postgres.test.ts` pass (42 tests).
- `pnpm --filter @paperclipai/server typecheck` passes.
- Local `pnpm verify` selects most of the suite for this change (2,979
of 3,855 files). Required CI supplies that coverage.

## Risks

- No migration rule changes. A run whose bundle is gone still blocks the
move, online and offline.
- The maintenance command now exits 1 when a run stays unsaved, as it
did before when the page threw.

> 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, with tool use and code
execution in Claude Code.

## 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-23 12:51:59 -06:00
..