mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
## Thinking Path
- Paperclip Cloud moves a hosted instance off its volume with an offline
maintenance process (`server/src/maintenance/ephemeral-migration*.ts`).
Each data owner either migrates its records or refuses with a fixed
code; the maintenance receipt reports that code to the Cloud enrollment
driver, which rolls back and records it.
- The workspace owner refuses as
`remote_workspace_migration_blocked:<reason,reason>` (for example
`...:workspace_recovery_unresolved` or
`...:archived_git_source_unavailable,local_source_unsafe_or_missing`).
- The receipt only accepted bare `[a-z_]` codes, so every workspace
refusal collapsed to `owner_migration_failed`, and the process logged
nothing. Two hosted enrollments rolled back with only
`owner_migration_failed`, leaving the admin unable to see which owner
refused or why.
- This change lets the owner's fixed reason list through (still
lowercase codes only, never free text) and logs the blocked phase and
code so the deployment log carries it too.
## Linked Issues or Issue Description
No existing issue; described in-PR per the bug report template. Related:
paperclipai/paperclip-cloud#1777 (Cloud side of the same fix).
### What happened?
Offline (maintenance) enrollment of two hosted instances rolled back.
The recorded reason was only `failure: "owner_migration_failed"` (Cloud
showed `phase: "unreported"`), and the maintenance deployment log
contained no refusal at all.
### Expected behavior
The receipt and the deployment log name the refusing owner and its fixed
reason codes, e.g.
`remote_workspace_migration_blocked:workspace_recovery_unresolved`.
### Steps to reproduce
Start `startEphemeralMigrationService` with a `migrate` that throws
`remote_workspace_migration_blocked:archived_git_source_unavailable,local_source_unsafe_or_missing`
(what `reserveMigration` throws for a blocked workspace); `GET /status`
reports `owner_migration_failed` and nothing is logged. The new test in
this PR does exactly this.
### Paperclip version or commit
7d26bdaa (deployed) and origin/master 4daeab5c76; the maintenance files
are identical.
### Deployment mode
Hosted (Cloud-managed), offline maintenance entry
`server/dist-runtime/ephemeral-migration.mjs`.
## What Changed
- `server/src/maintenance/ephemeral-migration-service.ts`: new
`ownerRefusalCode`. A bare `[a-z_]` code passes as before. Only an
allowlisted reason-list owner (`remote_workspace_migration_blocked`) may
carry `:reason,reason`; each reason must be a fixed lowercase code, a
malformed list keeps just the owner code, and more than 32 reasons keep
the first 31 plus `more_reasons_truncated`. Anything else reports
`owner_migration_failed`. Logs `{event: "ephemeral_migration_blocked",
phase, failure}` to stderr when blocked.
- `server/src/maintenance/ephemeral-migration-service.test.ts`: receipt
and log for a structured refusal with a workspace phase; sanitized log
for an arbitrary error; allowlist, malformed and truncation cases.
## Verification
- Red: new test failed on origin/master (`failure:
"owner_migration_failed"`).
- Green: `cd server && npx vitest run
src/maintenance/ephemeral-migration-service.test.ts` (16/16). `npx tsc
-p server/tsconfig.json --noEmit` clean.
- `pnpm verify` selected a broad server shard; stopped it after 30 min
per AGENTS.md section 7 and rely on CI for broad coverage.
- Not run: a live enrollment.
## Risks
- Low. Diagnostics only; migration and blocking behavior are unchanged.
The accepted shape cannot carry paths, URLs, secrets or stack text.
Rollback: revert.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use.
## 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>