Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m
`docs/RELEASE-PROCESS.md` §8.

## Unreleased
- fix(exec): **`exec.sh <script> --help` no longer applies the script (#820)**: arguments after the script path were silently ignored, so an agent checking usage with `exec.sh mdlsource/NNN-x.mdl --help` (or a flag typed after the script) ran a real model write. Now `--help` / `-h` after the script prints usage and exits 2 (the script is not run; exit 0 stays "applied, gate passed"), a bare `exec.sh --help` exits 0, and any other argument after the script exits 2 (`unexpected argument after the script: '<arg>' — nothing was executed`), both before the lock, the commit, the snapshot, BUILD-LOG and mxcli; `--patch <script> [args...]` still passes its args through. Fixture: `tests/wave2/test-exec-lock-watch.sh` — simulated requirements-driven build run, 2026-11-20
- new(doctor, bug ledger): **a guard for mxcli's silent MxBuild fallback**: when the project's Mendix version is not in `~/.mxcli/mxbuild/` (and no Studio Pro of that version exists), `mxcli docker build` / `docker check` fall back to the newest cached MxBuild and print its path but no version warning (`run --local` is exact-or-refuse); `bin/doctor.sh` now warns, naming the model version, the cached ones and `./mxcli setup mxbuild -p <app>.mpr` (`mxtk_mxbuild_cache_gap`, warning only, never changes a gate). Ledger entry `BUG-DRAFT-mxbuild-silent-version-fallback`; upstream issue not filed. — a four-app Mendix build (field run), independent review
- fix(gate-check): **a fresh clone no longer FAILs Stage 3 as "stale render"**: `blueprint.html` / `process-map.html` freshness used `[ render -ot source ]`, a nanosecond mtime compare, and a checkout stamps files in directory order (`process-map.html` lands before `process-model.json`), so an unedited project read stale on every clone (reproduced: 200-wireframe checkout, 10 of 10 clones). New `bin/lib/render-fresh.sh` keeps `-ot` as the first test (a pass never flips, no git call) and, only where `-ot` would FAIL, asks git once per render (one `log`, one `status`) whether the source was committed after the render's commit; measured 0.19 s for 200 sources all `-ot`-stale on a 300-commit history (a per-source git version cost 12.9 s). Limit: a depth-1 clone cannot see a genuinely stale render. Field run: a four-app Mendix build checked out on a second machine. — a four-app Mendix build (field run), independent review
- fix(test-stack-up, e2e-harness-base): **the app port follows the app's configured port, and a multi-app start is no longer pinned to 8080**: with no `APP_PORTS`, `test-stack-up.sh` puts `RUN_LOCAL_APP_PORT`, then `APP_PORT` from the `.docker/.env` beside the `.mpr` (`apps/<App>/.docker/.env`; the project-root one as fallback) first, ahead of the old fixed `8080 8081 8084` tail. A fresh `run --local` start for a model under `apps/` with no handshake and no configured port used to fall back to 8080 for every app (`--app-port 8080`); it now exits 4 naming `RUN_LOCAL_APP_PORT`. `e2e-harness-base.md` states that a PAD/Docker runtime listens on 8080 *inside* the container only. Fixtures T28–T32 added. Field run: a four-app Mendix build on 8081–8084 whose fresh start failed with every app pinned to 8080. — a four-app Mendix build (field run), independent review
Expand Down
29 changes: 26 additions & 3 deletions project-bin/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
# 1 NOT applied, or rolled back: a refusal, a failed pre-exec check, a gate that failed or
# could not run, a patch that failed or was not verified. Also a PARTIAL application.
# Exception: a LINT ROSE under `Lint gate: hard` (write KEPT; read the last line).
# 2 usage error (no script, bad argument, missing or unrunnable file); nothing was touched
# 2 usage error (no script, bad argument, missing or unrunnable file); nothing was touched.
# Also `<script> --help|-h` (#820): usage is printed and the script is NOT run.
# Only a bare or leading `--help|-h` (no script before it) exits 0, with usage only.
# 4 applied and the gate passed, but LINT ROSE or LINT BLIND. The write is KEPT: do not
# re-apply it. The last line of output reads "gate passed, lint only". Opt-in: with
# `Lint gate: hard` in PROJECT.md a LINT ROSE exits 1 instead (write still kept, #496).
Expand All @@ -54,7 +56,7 @@
# blind lint could not run or measure (a blind rule, reverted rules, lint-gate fault, no baseline)
# skipped lint was skipped (SKIP_LINT) or bin/lint-gate.sh is not installed
# na lint never ran on this path (a refusal, a restored write, a --patch)
# NO LINE: exit 2 (usage error), a missing .mpr, and any abort under `set -e` before a verdict
# NO LINE: exit 2 (usage error, including `<script> --help`), `exec.sh --help` (exit 0, usage only), a missing .mpr, and any abort under `set -e` before a verdict
# (for example a failing snapshot step) print no MXTK-RESULT line. Read "no MXTK-RESULT line" as
# "no verdict reached", never as success. The line goes to STDOUT; some refusal text goes to
# STDERR, so capture both streams (2>&1) when reading a run.
Expand Down Expand Up @@ -322,8 +324,16 @@ mxtk_subjects() { # $1 = MDL script
# `[--commit-first] [--cr CR-NN]`; in that order commit-first committed the model and the run
# went on with "--cr" as its script path.
CR_ID=""; COMMIT_FIRST="${MXTK_COMMIT_FIRST:-0}"; PATCH_MODE=0; ADVISORY=""
exec_usage() { # stdout; --help / -h (#820)
echo "Usage: ./bin/exec.sh [--commit-first] [--cr CR-NN] <script.mdl>"
echo " ./bin/exec.sh [--commit-first] [--cr CR-NN] --patch <script> [args...]"
echo " ./bin/exec.sh --change-class | --watch-compat | --subjects <script.mdl> (advisory; writes nothing)"
echo "Flags go BEFORE the script. Only --patch takes arguments after it (passed to the patch script)."
echo "Exit codes and the MXTK-RESULT line: the header of bin/exec.sh."
}
while [ $# -gt 0 ]; do
case "$1" in
--help|-h) exec_usage; exit 0 ;;
--cr)
CR_ID="${2:-}"
case "$CR_ID" in
Expand All @@ -342,12 +352,25 @@ while [ $# -gt 0 ]; do
esac
done
case "${1:-}" in
--help|-h) exec_usage; exit 0 ;;
--*)
echo "✗ Unknown option or misplaced flag '$1' — nothing was committed, snapshotted or executed." >&2
echo " Usage: ./bin/exec.sh [--commit-first] [--cr CR-NN] <script.mdl>" >&2
echo " ./bin/exec.sh [--commit-first] [--cr CR-NN] --patch <script> [args...]" >&2
exit 2 ;;
esac
# Arguments AFTER the script (#820). They used to be ignored, so `exec.sh s.mdl --help` (an agent
# checking usage) or a flag typed after the script ran a real model write. Only --patch takes
# trailing args (they go to the patch script, so `--patch s.py --help` still passes --help on).
# Anywhere else: --help / -h prints usage and exits 2 (exit 0 means "applied, gate passed" when a
# script was named), anything else is refused — both before the lock, the commit, the snapshot,
# BUILD-LOG and mxcli. A bare/leading `exec.sh --help` (no script) exits 0.
if [ "$PATCH_MODE" != "1" ] && [ $# -gt 1 ]; then
for _a in "${@:2}"; do case "$_a" in --help|-h) exec_usage; echo "(usage only: the script was NOT run — exit 2)" >&2; exit 2 ;; esac; done
echo "✗ unexpected argument after the script: '$2' — nothing was executed." >&2
echo " Flags go before the script: ./bin/exec.sh [--commit-first] [--cr CR-NN] <script.mdl> (./bin/exec.sh --help)" >&2
exit 2
fi
if [ "$ADVISORY" = "--change-class" ]; then
[ -f "${1:-}" ] || { echo "Usage: ./bin/exec.sh --change-class <script.mdl>" >&2; exit 2; }
mxtk_change_class "$1"
Expand Down Expand Up @@ -528,7 +551,7 @@ MPR_BASE="${MPR##*/}"
NAME="${MPR_BASE%.mpr}"
SCRIPT="${1:-}"
[ $# -gt 0 ] && shift
# Remaining args go to the patch script, after the model path. An MDL run takes none.
# Remaining args go to the patch script, after the model path. An MDL run takes none (refused above, #820).
LOG_NAME="${SCRIPT##*/}"
[ "$PATCH_MODE" = "1" ] && LOG_NAME="patch: $LOG_NAME"

Expand Down
50 changes: 50 additions & 0 deletions tests/wave2/test-exec-lock-watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
# built in place with an app recorded asks app-restart.sh --if-client-gone and reports the
# restart done; E4 a full gate built in the copy (.mxtk/build/) asks nothing; E5 a Java
# action written with 0 units changed, E6 an opaque --patch script → restart still asked.
# #820: args after the script — --help/-h print usage (exit 2), anything else exits 2; neither
# calls mxcli, snapshots or writes BUILD-LOG; bare --help exits 0; a plain run still reaches mxcli; args after a
# --patch script still pass through to it.
#
# NOTHING here touches a real .mpr, mxcli, mxbuild or app. Throwaway git repos with stubs, as
# in test-bug07-08.sh.
Expand Down Expand Up @@ -69,6 +72,7 @@ echo "Snapshot saved: $D"
SNAP
cat > "$P/mxcli" <<'MXCLI'
#!/usr/bin/env bash
[ -n "${MXCLI_LOG:-}" ] && echo "$*" >> "$MXCLI_LOG"
case "${1:-}" in check) exit 0 ;; exec) echo "fake mxcli exec"; exit 0 ;; esac
exit 0
MXCLI
Expand Down Expand Up @@ -250,6 +254,43 @@ has " and named" "$OUT" "'--bogus'"
hasnt " and nothing executed" "$OUT" "fake mxcli exec"
( cd "$P" && git checkout -q -- mprcontents )

echo "-- arguments after the script (#820): --help prints usage (exit 2), anything else is refused"
# Field finding (simulated build, 2026-11-20): an agent ran `exec.sh <script> --help` to read the
# usage and the script was applied to the model — args after the script were silently ignored.
ML="$WORK/mxcli.calls"
blog() { cat "$P/docs/BUILD-LOG.md" 2>/dev/null | cksum; }
for t in "--help" "-h" "--commit-first --help"; do
rm -f "$ML"; B0="$(blog)"; NSNAP="$(ls "$P/.mpr-snapshots" | grep -c .)"
case "$t" in --commit-first*) OUT="$(MXCLI_LOG="$ML" run "$P" --commit-first mdlsource/test.mdl --help)" ;;
*) OUT="$(MXCLI_LOG="$ML" run "$P" mdlsource/test.mdl "$t")" ;; esac; RC=$?
[ "$RC" -eq 2 ] && ok "script $t: exit 2 (usage only, not run)" || bad "script $t: rc $RC (want 2)"
has " prints the usage" "$OUT" "Usage: ./bin/exec.sh"
[ ! -s "$ML" ] && ok " mxcli never called" || bad " mxcli was called: $(cat "$ML")"
[ "$(blog)" = "$B0" ] && ok " BUILD-LOG unchanged" || bad " BUILD-LOG changed"
[ "$(ls "$P/.mpr-snapshots" | grep -c .)" = "$NSNAP" ] && ok " no snapshot taken" || bad " a snapshot was taken"
done
rm -f "$ML"; B0="$(blog)"; NSNAP="$(ls "$P/.mpr-snapshots" | grep -c .)"
OUT="$(MXCLI_LOG="$ML" run "$P" --help)"; RC=$?
[ "$RC" -eq 0 ] && ok "bare exec.sh --help: exit 0" || bad "bare --help: rc $RC (want 0)"
has " prints the usage" "$OUT" "Usage: ./bin/exec.sh"
[ ! -s "$ML" ] && ok " mxcli never called" || bad " mxcli was called: $(cat "$ML")"
[ "$(blog)" = "$B0" ] && ok " BUILD-LOG unchanged" || bad " BUILD-LOG changed"
[ "$(ls "$P/.mpr-snapshots" | grep -c .)" = "$NSNAP" ] && ok " no snapshot taken" || bad " a snapshot was taken"
OUT="$(MXCLI_LOG="$ML" run "$P" mdlsource/test.mdl --bogus)"; RC=$?
[ "$RC" -eq 2 ] && ok "script --bogus: exit 2" || bad "script --bogus: rc $RC (want 2)"
has " names the argument and says nothing ran" "$OUT" "unexpected argument after the script: '--bogus' — nothing was executed"
[ ! -s "$ML" ] && ok " mxcli never called" || bad " mxcli was called: $(cat "$ML")"
[ "$(blog)" = "$B0" ] && ok " BUILD-LOG unchanged" || bad " BUILD-LOG changed"
[ "$(ls "$P/.mpr-snapshots" | grep -c .)" = "$NSNAP" ] && ok " no snapshot taken" || bad " a snapshot was taken"
[ ! -e "$LOCK" ] && ok " no lock left" || bad " lock left behind"
OUT="$(MXCLI_LOG="$ML" run "$P" --subjects mdlsource/test.mdl extra)"; RC=$?
[ "$RC" -eq 2 ] && ok "an advisory mode with a trailing arg is refused too (rc 2)" || bad "--subjects s.mdl extra: rc $RC"
rm -f "$ML"; B0="$(blog)"
OUT="$(MXCLI_LOG="$ML" run "$P" mdlsource/test.mdl)"; RC=$?
[ "$RC" -eq 0 ] && ok "control: plain exec.sh s.mdl still runs (rc 0)" || bad "control run failed (rc $RC): $(printf '%s' "$OUT" | tail -3)"
grep -q '^exec' "$ML" 2>/dev/null && ok " and reaches mxcli exec" || bad " mxcli exec not called: $(cat "$ML" 2>/dev/null)"
[ "$(blog)" != "$B0" ] && ok " and writes its BUILD-LOG row" || bad " no BUILD-LOG row"

