(b) environment/packaging, not a watcher logic bug. scripts/ols-htaccess-watcher.sh is tracked as git mode 100644 (it was 100644 before #61 too). The shared-ols image chmod +xes it, but a bare CI checkout does not, so the test's env ... "$W" died with env: .../ols-htaccess-watcher.sh: Permission denied (last line of the job log) and no case could restart. The failures were all the "should trigger" cases (+0); the "does NOT" cases passed vacuously. Reproduced locally by running trunk's test on a git archive checkout in debian:trixie-slim. inotify-tools and apt-get update were fine in CI. Debounce/floor was not involved.
Production (old, pre-#61 image) is unaffected: the Dockerfile chmods the script and the pre-#61 logic is unchanged.
Changes
Watcher mode 100755.
Floor window: an edit inside the 60 s floor used to be dropped (never applied until another edit). It is now deferred to the end of the window and coalesced into ONE restart (bounded by FLOOR; the event stream is drained meanwhile).
Test: asserts the exec bit, launches via bash, stops children before the parent (the old cleanup leaked inotifywait + subshell into later sections, which also made restart counts unreliable), and adds 3 floor/coalesce cases (12 ok total).
No workflow change needed (no pull_request workflow touched).
Verification
Test run 5x in CI-equivalent (debian:trixie-slim + apt inotify-tools) and 5x inside the real shared-ols image (inotify-tools baked in, PR scripts copied over /scripts' test layout), all 10 in parallel: 10/10 ALL PASS, 12 ok each, no flakes. Plain-site and folder-docRoot cases both trigger.
Do not merge until the image is rebuilt deliberately.
## Root cause of CI run 6313 (Shell-Checks)
(b) environment/packaging, not a watcher logic bug. `scripts/ols-htaccess-watcher.sh` is tracked as git mode 100644 (it was 100644 before #61 too). The shared-ols image `chmod +x`es it, but a bare CI checkout does not, so the test's `env ... "$W"` died with `env: .../ols-htaccess-watcher.sh: Permission denied` (last line of the job log) and no case could restart. The failures were all the "should trigger" cases (+0); the "does NOT" cases passed vacuously. Reproduced locally by running trunk's test on a `git archive` checkout in debian:trixie-slim. inotify-tools and apt-get update were fine in CI. Debounce/floor was not involved.
Production (old, pre-#61 image) is unaffected: the Dockerfile chmods the script and the pre-#61 logic is unchanged.
## Changes
- Watcher mode 100755.
- Floor window: an edit inside the 60 s floor used to be dropped (never applied until another edit). It is now deferred to the end of the window and coalesced into ONE restart (bounded by FLOOR; the event stream is drained meanwhile).
- Test: asserts the exec bit, launches via `bash`, stops children before the parent (the old cleanup leaked inotifywait + subshell into later sections, which also made restart counts unreliable), and adds 3 floor/coalesce cases (12 ok total).
- No workflow change needed (no pull_request workflow touched).
## Verification
Test run 5x in CI-equivalent (debian:trixie-slim + apt inotify-tools) and 5x inside the real shared-ols image (inotify-tools baked in, PR scripts copied over /scripts' test layout), all 10 in parallel: 10/10 ALL PASS, 12 ok each, no flakes. Plain-site and folder-docRoot cases both trigger.
Do not merge until the image is rebuilt deliberately.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
CI run 6313 Shell-Checks failed "plain site docRoot .htaccess triggers (+0)":
the watcher was tracked as mode 100644 (the image chmods it, a bare CI
checkout does not), so `env ... ols-htaccess-watcher.sh` died with
"Permission denied" and no case ever restarted. Not a watcher logic bug.
- watcher: mode 100755
- watcher: an edit inside the FLOOR window is deferred to the end of the
window (one coalesced restart, bounded by FLOOR) instead of dropped
- test: assert executable bit, launch via bash, kill children before parent
(leaked inotifywait/subshell from earlier sections), add floor/coalesce cases
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
- floor wait was based on wall-clock date: a backward clock step could stretch
the deferral far past FLOOR; $SECONDS is monotonic and bounds it to FLOOR.
- $(date) forked on every drained event; under unrelated churn that burned CPU
for up to FLOOR seconds. Builtin $SECONDS needs no fork.
- last_restart is stamped on every attempt so a failing lswsctrl is limited to
one try per FLOOR instead of retrying on each event.
- IFS= read -r so path names with leading/trailing whitespace are not trimmed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Verdict: approve, with one hardening commit pushed to the branch (432741d).
Production behaviour change (deferred coalesced restart)
Restart storms: at most one lswsctrl restart per FLOOR window. Every restart goes through do_restart, which waits out the window first.
Wait is bounded by FLOOR. The loop only drains events with read -t 1, so the pipe cannot back up, and edits that arrive while waiting are covered by the pending restart, so nothing is dropped.
Both docroot kinds still trigger: plain public_html and a folder docroot (public_html/<sub>). The test checks both, and the plugin-cache .htaccess files still do not.
Entrypoint compatibility: entrypoint-shared-ols.sh starts it with /scripts/ols-htaccess-watcher.sh &. The Dockerfile chmods it and it is now 100755 in git, so both paths work. $WATCHER_PID is killed on TERM.
Path names (tenant-controlled): the path is only read with read -r and used as an associative-array key. It is never evaled or put into a command line. I tested directories named $(touch ...), backticks, a]b and x;y and nothing executed.
Known and accepted: a file name containing a newline can fake an extra "path" line. The worst case is a restart, still limited to one per FLOOR.
The floor was based on wall-clock date +%s. A backward clock step would have stretched the deferral well past FLOOR, so "bounded by FLOOR" did not strictly hold. It now uses bash $SECONDS, which is monotonic.
$(date) forked once per drained event. Unrelated churn under /mnt/users makes read return instantly, so the wait loop became a fork loop for up to 60 s. $SECONDS needs no fork.
last_restart was only stamped on success, so a failing lswsctrl retried on every event. It is now stamped on every attempt, so a failing restart is also limited to one try per FLOOR.
IFS= read -r in the main loop, so leading or trailing whitespace in a path is not trimmed.
Verification (image Dockerfile.shared-ols built from the branch, run in the container)
scripts/tests/ols-htaccess-watcher.test.sh: ALL PASS x3, 12/12 checks each. shellcheck -S warning is clean on both scripts.
Burst test: 300 writes in 10 s to a docroot .htaccess, plus 900 hostile-named plugin-cache .htaccess writes, with DEBOUNCE=3 and FLOOR=20. It produced 2 restarts for the burst, at +3 s and a single deferred one at +23 s. The 20 s spacing matches FLOOR. It never produced more than one restart per window.
Second edit inside the window: a folder-site edit made right after was applied by its own restart at +43 s, the end of the next window. It was not lost.
Idle CPU is about 0.0-0.1 %. No injection artifacts were created.
CI: the Shell-Checks job runs this test with inotify-tools installed, and the script is shellchecked in the same job. It runs on a bare checkout, which now has the exec bit. The workflow only triggers on trunk push or manual dispatch, so no build ran for the branch.
Merging with [skip ci] so trunk does not publish all image families. No build will be dispatched.
## Independent review (reviewer was not the author)
**Verdict: approve, with one hardening commit pushed to the branch (432741d).**
### Production behaviour change (deferred coalesced restart)
- Restart storms: at most one `lswsctrl restart` per FLOOR window. Every restart goes through `do_restart`, which waits out the window first.
- Wait is bounded by FLOOR. The loop only drains events with `read -t 1`, so the pipe cannot back up, and edits that arrive while waiting are covered by the pending restart, so nothing is dropped.
- Both docroot kinds still trigger: plain `public_html` and a folder docroot (`public_html/<sub>`). The test checks both, and the plugin-cache `.htaccess` files still do not.
- Entrypoint compatibility: `entrypoint-shared-ols.sh` starts it with `/scripts/ols-htaccess-watcher.sh &`. The Dockerfile chmods it and it is now 100755 in git, so both paths work. `$WATCHER_PID` is killed on TERM.
- Path names (tenant-controlled): the path is only read with `read -r` and used as an associative-array key. It is never `eval`ed or put into a command line. I tested directories named `$(touch ...)`, backticks, `a]b` and `x;y` and nothing executed.
- Known and accepted: a file name containing a newline can fake an extra "path" line. The worst case is a restart, still limited to one per FLOOR.
### Defects fixed (432741d)
1. The floor was based on wall-clock `date +%s`. A backward clock step would have stretched the deferral well past FLOOR, so "bounded by FLOOR" did not strictly hold. It now uses bash `$SECONDS`, which is monotonic.
2. `$(date)` forked once per drained event. Unrelated churn under `/mnt/users` makes `read` return instantly, so the wait loop became a fork loop for up to 60 s. `$SECONDS` needs no fork.
3. `last_restart` was only stamped on success, so a failing `lswsctrl` retried on every event. It is now stamped on every attempt, so a failing restart is also limited to one try per FLOOR.
4. `IFS= read -r` in the main loop, so leading or trailing whitespace in a path is not trimmed.
### Verification (image `Dockerfile.shared-ols` built from the branch, run in the container)
- `scripts/tests/ols-htaccess-watcher.test.sh`: ALL PASS x3, 12/12 checks each. shellcheck -S warning is clean on both scripts.
- Burst test: 300 writes in 10 s to a docroot `.htaccess`, plus 900 hostile-named plugin-cache `.htaccess` writes, with DEBOUNCE=3 and FLOOR=20. It produced 2 restarts for the burst, at +3 s and a single deferred one at +23 s. The 20 s spacing matches FLOOR. It never produced more than one restart per window.
- Second edit inside the window: a folder-site edit made right after was applied by its own restart at +43 s, the end of the next window. It was not lost.
- Idle CPU is about 0.0-0.1 %. No injection artifacts were created.
- CI: the `Shell-Checks` job runs this test with `inotify-tools` installed, and the script is shellchecked in the same job. It runs on a bare checkout, which now has the exec bit. The workflow only triggers on trunk push or manual dispatch, so no build ran for the branch.
Merging with `[skip ci]` so trunk does not publish all image families. No build will be dispatched.
jknapp
merged commit 15cd30fa3b into trunk2026-11-24 16:30:24 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Root cause of CI run 6313 (Shell-Checks)
(b) environment/packaging, not a watcher logic bug.
scripts/ols-htaccess-watcher.shis tracked as git mode 100644 (it was 100644 before #61 too). The shared-ols imagechmod +xes it, but a bare CI checkout does not, so the test'senv ... "$W"died withenv: .../ols-htaccess-watcher.sh: Permission denied(last line of the job log) and no case could restart. The failures were all the "should trigger" cases (+0); the "does NOT" cases passed vacuously. Reproduced locally by running trunk's test on agit archivecheckout in debian:trixie-slim. inotify-tools and apt-get update were fine in CI. Debounce/floor was not involved.Production (old, pre-#61 image) is unaffected: the Dockerfile chmods the script and the pre-#61 logic is unchanged.
Changes
bash, stops children before the parent (the old cleanup leaked inotifywait + subshell into later sections, which also made restart counts unreliable), and adds 3 floor/coalesce cases (12 ok total).Verification
Test run 5x in CI-equivalent (debian:trixie-slim + apt inotify-tools) and 5x inside the real shared-ols image (inotify-tools baked in, PR scripts copied over /scripts' test layout), all 10 in parallel: 10/10 ALL PASS, 12 ok each, no flakes. Plain-site and folder-docRoot cases both trigger.
Do not merge until the image is rebuilt deliberately.
🤖 Generated with Claude Code
https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
Independent review (reviewer was not the author)
Verdict: approve, with one hardening commit pushed to the branch (
432741d).Production behaviour change (deferred coalesced restart)
lswsctrl restartper FLOOR window. Every restart goes throughdo_restart, which waits out the window first.read -t 1, so the pipe cannot back up, and edits that arrive while waiting are covered by the pending restart, so nothing is dropped.public_htmland a folder docroot (public_html/<sub>). The test checks both, and the plugin-cache.htaccessfiles still do not.entrypoint-shared-ols.shstarts it with/scripts/ols-htaccess-watcher.sh &. The Dockerfile chmods it and it is now 100755 in git, so both paths work.$WATCHER_PIDis killed on TERM.read -rand used as an associative-array key. It is neverevaled or put into a command line. I tested directories named$(touch ...), backticks,a]bandx;yand nothing executed.Defects fixed (
432741d)date +%s. A backward clock step would have stretched the deferral well past FLOOR, so "bounded by FLOOR" did not strictly hold. It now uses bash$SECONDS, which is monotonic.$(date)forked once per drained event. Unrelated churn under/mnt/usersmakesreadreturn instantly, so the wait loop became a fork loop for up to 60 s.$SECONDSneeds no fork.last_restartwas only stamped on success, so a failinglswsctrlretried on every event. It is now stamped on every attempt, so a failing restart is also limited to one try per FLOOR.IFS= read -rin the main loop, so leading or trailing whitespace in a path is not trimmed.Verification (image
Dockerfile.shared-olsbuilt from the branch, run in the container)scripts/tests/ols-htaccess-watcher.test.sh: ALL PASS x3, 12/12 checks each. shellcheck -S warning is clean on both scripts..htaccess, plus 900 hostile-named plugin-cache.htaccesswrites, with DEBOUNCE=3 and FLOOR=20. It produced 2 restarts for the burst, at +3 s and a single deferred one at +23 s. The 20 s spacing matches FLOOR. It never produced more than one restart per window.Shell-Checksjob runs this test withinotify-toolsinstalled, and the script is shellchecked in the same job. It runs on a bare checkout, which now has the exec bit. The workflow only triggers on trunk push or manual dispatch, so no build ran for the branch.Merging with
[skip ci]so trunk does not publish all image families. No build will be dispatched.