oliver-zehentleitner / maity
runner: the worktree prune removes read-only leftovers like the scratch removal does (one tree removal)
tsk-9352edeh9r09 Open
Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: design / duplication.
What is wrong: two tree removals behave differently. cli/src/maity/runner/scratchop.py:180-308 (_remove_in, _widen :214, _empty :272) restores the owner's access before emptying a directory, because build tools leave 0555/0000 directories (e.g. the Go module cache), and re-checks the inode before rmdir. cli/src/maity/runner/worktree.py:247-274 (_remove_tree) uses a plain os.fwalk + unlink with no widening, no PermissionError handling and no inode re-check. A subagent worktree holding a read-only cache therefore raises out of prune_orphans; the supervisor (runner/supervisor.py:1190-1193) logs "worktree prune skipped" and the clone stays unsupported, the stuck state the prune was built to clear.
Proposal: worktree.py uses scratchop's _remove_in/_empty (or the shared walk module from the fdwalk card of this round); add a test with a 0555 subdirectory.
Effort / risk: S-M. Low risk.