fix: P0+P1 fixes from pre-merge review of hook engine#1346
Conversation
- runner: print captured output on non-zero exit (P0.1) - main: add hook/pipe to META_COMMANDS (P0.2) - init: store integrity hash after Gemini script install (P0.3) - hook_cmd: audit log + permission check for all agent paths (P1.1, P1.2) - runner: include failure_lines in cargo test summary (P1.5) - Cargo.toml: remove unconditional libc dep (P1.7) - init: clean stale settings.json entries during migration (P1.8)
Review — PR #1346 (P0/P1 fixes)Good progress. 5 out of 8 fixes are correct. 3 issues need attention before merge. Fix status
Blockers (2)
Minor
|
|
P0.1 : look good to me, for error we use eprint , to be transparent , returning in stderr as real err |
|
wait, my bad sorry , for p0.1 we should split stream for stderr and use eprint & print respectivly, working on it, was too fast on my answer |
|
fixed :) thanks for the review |
FlorianBruniaux
left a comment
There was a problem hiding this comment.
Local build + test run. 1 test failing.
Failing test — test_cursor_rewrite_flat_format
thread '...test_cursor_rewrite_flat_format' panicked at src/hooks/hook_cmd.rs:765:9:
assertion `left == right` failed
left: String("allow")
right: "ask"
Root cause: run_cursor_inner calls permissions::check_command() which reads the real settings.json/settings.local.json from disk. The test assumes git status has no allow rule (verdict = Default → "ask"), but on machines with Bash(git:*) in their local settings that command gets Allow → "allow".
You already fixed test_cursor_no_hook_specific_output for this — you made the assertion permissive (perm == "allow" || perm == "ask"). Same fix needed on line 765, or better: use check_command_with_rules with empty rules in run_cursor_inner to guarantee isolation regardless of what's in the developer's settings files. The second option is cleaner and tests the actual default-permission code path explicitly.
Typo from #1277 still open
pipe_cmd.rs:70: "{} matches in {}F:\n\n" — the F: artifact was in my review of #1277 but wasn't addressed here. Quick fix: "{} matches in {} files:\n\n".
Everything else looks correct. The P0.1 fd-separation fix (stdout → print!, stderr → eprint!) and the raw_stderr field addition are solid. P1.8 migration logic in init.rs is a meaningful fix for the stale-entry upgrade bug.
Fix the test isolation issue and the typo, then good to go.
|
For the typo, make sense for RTK to compress "files" into "F" |
Fixes 8 issues (3 P0, 5 P1) identified during pre-merge review of the hook engine (feat-hook-engine branch).
Summary
P0 — Blockers
P0.1: Silent output drop on command failure (runner.rs:81)
When the underlying command fails (non-zero exit), the skip_filter_on_failure path returned the exit code without printing any output. Affects 14 call sites (ls, tree, psql, kubectl, docker, gh).
P0.2: hook and pipe missing from META_COMMANDS (main.rs:1078)
On Clap parse failure (version mismatch, typo in settings.json), RTK fell through to shell execution instead of showing a Clap error.
P0.3: store_hash never called — integrity system inert (init.rs)
Gemini bash script was installed without storing a SHA-256 baseline. Tamper detection was dead on arrival.
P1 — Important
P1.1: Audit log only covers Claude Code path (hook_cmd.rs)
RTK_HOOK_AUDIT=1 produced no output for Copilot, Gemini, or Cursor hooks.
P1.2: Cursor always emits "permission": "allow" (hook_cmd.rs:437)
Permission system bypassed — every rewritten command got "allow" regardless of deny/ask rules.
P1.5: failure_lines collected but never used (runner.rs:189)
extract_test_summary collected cargo test failure details (assertion messages, expected vs actual) but never included them in output. Agent only saw failure names, not diagnostics.
P1.7: libc declared unconditionally (Cargo.toml)
libc = "0.2" in [dependencies] pulled it in on all platforms. Only needed under [target.'cfg(unix)'.dependencies].
P1.8: Migration leaves stale settings.json entry (init.rs:969)
migrate_old_hook_script() deleted ~/.claude/hooks/rtk-rewrite.sh but left the stale entry in settings.json. hook_already_present() matched the stale entry and blocked the new rtk hook claude from being registered. Hooks silently broken after upgrade. Same issue for Cursor hooks.json.
Noted (no fix needed)
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --all— 1590 passed, 0 failed, no new clippy warningsrtk ls /nonexistentprints error message to stderr, exits 2rtk hook claudshows Clap error with suggestion, not shell fallbackRTK_HOOK_AUDIT=1+ Copilot hook → audit log entry written to~/.local/share/rtk/hook-audit.log"permission":"ask"for non-allowed commands,"permission":"allow"for allowed ones