Skip to content

exec.sh: refuse arguments after the script; --help anywhere (#820) - #822

Open
MendixMau wants to merge 2 commits into
masterfrom
triage/820-exec-trailing-args
Open

MendixMau wants to merge 2 commits into
masterfrom
triage/820-exec-trailing-args

Conversation

@MendixMau

@MendixMau MendixMau commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Fixes #820

Direct lane

What changed and why (one paragraph):
project-bin/exec.sh refused an unknown --flag only when it came before the script. Anything after the script path was ignored, so exec.sh mdlsource/NNN-x.mdl --help (an agent checking usage, seen in a simulated build run on 2026-11-20) applied the script to the model. The script also landed in BUILD-LOG. Now, once the leading flags and the script are parsed and --patch is not in use: --help / -h after the script prints usage and exits 2 (the script is NOT run; exit 0 means "applied, gate passed" once a script is named), and any other argument after the script exits 2 with ✗ unexpected argument after the script: '<arg>' — nothing was executed. Both happen before the lock, --commit-first, the snapshot, the BUILD-LOG write and any mxcli call. A bare or leading exec.sh --help / --commit-first --help (no script before it) prints usage and exits 0. Both cases are documented in the header's exit-code table and its NO LINE note. --patch <script> [args...] is unchanged: its args go to the patch script, including a --help. The advisory modes (--change-class, --watch-compat, --subjects) take one script, so they also refuse a trailing argument. This is a deliberate new exit 2 for a misuse that used to run. After the independent review (MERGE-AFTER-FIX), <script> --help exits 2, so the PR now follows the issue's proof line.

Impact

Row Answer
Process — human steps or gates added/removed; does anything new block; new stage artifacts One new refusal: exec.sh <script> <anything> outside --patch now exits 2 (a usage error per the header's exit-code table) instead of running. It touches nothing. `<script> --help
Dependencies — shared files touched; order vs other open PRs; new tools/platform assumptions; new artifact reads + their producer Touches project-bin/exec.sh (arg parsing, ~20 lines, right after the leading-flag loop). It may need a rebase against other open exec.sh PRs, but there is no logical dependency. It uses bash ${@:2}, which bash 3.2 (macOS) supports. No new tools and no new artifact reads.
Context cost none: no routed or always-loaded file touched (render-routing.sh --check: baseline 65568 words / budget 80000, unchanged).
Behaviour n/a: scripts only (the usage text is printed on demand, not loaded)
Runtime n/a. One [ $# -gt 1 ] test per exec, with no process start.

Time cost: per exec · ~0 s (one shell test, no fork) on Linux container · can force rework: n · offset: maintainer OK

Field evidence:
No field run against a real model: mxcli is not available in this environment (the download returned 403). The evidence is the simulated-run finding in #820, where exec.sh <script> --help re-applied the script, plus a fixture whose stubbed mxcli records every call:

tests/wave2/test-exec-lock-watch.sh, new #820 section:

  • exec.sh s.mdl --help, exec.sh s.mdl -h and exec.sh --commit-first s.mdl --help each exit 2 and print usage. mxcli is not called, BUILD-LOG is unchanged and no snapshot is taken.
  • Bare exec.sh --help exits 0 and prints usage. mxcli is not called, BUILD-LOG is unchanged and no snapshot is taken.
  • exec.sh s.mdl --bogus exits 2 and names the argument. mxcli is not called, BUILD-LOG is unchanged, no snapshot is taken and no lock is left. --subjects s.mdl extra also exits 2.
  • Control: plain exec.sh s.mdl exits 0, reaches mxcli exec and writes its BUILD-LOG row.
  • --patch args-patch.sh --help --x 1: the patch script receives --help --x 1, and exec.sh prints no usage of its own.
exec.sh test-exec-lock-watch.sh
origin/master PASS=134 FAIL=18 (every #820 case fails: the script ran, mxcli check was called, BUILD-LOG changed, a snapshot was taken, --bogus exit 0)
this branch PASS=157 FAIL=0 (after the review fix; it was 152/0 before the bare---help case was added)

The other fixtures that target exec.sh, all green on the branch: test-exec-approval (47/0), change-class (21/0), check-refusal (10/0), cr-brief-warn (19/0), crash-rollback (13/0), gate-kind (32/0), gate-log (24/0), gate-retry (52/0, including the L usage cases), hash-verify (49/0, --patch, rerun after the review fix), lint-autorestore (17/0), lint-diff (9/0), process-budget (4/0), result-line (72/0), step-times (7/0), subjects (6/0).

Also run: bin/check-scripts.sh (145/145 parse), bin/check-pr-discipline.sh origin/master (clean), the leak guard (clean) and bin/check-portability.sh (clean).

  • No client data anywhere in the diff
  • Size cap: 3 files, ~80 lines
  • Test tier reached: T1 (stubbed-mxcli fixture). T2/T3 were not reached because no mxcli is available here.
  • For a new/changed instrument: both layouts are covered because the check runs before find_mpr and is layout-independent. Both platforms are considered: ${@:2} is bash 3.2-safe and there is no new external tool. The golden input is the CLI argument line itself; there is no tool output to capture.
  • For a new skill: n/a
  • CHANGELOG.md line appended, credited to the simulated requirements-driven build run (2026-11-20)
  • New bug entries: n/a

Review: MERGE-AFTER-FIX — the fixes are pushed (90d6e5d) and await re-review

https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC


Generated by Claude Code

Arguments after the script path were silently ignored, so
`exec.sh <script> --help` (an agent checking usage) applied the script
to the model. Outside --patch, --help/-h now print usage and exit 0,
and any other trailing argument exits 2 before the lock, commit,
snapshot, BUILD-LOG and mxcli. --patch args still pass through.

Fixture: tests/wave2/test-exec-lock-watch.sh (master 134 pass / 18 fail,
branch 152 / 0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
@MendixMau

Copy link
Copy Markdown
Owner Author

Review: MERGE-AFTER-FIX — the fix is correct and breaks no caller, but exec.sh <script> --help now exits 0. In this script's own exit-code table, 0 means "applied, gate passed".
Value: Fixes #820 as reported. The new block at project-bin/exec.sh:365-370 runs before --change-class/--subjects, the lock, --commit-first, the snapshot, BUILD-LOG and mxcli. Nothing is overbuilt (about 20 lines plus a fixture). Two extra cases are also caught: exec.sh a.mdl b.mdl used to run only a.mdl without saying so, and now exits 2. --patch --help now prints usage where it used to exit 2.
Regression risk: Low. I searched bin/, project-bin/, templates, skills/ (generated rules included), agent stubs and wire-agents text. No caller passes an argument after an MDL script:

  • affected-tests.sh:246 and mdl-rules.sh:225 call --subjects <one file>.
  • doctor.sh:433 and the wf-*.py headers use --patch with args, which still pass through (exec.sh:365 is gated on PATCH_MODE).

So a synced project gets no new exit 2 from any toolkit caller. The check is plain arg parsing that runs before find_mpr, so it is the same on both layouts. ${@:2} works on bash 3.2. No gate verdicts or parsed output change.
Correctness: I found no bugs. Fixtures run in the detached worktree:

The --patch passthrough assertion is real: the patch script writes out the argv it received. No captured golden input is needed, because nothing here parses tool output.

On the --help exit code: a bare exec.sh --help exiting 0 is fine. The trailing form is the misuse #820 describes. An agent that follows the header's "branch on the code" (exec.sh:24-36, repeated in skills/iterative-build-loop.md) reads 0 as "applied". This exit-0 path is not listed in the exit-code table or in the "NO LINE" list (exec.sh:51). The issue's Proof asked for exit 2, and that is the safer answer.
Context cost: 65568 → 65568 baseline words (render-routing.sh --check on master and on the PR head). No routed file is touched.
Time cost: about 0 per build row. It adds one [ $# -gt 1 ] test and no fork.
Exact fixes required:

  1. At project-bin/exec.sh:366, --help/-h that comes after a script should still print usage but exit 2, not 0. Leading --help (exec.sh:335, :353) stays at 0. Update the three #820 loop cases in tests/wave2/test-exec-lock-watch.sh to expect rc 2 for the trailing form, and add one case for bare exec.sh --help → 0.
  2. In the header (exec.sh:30 and the NO LINE note at :51), add: "--help/-h before the script: usage, exit 0, no MXTK-RESULT line; any argument after an MDL script, --help included: exit 2." Change the CHANGELOG line to match.

Generated by Claude Code

Exit 0 means "applied, gate passed" when a script is named, so usage
printed after a script now exits 2 (the script is still not run). A
bare or leading `exec.sh --help` keeps exit 0. Header exit-code table
and the NO LINE note document both; fixture updated (+ bare --help case).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
@MendixMau

Copy link
Copy Markdown
Owner Author

Review: MERGE — re-review at 90d6e5d: both MERGE-AFTER-FIX items are fixed. A trailing --help now exits 2 without running anything, and the header, the NO LINE note and the CHANGELOG all document it. Merge only after the checks CI run finishes green; it was still in progress when I wrote this.
Value: Unchanged from the first review. Fixes #820: arguments after an MDL script are refused before the lock, --commit-first, the snapshot, BUILD-LOG and mxcli. In detail:

  • exec.sh <script> --help|-h prints usage, adds a stderr line saying the script was NOT run, and exits 2 (project-bin/exec.sh:369).
  • A bare or leading --help, with no script before it, still exits 0 (exec.sh:337, :355).
    Regression risk: Low, and the fix pass did not change it. No toolkit caller passes arguments after an MDL script:
  • affected-tests.sh:246 and mdl-rules.sh:225 call --subjects <one file>.
  • doctor.sh:433 and the wf-*.py headers use --patch, which still passes its args through.

The check is plain arg parsing that runs before find_mpr, so it behaves the same on both layouts. ${@:2} works on bash 3.2. The PR merges cleanly onto origin/master (git merge-tree).
Correctness:

  • Fix 1: in tests/wave2/test-exec-lock-watch.sh:263-278, the three trailing-help cases (--help, -h, --commit-first s.mdl --help) now expect rc 2. Each also asserts that mxcli was not called, BUILD-LOG is unchanged and no snapshot was taken. A new bare --help case asserts rc 0, the usage text, no mxcli call, no BUILD-LOG change and no snapshot.
  • Fix 2: the exit-code table at exec.sh:31-33 and the NO LINE note at exec.sh:59 both cover the two --help forms, and the CHANGELOG line matches.
  • Fixture runs in the detached worktree: lock-watch 157/0, hash-verify (--patch) 49/0. bash -n passes.

No new bugs.
Context cost: 65568 → 65568 baseline words, measured in the first review. The fix commit changes no routed file.
Time cost: about 0 per build row (one [ $# -gt 1 ] test, no fork).


Generated by Claude Code

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.

[bug] exec.sh script.mdl --help runs the script: arguments after the script are silently ignored

2 participants