Skip to content

real-mxcli drift: refusal cause, MXCLI_HOME download, rollback leftovers, leak-guard nudge, untagged version, v0.32 module captures - #823

Open
MendixMau wants to merge 9 commits into
masterfrom
fix/real-mxcli-drift
Open

MendixMau wants to merge 9 commits into
masterfrom
fix/real-mxcli-drift

Conversation

@MendixMau

@MendixMau MendixMau commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Direct lane

What changed and why (one paragraph):
A drift probe ran the toolkit against a real mxcli (a source build, mxcli version v0.32.0-374-g591bcd73e) and a real MxBuild 11.8.0, on a blank Mendix 11.8.0 app scaffolded with bin/init-project.sh. It found six places where the toolkit's assumptions about mxcli no longer hold. Each one was re-checked on the real binary before it was fixed, and each has its own commit and a fixture built from verbatim captures.

  1. exec.sh's check_refusal_reason kept only the header of v0.32's two-line reference error (statement 3: microflow 'X' has reference errors:), so the 🚫 BUILD-LOG row named no cause. The - entity not found: … line is now appended.
  2. _common.sh looks for MxBuild at ${MXCLI_HOME:-~/.mxcli}, but mxcli always caches under ~/.mxcli (os.UserHomeDir, cmd/mxcli/docker/download.go). So when MXCLI_HOME pointed elsewhere, exec.sh's auto-download "succeeded", the result was then not found, and the exec was refused. mxtk_ensure_mxbuild now uses the MxBuild ready: <path> line that mxcli prints, but only when the version matches, and says that MXCLI_HOME is not mxcli's setting.
  3. A rolled-back exec left themesource/<module>/ behind, untracked, for a module the run had created. The gate's own mx check generates that folder for every module that lacks one; mxcli exec does not write it. The snapshot covers only the .mpr and mprcontents/. exec.sh now tees the mxcli exec stdout and takes module names only from mxcli's own Created module: X lines. These strings are verbatim from v0.32: an existing module prints Module 'X' already exists, an if not exists on an existing module prints module X already exists, skipped (if not exists), and a module role prints Created module role: M.R. None of those three count. After a successful auto-restore, the folders of those modules (themesource/<x>, javasource/<x>, javascriptsource/<X> or <x>, as in mxcli's removeModuleSourceDirs) are moved into .mpr-snapshots/<snap>/stray-module-dirs/<rel> and the path is printed. This happens only when a folder did not exist at snapshot time and holds no tracked file. If there is no captured exec output (--patch), nothing is moved. Every other folder is left alone, including a peer's new folder in the window and an existing module's folder that the gate regenerates. (Revised twice after independent review: the first version deleted every new untracked folder in the window; the second took names from the script text, so create or modify module <existing> was moved.)
  4. init-project.sh's closing leak-guard line said "no <toolkit>/.leakguard-deny found" even when MXTK_LEAKGUARD_DENYFILE was set and init had just written that file. The line now names $DENYFILE.
  5. describe-baseline.sh recorded no -- baseline-mxcli: line for an untagged build (mxcli version 591bcd7 (…)), so an mxcli upgrade read as DRIFT instead of RESTAMP. It now records the commit word when there is no vX.Y.Z.
  6. v0.32 adds Version and Type columns and a (N modules) trailer, and none of the module-table captures covered them. New verbatim v0.32 captures are added, and own-modules.awk, page-scope.sh and review-module.sh's module-exists grep are asserted on them. All three already parse v0.32 correctly, so this is a regression guard, not a fix.

Impact

Row Answer
Process — human steps or gates added/removed; does anything new block; new stage artifacts None added or removed. Nothing new blocks. Item 2 turns a false refusal into a gated write: the exec is now verified by the mxbuild that mxcli actually downloaded. Item 3 removes, after a rollback only, folders that the rolled-back write created.
Dependencies — shared files touched (_common.sh, exec.sh, skill-routing.tsv, …); order vs other open PRs; new tools/platform assumptions; new artifact reads + their producer project-bin/exec.sh (items 1 and 3), project-bin/_common.sh (mxtk_ensure_mxbuild only), project-bin/describe-baseline.sh, bin/init-project.sh. No new tools. Item 2 reads mxcli's own stdout line MxBuild ready: <path>; it has one print site, cmd/mxcli/setup.go:141, which covers both the cached and the fresh-download path. Item 3 tees mxcli exec stdout (stdout only; stderr unchanged; PIPESTATUS keeps the exit code). The pipeline sits in `{ …; }
Context cost — always-loaded words per role at the affected stage(s), base → head, and baseline total vs 80,000, pasted from bin/render-routing.sh --check on both — or "none: no routed or always-loaded file touched" none: no routed or always-loaded file touched (render-routing.sh --check: "Baseline: 65568 words (budget 80000)", unchanged)
Behaviour — A/B result for agent-read text, or "NOT RUN: ", or "n/a: scripts only" n/a: scripts only. NOT RUN for agent text: no skill or agent-read text changed. The maintainer can accept this or ask for an A/B.
Runtime — seconds/resources added or saved per exec, gate or check Item 1: one awk rule, only on the refusal path. Item 3: one glob over three folders after the snapshot; on a rollback only, one sed over the exec output plus one git ls-files per candidate folder. Measured as unnoticeable inside the field runs below (snapshot 0–1s as before). Item 2: none on the normal path; on the download path it saves a refused exec. Items 4–6: none.

Time cost: per exec · <0.1 s (glob of themesource/javasource/javascriptsource; rollback-only git ls-files) on a Linux x86-64 container · can force rework: n · offset: keeps the rolled-back module's untracked folders out of a later git add -A, and keeps them recoverable in the snapshot

Field evidence — all on the real binaries: mxcli version v0.32.0-374-g591bcd73e (2026-11-20T18:31:01Z) (sha256 e3e84102…70ead7f), MxBuild 11.8.0 from the Mendix CDN, and a blank Mendix 11.8.0 app (mxcli new ProbeApp --version 11.8.0) scaffolded with init-project.sh, plus a Sales module. The project was synced to master 1a56c3a, then this branch's exec.sh, _common.sh and describe-baseline.sh were installed into its bin/. It ran at a short path (/tmp/mxd/…), because MxBuild hits PathTooLongException under deep directories.

Item master (same model, same binaries) this branch
1 Script 02-broken.mdl. BUILD-LOG row: check: statement 3: microflow 'Broken2.ACT_Thing' has reference errors: Row: check: statement 3: microflow 'Broken2.ACT_Thing' has reference errors: entity not found: Broken2.Missing (referenced by create), verdict=refused
2 With MXCLI_HOME pointing elsewhere: MxBuild ready: /root/.mxcli/mxbuild/11.8.0/modeler/mxbuild, then "download reported success but no runnable mxbuild was found afterwards", then ✗ REFUSING to exec Same setup: note: mxcli caches under ~/.mxcli whatever MXCLI_HOME says …; using the mxbuild it reported, then mx check 0 errors, verdict=applied verified=yes, exit 0
3 05-slip2.mdl (create module SlipTwo + member typo). CE1613 → restored, and afterwards git status shows ?? themesource/sliptwo/{settings.json,web/*,native/*} (5 files) Head a0face6, fresh scaffold synced to it, real chain, mx-check gate, via mxsem.sh. Script 07-mixed.mdl: create or modify module Sales; (an existing module whose themesource folder was removed beforehand) + create module SlipFour; + member typo. mxcli printed Module 'Sales' already exists and Created module: SlipFour. Then CE1613 → restored and → Moved themesource/slipfour/ (source folder of module SlipFour, which this run created: mxcli printed "Created module: SlipFour") to /tmp/mxd/d3/.mpr-snapshots/20261120-200228/stray-module-dirs/themesource/slipfour. themesource/sales/, which the gate regenerated in the window, stayed in place. Earlier run on 9daca41: a peer's themesource/peerwork/ and javascriptsource/PeerJs/, created after the snapshot, survived.
4 init with MXTK_LEAKGUARD_DENYFILE set: Registered … (<denyfile>), then 230 lines later Leak guard: no <toolkit>/.leakguard-deny found fixture: the nudge names the override file
5 A make build on a shallow clone (relinked from the same source with VERSION=591bcd7) prints mxcli version 591bcd7 (…), and no baseline-mxcli line is stamped stamps -- baseline-mxcli: 591bcd7; a later v0.32.0 build reads as RESTAMP (591bcd7 → v0.32.0)
6 parsers correct on v0.32 same; now pinned by captures

Layouts: item 3's fixture runs both a single tree and .mpr under app/ (the real snapshot-mpr.sh and restore-mpr.sh); the field run used a single tree only. Item 2 does not depend on layout: it resolves the mxbuild cache, not project paths.

Fixtures, master vs branch (scoped: each new fixture, plus the existing ones that target the touched files)

Fixture master branch
test-exec-check-refusal.sh (case F added, capture reference-v0.32.0.out + its .mdl) 11 pass, 1 fail (F) 12 pass, 0 fail
test-mxbuild-setup-home.sh (new; capture setup-mxbuild-cached-v0.32.0.out) 5 pass, 2 fail (A) 7 pass, 0 fail
test-exec-rollback-module-dirs.sh (the 5 folder files mx check generated + git status + verbatim mxcli exec stdout captures with their .mdl; cases E and F added after review) master 16 pass, 8 fail; 9daca41 20 pass, 4 fail (F: Moved themesource/sales/ … which this script created, foo not moved) 24 pass, 0 fail
test-init-leakguard-nudge.sh (new) 1 pass, 1 fail (B) 2 pass, 0 fail
test-describe-baseline.sh (2 cases added; untagged and v0.32.0-374 --version captures) 33 pass, 2 fail 35 pass, 0 fail
test-show-modules-v032.sh (new; v0.32 show modules / list modules / SHOW PAGES IN captures) 11 pass (regression guard) 11 pass
existing: test-exec-result-line.sh, test-mxbuild-version-match.sh, test-rehost-list-modules.sh, test-page-scope-protected.sh — 72/0, 23/0, 8/0, 6/0
test-exec-result-line.sh case N added after the third review (mktemp / tee into exec-out.* fail after the write; mxcli exit 3 preserved) a0face6: 77 pass, 9 fail (N1–N3: no RESULT line, exec.sh aborted) 86 pass, 0 fail
existing, re-run on a5dbbad: test-exec-rollback-module-dirs.sh, test-exec-crash-rollback.sh, test-exec-lint-autorestore.sh, test-exec-hash-verify.sh, test-exec-gate-retry.sh, test-exec-check-refusal.sh, test-bug07-08.sh — 24/0, 13/0, 17/0, 49/0, 52/0, 12/0, 48/0

Also run: bin/check-scripts.sh (clean), check-no-client-data.sh (clean), check-portability.sh (clean, 414 files), check-pr-discipline.sh (clean), render-routing.sh --check (in sync).

Found but not fixed (out of scope): review-module.sh's with_timeout runs inside $(…) at line 286. The watchdog's sleep 60 holds the command substitution's pipe open, so every module-exists probe without a catalog takes the full 60 s even when mxcli answers at once. Measured at 60 s per call with an instant stub. test-review-conformance-per-brd.sh already works around it.

  • No client data anywhere in the diff
  • Size cap: 10 files outside fixtures/captures/CHANGELOG. The code under bin/, project-bin/ and pipelines/ is 4 files, +70/−11; the rest is fixture scripts.
  • Test tier reached: T3 — run on the real mxcli v0.32.0-374 and MxBuild 11.8.0 against a real Mendix 11.8.0 model (the field table above), plus T1 fixtures
  • For a new/changed instrument: golden input captured (not hand-written), both layouts (item 3 fixture), both platforms considered (only bash/awk/sed/git already used by these scripts; no new tools; tee + PIPESTATUS is bash 3.2-safe)
  • For a new skill: n/a
  • CHANGELOG.md line appended in each commit, crediting the real-mxcli field run
  • No bug entries added

Review: MERGE-AFTER-FIX (third review, of a0face6) — fix pushed in a5dbbad, awaiting re-review

https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC


Generated by Claude Code

… the refusal row

mxcli v0.32 prints "statement N: microflow 'X' has reference errors:" and the cause on the
next line as "  - entity not found: ...". check_refusal_reason kept only the header, so the
BUILD-LOG row lost the cause. Fixture F on a verbatim capture from mxcli v0.32.0-374.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
…LI_HOME points elsewhere

mxcli always caches MxBuild under ~/.mxcli (os.UserHomeDir) and ignores MXCLI_HOME, which only
the toolkit reads, so exec.sh's auto-download "succeeded" and was then not found. Take the
"MxBuild ready: <path>" line when re-discovery finds nothing, version-checked. Fixture on a
verbatim `setup mxbuild` capture from mxcli v0.32.0-374.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
The snapshot covers the .mpr and mprcontents/ only; `create module` also writes
themesource/<module>/, which stayed behind untracked after a failed gate restored the model
(real mxcli v0.32.0-374, CE1613 rollback). After a successful auto-restore, remove folders
under themesource/, javasource/, javascriptsource/ that did not exist at snapshot time and
hold no tracked file. Fixture on the verbatim leftover files, single tree and app/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
With MXTK_LEAKGUARD_DENYFILE set, init registered the project in that file, then said
"no <toolkit>/.leakguard-deny found ... Create it" because the nudge tested the default path.

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

A `make build` on a shallow clone prints "mxcli version 591bcd7 (...)"; the vX.Y.Z grep read
it as empty, no -- baseline-mxcli: line was written, and an upgrade read as DRIFT. Fixture on
verbatim untagged and v0.32.0-374 --version captures.

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

v0.32 adds Version/Type columns and a "(N modules)" trailer; the existing captures predate both.
Adds real show modules / list modules / SHOW PAGES IN captures and asserts own-modules.awk,
page-scope.sh and review-module.sh's module-exists grep on them (regression guard: all pass
on master too).

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 — item 3's rm -rf deletes ANY new untracked folder under themesource/javasource/javascriptsource that appears during the exec window, not just the rolled-back module's (reproduced on real mxcli v0.32 + MxBuild 11.8: a peer's themesource/peerwork/ and javascriptsource/PeerJs/ were deleted, unrecoverably)
Value: All six items fix what is reported. Items 1, 2, 4, 5 and 6 are proportionate. I re-ran the captures on the real binaries (reference-v0.32.0.out and setup-mxbuild-cached-v0.32.0.out are byte-identical; the sliptwo files are identical too). Item 2 checked end to end: with MXCLI_HOME=/tmp/empty, exec printed the note and gave verdict=applied verified=yes.
Regression risk: Item 2 (_common.sh:1778-1795) relaxes a guard, but safely. It needs setup rc 0, -x, and the version in the directory name (mxtk_version_in_name, fixture C). MxBuild itself still refuses a model of another version. It follows rule 6, and rule 7 does not apply. Item 3 (exec.sh:1757-1767) uses time as its only test: whatever is new since MODDIRS_BEFORE (line 1774) and untracked gets removed. The window is 1-3 minutes (two mx check runs). This toolkit runs several sessions in one tree, so peer or user work in a new folder, or a new nested repo, gets deleted. Master left all of it alone. These are kept correctly: folders that existed before (empty, ignored, symlinks), and the target of a new symlink. Bash 3.2 constructs are fine. Both layouts are covered by fixture A/B. The merge with origin/master is clean.
Correctness: The attribution is wrong. mxcli exec "create module SlipTwo" writes nothing under themesource/. Real mx check (the gate) generates themesource/sliptwo/ (the 5 captured files plus an empty public/) for every module that lacks one. So the comments (exec.sh:1744-1749), the CHANGELOG, the fixture header and the fixture dir name created-by-create-module are all wrong. The real run also printed "Removed themesource/sales/ (created by this write, not in the restored model)" for the EXISTING module Sales. That is false, and the post-restore attribution mx check regenerated it anyway. Item 1: checked against 7 real multi-line refusals (multiple causes, page and association errors, syntax, member slip). No regressions, and only the first cause is appended. Item 5: OK.
Context cost: 65568 → 65568 (render-routing --check, base 1a56c3a and head)
Time cost: per exec under 0.01 s (three globs). Only with MXCLI_HOME mismatched, add about 0.1-0.15 s (a cached setup mxbuild on each exec, measured). Before, that case was refused.
Exact fixes required (MERGE-AFTER-FIX only):

  1. remove_new_module_dirs: remove a folder only when its name is a module the rolled-back script creates. Match create module X in $SCRIPT, using themesource/<lower>, javasource/<lower> and javascriptsource/<X or lower>, as in mxcli's removeModuleSourceDirs. Any other new folder is left alone.
  2. Move the folder, don't delete it: mv it into "$NEWEST_SNAP/stray-module-dirs/<rel>" and print the path, so a wrong match can be recovered.
  3. Correct the attribution to "the gate's mx check generates it" in exec.sh:1744-1749, the CHANGELOG line, the fixture header and the fixture dir name. Reword the message so it no longer claims "not in the restored model".
  4. Fixture: add case E. A folder created during the window by something other than the script (have the stub mxbuild create themesource/peerwork/x.scss) must still be there after the rollback.

Generated by Claude Code

…o the snapshot

Review of #823 (MERGE-AFTER-FIX): the item-3 cleanup deleted every new untracked folder under
themesource/javasource/javascriptsource that appeared during the exec window, including a peer
session's. Now only the folders of modules the script creates (`create module X`: themesource/<x>,
javasource/<x>, javascriptsource/<X>|<x>, mxcli's removeModuleSourceDirs naming) are touched,
and they are moved to <snapshot>/stray-module-dirs/<rel>, with the path printed, not deleted.
Attribution corrected: the gate's `mx check` generates themesource/<module>/, not mxcli exec.
Fixture case E: a folder another writer creates in the window survives.

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 — (re-review of head 9daca41) three of the four fixes hold on the real chain. But create or modify module Sales on an EXISTING module still moves that module's folder: real run, "Moved themesource/sales/ (source folder of module Sales, which this script created)". The claim is false, and mx check regenerated the folder right after.
Value: The four earlier fixes check out:

  • (1) The candidates are now limited to the script's own create module names (exec.sh:1760-1764).
  • (2) The folder is moved into <snap>/stray-module-dirs/ and the path is printed (:1766-1781). Snapshots are pruned after 5 newer ones, so it can be recovered until then.
  • (3) The attribution is corrected in the comment, CHANGELOG and fixture. Confirmed: the gate's mx check generates the folder.
  • (4) Case E was added.
    Regression risk: Real chain (mxcli v0.32.0-374, MxBuild 11.8.0, /tmp/rv823, mx-check gate). The script was create or modify module Sales; create or modify module MyFirstModule; create module My_Slip; plus a CE1613 slip. Peer folders themesource/peerwork/ and javascriptsource/PeerJs/, created mid-exec, were both KEPT. My_Slip was lowercased correctly, and themesource/my_slip was moved. MyFirstModule's tracked folder was untouched. A pre-existing untracked javascriptsource/Sales/ is skipped by the MODDIRS_BEFORE test. --patch: script_created_modules returns nothing in PATCH_MODE, and hash-verify passes 49/0. Both layouts are covered by fixtures A and B. Bash 3.2 constructs are fine. Merges cleanly onto origin/master.
    Correctness: The parser is at exec.sh:1760-1764.
  • or (modify|replace) is accepted, so a module that already exists counts as "created" whenever the gate generated its folder during the window. A peer's new themesource/sales/ would be moved too.
  • create module if not exists Foo yields if, and create module role Sales.User yields role. Wrong names are harmless (they only match folders by those names), but Foo's leftover stays.
  • An inline mdl 1; create module X; is missed. That fails safe.
    Fixtures on head: rollback-module-dirs 20/0, check-refusal 12/0, result-line 72/0, bug07-08 48/0, crash-rollback 13/0, lint-autorestore 17/0, hash-verify 49/0, gate-retry 52/0, describe-baseline 35/0, mxbuild-setup-home 7/0.
    Context cost: 65568 → 65568 (no routed file touched since the previous review)
    Time cost: per exec under 0.01 s. About 0.1–0.15 s only when MXCLI_HOME is mismatched (that case was refused before).
    Exact fixes required (MERGE-AFTER-FIX only):
  1. Take the module names from what mxcli actually created, not from the script text. Tee the mxcli exec output (exec.sh:2373, as the check already does at :1622) and use its Created module: <X> lines. mxcli prints "Module 'Sales' already exists" for an existing module. Acceptable minimum: drop the or (modify|replace) alternative and reject the if / role keywords.
  2. Fixture: add a case where create or modify module <existing> has a folder that appears in the window, and assert that the folder is not moved.

Generated by Claude Code

…:" output

Re-review of #823: `create or modify module Sales` on an existing module still had its
gate-generated folder moved with a false "which this script created". exec.sh now tees the
`mxcli exec` stdout and moves only the folders of modules mxcli reported as "Created module: X"
(verbatim v0.32 strings: an existing one prints "Module 'X' already exists"; `if not exists`
on an existing one is "skipped"). No captured output (--patch) means no moves. Fixture case F
on verbatim exec captures: existing Sales kept, `if not exists` Foo moved.

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 — (re-review 2, head a0face6) The module names now come from mxcli's own Created module: X lines, and that holds on the real chain. One new problem: the bare | tee runs under set -e with no || guard. If tee fails (mktemp or TMPDIR full or unwritable), exec.sh aborts AFTER mxcli has written, with no gate, no restore and no MXTK-RESULT line.
Value: Every earlier finding is fixed:

  • Names come from what mxcli printed, not from the script text (exec.sh:1767-1770).
  • create or modify on an existing module prints "Module 'Sales' already exists". if not exists on an existing module prints "…already exists, skipped". A role prints "Created module role:". None of these match. I captured all three on the real v0.32 binary, and exec-existing-and-ifnotexists-v0.32.0.out is byte-identical to my re-run.
  • Fixture F was added.
    Regression risk: Real chain (mxcli v0.32.0-374, MxBuild 11.8, /tmp/rv823c, mx-check gate, via mxsem.sh). Script: create or modify module Sales; create or modify module MyFirstModule; create module My_Slip; plus a CE1613 slip.
  • Only themesource/my_slip was moved into stray-module-dirs/.
  • The regenerated themesource/sales/ was not moved.
  • MyFirstModule was untouched.
  • The peer folders themesource/peerwork/ and javascriptsource/PeerJs/ were kept.
  • verdict=restored exit=1.
    Exit codes otherwise match master: a mid-script mxcli failure (SKIP_CHECK=1, bad association) gives ✗ mxcli exec exited 1 and verdict=partial exit=1. A clean apply gives verdict=applied exit=0. The temp file was removed on all three paths, with 0 exec-out.* left. Its removal is in the EXIT trap (:1069), the only EXIT trap after line 171. PIPESTATUS[0] and tr/sed -n work on bash 3.2. stdout still streams line by line (Go writes unbuffered). mxcli's stderr WARNING may now interleave differently with stdout, which is cosmetic. Nothing parsed exec stdout before this change. Merges cleanly onto origin/master.
    Correctness: :2378-2380. Before, cmd || EXEC_STATUS=$? kept a failure from tripping set -e. Now the pipeline's status is tee's. I reproduced this: bash -ec 'false | tee /nonexistent/x; echo NOT-REACHED' exits 1 without echoing. A failed EXEC_OUT="$(mktemp …)" also aborts with no result line, before the write. Fixtures on head: rollback-module-dirs 24/0, check-refusal 12/0, result-line 72/0, bug07-08 48/0, crash-rollback 13/0, lint-autorestore 17/0, hash-verify 49/0, gate-retry 52/0, describe-baseline 35/0, mxbuild-setup-home 7/0.
    Context cost: 65568 → 65568 (render-routing --check)
    Time cost: per exec under 0.01 s (one tee and one mktemp). About 0.1–0.15 s only with a mismatched MXCLI_HOME (previously refused).
    Exact fixes required (MERGE-AFTER-FIX only):
  1. exec.sh:2379-2380: replace those two lines with
    EXEC_OUT="$(mktemp "${TMPDIR:-/tmp}/exec-out.XXXXXX" 2>/dev/null)" || EXEC_OUT=""
    { "${PMXCLI:-./mxcli}" exec "$SCRIPT" -p "$MPR" | tee ${EXEC_OUT:+"$EXEC_OUT"}; EXEC_STATUS=${PIPESTATUS[0]}; } || true
    This keeps mxcli's exit code, and a tee or mktemp failure only costs the folder move. With no EXEC_OUT, script_created_modules already returns nothing.

Generated by Claude Code

…fter the write

Third review of #823: `mxcli exec | tee "$EXEC_OUT"` made the pipeline's status tee's, so under
set -e a failing tee (or a failing mktemp just before) ended exec.sh with no gate, no restore and
no MXTK-RESULT line. Reviewer's form: mktemp failure leaves EXEC_OUT empty (tee passes through,
nothing is moved later), the pipeline sits in `{ ...; } || true`, EXEC_STATUS is mxcli's exit
code. Fixture test-exec-result-line.sh N1-N3 (mktemp/tee wrappers failing only for exec-out.*).

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 3, head a5dbbad) The tee/mktemp guard is in exactly the form requested. A failed capture can no longer abort exec.sh, and mxcli's exit code is kept. Fixture case N fails on a0face6 and passes on head.
Value: exec.sh:2382-2383 is the requested form, character for character: mktemp … 2>/dev/null || EXEC_OUT="" and { … | tee ${EXEC_OUT:+"$EXEC_OUT"}; EXEC_STATUS=${PIPESTATUS[0]}; } || true. Earlier rounds fixed the rest: names come from mxcli's Created module: lines, the folder is moved into the snapshot, the attribution is corrected, and cases E/F exist.
Regression risk: Real chain (mxcli v0.32.0-374, MxBuild 11.8, /tmp/rv823d, via mxsem.sh): a clean apply printed Created module: Sales, gave verdict=applied verified=yes exit=0, and left 0 exec-out.* files. The exit codes from the round-2 real runs are unchanged by this edit: restored gives exit 1, a mid-script failure gives partial exit 1. Bash 3.2: ${VAR:+"$VAR"} with an empty value expands to no argument, so a bare tee only passes the output through. Merges cleanly onto origin/master.
Correctness: The new fixture case is in test-exec-result-line.sh (N, not in rollback-module-dirs). Run against a0face6's exec.sh it fails in N1, N2 and N3 (0 RESULT lines, and N1 loses the exec stdout). On head it passes 86/0, with no temp file left. N2 (tee fails) is the true post-write case: on a0face6 you see "fake mxcli exec" printed and then the abort. N1 and N3 (mktemp fails) abort BEFORE the write on a0face6, because mktemp runs before mxcli. So the header's "AFTER mxcli wrote" is accurate only for N2. N1's first assertion (rc 1 && !kept) also passes on a0face6, so it does not discriminate; the RESULT-line assertions do. Wording only, not blocking. Other fixtures: rollback-module-dirs 24/0, crash-rollback 13/0.
Context cost: 65568 → 65568 (render-routing --check)
Time cost: per exec under 0.01 s. About 0.1–0.15 s only with a mismatched MXCLI_HOME (previously refused).


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.

2 participants