Skip to content

fix(rpc): refuse move_session copy ids the parser let through (#5930) - #6217

Open
surlymochan wants to merge 2 commits into
code-yeongyu:mainfrom
surlymochan:fix/5930-move-copy-review-lows
Open

surlymochan wants to merge 2 commits into
code-yeongyu:mainfrom
surlymochan:fix/5930-move-copy-review-lows

Conversation

@surlymochan

@surlymochan surlymochan commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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 copy sessionId now passes the same rule forkFrom applies (assertValidSessionId), in addition to isPlainId. An id ending in ., _ or - (e.g. copy-, a.) is refused with invalid_move_request before anything is written, instead of passing the parser and failing as move_failed after 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 + new ownershipSessionIds helper in ownership.ts: copying a copy back under an id named by a session_id of an ownership entry the source inherited is refused with invalid_move_request. Previously only the source's own header id was refused, so the copy answered success: true but refused every write.
  • docs/rpc.md copy 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 ids copy- / a. added to the refusal table (pre-fix: move_failed); new copy-back test — copy a revoked import under copy-5889, then copy that copy under the older inherited id (pre-fix: success: true).
  • test/session-manager/custom-session-id.test.ts: forkFrom with id copy- 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

  • parseCopy now applies the same ID rule as forkFrom, refusing trailing-separator IDs with invalid_move_request instead of failing as move_failed after the target folder was created.
  • forkFrom validates the ID before creating the target folder.
  • copySessionAs refuses a copy ID named by an ownership entry the source inherited.
  • Adds a changelog fragment for the fix.

Written for commit 21ff547. Summary will update on new commits.

View guided diff

…5930)

- parseCopy now applies the same id rule forkFrom applies, so an id
  ending in '.', '_' or '-' is refused with invalid_move_request
  before anything is written instead of failing as move_failed.
- forkFrom validates the id before creating the target folder, so a
  rejected fork no longer leaves an empty folder behind.
- copySessionAs refuses any id named by a session_id of an ownership
  entry the source inherited, so copying a copy back under an older id
  no longer answers success for a copy that refuses every write.
- docs/rpc.md copy paragraph updated in the same increment.

fixes code-yeongyu#5930
@code-yeongyu

Copy link
Copy Markdown
Owner

Thanks @surlymochan, approved. One note for later, not blocking: ownershipSessionIds (packages/coding-agent/src/core/session-move/ownership.ts:101-109, used at copy.ts:50) refuses any id named by any inherited ownership entry, even when replaying those entries under that id would end writable (for example, only a session_moved_in naming it). Re-running sessionOwnership with the candidate id would refuse exactly the unsafe cases. Erring on the refusing side is fine for now.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

move_session copy: two review LOWs from #5920 (id rule mismatch, copy-back under an inherited id)

2 participants