You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ux/safety: uninstall_codex_at deletes RTK.md before patching AGENTS.md — half-mutated state on second-step failure #26
uninstall_codex_at() (src/hooks/init.rs:870-922) removes the canonical/legacy markdown files first (~lines 880-898), then patches AGENTS.md (~lines 900+). If the second step fails (filesystem full, permission flip, signal during the write), the user is left with AGENTS.md still importing @CONTEXTCRAWLER.md or @RTK.md while the actual file is gone — Codex will then log warnings on every load.
Caught by adversarial codex review of today's commit range, independently confirmed.
Severity
Low. Correctness/UX bug, not a security boundary cross — no privilege escalation, no data exposure. But it leaves the user in a state where init --show reports an inconsistent install and uninstall cannot easily be re-run to recover (the file it needed to delete is already gone).
Fix (proposed)
Reorder the operations so AGENTS.md mutation happens first and the file deletes only happen if the AGENTS.md write succeeded:
Read AGENTS.md, compute the desired new content
atomic_write AGENTS.md (succeeds or fails atomically)
Only on success, delete the on-disk md files
If AGENTS.md write fails, return the error with the on-disk files still intact — user can re-run uninstall and we'll detect the same state again
Idempotency is already a goal of this function; this just makes the failure mode also recoverable.
Out of scope
The reverse ordering question (atomic across both ops) — we don't have a transactional fs primitive, but at least the proposed ordering puts the irreversible step last.
Test plan
Existing test_uninstall_codex_at_is_idempotent still passes
New test: inject an AGENTS.md write error (e.g. read-only fixture dir), verify the md file was NOT deleted
Regression-check: AGENTS.md mutation visible BEFORE md file deleted in the happy path
Activity
Merge pull request #65 from thehoff/fix/uninstall-codex-ordering-26
chore(release): v0.1.7 — version bump + release-engineering rebrand +…
fix(uninstall): reorder uninstall_codex_at to patch AGENTS.md before …