Repository navigation
fix(uninstall): reorder uninstall_codex_at — AGENTS.md before file deletes (#26) - #65
Merged
Merged
Conversation
…deleting files (#26) The previous `delete-then-patch` order left users in an inconsistent state if the AGENTS.md patch failed (filesystem full, permission flip, signal during write): CONTEXTCRAWLER.md / RTK.md was already gone but AGENTS.md still imported the deleted path. Codex then warned on every load AND re-running `uninstall` failed because the helper tried to delete files that no longer existed. ## Fix Two changes in `uninstall_codex_at`: 1. **Reorder**: patch AGENTS.md FIRST, delete files SECOND. The new failure shapes are clean: - patch fails -> nothing removed, safe to rerun - patch succeeds -> both phases complete (file deletes after the atomic_write are nearly always trivial; AGENTS.md is the contended step) 2. **Collapse mutations**: the block-removal and @-reference-strip were two separate atomic_writes, leaving a tiny window where the block was gone but the @-reference remained. Both now happen in one read + one atomic_write — single point of failure with clean rollback semantics. The standalone `remove_rtk_reference_from_agents` helper had no other callers; its body was inlined into `uninstall_codex_at` and the helper was removed. The same tests that covered it now cover the inlined logic via the orchestrator. ## Pinning test `test_uninstall_codex_at_patches_agents_md_before_deleting_files`: - Sets up AGENTS.md with both a `<rtk-instructions>` block AND a separate `@CONTEXTCRAWLER.md` line + the actual CONTEXTCRAWLER.md file. - Runs uninstall. - Asserts: AGENTS.md is fully clean (both mutations applied), CONTEXTCRAWLER.md is deleted, and the `removed` Vec contains entries for all three operations. ## Verified - cargo build clean: 0 warnings - cargo test --bin contextcrawler: 2117 pass / 0 fail - 5/5 existing test_uninstall_codex_at_* still pass alongside the new pin - All 9 integration suites green Closes #26.
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
Closes #26 —
uninstall_codex_atdeleted CONTEXTCRAWLER.md before patching AGENTS.md. If the patch failed, the user was left with files gone but AGENTS.md still importing them → Codex warned on every load AND re-running uninstall failed (delete-of-missing-file).Fix
atomic_writeinstead of two separate writes (close the smaller half-mutated window).remove_rtk_reference_from_agentshad no other callers; body moved into the orchestrator.New failure shapes
Pinning test
test_uninstall_codex_at_patches_agents_md_before_deleting_files— fixture has both a block AND a separate @-ref + the file; asserts all 3 mutations land and the file gets deleted. The 5 pre-existingtest_uninstall_codex_at_*tests still pass alongside.Verified
cargo buildclean, 0 warningscargo test --bin contextcrawler— 2117 pass, 0 failCloses #26.