Skip to content

fix(rewrite): localize opaque pipeline grouping - #4285

Open
tayfuryldz wants to merge 1 commit into
rtk-ai:developfrom
tayfuryldz:fix/4283-localize-pipeline-grouping
Open

tayfuryldz wants to merge 1 commit into
rtk-ai:developfrom
tayfuryldz:fix/4283-localize-pipeline-grouping

Conversation

@tayfuryldz

Copy link
Copy Markdown
Contributor

Closes #4283

Summary

  • scope the opaque-grouping safety gate to the pipeline that actually contains grouping
  • preserve an opaque trailing clause byte-for-byte after rewriting an earlier independent pipeline
  • keep pipelines containing grouping themselves conservative and raw
  • add regression coverage for case clauses and grouped trailing clauses

Validation

  • cargo fmt --all -- --check
  • cargo test --offline --no-default-features discover::registry::tests::test_pipeline_ -- --nocapture: 6 passed
  • cargo test --offline --no-default-features test_safe_pipeline_before_case_rewrites_producer -- --nocapture: passed
  • git diff --check

@rtk-release-bot rtk-release-bot Bot added the wrong-base PR targets master instead of develop label Sep 26, 2026
@rtk-release-bot

Copy link
Copy Markdown
Contributor

Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch.

See CONTRIBUTING.md for details.

@CLAassistant

CLAassistant commented Sep 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes the shell command rewrite logic so the opaque-grouping safety gate only applies to the specific pipeline that actually contains grouping, rather than affecting unrelated independent pipelines. It also preserves an opaque trailing clause byte-for-byte when rewriting an earlier independent pipeline, and adds regression tests for case clauses and grouped trailing clauses.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4283


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@tayfuryldz
tayfuryldz changed the base branch from master to develop September 26, 2026 19:12
@ellugia

ellugia commented Oct 20, 2026

Copy link
Copy Markdown

Thanks for working on this. I investigated this issue using Codex, under my supervision, on Windows with PowerShell and RTK 0.50.0. All command execution and source inspection described below were performed through Codex.

Confirmed on RTK 0.50.0

Inside a valid Git repository, this block produces unfiltered Git output and no corresponding rtk git status history entry:

git status; rtk gain --history; Write-Output (Get-Date) | Out-Null

The pipeline is separate from git status, but its combination of parentheses and | disables rewriting of the whole line.

These controls produced condensed Git output and a corresponding history entry:

git status; rtk gain --history
git status && rtk gain --history
git status; rtk gain --history; Write-Output (Get-Date)
git status; rtk gain --history; Write-Output 'literal' | Out-Null
git status; rtk gain --history; Write-Output '(literal)' | Out-Null

Parentheses and the pipe in separate statements still reproduced the failure:

git status; rtk gain --history; Write-Output (Get-Date); Write-Output 'literal' | Out-Null

I also reproduced it with a practical PowerShell expression:

git status; rtk gain --history; Get-ChildItem -LiteralPath (Join-Path $env:LOCALAPPDATA 'rtk') -Force | Select-Object Name

Direct rtk rewrite checks agreed:

  • Parentheses without a pipe: returned a rewrite containing rtk git status.
  • A pipe without parentheses: returned a rewrite.
  • Parentheses combined with a pipe: exit code 1, no rewrite.

Source inspection of this PR

I used Codex to download the PR branch at commit 24a028310082d0cedbf0fd57b1734001681e3965 and inspect rewrite_compound and the added regression tests.

Based on that inspection, the localized pipeline_has_opaque_grouping check appears to address the main PowerShell example: the earlier independent git status can be rewritten while the grouped PowerShell pipeline remains unchanged. The Join-Path example appears to follow the same path.

I have not compiled or executed the PR branch. The available environment has no Rust/Cargo toolchain, so this assessment is based on source inspection, not an executed validation. I therefore cannot confirm that these cases pass with the patch.

Would it be useful to add the PowerShell examples above as regression tests, asserting that the independent Git command is rewritten while the grouped pipeline is preserved?

Tracking caveat

The Codex Windows sandbox provided a different %LOCALAPPDATA% for each tool invocation, resulting in separate RTK history databases. I checked execution and history within the same invocation to distinguish a genuine missed rewrite from consulting a different database.

Investigation method

The entire investigation was carried out using Codex under my supervision, including command execution and source inspection. The distinction above between observed results on RTK 0.50.0 and the source-only assessment of this PR is intentional.

No RTK configuration was changed during these checks.

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

Labels

bug-fix needs-rebase rewrite wrong-base PR targets master instead of develop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A case (or subshell / brace group) anywhere on a line disables rewriting of every pipeline on that line

3 participants