Files
PaperClipAI/server
DottaandClaude Opus 5.5 724693f635 fix(workspaces): move a managed folder online when another record names it by a different path (#22721)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - A hosted server moves each local workspace to shared storage in
bounded online passes while it serves work
> - An ordinary managed folder can move online when every task record
that points at it is fenced by the folder's source locks
> - On staging, one stack keeps 26 workspaces blocked with
`workspaces:source_scope_ordinary_member_locator_mismatch`
> - The check compares the text of each record's path with the folder's
physical path, so a record that names the same folder through a symlink
or with a trailing slash is refused
> - The source locks already come from the physical path, so writers
through either spelling take the same lock
> - This pull request compares physical paths, and names a record that
encloses the folder separately
> - The benefit is that these workspaces move online exactly as they
move offline, with the same fence

## Linked Issues or Issue Description

Refs #22644

**What happened?**
After repeated online passes on staging (Core 4434d12e), one stack
reports `source_scope_ordinary_member_locator_mismatch` x26.

**Expected behavior**
A managed folder moves online when every record that points at it is
fenced. The offline move captures the same folder for each record. The
online move must accept the same data, never more.

**Steps to reproduce**
1. Create a managed project folder with three task records that point at
it.
2. Change one record's `cwd` and `providerRef` to a symlink to the
folder, or add a trailing slash.
3. Run `inventoryRemoteWorkspaceMigration` online for another record. It
reports `ordinary_member_locator_mismatch`.

**Why it is safe**
- The online proof already finds members by physical path
(`physicalPath`, which resolves symlinks).
- `workspaceSourceIdentities` takes source lock keys from the canonical
path. A writer that uses the other spelling takes the same project or
task lock.
- Each member's lifecycle lock is still held. The publication still
checks the source scope again under lock, so a retargeted symlink
changes the scope and blocks the move.

## What Changed

- `ordinaryMemberUnproven` compares the physical `cwd` and `providerRef`
of each overlapping record with the folder:
  - inside the folder: `ordinary_member_nested` (unchanged);
- a parent of the folder: new code `ordinary_member_encloses_root`
(still blocked);
- the same folder by any spelling: accepted, with all other member
checks unchanged;
- a record without `cwd`, or with a locator that points somewhere else:
`ordinary_member_locator_mismatch` (unchanged).
- Only member records change. The migrating workspace's own path must
still be canonical.

## Verification

- Red on `origin/master` (b908678ea3): the trailing slash and symlink
tests report `ordinary_member_locator_mismatch`. The enclosing test
reports `ordinary_member_locator_mismatch` instead of
`ordinary_member_encloses_root`.
- Green with the fix. Both spellings are eligible and the migration
publishes. The other record stays local and the folder's files stay in
place. An enclosing record and a locator elsewhere stay blocked, with no
workspace operation.
- `cd server && npx vitest run
src/services/remote-workspace-migration.test.ts
src/services/remote-workspace-online-source.test.ts
src/services/remote-workspace-cohort-migration.test.ts
src/services/remote-workspace-migration-concurrency.test.ts`: 4 files,
368 tests passed (embedded PostgreSQL).
- `cd server && pnpm typecheck`: passed.

## Risks

- Low to medium. More ordinary folders become movable online. The fence
does not change: path-derived source locks, each member's lifecycle
lock, and the scope recheck under lock at publication.
- A record that encloses the folder stays blocked. Its own move would
need a scope that covers the larger folder. Offline captures each record
separately.

## 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 19:41:03 -06:00
..