feat(git): workspace turn checkpointing via git shadow refs for safe rollback - #635
Open
cagdasyurekli wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #614
Summary
Implements automatic workspace turn checkpointing via lightweight git shadow refs (
refs/openworker/checkpoints/<session_id>/<turn_index>) and introduces therevert_turntool and engine method for safe workspace rollback without polluting git history or HEAD.Key Changes
coworker/tools/git.py):create_checkpoint(workspace, session_id, turn_index): Uses an isolated temporary index file (GIT_INDEX_FILE=<tmp>) to stage all tracked, modified, and untracked changes (git add -A), write the tree (git write-tree), create a commit (git commit-tree), and point a shadow ref (refs/openworker/checkpoints/<session_id>/<turn_index>) to it. Leaves the repository's real index, HEAD, and working branches untouched.list_checkpoints(workspace, session_id): Enumerates available shadow checkpoint refs.restore_checkpoint(workspace, session_id, turn_index): Restores workspace files to the checkpointed snapshot viagit checkout <ref> -- ., and safely prunes newly created untracked files while preserving.gitand.gitignored files.revert_turntool: Registered undergit_tools, exposing an interactive or programmatically invokable rollback tool.coworker/engine.py):write_local_file,replace_file_content,run_shell,apply_patch, etc.) executes in a given turn.engine.revert_turn(turn_index)to rollback the working tree.coworker/agent.py,coworker/agents/base.py,coworker/catalog.py):session_idtoAgentContextandgit_tools.coworker/risk.py):revert_turnasRiskClass.WRITE_LOCALrequiring explicit confirmation/approval where applicable.tests/test_git_checkpoints.py):.gitignored files, and engine integration during agent turns.