Repository navigation
fix(appearances): finish a pack delete a held file interrupted - #33703
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix reuses the existing Not checked: whether a real Windows hold on a pack file behaves as the faked What this change shipsInventory (6 items) — 5 justifiedIntent: delete a custom appearance pack on Windows even when another program briefly holds one of its files open. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 2d417f6 Description read[DESCRIPTION-READ] c2d3ce20dac6d3454034394ef8f3fc7a1cd6655c8704c51b358d6811d24ac20f That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The delete runs in a worker thread, so the retry can sleep. Keeping the manifest until last means a half-finished delete still shows in the gallery, and the Windows branch is covered by tests forced to run on Linux and by the Windows CI lane. Notes
[DESIGN-REVIEWED] 2d417f6 Description read[DESCRIPTION-READ] d29e8277f349a2d8a04992dcc479001648100fde47c7b6abcbcb473656d48208 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approving. delete_pack replaces a bare shutil.rmtree with platform_compat.remove_with_retry per child, manifest.json last, so a briefly held Windows file no longer half-deletes a pack (appearance_packs/store.py:543-549, platform_compat_files.py:620-664). Link refusal and containment checks are unchanged and run first; both new tests turn red under mutation.
6eff28e to
99382f7
Compare
|
Rebased: main moved in The new head also keeps Linux and macOS on the single [operator: bolichen97] |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 99382f7. Since the approved 6eff28e, the per-entry, manifest-last walk runs only where shutil.rmtree walks by path (Windows: if not shutil.rmtree.avoids_symlink_attacks). POSIX keeps the single fd-based rmtree, and a new test pins that a pack swapped for a symlink mid-delete removes nothing outside the pack. Tests 41/41, both guards turn a named test red under mutation. The GPT lane is red on a hand-placed MANIFEST.JSON edge case (low harm, one-token fix); the author needs to fix it or file an override before merge. Decisive lines: src/kiro_crew/appearance_packs/store.py:543-550, src/kiro_crew/platform_compat_files.py:640-648, test/test_appearance_packs_store.py (test_a_pack_swapped_for_a_symlink_mid_delete_deletes_nothing_outside)
On Windows, deleting a custom appearance pack while another program held one of its files open (an editor, an indexer, an antivirus scan) failed with WinError 32 and left a half-deleted pack behind. The delete now goes through platform_compat.remove_with_retry, which waits out the sharing violation for about three seconds, the same helper the meeting delete uses since #32190. Where shutil.rmtree walks a folder by path (Windows), the pack's entries are removed one at a time with manifest.json last, so a hold that outlasts the wait leaves the pack listed and a second delete finishes it. Everywhere else the delete stays one shutil.rmtree call, which removes through the folder it opened. The platform-compat helper table names the pack delete among its callers. Part of #32171
99382f7 to
2d417f6
Compare
|
self-added: yes
[operator: bolichen97] |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 2d417f6. Since the APPROVE on 99382f7, the only change is the fix for the GPT finding. The manifest-last skip now compares child.name.casefold(), so a MANIFEST.JSON also stays until last on Windows. A new test pins this, and reverting the casefold turns that test red. Tests pass 42/42, and every AI lane, including GPT and Sensitive Change Review, is green on this head. Decisive lines: src/kiro_crew/appearance_packs/store.py:548, test/test_appearance_packs_store.py:195-225 (test_a_hold_past_the_retry_keeps_a_case_variant_manifest)
Problem / Motivation
Goal: Deleting a custom appearance pack on Windows finishes even when another program briefly holds one of its files open.
On Windows,
AppearanceStore.delete_packremoved the pack folder with a bareshutil.rmtree. A file held open by an editor, an indexer or an antivirus scan raisesPermissionError(WinError 32), so the delete stopped partway: part of the pack was gone, the rest stayed on disk, and the dashboard answered404 pack_not_found.Why it matters
A user who deletes a pack while another program glances at one of its files gets a half-deleted pack and a "no such appearance pack" error, and has to delete it again by hand. Both the crew appearance library and Crew Companion's gallery delete through this store.
Not a goal
code_review_sagedeletes windows: code_review_sage and appearance pack deletes fail on a briefly held file, bare shutil.rmtree with no retry #32171 also lists; the issue stays open for them.404 pack_not_found.rmtreecalls, which remove its own staging and backup folders during a save.What changed (motivation → approach → change)
A pack delete on Windows now waits out a briefly held file instead of failing at the first one. A file held for longer still fails the delete, but the pack stays in the gallery, so deleting it again finishes the job. Linux and macOS delete an open file, so they behave as before.
The cause was the bare
shutil.rmtreeindelete_pack. The delete now goes throughplatform_compat.remove_with_retry, the helper the meeting delete uses (#32190). It retries a sharing violation (winerror32/33) for about three seconds, then raises an error naming the held file.shutil.rmtree.avoids_symlink_attacksis false (Windows)remove_with_retry, the manifest last whatever its letter case (MANIFEST.JSONis the same file there), then the folder; the gallery lists only packs that have a manifestremove_with_retrycall on the folder, which is the sameshutil.rmtreeas before and removes through the folder it openedThe link refusal and the containment check still run first, and any failure is still logged and answered
False. The helper table indocs/system-specs/common/platform-compat.mdnames the pack delete among its callers.Backwards compatibility
Compatible: every delete that succeeds today succeeds the same way. On Windows a sharing violation is retried for up to about three seconds per held entry before the same
Falseanswer, and the dashboard's config lock, which the delete runs under, is held for that wait. Every other error, and every error on Linux and macOS, fails at once as before; there the delete is the same singleshutil.rmtreecall as today.Removes nothing: the same folder is deleted after the same link and containment checks.
Tests
test/test_appearance_packs_store.py::TestPathSafety::test_deleting_a_pack_waits_out_a_file_held_open_briefly: unlinkingidle.svgraises WinError 32 once, then succeeds; the delete returnsTrueand the folder is gone.test_a_hold_past_the_retry_keeps_the_pack_listed_to_delete_again(same file):working.svg, which Windows lists aftermanifest.json, stays held on every attempt; the delete returnsFalse, the pack is still listed, and a second delete after the hold ends returnsTrue.test_a_hold_past_the_retry_keeps_a_case_variant_manifest(same file): the manifest is namedMANIFEST.JSONand the folder is listed in Windows order (case-insensitive, so it comes beforeworking.svg); withworking.svgheld, the delete returnsFalseandMANIFEST.JSONis still on disk.shutil.rmtree.avoids_symlink_attacksto false so they run the Windows path on Linux;remove_with_retrykeys onwinerror, not on the OS. The Windows backend lane runs them natively.test_a_pack_swapped_for_a_symlink_mid_delete_deletes_nothing_outside(same file, skipped where rmtree walks by path): the pack folder is replaced by a link to another folder after the delete starts; nothing in that other folder is removed and the delete returnsFalse.test/test_appearance_packs_store.pyrun 10 times, each in a fresh shuffled order, 42 of 42 every run; the four delete tests above 20 times at-n0and 10 times at-n 4beside two sibling appearance-pack test files, green every run.Proof: PROVEN test/test_appearance_packs_store.py::TestPathSafety::test_deleting_a_pack_waits_out_a_file_held_open_briefly, test/test_appearance_packs_store.py::TestPathSafety::test_a_hold_past_the_retry_keeps_the_pack_listed_to_delete_again, test/test_appearance_packs_store.py::TestPathSafety::test_a_hold_past_the_retry_keeps_a_case_variant_manifest (head 2d417f6)
Manual verification
N/A — the behaviour is Windows-only and the unit test forces the exact
winerrorthe helper reads; not run on a Windows host.Screenshots / video
N/A — backend-only change; no frontend file is touched.
Related Issues
Part of #32171
Sibling sweep
Swept: git grep -nE "shutil.rmtree(" -- src/kiro_crew/appearance_packs, plus the sites #32171 lists
Sibling: src/kiro_crew/appearance_packs/store.py:307 -- not affected -- the other rmtree calls in this file (307, 637-708) remove the store's own
.tmp-*staging and.old.*backup folders, which no user program has openSibling: src/kiro_crew/apps/builtins/code_review_sage/sage_lib/store.py:883 -- tracked in #32171
Sibling: src/kiro_crew/apps/builtins/code_review_sage/sage_lib/learning.py:225 -- tracked in #32171
Pattern harvest
Rule candidate: review-prompt
Pattern: a user-initiated delete of a folder the user can open in other programs calls
shutil.rmtreeinstead ofplatform_compat.remove_with_retryChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)