Skip to content

fix(tier3): preserve exit status for quoted script paths - #727

Merged
rng1995 merged 25 commits into
NVIDIA:mainfrom
Afloat16:fix/preserve-quoted-script-exit-status
Nov 23, 2026
Merged

rng1995 merged 25 commits into
NVIDIA:mainfrom
Afloat16:fix/preserve-quoted-script-exit-status

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A single command such as python 'scripts/my task.py' is recognized as invoking the expected script, but command_succeeded reports it as not checked even when the tool recorded exit code 0 or 2. Exit-status attribution rejoins decoded shell tokens with spaces, losing the quoted path boundary before it checks the invocation again.

For a single shell-command segment, use the original command text for the existing invocation check. Keep the existing rejection of unmodelled shells, control syntax and inline shell programs, and leave compound-command attribution unchanged.

Current review follow-up

Current head: fa1db9974a36ceeca8cf6f12fe29479a702afff8, including the quoted-hash fix in cd2232b329cb0d1f230d4ffba7b562ed7424572e and a merge of main a3bb7e91a325c92e1d2e05bcd716e1139e3624f2 that preserves both Unreleased entries. Every PR code/test blob is unchanged by that merge.

The comment scanner now rejects an unmodelled expansion only when it would remove comment text. With no comment removed, original spelling and existing status attribution are preserved, including quoted literal hashes next to command substitution, backticks or parameter defaults. Actual pipelines and ambiguous nested comment boundaries remain unattributed. The earlier split-identifier, ANSI-C quote-state and Bash 3.2 guard fixes remain in place.

  • Native Bash/Zsh regressions reproduce 32 failures with 252 passing controls on the preceding source, then all 284 quoted-status cases pass with the fix, including six new real-pipeline controls.
  • 2,463 tests pass across seven complete related modules: quoted status, declarative checks, declarative coverage, shell lexing, invocation evidence, shared adapters and invocation differential.
  • Full Ruff, changed-file formatting, diff checks, source/archive OSS scans and isolated wheel/sdist builds pass on the tested fix tree.
  • Validation used Linux with Python 3.12.14 and native Bash/Zsh. macOS Bash 3.2 was not run locally. Hosted CI remains the integration gate; no complete repository-suite pass is claimed.

Original verification

Four new regression cases fail on unchanged base 8fe9723: single- and double-quoted paths, each with success and nonzero exit status. Three additional controls retain unavailable status for pipelines, || true, and a following unrelated command.

python -m pytest tests/tier3/test_quoted_script_status.py tests/tier3/test_declarative_checks.py tests/reporting/test_declarative_coverage.py -q — 60 passed.

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes (Unreleased changelog)
  • Ran make lint equivalent: python -m ruff check src tests
  • Full make test did not complete successfully in this environment (see below)
  • Ran make build equivalent: python -m build (wheel and sdist)
  • Did not add credentials, private datasets, or proprietary benchmark content

The unchanged base 8fe9723, tested with python -m pytest -x -q, stops after 456 passed and 19 deselected at tests/ci/test_gateway_benchmark_workflows.py::test_gitlab_enriched_tier1_applies_the_keyless_job_baselines[extra0-expected0]. The sandbox has no /tmp, while that workflow fixture explicitly invokes mktemp -d /tmp/skillevaluator-enriched-tier1.XXXXXX. The same test fails for the same reason on the retry branch. No full-suite pass is claimed.

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@chrisknvidia chrisknvidia 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.

Thanks, this is a real gap and the fix is the right size. I reproduced it on main: python 'scripts/my task.py' with a recorded exit code comes back as "status could not be attributed", and with this change it reports the recorded 0 or 2. I checked a range of quoting styles (unquoted, single, double, escaped space, env prefix, redirects, pipelines, || true, ; echo, compound &&) and only the quoted-path-with-spaces cases change; everything else gives the same answer as before. Nothing new is executed here, and the single-segment branch runs after the same guards as before, so it does not widen what gets credited. The four regression cases fail on main and pass here; the three control cases pass on both. One small note inline about compound commands. CHANGELOG entry is under Unreleased.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>

@rng1995 rng1995 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.

Thanks, @Afloat16, for preserving exit status for quoted script paths. I independently reproduced the remaining shell-negation issue: a script that exits 2 under ! python 'scripts/my task.py' 2 gives the shell status 0, and the new single-segment branch incorrectly passes command_succeeded; a script that exits 0 is incorrectly failed with shell status 1. The base leaves these quoted-path cases unclassified. Please keep negated commands unattributed unless the script's own status is known.

Validation: 31 quoted-path and declarative-check tests passed, plus an actual local-shell reproduction of both inverted outcomes. The existing issue remains unresolved; this review adds no duplicate inline thread.

rng1995 and others added 4 commits November 17, 2026 09:58
Address the outstanding review with focused regression coverage and
synchronize current main, keeping the release note under Unreleased.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Exercise escaped directory spaces independently from filename detection,
assert that each script actually ran, and skip the POSIX shell fixture
where bash execution is unavailable.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Retain the latest release notes and merged fixes alongside this change.

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@rng1995 rng1995 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.

