Skip to content

Commit 02e4366

Browse files
authored
fix(exec): keep the gate's full mxbuild output in a per-run log (#452)
fix(exec): keep the gate's full mxbuild output in a per-run log. Independent review: APPROVE. Verdict: APPROVE r3 on head after merging the fixed #451 (f4cc5ae, fd90628) into fix/gate-full-log; the merge was clean. r2 APPROVE stands. gate-log 24/24 and gate-retry 24/24 on the merged head, check-pr-discipline clean. Merges after #451.
1 parent dc840ee commit 02e4366

5 files changed

Lines changed: 205 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m
1919

2020
## Unreleased
2121

22+
- fix(exec): **the gate keeps mxbuild's full output in a per-run log and names it on screen and in the BUILD-LOG row.** exec.sh printed `head -20` of the output and deleted the rest, so the evidence of a failed gate (a CE1613 detail among it) was lost in a field migration project (12 modules). A gate that does not pass now writes `.mpr-snapshots/.mxbuild-logs/<run>.log` (newest 30 kept; a dot dir, so `restore-mpr.sh` and the snapshot pruning skip it; a clean or delta-gate pass writes none, and a retry always keeps the first attempt's output next to the second); the screen shows the top lines plus the path and the row ends with `mxbuild log: <path>`. Test: `tests/wave2/test-exec-gate-log.sh` (Refs #442, #448, #171, #285, #424) — field migration project
2223
- fix(exec): **the gate pauses this project's `mxcli run --local --watch` while mxbuild runs and retries once on an infra exit.** The gate's mxbuild and a live watcher both write `deployment/`; in a field migration project (12 modules) 17 of 27 failed gates were "gate could not run" (mxbuild exit 1, no CE code), against 0 of 22 in watcher-free copies. The watcher is stopped (SIGSTOP) for the gate and resumed (SIGCONT, also in the EXIT trap); an exit 1 or 3 with no CE code and no errors file is retried once and the BUILD-LOG row says `retry after infra exit`; a final failure still takes the #424 rollback. The match is exact (the watcher's project dir must equal this project's root, so a sibling `-copy` or a nested worktree watcher is never paused), and the paused pids are recorded in `.mpr-snapshots/.watcher-paused` so the next exec.sh resumes a watcher left stopped by a SIGKILLed one and says so. Test: `tests/wave2/test-exec-gate-retry.sh` (Refs #441, #444, #171, #285, #424) — field migration project
2324
- learn(load-test): **trap 9, an unlicensed local runtime caps concurrent sessions at 6 ("Maximum number of sessions exceeded!") and stops itself after a random 2 to 4 hours, both reading as the app failing under load; more than 6 users needs a licensed runtime or a cloud sandbox.** Text only, ondemand skill. Source: a personal licence-budget gate written after parallel journey runs hit both — MendixMau
2425
- fix(progress-report): **the full plan tables (one table per phase plus views A and B) now sit in one closed `<details>` card below the phase cards, so a large plan no longer pushes the rest of the report off screen; the phase cards above stay the summary, and nothing is written when the project has no plan fragment.** Test: P6 in `test-progress-report-polish.sh` — MendixMau

‎project-bin/_common.sh‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ find_java_exe() {
590590
MXTK_PAUSED_PIDS=""
591591
MXTK_PAUSED_FILE=""
592592
MXTK_GATE_RETRY_NOTE=""
593+
MXTK_GATE_FIRST_OUT=""
594+
MXTK_GATE_FIRST_EXIT=""
593595

594596
# mxtk_watcher_pids <project-root> - pids of `mxcli run --local --watch` that belong to this
595597
# project. Exact match only: the watcher's project dir (the directory of its -p argument,
@@ -680,18 +682,21 @@ mxtk_resume_leftover() {
680682
# on the model; a real model error always names a CE code. An errors file with content (for
681683
# example a version mismatch in errors[]) is deterministic and is not retried.
682684
# Prints nothing on stdout (callers discard the count); sets the same MXTK_MXBUILD_* globals as
683-
# mxtk_mxbuild_error_count, plus MXTK_GATE_RETRY_NOTE ("retry after infra exit" or empty).
685+
# mxtk_mxbuild_error_count, plus MXTK_GATE_RETRY_NOTE ("retry after infra exit" or empty); after a
686+
# retry MXTK_GATE_FIRST_OUT / MXTK_GATE_FIRST_EXIT hold the FIRST attempt's output and exit code
687+
# (the MXTK_MXBUILD_* globals describe the final attempt only).
684688
# Returns mxtk_mxbuild_error_count's code for the final attempt.
685689
mxtk_gate_mxbuild() {
686690
local _mpr="$1" _timeout="${2:-0}" _ef="$3" _rc=0
687-
MXTK_GATE_RETRY_NOTE=""
691+
MXTK_GATE_RETRY_NOTE=""; MXTK_GATE_FIRST_OUT=""; MXTK_GATE_FIRST_EXIT=""
688692
mxtk_pause_watchers "${PROJECT_ROOT:-$(dirname "$_mpr")}"
689693
mxtk_mxbuild_error_count "$_mpr" "$_timeout" "$_ef" >/dev/null || _rc=$?
690694
case "${MXTK_MXBUILD_EXIT:-}" in
691695
1|3)
692696
if [ ! -s "$_ef" ] && ! grep -Eq -- 'CE[0-9]{4}' <<<"${MXTK_MXBUILD_OUT:-}"; then
693697
echo " ⚠ retry after infra exit: mxbuild exited $MXTK_MXBUILD_EXIT with no CE code and no errors file; building once more" >&2
694698
MXTK_GATE_RETRY_NOTE="retry after infra exit"
699+
MXTK_GATE_FIRST_OUT="${MXTK_MXBUILD_OUT:-}"; MXTK_GATE_FIRST_EXIT="$MXTK_MXBUILD_EXIT"
695700
: > "$_ef"
696701
_rc=0
697702
mxtk_mxbuild_error_count "$_mpr" "$_timeout" "$_ef" >/dev/null || _rc=$?

‎project-bin/exec.sh‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ BUILD_LOG="$PROJECT_ROOT/docs/BUILD-LOG.md"
437437
GATE_STATE="not-run" # not-run | skipped | unverified | pass | fail
438438
GATE_ERRORS="?" # mxbuild error count behind a pass (0 = clean); recorded in the stamp
439439
MXB_WHY="" # mxbuild's errors[] reason when it exited without checking the model
440+
MXB_LOG_NOTE="" # "mxbuild log: <path>" when the gate's full output was saved (BUILD-LOG detail)
440441
GATE_NOTE="" # "retry after infra exit" when a gate mxbuild was run twice
441442

442443
# ── Exec approval (auto records itself) ──────────────────────────────────────
@@ -491,7 +492,7 @@ HDR2
491492
# The gate cell is read from GATE_STATE rather than passed in, so no caller
492493
# can omit it — a blank cell in this table reads as "fine", which is the exact
493494
# false-green the gate exists to prevent.
494-
_detail="$2${CHANGE_CLASS:+ · change: $CHANGE_CLASS}${CR_ID:+ · cr: $CR_ID}${SCAN_NOTE:+ · $SCAN_NOTE}${GATE_NOTE:+ · $GATE_NOTE}${HV_NOTE:+ · $HV_NOTE}$_EXEC_APPROVAL_SUFFIX${STEP_TIMES:+ · steps: $STEP_TIMES}"
495+
_detail="$2${CHANGE_CLASS:+ · change: $CHANGE_CLASS}${CR_ID:+ · cr: $CR_ID}${SCAN_NOTE:+ · $SCAN_NOTE}${GATE_NOTE:+ · $GATE_NOTE}${MXB_LOG_NOTE:+ · $MXB_LOG_NOTE}${HV_NOTE:+ · $HV_NOTE}$_EXEC_APPROVAL_SUFFIX${STEP_TIMES:+ · steps: $STEP_TIMES}"
495496
printf '| %s | `%s` | %s | %s | %s |\n' \
496497
"$(date '+%Y-%m-%dT%H:%M:%S%z')" "$LOG_NAME" \
497498
"${GATE_STATE:-not-run}" "$1" "$_detail" >> "$BUILD_LOG"
@@ -1643,12 +1644,46 @@ if [ -x "$MXBUILD" ] && [ -x "$JAVA_EXE" ]; then
16431644
MXB_WHY="${MXTK_MXBUILD_WHY:-}"
16441645
step_done gate
16451646

1647+
# Keep the gate's full mxbuild output when the gate did not pass. The screen shows only the
1648+
# top lines (the failure detail is often in the tail), and the temp file behind
1649+
# mxtk_mxbuild_error_count is gone by now, so without this the evidence of a failed gate was
1650+
# lost (a field migration project lost the detail of a CE1613 this way). mxbuild prints output
1651+
# on a clean build too, so the log is written from the failure branches below (mxb_log_hint)
1652+
# and never for a pass, a delta-gate pass over pre-existing errors included. The one exception
1653+
# is a retry: the first attempt's output is the evidence of the infra exit, so a retry always
1654+
# leaves a log, with both attempts in it. One file per run, under .mpr-snapshots/.mxbuild-logs/,
1655+
# the newest 30 kept. The DOT in the name is load-bearing: restore-mpr.sh (no argument picks
1656+
# the newest) and snapshot-mpr.sh (keeps 5) glob `.mpr-snapshots/*/`, which skips dot dirs.
1657+
# Its project-relative path goes on screen and in the row.
1658+
MXB_LOG_REL=""
1659+
mxb_save_log() {
1660+
[ -z "$MXB_LOG_REL" ] || return 0
1661+
[ -n "$MXBUILD_OUT$MXTK_GATE_FIRST_OUT" ] || return 0
1662+
_MXB_LOG_DIR="$PROJECT_ROOT/.mpr-snapshots/.mxbuild-logs"
1663+
MXB_LOG_REL=".mpr-snapshots/.mxbuild-logs/$(date +%Y%m%d-%H%M%S)-$$.log"
1664+
if mkdir -p "$_MXB_LOG_DIR" 2>/dev/null && {
1665+
if [ -n "$MXTK_GATE_RETRY_NOTE" ]; then
1666+
printf '=== attempt 1 (exit %s, infra failure, retried) ===\n%s\n=== attempt 2 (final, exit %s) ===\n%s\n' \
1667+
"$MXTK_GATE_FIRST_EXIT" "$MXTK_GATE_FIRST_OUT" "$MXBUILD_EXIT" "$MXBUILD_OUT"
1668+
else
1669+
printf '%s\n' "$MXBUILD_OUT"
1670+
fi > "$PROJECT_ROOT/$MXB_LOG_REL"; } 2>/dev/null; then
1671+
MXB_LOG_NOTE="mxbuild log: $MXB_LOG_REL"
1672+
ls -t "$_MXB_LOG_DIR"/*.log 2>/dev/null | sed -n '31,$p' | while IFS= read -r _old; do rm -f "$_old"; done
1673+
else
1674+
MXB_LOG_REL=""
1675+
fi
1676+
}
1677+
mxb_log_hint() { mxb_save_log; [ -z "$MXB_LOG_REL" ] || echo " full mxbuild output: $MXB_LOG_REL"; }
1678+
if [ -n "$MXTK_GATE_RETRY_NOTE" ]; then mxb_save_log; fi
1679+
16461680
if [ -f "$ERRORS_FILE" ] && [ -s "$ERRORS_FILE" ]; then
16471681
CE_COUNT=$(err_count "$ERRORS_FILE")
16481682
if [ "$CE_COUNT" = "?" ]; then
16491683
GATE_STATE="unverified"
16501684
echo " ⚠ mxbuild errors file could not be parsed — check manually."
16511685
echo "$MXBUILD_OUT" | grep -v "^$\|icon\|Microsoft\|Assembly\|__" | head -10 || true
1686+
mxb_log_hint
16521687
elif [ "$CE_COUNT" = "0" ] && [ "$MXBUILD_EXIT" -ne 0 ]; then
16531688
# Non-empty errors file, 0 Error problems, NON-ZERO exit: mxbuild never checked the
16541689
# model. The reason sits in errors[], which err_count does not read, e.g. (verbatim,
@@ -1662,6 +1697,7 @@ if [ -x "$MXBUILD" ] && [ -x "$JAVA_EXE" ]; then
16621697
echo " ✗ mxbuild exited $MXBUILD_EXIT and listed 0 model problems — it did NOT check the model."
16631698
echo " ${MXB_WHY:-no reason in errors[]; mxbuild output follows}"
16641699
[ -z "$MXB_WHY" ] && { echo "$MXBUILD_OUT" | grep -v "^$\|icon\|Microsoft\|Assembly\|__" | tail -10 || true; }
1700+
mxb_log_hint
16651701
echo " A version mismatch is fixed by the matching mxbuild: ./mxcli setup mxbuild -p $MPR_BASE"
16661702
echo " (find_mxbuild prefers it once cached), or MXBUILD_PATH=<that mxbuild>."
16671703
elif [ "$CE_COUNT" = "0" ]; then
@@ -1711,6 +1747,7 @@ if [ -x "$MXBUILD" ] && [ -x "$JAVA_EXE" ]; then
17111747
rm -f "$ERRORS_FILE"
17121748
else
17131749
GATE_STATE="fail"
1750+
mxb_save_log
17141751
CE_CODES=$(err_codes "$ERRORS_FILE")
17151752
read -r NEW_COUNT NEW_CODES <<EOF
17161753
$(err_report count "$ERRORS_FILE")
@@ -1801,6 +1838,7 @@ EOF
18011838
echo " ✗ mxbuild failed to run (exit $MXBUILD_EXIT) — gate could not verify the model."
18021839
[ -n "$MXB_WHY" ] && echo " mxbuild says: $MXB_WHY"
18031840
echo "$MXBUILD_OUT" | grep -v "^$\|icon\|Microsoft\|Assembly\|__" | head -20 || true
1841+
mxb_log_hint
18041842
# mxbuild CRASHED ON THE WRITTEN MODEL (field 2026-10-13, Mendix 11.14.0, mxcli v0.25.0): a
18051843
# two-hop data source passed `check`, then mxbuild's loader died with no errors file. This
18061844
# branch kept the write, the next exec printed "Baseline NOT measured" and wrote on top of a

0 commit comments

Comments
 (0)