Repository navigation
Conversation
`rtk rewrite` only recognised the `RTK_DISABLED=1 <cmd>` prefix inside the command text and ignored the variable in its own environment, so every hook and embedding host had to check it before spawning rtk. The exported form is now a passthrough (exit 1, no output) decided before the permission settings, the lexer and the registry are consulted. The prefix form and every other exit code are unchanged, and only the exact value `1` counts. Refs rtk-ai#1153 Refs rtk-ai#3791 Earlier hook-level attempt: rtk-ai#1167 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FDTLBQWy4T7E9vE7ozX7r4
zerone0x
added a commit
to zerone0x/rtk
that referenced
this pull request
Sep 7, 2026
…tk-ai#3917 Tell the host to check RTK_DISABLED itself before spawning `rtk rewrite`, state that releases up to 0.48.0 honor it only as an in-command prefix, and link rtk-ai#3917, which makes `rtk rewrite` honor the exported variable too. The note stays true before and after that PR lands. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FDTLBQWy4T7E9vE7ozX7r4
Review follow-up: with the variable exported the exclusions and transparent prefixes are never consulted, so `run` no longer loads them and a disabled invocation costs one environment lookup and no file I/O. The parameterised `evaluate` path and its tests are unchanged. Refs rtk-ai#1153 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01FDTLBQWy4T7E9vE7ozX7r4
zerone0x
added a commit
to zerone0x/rtk
that referenced
this pull request
Nov 2, 2026
…tk-ai#3917 Tell the host to check RTK_DISABLED itself before spawning `rtk rewrite`, state that releases up to 0.48.0 honor it only as an in-command prefix, and link rtk-ai#3917, which makes `rtk rewrite` honor the exported variable too. The note stays true before and after that PR lands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk rewritenow honoursRTK_DISABLED=1exported in its environment: the outcome is a passthrough (exit 1, nothing on stdout), decided before the permission settings, the lexer and the registry are consulted. Until now only theRTK_DISABLED=1 <cmd>prefix inside the command text was recognised:RTK_DISABLED=1 rtk rewrite "git status"still printedrtk git statusand exited 3.rtk rewriteis the single source of truth that every shipped hook and plugin (the Claude and Cursor shell hooks, OpenCode, Pi/OMP, Hermes) and every embedding host calls, so one switch covers all of them. Today only the Pi extension checksprocess.env.RTK_DISABLEDon its own (hooks/pi/rtk.ts); that check keeps working and becomes redundant rather than required, and a host that spawnsrtk rewritedirectly no longer has to reimplement it before every spawn.1counts, as withRTK_TELEMETRY_DISABLEDandRTK_HOOK_AUDIT, so a parent that exported it can hand one childRTK_DISABLED=0to re-enable it. Every other exit code is unchanged, no file I/O is added to the rewrite path, and the shipped hook scripts are untouched.rtk hook <agent>entry points inhook_cmd.rscall the registry directly rather than going throughrewrite_cmd, so they still ignore the variable. That is the exact case reported in Feature request: disable rtk hook for one process tree #3791 and is left for a follow-up.evaluateas a parameter (theevaluate_with_verdictpattern from Rewrite tests fail when local permission settings allow git commands #3146), so the unit tests never touch the process environment. A small integration test spawns the binary to pin the exit-code/stdout contract and the "only1counts" rule. The existing registry subprocess test now clearsRTK_DISABLEDfor its child, so a developer's own export cannot mask the prefix warning it asserts on.Refs #1153 #3791
#1167 is the earlier attempt at the same feature; it calls
process::exit(1)at the top ofrun()and has been conflicting since April. This PR keeps the decision in the testable path instead.Test plan
cargo fmt --all -- --check;cargo clippy --all-targets(clean); soft lints-W clippy::unwrap_used -W clippy::panic -W clippy::expect_used(no new warnings)cargo test --allwith an isolatedHOME/RTK_DB_PATH/RTK_TEE_DIR: the full suite passes (3124 in the main crate plus the integration suites), including the 4 new unit tests and the 2 new end-to-end testsRTK_DISABLED=1 ./target/debug/rtk rewrite "git status"; echo $?prints nothing and1; without the variable, or withRTK_DISABLED=0, it printsrtk git statusand3;rtk rewrite "RTK_DISABLED=1 git status"still exits 1 with the existing stderr warninggit statusPreToolUse payload piped intoRTK_DISABLED=1 bash hooks/claude/rtk-rewrite.shemits nothing and exits 0; without the variable the rewrite is emittedhooks/claude/test-rtk-rewrite.shagainst this build: 57/66 pass and theRTK_DISABLEDprefix section passes; the same 9 cases (unrelatedrg/pipeline expectations and the audit-log cases the v3 script does not implement) fail identically against the 0.48.0 release binary