Skip to content

fix: parse-failure tracking, Windows tee path, passthrough output loss (#3339) - #3344

Merged
KuSh merged 7 commits into
rtk-ai:developfrom
SomSamantray:fix/passthrough-tracking-and-tee-path
Nov 25, 2026
Merged

KuSh merged 7 commits into
rtk-ai:developfrom
SomSamantray:fix/passthrough-tracking-and-tee-path

Conversation

@SomSamantray

Copy link
Copy Markdown
Contributor

Fixes the three related bugs reported in #3339, all rooted in how rtk's Tier-3 "parsing failed" fallback (ParseResult::Passthrough) is tracked and displayed.

1. rtk gain counted parse failures as savings

timer.track(...) was called unconditionally, even for Passthrough-tier runs. Since the passthrough content is a truncated view of the raw output, the size difference between "raw" and "shown" was counted as savings — even though nothing was parsed or summarized, and truncation only happened because parsing failed.

Fix: route genuine Tier-3 failures through the existing record_parse_failure_silent + TimedExecution::track_passthrough plumbing (already used by rtk gain --failures) instead of the generic savings timer. Applied to playwright test, pnpm list, pnpm outdated, and vitest/jest run — the four call sites sharing this pattern. Explicit user-requested passthrough (e.g. vitest's --reporter override) is untouched — it isn't a failure.

2. Tee hint path broken on Windows

[full output: ~/path/to/log] mixed a forward-slash ~ with native backslash separators, and could resolve ~ against a different home directory than the invoking Git Bash/MSYS shell's own ~ expansion uses.

Fix, in display_path:

  • Normalize the home-relative portion to forward slashes unconditionally (previously only the whitespace-quoting branch did this).
  • Prefer $HOME over the OS home-directory API when stripping the home prefix, converting Git Bash/MSYS's POSIX-style HOME (/c/Users/name) to a native path first — otherwise it would never match via strip_prefix and would silently defeat the ~ shorthand.
  • Reject an empty HOME value (an empty PathBuf's strip_prefix trivially matches everything).

This keeps the existing ~/ shorthand (per #2325's direction) rather than reverting to always-absolute paths, an approach previously tried in #2187/#2701.

3. Passthrough could silently emit nothing

When parsing failed and a command's real output was empty on stdout (diagnostic on stderr instead), the passthrough fallback was itself empty. never_worse then preferred that empty result over the real combined output, discarding it.

Fix: build the passthrough fallback content from the combined stdout+stderr instead of stdout alone, for all four call sites above.

Notes

  • No local rtk checkout existed when this was written — verified against a fresh develop clone before implementing.
  • cargo fmt --all, cargo clippy --all-targets -- -D warnings, and cargo test --all all pass (2523 tests; the only 2 failures in this environment — hooks::rewrite_cmd::tests::unattestable_passthrough::* — are pre-existing and unrelated, reproduced identically on unmodified develop).
  • pnpm list's Tier-1/Degraded guard and tracking stay anchored to stdout alone (unchanged) — only the Tier-3 arm uses the combined stream, so a stderr notice alongside a successful parse doesn't inflate the reported savings ratio.

@CLAassistant

CLAassistant commented Jul 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bharvey42

Copy link
Copy Markdown

Carried in a local fork build since 2026-08-08 (Windows 11, Git Bash / x86_64-pc-windows-gnu, daily use), no regressions.

The tee-hint half fixes a real day-to-day annoyance on Windows: the [full output: ~/...] hint mixed a forward-slash ~ with native backslash separators, and could resolve ~ against a different home directory than the invoking MSYS shell's own ~ expansion uses — so the path it printed wasn't reliably pasteable back into the same shell. Preferring HOME over the OS home-directory API is the right call there; that is the root Git Bash's own expansion resolves against.

Still merges cleanly with develop as of today (aa40853).

@bharvey42

Copy link
Copy Markdown

Re-verified the passthrough-loss half (#3339 part 3) today:

  • Still reproduces on stable v0.50.0 and on develop 3a12dfe. rtk vitest run --config does-not-exist.config.ts prints only the tee hint (72 B of stdout), while raw vitest prints 1880 B explaining why the run failed. The parse-failure arm still builds from stdout, but vitest reports startup errors on stderr.
  • With the three runner commits (6b1c12f, ca8007a, 9a36d1c) on develop, the error message comes through (1881 B).

Two things now stand between this PR and a clean merge:

  1. src/core/tee.rs conflicts with develop. Develop now prints the hint as "$HOME/AppData/Local/rtk/tee/…", which appears to cover what 4b958d9 fixed, so that commit can probably be dropped.
  2. cargo fmt --all -- --check fails on two test asserts in src/cmds/js/pnpm_cmd.rs (around lines 793 and 814).

With the runner commits alone on develop: clippy clean, full suite 3942 passed / 2 failed. Both failures are pre-existing Windows-only baselines.

@bharvey42

Copy link
Copy Markdown

Rebased this onto current develop (c356374) so it's mergeable again. Branch: bharvey42:rebase/3344-onto-develop (cf4eaa0). Your authorship is kept on all four commits.

What changed in the rebase:

  • playwright / pnpm / vitest commits: applied cleanly. I folded the cargo fmt fixes into the pnpm and vitest commits, so cargo fmt --check now passes.
  • tee commit: ported, because develop split tee.rs into a dispatcher plus tee_file.rs. The change now lives in tee_file.rs::display_path. Since fix(tee): quote recovery hint paths with spaces #2325, develop already avoids mixed separators by quoting ("$HOME/AppData/..."). What it still got wrong is the home it strips against: dirs::home_dir() (the Windows profile), while the shell expands ~/$HOME against its own HOME. The port reads HOME through user_dirs::env_path, so the only_user_dirs_resolves_user_locations scan passes and test builds only see a HOME the test sets. It also keeps your MSYS conversion and empty-HOME guard, and adds tests for the HOME preference, empty HOME, and MSYS HOME.

Verified on Windows 11 / Git Bash (x86_64-pc-windows-gnu):

  • cargo clippy --all-targets is clean. cargo test --all gives 3960 passed / 2 failed; both failures also fail on pristine develop on Windows (find_cmd::run_from_args_propagates_find_exit_status, stream::test_read_lines_lossy_preserves_lines_after_invalid_utf8).
  • Inflated savings metric, unreachable truncation log on Windows, and passthrough that doesn't pass through #3339 part 3 still reproduces on stable v0.51.0: rtk vitest run --config does-not-exist.config.ts prints 72 B (tee hint only). With this branch it prints 1881 B including vitest's own error.
  • Tee hint with Git Bash's HOME=/c/Users/<me>: v0.51.0 prints [full output: "$HOME/AppData/Local/rtk/tee/…_cargo_check.log"], and this branch prints [full output: ~/AppData/Local/rtk/tee/…_cargo_check.log], which resolves to the file.

To adopt it (this replaces the PR head with the rebased commits):

git fetch https://github.com/bharvey42/rtk rebase/3344-onto-develop
git checkout fix/passthrough-tracking-and-tee-path
git reset --hard FETCH_HEAD
git push --force-with-lease

Maintainers can push it too, since edits from maintainers are enabled on this PR.

SomSamantray and others added 6 commits October 8, 2026 16:02
…loss

When PlaywrightParser::parse falls back to Passthrough (all parsing
tiers failed), the run was tracked through the same savings timer used
for successful parses -- so the truncation-driven size difference was
recorded as token savings even though nothing was parsed. Route genuine
Tier-3 failures through the existing record_parse_failure_silent +
track_passthrough plumbing instead.

Also build the passthrough fallback content from the combined
stdout+stderr rather than the parser's stdout-only truncation, so a
failure reported only on stderr (empty stdout) isn't silently dropped.

Part of rtk-ai#3339.
Same fix as playwright applied to pnpm list and pnpm outdated: genuine
Tier-3 parse failures now route through record_parse_failure_silent +
track_passthrough instead of being counted as token savings, and the
passthrough fallback content is built from the combined stdout+stderr
so a stderr-only failure isn't dropped.

pnpm list's Tier-1/Degraded guard and tracking stay anchored to stdout
alone (unchanged from before this fix) -- only the Tier-3 arm uses the
combined stream, so a stderr notice alongside a successful parse
doesn't inflate the reported savings ratio. pnpm outdated's existing
"All packages up-to-date" empty-display fallback is untouched.

Part of rtk-ai#3339.
Same fix as playwright/pnpm applied to vitest/jest run. Adds an
is_parse_failure field to FormattedTestOutput, set only in the genuine
ParseResult::Passthrough arm inside format_test_output -- distinct
from the explicit user-requested passthrough path (an explicit
--reporter override), which is not a failure and keeps its existing
behavior. run_test branches its tracking call on that field: genuine
failures route through record_parse_failure_silent +
track_passthrough; everything else keeps the existing timer.track
call. The passthrough fallback content is now built from the combined
stdout+stderr instead of stdout alone.

Part of rtk-ai#3339.
…rators

The tee recovery hint (e.g. [full output: ~/path/to/log]) strips the home
prefix against the OS home-directory API, but the shell that reads the hint
expands ~ and $HOME against its own HOME. On Windows those differ: Git
Bash/MSYS set HOME themselves (commonly /c/Users/name), and on redirected or
roaming profiles it need not be the profile folder at all, so the hint can
point at the wrong file.

- Prefer the HOME environment variable (read through user_dirs::env_path,
  so test builds see only what the test sets) when stripping the home
  prefix, falling back to user_dirs::home. Convert an MSYS-style HOME to
  a native path before comparing, since passed through unconverted it
  would never match a native path via strip_prefix. Reject an empty HOME
  value, since an empty PathBuf's strip_prefix trivially matches any path.
- Normalize the home-relative portion to forward slashes in display_path,
  so a home-relative Windows path no longer needs the quoted "$HOME/..."
  form just because of its separators.

Rebased onto the tee.rs -> tee_file.rs split; the change now lives in
tee_file.rs's display_path.

Part of rtk-ai#3339.
Based on bharvey42's rebase of this branch (rebase/3344-onto-develop,
authorship kept). The only conflict was two test blocks added side by
side in vitest_cmd.rs; both are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pszymkowiak
pszymkowiak force-pushed the fix/passthrough-tracking-and-tee-path branch from 4b958d9 to 92b8a4b Compare November 23, 2026 19:22
@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hi @SomSamantray, thanks for this, and sorry it sat for so long.

Your branch conflicted with develop, so I updated it for you (edits from maintainers are enabled). It now holds @bharvey42's rebase of your four commits, with your authorship kept (rebase/3344-onto-develop), plus a merge of the current develop. Thanks @bharvey42 for doing the port. If you have local work on this branch, run git fetch and git reset --hard origin/fix/passthrough-tracking-and-tee-path before pushing again.

I tested it against develop. When vitest fails at startup with its error on stderr:

  • develop shows only [RTK:PASSTHROUGH] vitest parser: All parsing tiers failed, and rtk gain counts the failed run as 100% savings.
  • With this branch, vitest's real error comes through, and the run is no longer counted as savings.

fmt, clippy and the vitest/pnpm/playwright/tee tests pass on Linux. The tee tests for the Git Bash HOME (MSYS path, empty HOME) pass on native Windows. I'll merge once CI is green on the updated branch.

@pszymkowiak
pszymkowiak requested review from KuSh and aeppling November 23, 2026 20:10
… and booked

Replay what each tool really printed through a stand-in on PATH and read back
the rows rtk wrote: a stderr-only startup error reaches the user, the run is
booked as a parse failure with no tokens, and a parsed pnpm outdated run is
still booked as savings. The passthrough rows now use passthrough_label, so the
stored command is the one that ran, without a "(passthrough)" suffix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1 of 3 — APPROVED, follow-ups filed

Claim: when the playwright, pnpm list/outdated and vitest/jest parsers all fail, rtk shows the tool's stdout and stderr together and books the run as a parse failure instead of savings; the tee hint's ~/ resolves against the invoking shell's HOME, with forward slashes.
Scope: accept (round 1, frozen); maintainer PRs: none overlap.
Ran: real vitest 3.2.4, jest 29.7, playwright 1.56.1 and pnpm 12.15 in Docker, 22 cases × develop c43b5c4 / head 92b8a4b, each through rtk rewrite first: startup errors reported on stderr only, a broken package.json, passing and failing runs, --reporter=verbose, non-test subcommands, an over-cap tier-3 run, plus tee mode on Linux with 5 HOME/XDG_DATA_HOME layouts; invariants: under the hook, split streams, every decision, over-cap + accounting, non-default targets; savings on parsed runs unchanged on both sides (41–91%) vs 20% floor (CONTRIBUTING.md)
Pins: 17 decisions, 17 mutated, 12 survived the PR's suite (tier routing and stdout→combined content in playwright, pnpm list and pnpm outdated, vitest's booking branch, the four fallback_succeeded flags); the fixup kills the 6 reachable ones, the rest make no difference on any real output found. The 2 Windows-only decisions (MSYS conversion, separator normalization) were read, not mutated; their tests run on both Windows jobs.
Matrix: executed this round; pin check: executed this round
CI @f5f63163: all green

Blocks merge (0, frozen at round 1)

None.

Optional — will not hold merge

  • Non-test invocations now write a parse-failure row too: rtk playwright install --dry-run, rtk playwright show-report <dir> and rtk jest --listTests each add one, with output unchanged. They already print the [RTK:PASSTHROUGH] warning on develop; evidence added to #1585.
  • fallback_succeeded is !shown.trim().is_empty() here, while the fallbacks in lib.rs pass true whenever the raw output reached the user. No real run I found produced an empty shown, so it never differs today.
  • playwright joins the streams as stdout + "\n" + stderr, so an empty stderr adds one trailing newline (show-report: 30 → 31 B).

Filed as follow-ups

  • #2658 rtk pnpm outdated exits 0 when pnpm fails — pre-existing; absorbed, comment added (with this PR the broken-manifest error is now shown, the exit status is still 0).
  • #1585 non-test playwright subcommands go through the result parser — pre-existing; absorbed, comment added.
  • #5283 rtk pnpm list passes a nameless project through and counts the project itself as a package — outside this PR's hunks; filed.
  • #5284 tier-3 output over passthrough_max_chars is cut with no recovery hint when the command exits 0 — pre-existing; filed.

Checked and correct — no need to re-verify

  • A startup error on stderr: develop prints only the recall hint (43 B); the head prints the tool's error (vitest 1314 B, jest 1014 B, playwright 650 B), exit code 1 kept, and books rtk:passthrough … 0/0 plus one parse_failures row.
  • rtk pnpm outdated on an invalid package.json: develop prints "All packages up-to-date"; the head prints ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR.
  • Parsed runs (vitest pass/fail, jest, playwright test, pnpm list, pnpm outdated) and --reporter=verbose: byte-identical output and identical savings rows on both sides.
  • Tee hints on Linux are identical on both sides for HOME, HOME with a trailing slash, XDG_DATA_HOME outside HOME, and a data path with a space ("$HOME/My Data/…"); every hint resolves in bash.
  • Merge with develop 9a94ec1: fmt, clippy and the full suite pass.

Your questions

None asked.

Next

fixup f5f6316 pushed, code-reviewed: adds tests/js_parse_failure_tracking_test.rs (8 cases replaying captured vitest, playwright and pnpm streams through a stand-in on PATH and reading back the rows rtk wrote) and books the new passthrough rows with tracking::passthrough_label, so the stored command reads rtk:passthrough pnpm outdated instead of rtk:passthrough pnpm outdated (passthrough) — approving.
Rounds: 1/3. Threads: 0 open, 0 resolved this round.

The PR body has no closing keyword, so #3339 stays open after the merge and needs closing by hand.

@KuSh
KuSh merged commit e87da19 into rtk-ai:develop Nov 25, 2026
16 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Nov 25, 2026
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.

5 participants