Skip to content

feat(workspace): finish a working-copy move a crash cut short - #15

Open
PiquelChips wants to merge 1 commit into
feat/events-log-movesfrom
feat/events
Open

PiquelChips wants to merge 1 commit into
feat/events-log-movesfrom
feat/events

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

A command that moves the working copy checks out the new files, then points workspace at the new revision. A crash or a power loss in between left the files half checked out. Nothing recorded what they were moving from or to.

Crash-safe moves:

  • A move that checks files out first durably writes a moving marker. The marker records the trees the move goes from and to, and its revision. The move removes it, durably too, once workspace points at the revision.
  • The next command finishes the move, or takes it back if its revision wasn't written. It only touches files that still match one side, so edits and new files survive, in the draft the command's snapshot finds.
  • A refused move that gets cut short is taken back, not finished: taking a refused checkout back publishes the marker again first.
  • A move that can't be finished leaves the files as they are and never blocks later commands. Recovery reads every blob before it changes any file.
  • A moving marker that can't be read is kept and reported, and the working copy doesn't move until it's removed. Other commands still run.

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code)

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 083673dd-0858-4746-b15b-70ee723cb639
Commits

Reviewing files that changed from the base of the PR and between d21e781 and 8138a2c.

Files selected for processing: 5

  • apps/origin-src/src/oplog.rs
  • apps/origin-src/src/workspace/mod.rs
  • apps/origin-src/src/workspace/registry.rs
  • apps/origin-src/src/worktree.rs
  • apps/origin-src/tests/cli.rs
Walkthrough

This change adds a durable operation log and derives a filtered event stream from its entries. The index catches up from settled log records. Workspace moves are logged and can recover after interruption. New CLI commands list operations, undo a workspace move, and watch events.

Changes: Operation history and workspace commands

Layer / File(s) Summary
Framed operation log and effect recording
apps/origin-src/src/frames.rs, apps/origin-src/src/oplog.rs, apps/origin-src/src/store/mod.rs, apps/origin-src/src/targets.rs, apps/origin-src/src/queue.rs, apps/origin-src/src/lib.rs, crates/origin-shared/src/object/statement.rs
Adds checked frames and a segmented operation log. Store commits, pending landings, and target advances record their effects. Record IDs expose object-kind and object-ID conversions.
Index catch-up and rebuild
apps/origin-src/src/index.rs
The index tracks its applied log sequence and catches up from settled entries. It rebuilds when the required log history is damaged or expired, and uses version 3 frames.
Logged workspace moves and recovery
apps/origin-src/src/workspace/mod.rs, apps/origin-src/src/workspace/land.rs, apps/origin-src/src/workspace/registry.rs, apps/origin-src/src/cli.rs, apps/origin-src/tests/cli.rs
Workspace actions record move reasons and actor context. A durable move marker supports recovery after interrupted checkouts. Tests cover recovery paths and retained file edits.
Derived event stream and watch command
apps/origin-src/src/events.rs, apps/origin-src/src/policy.rs, apps/origin-src/src/workspace/ops.rs, apps/origin-src/src/cli.rs, apps/origin-src/tests/cli.rs, apps/origin-src/benches/store.rs, README.md, AGENTS.md
Adds event derivation, filtering, cursor-based reads, and polling. The CLI prints matching events, and benchmarks cover reading and polling events.
Operation listing and workspace undo
apps/origin-src/src/workspace/ops.rs, apps/origin-src/src/workspace/mod.rs, apps/origin-src/tests/cli.rs
Adds operation-log output and workspace-specific undo. Undo restores a prior revision or creates a new revision from its prior contents when needed. Tests cover undoing changes, descriptions, and resolutions.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Workspace
  participant Events
  participant OpLog
  CLI->>Workspace: watch(filter, since)
  Workspace->>Events: wait(cursor, filter, 256, 60 seconds)
  Events->>OpLog: read settled entries after cursor
  OpLog-->>Events: settled entries
  Events-->>Workspace: matching event page
  Workspace-->>CLI: print events and advance cursor
Loading

Possibly related issues

Possibly related PRs

  • piquel-fr/origin#8: This PR specifies the operation log, event delivery, crash-safe checkouts, and related commands implemented here.
  • piquel-fr/origin#11: This PR adds the record index that this change updates to catch up from the operation log.
  • piquel-fr/origin#14: This PR adds shared workspaces and checkout behavior that this change extends with logged moves and recovery.

Suggested labels: area/landing

Merge Risk: Moderate · previous review d21e7