echo "-- two-tree checkout (.mpr under app/): lock and --commit-first (#304 review; CLAUDE.md field-proof rule 2)"
T="$WORK/twotree"; mkproj "$T"
( cd "$T" && mkdir app && git mv Fixture.mpr app/ && git mv mprcontents app/ \
Expand Down Expand Up @@ -494,6 +535,15 @@ case "$OUT" in *"→ Watch:"*)
hasnt "E6 not 'changed nothing'" "$OUT" "changed nothing in the model" ;;
*) bad "E6 [setup] the --patch exec did not reach the watch advisory: $(printf '%s' "$OUT" | tail -4)" ;;
esac
# #820: args after a --patch script still pass through to it (only an MDL run refuses them).
printf '#!/usr/bin/env bash\nshift; printf "%%s\\n" "$@" > "$(dirname "$0")/../.patch-args"\n' > "$P/mdlsource/args-patch.sh"
( cd "$P" && git add mdlsource && git -c user.email=t@t -c user.name=t commit -qm argspatch ) >/dev/null 2>&1
rm -f "$P/.patch-args"
OUT="$(run "$P" --patch mdlsource/args-patch.sh --help --x 1)"; RC=$?
[ "$(cat "$P/.patch-args" 2>/dev/null | tr '\n' ' ')" = "--help --x 1 " ] && ok "#820 --patch <script> --help --x 1: args reach the patch script" \
|| bad "#820 --patch args not passed through (rc $RC): $(cat "$P/.patch-args" 2>/dev/null) $(printf '%s' "$OUT" | tail -3)"
hasnt "#820 --patch did not print exec.sh usage instead" "$OUT" "Usage: ./bin/exec.sh"
rm -f "$P/.patch-args"
# E5b: the same Java rewrite in a project whose path holds a space. An unquoted `find $_side`
# split the path, failed silently and called the model "same" (#721 review).
SP="$WORK/my proj"; cp -a "$P" "$SP"
Expand Down
Loading