Skip to content

Commit f3ae91e

Browse files
committed
fix(dev): stop the session reaper deleting shared binaries
make refuses a session id whose `ze-<sid>` collides with a shared binary name (mk/session.mk, the ZE_BIN_NAMES filter). reap_binaries had no matching guard, so `session-scratch.sh --clean` with the session id `test` matched bin/ze-test on its `bin/*-$sid` glob and deleted the shared test runner that humans and CI build. Same for `ze-chaos`, `ze-perf`, `ze-analyze` and the rest. rm -f is irreversible, which is why the guard belongs on the side that DELETES and not only on the side that creates names. An earlier Review Gate noted the reaper half was "narrower" than make and stopped at the observation. The shared list is derived from mk/session.mk rather than repeated here, so the two cannot drift -- the drift is what caused this. Proven rather than asserted: with sid `test` and bin/ holding ze-test, ze-chaos, ze-mysession-test and other-test, the reaper now leaves the two shared binaries and still removes the two session-suffixed ones. Found by an independent closure review of spec-session-scoped-build-artifacts. That review also measured bin/ at 2.3 GB with orphaned binaries outside any sweeper, because reap_binaries only runs for an id that still has a tmp/s/<sid>/ directory. That is a separate defect and plan/spec-session-bin-directory.md already owns it.
1 parent 3007298 commit f3ae91e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

scripts/dev/session-scratch.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,22 @@ reap_binaries() {
9090
"" | */* | . | ..) return 0 ;;
9191
esac
9292
[ -d bin ] || return 0
93+
94+
# The SHARED binary names, derived from mk/session.mk rather than repeated
95+
# here, so the two cannot drift. make already refuses a session id whose
96+
# `ze-<sid>` collides with one of them (mk/session.mk, the ZE_BIN_NAMES
97+
# filter); this reaper had no such guard, so `--clean` with sid `test`
98+
# matched bin/ze-test on the glob below and deleted the shared test runner
99+
# that humans and CI build. rm -f is irreversible, which is why the guard
100+
# belongs on this side too and not only on the side that creates names.
101+
local shared
102+
shared=" $(sed -n 's/^ZE_BIN_NAMES *:*= *//p' mk/session.mk | head -1) "
103+
93104
for f in bin/*-"$sid"; do
94105
[ -f "$f" ] || continue
106+
case "$shared" in
107+
*" $(basename "$f") "*) continue ;;
108+
esac
95109
if [ "$require_idle" = "1" ] && [ -n "$(find "$f" -mmin -1440 -print -quit 2>/dev/null)" ]; then
96110
continue
97111
fi

0 commit comments

Comments
 (0)