Commit 4f7b674
fix(plugins): chmod +x generated hook scripts in write_hook_plugin — closes ROADMAP #25 hotfix lane
Linux CI was failing 'hooks::tests::collects_and_runs_hooks_from_enabled_plugins'
with 'PostToolUse hook .../hooks/post.sh failed to start for "Read":
Broken pipe (os error 32)'. Three reproductions today on main:
24120271422, 24120538408, 24121392171 — escalated from first-attempt
flake to deterministic-red on the third push.
Root cause (per ROADMAP #25, recorded at 79da4b8): the test helper
write_hook_plugin in rust/crates/plugins/src/hooks.rs writes pre.sh,
post.sh, and failure.sh via fs::write with #!/bin/sh shebangs but
never sets the execute bit. On Linux, Command::new(path).spawn() on a
shebang script without +x can race in fork/exec — the pipe setup
succeeds, the post-fork exec fails, and the parent observes 'Broken
pipe (os error 32)' instead of a clean 'Permission denied'. macOS
fork/exec ordering happens to paper over it, which is why the test
passed locally and only flaked on Linux CI.
Surgical hotfix per gaebal-gajae's direction (message
1491325062031343787 in #clawcode-building-in-public): only the
chmod-+x in write_hook_plugin and a regression guard. No broader
harness cleanup. The deeper plugin-test sealing pass for ROADMAP #25
+ #27 stays in gaebal-gajae's OMX lane
omx-issue-149131850982-flaky-hooks-test.
Changes:
1. New helper make_executable(&Path) in the test module that sets
mode 0o755 via std::os::unix::fs::PermissionsExt under #[cfg(unix)]
and is a no-op on non-unix targets.
2. write_hook_plugin now binds each script's path to a local, calls
fs::write on it, then calls make_executable on it before moving
on. Three call sites: pre.sh, post.sh, failure.sh.
3. New regression guard test generated_hook_scripts_are_executable
under #[cfg(unix)] that calls write_hook_plugin and asserts each
of the three generated .sh files has at least one execute bit set
(mode & 0o111 != 0). Future tweaks to write_hook_plugin cannot
silently regress the chmod without breaking CI.
Verification:
- cargo test --release -p plugins hooks:: → 4 passing (3 existing
hooks tests + new generated_hook_scripts_are_executable),
including the previously-flaking
collects_and_runs_hooks_from_enabled_plugins
- cargo test --release -p plugins → 35 passing, 0 failing
- cargo fmt -p plugins → clean
- cargo clippy -p plugins -- -D warnings → clean
Co-authored-by: gaebal-gajae <gaebal-gajae@layofflabs.com>1 parent 647ff37 commit 4f7b674
1 file changed
Lines changed: 47 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
362 | 374 | | |
363 | 375 | | |
364 | 376 | | |
| |||
368 | 380 | | |
369 | 381 | | |
370 | 382 | | |
| 383 | + | |
| 384 | + | |
371 | 385 | | |
372 | | - | |
| 386 | + | |
373 | 387 | | |
374 | 388 | | |
375 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
376 | 393 | | |
377 | | - | |
| 394 | + | |
378 | 395 | | |
379 | 396 | | |
380 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
381 | 401 | | |
382 | | - | |
| 402 | + | |
383 | 403 | | |
384 | 404 | | |
385 | 405 | | |
| 406 | + | |
386 | 407 | | |
387 | 408 | | |
388 | 409 | | |
| |||
496 | 517 | | |
497 | 518 | | |
498 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
499 | 543 | | |
0 commit comments