Summary
The "background guardian process that watches its owner's liveness via a FIFO stop-channel plus ps -o ppid= reparenting checks, and self-cleans up" pattern is implemented twice, independently, in two different modules — once for command timeouts in lib_std.sh and once for GitHub API retry-capture cleanup in lib_gh.sh — with no shared, reusable primitive between them.
Details
lib/bash/std/lib_std.sh: __base_bash_libs_std_run_with_timeout_supervisor__ plus its watchdog/wrapper helpers implement a process-group supervisor with FIFOs, status files, and PID-recycling-safe signal delivery.
lib/bash/gh/lib_gh.sh: __base_bash_libs_gh_api_start_capture_guardian__ / __base_bash_libs_gh_api_stop_capture_guardian__ independently implement a background watcher that forks, opens a FIFO control channel, polls ps -o ppid= against BASHPID to detect owner reparenting (with a kill -0 fallback), and removes its workspace on exit — solving substantially the same "detect that my owner is gone without racing a recycled PID" problem the timeout supervisor already solved.
Both are carefully written and independently correct as far as static reading can tell, but they are two hand-maintained solutions to the same underlying primitive: "run a background helper that reliably notices when its owner goes away, without a PID-recycling race."
Impact
This is a maintainability and extensibility cost rather than a functional bug: any bug fix or hardening applied to one guardian implementation (e.g. a signal-handling edge case, a ps portability fix) has no mechanism to propagate to the other, and a third module that needs the same "supervise a background helper safely" capability will most likely reimplement it a third time rather than reuse either existing one, since neither is exposed as a public or even documented-internal primitive.
Suggested fix
Consider extracting the shared shape (FIFO control channel + owner-liveness polling + guaranteed cleanup) into one internal lib_std.sh primitive that both the timeout supervisor and the GitHub retry-capture guardian call into, parameterized by what "stop" means for each caller. This is a design/refactor issue, not a one-line fix, and is worth scoping as its own slice rather than attempting inline.
Summary
The "background guardian process that watches its owner's liveness via a FIFO stop-channel plus
ps -o ppid=reparenting checks, and self-cleans up" pattern is implemented twice, independently, in two different modules — once for command timeouts inlib_std.shand once for GitHub API retry-capture cleanup inlib_gh.sh— with no shared, reusable primitive between them.Details
lib/bash/std/lib_std.sh:__base_bash_libs_std_run_with_timeout_supervisor__plus its watchdog/wrapper helpers implement a process-group supervisor with FIFOs, status files, and PID-recycling-safe signal delivery.lib/bash/gh/lib_gh.sh:__base_bash_libs_gh_api_start_capture_guardian__/__base_bash_libs_gh_api_stop_capture_guardian__independently implement a background watcher that forks, opens a FIFO control channel, pollsps -o ppid=againstBASHPIDto detect owner reparenting (with akill -0fallback), and removes its workspace on exit — solving substantially the same "detect that my owner is gone without racing a recycled PID" problem the timeout supervisor already solved.Both are carefully written and independently correct as far as static reading can tell, but they are two hand-maintained solutions to the same underlying primitive: "run a background helper that reliably notices when its owner goes away, without a PID-recycling race."
Impact
This is a maintainability and extensibility cost rather than a functional bug: any bug fix or hardening applied to one guardian implementation (e.g. a signal-handling edge case, a
psportability fix) has no mechanism to propagate to the other, and a third module that needs the same "supervise a background helper safely" capability will most likely reimplement it a third time rather than reuse either existing one, since neither is exposed as a public or even documented-internal primitive.Suggested fix
Consider extracting the shared shape (FIFO control channel + owner-liveness polling + guaranteed cleanup) into one internal
lib_std.shprimitive that both the timeout supervisor and the GitHub retry-capture guardian call into, parameterized by what "stop" means for each caller. This is a design/refactor issue, not a one-line fix, and is worth scoping as its own slice rather than attempting inline.