Thanks @Afloat16 for this contribution! I reviewed 45ee1a927f. I reproduced the problem on main, confirmed this change fixes it, and ran the new and related tests on this head (all pass). I left 2 inline comments (1 P2, 1 P3) to address before this can be approved.

Treat |& as a pipeline separator and skip the shell time keyword and -p
options before checking for negation. Keep shell-tail and inverted statuses
unattributed while retaining the quoted single-command fix.

Add real Bash regressions for quoted and unquoted stderr pipelines and
both timed-negation forms. All 15 added failure cases reproduce on the
previous source; 2,154 related tests and full src/tests Ruff pass.

Merge main and retain this change under Unreleased.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16
Afloat16 requested a review from rng1995 November 18, 2026 03:12
@rng1995
rng1995 enabled auto-merge (squash) November 18, 2026 05:14
Signed-off-by: Afloat <ShuffleMonkey@163.com>
auto-merge was automatically disabled November 18, 2026 06:06

Head branch was pushed to by a user without write access

Keep real shell comment markers and physical command boundaries while
excluding their text from the exit-status separator scan. Preserve literal
hash arguments and real stderr pipelines, with native Bash and Zsh cases.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Stop comment-boundary inference at active shell expansions and backticks.
Preserve literal and escaped forms and keep the default tokenizer unchanged.
Record actual Bash and Zsh pipeline exits in the regression coverage.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Respect the recorded Bash and Zsh continuation behavior while preserving
exit-status attribution for plain braced identifier arguments.

Signed-off-by: Afloat <ShuffleMonkey@163.com>

@rng1995 rng1995 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.

Thanks @Afloat16 for this contribution and the updates! I re-checked 750b2abff9: 2 of 2 earlier comments are resolved. I left 4 follow-up comments inline (1 P1, 1 P2, 2 P3).

Keep no-comment commands on the existing tokenizer path, accept continued braced identifiers, use an ANSI-C state label compatible with the source scan, and gate stderr-pipeline tests on Bash 4.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Preserve existing status attribution when the comment scanner removes no text, while keeping ambiguous comment boundaries and real pipeline statuses unattributed.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Resolve only the competing changelog insertion. Preserve the reviewed pull request implementation, tests, and documentation unchanged while retaining upstream updates.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
@rng1995

rng1995 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@Afloat16 - Please resolve merge conflict to merge the PR.

Synchronize with NVIDIA/SkillEvaluator main f867b7f.
Retain this PR's entry under Unreleased and preserve published release history.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict in 3f50106dd9 by merging current main f867b7f311. The PR's release note remains under Unreleased, and published release history is unchanged.

The implementation and regression-test patch has the same stable patch ID before and after synchronization. On the exact merged tree, 316 passed in the focused checks (Linux, Python 3.12.14); full-source Ruff, changed-file formatting, and git diff --check pass.

Hosted checks on this head have completed: 21 successful, 2 skipped, no failures. The CI workflow passed.

rng1995 and others added 4 commits November 20, 2026 10:09
CHANGELOG.md: keep main's Unreleased content unchanged and keep this PR's
quoted-script-status bullet as the first entry under Unreleased > Fixed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
… comments

Skip the "--" option terminator after "time [-p]" when looking for a
negation, so "time -- ! cmd" and "time -p -- ! cmd" stay unattributed
instead of passing a check with the inverted shell status.

Only treat a comment as unmodelled when it follows a command
substitution, backtick or non-identifier parameter expansion. A comment
that comes before the expansion cannot be misread by nested quoting, so a
leading comment line no longer drops the script's recorded status.

Add native Bash and Zsh tests for both, with controls that keep a comment
after an expansion unattributed. Tests that need "time --" skip on Bash
versions that read "--" as a command name. Update the CHANGELOG entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Resolve the CHANGELOG.md conflict by keeping main's entries and this change's entry under Unreleased.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Resolve the CHANGELOG.md conflict by keeping main's entries and this change's entry under Unreleased.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>

@rng1995 rng1995 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.

Thanks @Afloat16 for this contribution! I re-checked c1e38b48c: I merged current main into the branch (the only conflict was CHANGELOG.md, resolved by keeping main's entries and this entry under Unreleased), confirmed that every earlier review comment is addressed in the code, and ran this PR's tests and ruff, which pass. I found nothing new. Approving. I also pushed one follow-up commit for two edge cases found while re-checking: time -- ! cmd (and time -p -- ! cmd) is no longer given a recorded exit status, and a comment that comes before a command substitution no longer drops the script's recorded status. Both are covered by native Bash and Zsh tests. The optional note about compound cd dir && python 'a b.py' paths is left as a follow-up.

@rng1995
rng1995 merged commit 17b4a59 into NVIDIA:main Nov 23, 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.

3 participants