Skip to content

fix(snapshot): remove work products added after rollback target - #1005

Open
Jackkp0t wants to merge 1 commit into
modelscope:mainfrom
Jackkp0t:fix/snapshot-rollback-artifacts
Open

Jackkp0t wants to merge 1 commit into
modelscope:mainfrom
Jackkp0t:fix/snapshot-rollback-artifacts

Conversation

@Jackkp0t

Copy link
Copy Markdown

Change Summary

Rolling back to an earlier snapshot currently leaves files added and tracked in a later snapshot: restore_snapshot() reports success, but later work products are still present. Git checkout uses overlay mode by default.

Restore snapshot contents as before, then use a non-overlay checkout to remove tracked work products absent from the target snapshot. Keep the current and legacy history-cache directories under their existing overlay behavior so LLMAgent.rollback() can read and truncate history created after the first snapshot.

Regression tests exercise actual Git repositories: restoring older/newer snapshots, removing later tracked files, retaining untracked files and snapshot metadata, and restoring existing history while preserving later history in both cache layouts.

Related issue number

No linked issue. Checked all 26 open PRs and snapshot-related issue/closed-PR searches. #1002 changes other tests in the same file but does not address removal of later tracked files.

Validation

  • Before the fix, the new regression fails because the later file still exists.
  • python -m pytest tests/utils/test_snapshot_smoke.py --allow-hosts=127.0.0.1,::1 -q: 27 passed, 32 subtests passed. Only loopback connections are allowed for the Windows asyncio event loop.
  • pre-commit run --files ms_agent/utils/snapshot.py tests/utils/test_snapshot_smoke.py: all applicable hooks passed.
  • git diff --check: passed.
  • Ran pre-commit install and pre-commit run --all-files. The full run reports existing lint/format issues in unrelated files (for example ms_agent/utils/file_lock.py E731, ms_agent/config/skills_manager.py E305 and .dev_scripts/webui/oss_distribution.py E128). The final patch was validated in a fresh worktree containing only the two relevant file changes.

Checklist

  • The pull request title is a good summary of the changes
  • Unit tests for the changes exist
  • Run pre-commit install and pre-commit run --all-files before git commit, and passed lint check (run; unrelated baseline failures listed above)
  • Documentation reflects the changes where applicable (function docstring clarified)

Prepared with Codex, including regression tests and a separate AI code review.

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.

1 participant