fix: prune stale Codex plugin version directories on install - #50
Open
camjac251 wants to merge 1 commit into
Open
fix: prune stale Codex plugin version directories on install#50camjac251 wants to merge 1 commit into
camjac251 wants to merge 1 commit into
Conversation
Install removed only the version directory it was about to write, leaving any sibling from an earlier install in place. Codex resolves the active plugin by scanning that directory and taking the highest version it finds, so a directory left behind by a newer install keeps being served after a downgrade: install 0.5.0, downgrade to 0.4.3, and Codex still loads 0.5.0. Install now prunes stale sibling version directories, which is what Codex's own installer does after it stages a new version. Pruning runs after the new version is copied into place so a failed copy cannot empty the cache, and it skips names that are not valid version segments, since Codex would never activate those.
3 tasks
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.
Summary
plugin installremoved only the version directory it was about to write, leaving any sibling from an earlier install in place. Codex resolves the active plugin by scanning that directory and taking the highest version it finds, so a directory left behind by a newer install keeps being served after a downgrade.Install 0.5.0, downgrade to 0.4.3, and Codex still loads 0.5.0.
Install now prunes stale sibling version directories, which is what Codex's own installer does after it stages a new version.
Evidence
codex-rs/core-plugins/src/store.rs,active_plugin_versionsorts ascending and takes the last entry:Codex's own installer calls
remove_old_plugin_versionsafter staging, which skips the version being installed and any name that is not a valid version segment.Notes
validate_plugin_version_segment(non-empty, not a traversal, ASCII letters, digits,.,+,_,-). Directories that fail it are left alone, since Codex would never activate them.removed_stale_version_pathsso the action is visible rather than silent.Test plan
npm run checkpasses (111 internal tests).