Resolve the working-copy recovery and durability issues before merging: concurrent commands or interrupted operations can leave files, pointers, and history inconsistent. Event filtering and command-input handling also need corrections, while retention-related edit loss requires a narrow combination of conditions.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(workspace): finish a working-copy move a crash cut short" matches a real and central part of the changeset. The workspace/mod.rs changes finish or reverse an interrupted `.origin/movin…
Full details: Title check

Explanation

The title "feat(workspace): finish a working-copy move a crash cut short" matches a real and central part of the changeset. The workspace/mod.rs changes finish or reverse an interrupted .origin/moving checkout on open, and the PR objectives describe this crash-safe move recovery. The title does not mention the main headline of the PR, which is the op log, undo, and watch features. It therefore covers one aspect of the change rather than the whole change, which fits a partial match.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the log at dawn,
Then follows cursors, hopping on.
A workspace steps back one small stride,
While checked frames keep events inside.
New changes leave their traces clear.

@PiquelChips
PiquelChips added this pull request to stack #18 October 18, 2026 16:04
@PiquelChips PiquelChips self-assigned this Oct 18, 2026
@PiquelChips PiquelChips added the enhancement New feature or request label Oct 18, 2026
@PiquelChips PiquelChips added this to the 0.1 milestone Oct 18, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Oct 18, 2026
@PiquelChips PiquelChips moved this from Needs Triage to In Progress in sourceorigin.dev Oct 18, 2026
@PiquelChips PiquelChips added the area/cli The local command line: changes, workspaces, the op log label Oct 18, 2026
@PiquelChips
PiquelChips force-pushed the feat/events branch 2 times, most recently from 2d96bb2 to 4501e96 Compare October 19, 2026 10:43
@PiquelChips
PiquelChips force-pushed the feat/events branch 2 times, most recently from 7a0956c to 7cf0437 Compare October 28, 2026 16:49
@PiquelChips
PiquelChips force-pushed the feat/events branch 2 times, most recently from d782d71 to da3e341 Compare November 2, 2026 23:34
@PiquelChips
PiquelChips force-pushed the feat/events branch 2 times, most recently from 175653e to 94bd2f6 Compare November 8, 2026 12:24
@PiquelChips
PiquelChips force-pushed the feat/events branch 2 times, most recently from a359ecf to 9c4b595 Compare November 8, 2026 15:21
@PiquelChips
PiquelChips force-pushed the feat/events branch 3 times, most recently from 5bb55bc to a0e2ca3 Compare November 10, 2026 17:22
@PiquelChips
PiquelChips removed this pull request from stack #38 November 13, 2026 22:15
@PiquelChips
PiquelChips added this pull request to stack #75 November 13, 2026 22:15
@PiquelChips
PiquelChips removed this pull request from stack #75 November 22, 2026 14:50
@PiquelChips PiquelChips changed the title feat(events): add the op log, undo and watch feat(workspace): finish a working-copy move a crash cut short Nov 22, 2026
@PiquelChips
PiquelChips changed the base branch from feat/workspaces to feat/events-log-moves November 22, 2026 14:53
@PiquelChips
PiquelChips added this pull request to stack #165 November 22, 2026 14:59
@PiquelChips

PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member Author

Note

🤖 Claude Opus 5.5 responding on behalf of piquel

On the review's two nitpicks (recovery tests that edit a path the interrupted move changes, and isolating the held entry's replay): not adding them. Recovery is tested by a_move_cut_short_is_finished_without_losing_edits and a_move_cut_short_before_its_revision_is_written_is_taken_back, and writers in progress by readers_wait_for_writers_and_sync_past_crashed_ones; both are test-only suggestions.

A command that moves the working copy checks out its files, then points
`workspace` at the new revision. A crash or a power loss in between left
the files half checked out, with nothing to say what they were moving
from or to.

A move that changes files now first publishes `.origin/moving`, durably,
naming the files it starts from, those it goes to, and their revision.
It removes the marker, durably too, once `workspace` points at the
revision. The next command to open the workspace finishes the move, or
takes it back if its revision wasn't written. It only touches the files
that are still on one side of the move, by content, so edits and new
files made since stay, in the draft the command's snapshot finds.

A refused checkout takes its files back as a move of its own, publishing
the marker again first, so a crash then finishes taking them back, not
the refused move. A marker that can't be parsed, or a move that can't be
finished, such as one whose blob can't be read, leaves the files as they
are rather than fail every command; restoring reads every blob before it
changes any file. A marker that can't be read at all is kept and
reported, and the working copy doesn't move until it's removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli The local command line: changes, workspaces, the op log enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant