feat(dispatch): run rtk as a busybox-style multi-call binary via argv[0]#2594
Closed
mazzz1y wants to merge 1 commit into
Closed
feat(dispatch): run rtk as a busybox-style multi-call binary via argv[0]#2594mazzz1y wants to merge 1 commit into
mazzz1y wants to merge 1 commit into
Conversation
When rtk is invoked under a tool's name via a symlink (e.g. `head` -> rtk), translate the invocation to the equivalent `rtk <sub>` via the rewrite registry and parse it with Clap; on no-equivalent or parse failure, exec the real tool. A self-check on resolved binaries prevents re-exec loops. - resolve_binary skips candidates that are symlinks whose target's file name is `rtk` (first_non_self_candidate); wrapper scripts that re-invoke rtk are out of scope and would loop — use symlinks for packaging. - synthesize_rtk_argv splices the arg tail from original OsStrings so quotes/escapes/non-UTF8 survive; a lexer round-trip guard passes structured args through to the real tool. - exec_real_tool: #[cfg(unix)] exec, #[cfg(not(unix))] spawn+wait. - telemetry fires only on real rtk runs, never on passthrough. - document manual symlink usage in README.
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 <sub>via the rewrite registry, and execs the real tool when there's no equivalent (or the synthesized form fails to parse)rtk) so a tool -> rtk symlink can't re-exec rtk forever — it always finds the genuine tool further down PATHWhy
I want to wire rtk into a Nix derivation that builds an idempotent, declarative setup across multiple tools on a machine. The auto-rewrite hook needs a Unix shell + per-agent hook config and mutates state at runtime, which doesn't fit a pure/idempotent Nix build.
With argv0 dispatch I can declaratively create tool -> rtk symlinks (
ln -s rtk head) in the derivation output and have those tools transparently routed through rtk's filters — no hook, no runtime mutation, reproducible across hosts.Tools rtk doesn't rewrite (or invocations with no equivalent) pass straight through to the real binary, so shadowing them on PATH is safe.
Test plan