Skip to content

fix(hooks/rewrite): restore php passthrough rewrite#1983

Open
YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:fix/php-rewrite-regression
Open

fix(hooks/rewrite): restore php passthrough rewrite#1983
YOMXXX wants to merge 1 commit into
rtk-ai:developfrom
YOMXXX:fix/php-rewrite-regression

Conversation

@YOMXXX
Copy link
Copy Markdown
Contributor

@YOMXXX YOMXXX commented May 20, 2026

Summary

  • Restore the hook rewrite for bare php commands so php, php artisan ..., and php script.php route through rtk php again for RTK history/tracking.
  • Classify php as passthrough with 0.0 estimated savings because this branch has no built-in PHP TOML/Rust filter.
  • Keep boundary guards so adjacent PHP tools such as phpunit, phpcs, and phpstan are not stolen by the interpreter rule.

Reviewer Note

This PR does not add PHP output filtering or token savings. Runtime check with a fake php binary confirms RTK_TOML_DEBUG=1 rtk php demo reports no TOML filter match, then rtk gain --history records rtk fallback: php demo with 0 saved tokens.

A real PHP/Artisan filter should be a separate PR with concrete sample outputs and savings evidence.

Fixes #1892

Tests

  • cargo fmt --all -- --check
  • cargo test --bin rtk php -- --nocapture
  • cargo test --bin rtk
  • cargo clippy --all-targets -- -D warnings

@YOMXXX
Copy link
Copy Markdown
Contributor Author

YOMXXX commented May 21, 2026

Quick status note for whoever picks this up — no rush.

The earlier CI run failed on cargo fmt --check (one if let line length in the new regression test). Pushed a one-line cleanup in f3d4100 (style(discover): rustfmt single-line if let in php regression test) but the follow-up run is sitting at action_required since this is a fork PR — the workflow needs a maintainer to approve before it runs. PR is otherwise unchanged: same scope, same code path, only the formatting on the test body moved.

Branch is MERGEABLE against develop, all earlier checks were green prior to the fmt regression, and a local cargo fmt --all -- --check && cargo clippy --all-targets && cargo test --bin rtk is clean. Happy to wait, just flagging the CI gate so it isn't quietly stuck.

Thanks!

@YOMXXX
Copy link
Copy Markdown
Contributor Author

YOMXXX commented May 25, 2026

Reviewer guide to reduce review time:

Expert lens: rewrite registry / interpreter passthrough.

This restores the missing php interpreter rewrite rule. It intentionally does not add a dedicated Commands::Php handler; the rewritten command goes through RTK's existing fallback passthrough path. The main correctness boundary is that php ... should match, while adjacent PHP tools such as phpunit, phpcs, and phpstan must not be swallowed by the interpreter rule.

Suggested review checks:

  • Confirm ^php(\s|$) is the right boundary for bare php and php <args>.
  • Confirm phpunit tests/ is not rewritten as rtk php ....
  • Confirm tests cover classify + rewrite, not only one side of the hook path.

@aeppling
Copy link
Copy Markdown
Contributor

Hello, i do not really understand on what filter does this php rule wire to

Did you really tried php and inspect RTK history to ensure token gains and php being filtered ?

This seems very unlikely

Restore the hook rewrite for bare php commands so issue rtk-ai#1892 gets RTK history/tracking again, but do not claim a PHP filter exists.

There is no built-in PHP TOML or Rust filter on this branch, so classify php as passthrough with 0% estimated savings. The rewrite still routes php, php artisan, and php script.php through rtk php, while adjacent tools such as phpunit remain untouched.

Tests: cargo fmt --all -- --check; cargo test --bin rtk php -- --nocapture; cargo test --bin rtk; cargo clippy --all-targets -- -D warnings
@YOMXXX YOMXXX force-pushed the fix/php-rewrite-regression branch from 21a938d to a319285 Compare May 29, 2026 16:08
@YOMXXX YOMXXX changed the title fix(hooks/rewrite): restore php → rtk php rewrite rule fix(hooks/rewrite): restore php passthrough rewrite May 29, 2026
@YOMXXX
Copy link
Copy Markdown
Contributor Author

YOMXXX commented May 29, 2026

Verified and updated in a319285. This PR now treats php as passthrough-only: it restores the hook rewrite/history path for #1892, but no longer claims there is a PHP filter or token savings.\n\nConcrete checks:\n- php, php artisan ..., and php script.php still rewrite to rtk php ....\n- Classification now reports RtkStatus::Passthrough and 0.0 estimated savings.\n- phpunit remains untouched by the PHP interpreter rule.\n- Runtime check with a fake php binary shows RTK_TOML_DEBUG=1 rtk php demo has no TOML match and rtk gain --history records rtk fallback: php demo with 0 saved tokens.\n\nSo the scope is now explicitly history/tracking restoration only. A real PHP/Artisan output filter should be a separate PR with sample outputs and measured savings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

php command is no longer rewritten to rtk php

2 participants