Skip to content

fix(doctor): keep the session recovery marker out of tracked .sageox/ - #1072

Open
aditeya08varma wants to merge 1 commit into
sageox:mainfrom
aditeya08varma:fix/session-recovery-marker-ignored-1062
Open

aditeya08varma wants to merge 1 commit into
sageox:mainfrom
aditeya08varma:fix/session-recovery-marker-ignored-1062

Conversation

@aditeya08varma

@aditeya08varma aditeya08varma commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1062

What broke

  • .sageox/.session-recovery.json holds a per-machine absolute workspace_path, and it was not in the managed .sageox/.gitignore.
  • It is worse than the report: a plain ox doctor (no --fix) stages the file itself. GetSageoxFilesToCommit matches .sageox/*.json, and ForceAddSageoxFiles runs git add -f, which overrides every ignore rule. So a gitignore entry alone, or a .git/info/exclude entry, does not stop it. That is why the file in the report sat staged even with a local exclude.

What this PR ships

  • Adds .session-recovery.json to sageoxGitignoreContent and requiredGitignoreEntries, next to the .needs-doctor* markers. Existing repos pick it up on their next ox doctor, the same way agent_tasks/ was rolled out.
  • GetSageoxFilesToCommit skips any match whose name is in requiredGitignoreEntries, so ox never force-stages a file its own gitignore ignores. Today this only changes behavior for this marker.
  • The "Repo state" check no longer counts a file listed in requiredGitignoreEntries as config to commit. If one is already in the index (the case in the report, where the marker was staged before this fix), doctor warns and says to unstage it with git rm --cached <path> instead of "Run 'git commit' to persist config". It only gives the advice and does not touch the index, matching how doctor handles other index removals.
Before After
git check-ignore .sageox/.session-recovery.json not ignored ignored
after plain ox doctor A .sageox/.session-recovery.json + "run git commit" nudge not staged, no nudge
marker already staged before the fix "Run 'git commit' to persist config" warning: unstage with git rm --cached .sageox/.session-recovery.json

Why ignore it instead of moving it

Moving the file into agent_instances/ (option 1 in the issue) would leave existing copies at the current path, and doctor would keep force-staging them. Nothing reads or deletes the marker today, so they would never be cleaned up. Ignoring it plus the staging skip covers new and existing files, with no storage path change.

Testing

  • TestSessionRecoveryMarker_NotStagedOrNudgedByDoctor: on a fresh repo, a plain ox doctor must not stage the marker. Before the fix it fails with A .sageox/.session-recovery.json.
  • TestSessionRecoveryMarker_IgnoredAfterDoctorUpgradesOldGitignore: a repo with the old gitignore gets the new rule.
  • With only the staging skip removed, the first test still fails. That proves the gitignore entry alone is not enough.
  • TestSessionRecoveryMarker_AlreadyStagedIsFlaggedNotNudgedToCommit: a marker already in the index must get the unstage advice. Before the fix it fails with "Run 'git commit' to persist config".
  • The related gitignore and staging tests, -race -count=3, and make test pass.

Notes

  • Clones that already committed the file still need one git rm --cached .sageox/.session-recovery.json. Doctor shows that advice when the file is staged or modified. A committed copy that has not changed since does not show up in git status, so doctor does not flag it.
  • .sageox/distill-state.json looks like the same kind of per-machine file. I left it alone because I am not sure it is meant to be local.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 21 minutes.

Check out review usage here.

View limit details

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

Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: sageox/ox/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 00aeadb8-a756-4bcc-af9c-bf64941497b7

📥 Commits

Reviewing files that changed from the base of the PR and between 8ea01f9 and 5b41322.

📒 Files selected for processing (4)
  • cmd/ox/doctor_git.go
  • cmd/ox/doctor_git_repos.go
  • cmd/ox/doctor_sageox.go
  • cmd/ox/doctor_sageox_local_state_test.go

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

session-recovery breadcrumb is written into tracked .sageox/, and doctor nudges you to commit it

1 participant