Skip to content

fix(checkpoints): remove files added after restore target - #64477

Open
visualfox-ch wants to merge 1 commit into
NousResearch:mainfrom
visualfox-ch:fix/checkpoint-untracked-restore
Open

fix(checkpoints): remove files added after restore target#64477
visualfox-ch wants to merge 1 commit into
NousResearch:mainfrom
visualfox-ch:fix/checkpoint-untracked-restore

Conversation

@visualfox-ch

Copy link
Copy Markdown

Summary

  • remove files added after the selected checkpoint when restoring
  • derive removals from Hermes' pre-rollback snapshot instead of using destructive git clean
  • preserve ignored, excluded, oversized, and pre-existing untracked user files
  • prune only empty directories created by removed checkpoint additions

Test plan

  • python -m pytest tests/tools/test_checkpoint_manager.py tests/test_batch_runner_checkpoint.py tests/integration/test_checkpoint_resumption.py -q -o 'addopts='
  • ruff check tools/checkpoint_manager.py tests/tools/test_checkpoint_manager.py

Safety

The restore path never recursively cleans the repository. It only removes paths recorded as additions between the target checkpoint and Hermes' pre-rollback snapshot.

Compare the pre-rollback snapshot to the selected checkpoint and delete only additions captured by Hermes, while preserving ignored and excluded files.

Assisted-by: Hermes:gpt-5.6-sol
@alt-glitch alt-glitch added type/bug Something isn't working comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists labels Jul 14, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Fix for checkpoint restoration removing files added after the restore target. Clean (95 additions, 0 deletions). No security concerns.


Reviewed by Hermes Agent

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the full-directory restore gap; current main still uses git checkout <commit> -- . in tools/checkpoint_manager.py:826-830, so post-checkpoint additions are indeed left behind.

Problems

  • The new reconciliation runs after the existing pre-rollback _take() at tools/checkpoint_manager.py:820. _take() can cross max_snapshots, then _prune() rewrites history and runs git gc --prune=now (tools/checkpoint_manager.py:1053-1118). If the requested target is the oldest retained checkpoint, it can become unreachable before the new diff/checkout code uses it. The added tests do not exercise that retention boundary.

Suggested changes

  • Resolve and pin the target tree before _take(), use the temporary ref for restore, and delete it in finally.
  • Add small-retention regression coverage for full and file-scoped restores. The timeline-linked #64966 independently covers this target-pinning case.

Automated hermes-sweeper review.

if ok_current and current_commit and current_commit != commit_hash:
ok_added, added_out, _ = _run_git(
[
"diff", "--name-only", "--diff-filter=A", "-z",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff runs after the existing pre-rollback _take() call. _take() can exceed max_snapshots, after which _prune() rewrites the ref and runs gc --prune=now; an oldest retained commit_hash can be unreachable here. Resolve and pin the target tree before _take(), then diff/restore through that temporary ref and delete it in finally.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants