fix(doctor): keep the model's real basename in the gate self-test scratch dir - #128
Merged
Merged
Conversation
…atch dir gate_selftest() copied the project model to a hardcoded "$scratch/model.mpr" while copying mprcontents/ beside it verbatim. mprcontents/ carries an internal record of the model's real basename, so the renamed copy is a mismatched pair: mxbuild bails before writing any error file, mxtk_mxbuild_error_count returns "?", and the self-test prints gate self-test: gate cannot read mxbuild's error file (baseline run) GATE_SELFTEST_LINE="fail (unreadable error file)" which is the F-042-class string meaning "the gate itself is broken" - a false FAIL on a perfectly healthy gate, sending people hunting a nonexistent problem. The scratch copy now keeps basename "$MPR", threaded through all four later references (baseline count, the mxcli injection's -p, the known-bad count); scratch_mpr is declared in the existing bash 3.2-compatible local list. NOT FIELD-RUN. This environment has no .mpr, no mxbuild and no Studio Pro, so the fix is reasoned and inspected only. One run of `bin/doctor.sh --gate-selftest <project>` on a macOS machine with Studio Pro 11 against a real model is what would prove it; do not tell the team to pull until that run exists. Found by Yvann during Mac/sandbox onboarding, 2026-09-22. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0187r9bQWkZAEppyEqrDevjK
This was referenced Sep 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Direct lane (changes to
skills/,bug-logs/,bin/,project-bin/,project-tests/, pipelines)What changed and why (one paragraph):
bin/doctor.sh'sgate_selftest()copied the project model into its scratch dir under ahardcoded name —
cp "$MPR" "$scratch/model.mpr"— and then copiedmprcontents/beside itverbatim.
mprcontents/carries an internal record of the model's real basename (e.g.App.mpr), so the renamed copy is a mismatched pair: mxbuild bails before writing any errorfile,
mxtk_mxbuild_error_countreturns?, and the self-test printsgate self-test: gate cannot read mxbuild's error file (baseline run)withGATE_SELFTEST_LINE="fail (unreadable error file)". That is the F-042-class string meaningthe gate itself is broken — so the symptom is a false FAIL on a perfectly healthy gate,
and it sends people hunting a problem that does not exist. The fix preserves the real basename
(
scratch_mpr="$scratch/$(basename "$MPR")") and threads it through all four later referencesto the scratch model: the baseline
mxtk_mxbuild_error_count, the mxcli injection'sexec … -p, and the known-badmxtk_mxbuild_error_count.scratch_mprjoins the function'sexisting
locallist (bash 3.2-compatible, no namerefs). A comment at the copy site recordswhy the name must not change, so the next reader does not "tidy" it back.
Reported by Yvann during Mac/sandbox onboarding, 2026-09-22.
Field evidence — which real project this ran against / was observed in, and what it measured
or fixed there (CLAUDE.md → "Shipping an instrument", rule 4; required for any instrument change):
CHANGELOG.md)tests/wave2/test-doctor-gate-selftest.shis theonly fixture covering this code. Its assertions are not greps over
doctor.sh— itexecutes doctor.sh against a fake project (
$P/Fixture.mpr+mprcontents/), a stubmxcli and five stub mxbuild behaviours. Read in full and checked against the change: the
mxbuild stub takes the last non-flag argument as the model and looks for its
.gate-selftest-bad-appliedmarker beside it, and the mxcli stub writes that markerbeside whatever
-ppath it is given — both are basename-agnostic, so every case(healthy / no-file / always-clean / constant-nonzero / slow, plus the two-tree case)
behaves identically before and after.
bash -n bin/doctor.shis clean. T2 is theoutstanding tier, per the Field evidence box. Running the fixture would confirm no
regression in the stubbed paths but cannot exercise the real-mxbuild/
mprcontentsinteraction that is the actual bug — I have not run it; say the word and I will.
(single-tree and
.mpr-under-app/), both platforms (macOS + Git Bash/Windows) considered— both layouts are covered by the fixture's two-tree case and are unaffected (the change
derives the name from
$MPR, whatever resolved it); both platforms are unaffected(
basenameonly). Golden input is the box above: not captured, and that is the gap.CHANGELOG.mdline appended in this PR, crediting Yvann (CI-checked)## BUG-DRAFT-<slug>:— n/a, deliberately.bug-logs/mxcli-bugs.mdis scoped by its own header to "Issues encountered … using mxcli + MDL. Collected for
reporting to the mxcli team." This is a defect in this toolkit's own instrument, not in
the mxcli CLI, so filing it there would send the mxcli team a bug they cannot act on. The
CHANGELOG.mdline is the record.Related check performed (no change made, scope discipline): grepped
bin/andproject-bin/for other places that copy an
.mprto a scratch/temp location under a fixed name alongsidemprcontents/. None found —doctor.shheld the only$scratch/model.mpr, andproject-bin/snapshot-mpr.shalready does the right thing (cp "$f" "$DEST/$(basename "$f")"plus
mprcontents/verbatim), withrestore-mpr.shas its mirror.🤖 Generated with Claude Code
https://claude.ai/code/session_0187r9bQWkZAEppyEqrDevjK
Generated by Claude Code