fix(rpc): refuse move_session copy ids the parser let through (#5930)
Follow-up to #5920 (part 2 of #5889, move_session op copy). Fixes #5930 — both review LOWs recorded there instead of folded after the CLEAR.
What changed
session-move-request.ts(parseCopy): the copysessionIdnow passes the same ruleforkFromapplies (assertValidSessionId), in addition toisPlainId. An id ending in.,_or-(e.g.copy-,a.) is refused withinvalid_move_requestbefore anything is written, instead of passing the parser and failing asmove_failedafter the target folder was created.session-manager.ts(forkFrom): the id is validated before the target folder is created, so a rejected fork no longer leaves an empty folder behind.session-move/copy.ts+ newownershipSessionIdshelper inownership.ts: copying a copy back under an id named by asession_idof an ownership entry the source inherited is refused withinvalid_move_request. Previously only the source's own header id was refused, so the copy answeredsuccess: truebut refused every write.docs/rpc.mdcopy paragraph updated in the same increment.
Tests (RED → GREEN)
New regression tests, all failing on the pre-fix code for the intended reason and passing after:
test/suite/rpc-move-session-copy.test.ts: trailing-separator idscopy-/a.added to the refusal table (pre-fix:move_failed); new copy-back test — copy a revoked import undercopy-5889, then copy that copy under the older inherited id (pre-fix:success: true).test/session-manager/custom-session-id.test.ts:forkFromwith idcopy-into a not-yet-created folder throws and the folder stays uncreated (pre-fix: folder created).
bun run --cwd packages/coding-agent test test/suite/rpc-move-session-copy.test.ts test/session-manager/custom-session-id.test.ts: 21/21 passed (pre-fix: 17 passed, 4 failed). bun run check: exit 0 (lint, fmt, tsc, install-lock).
Fixes #5930
Summary by cubic
Fixes three gaps in the move_session copy operation (#5930): invalid IDs ending in ., _, or - are now refused before anything is written, a rejected fork no longer leaves an empty folder behind, and copying a copy back under an older inherited ownership ID is refused instead of answering success: true for a copy that would refuse every write.
Bug Fixes
parseCopynow applies the same ID rule asforkFrom, refusing trailing-separator IDs withinvalid_move_requestinstead of failing asmove_failedafter the target folder was created.forkFromvalidates the ID before creating the target folder.copySessionAsrefuses a copy ID named by an ownership entry the source inherited.- Adds a changelog fragment for the fix.