Skip to content

Commit 86cb3c0

Browse files
committed
Merge #498 head 6b2ed75 into fix/stale-describe-261
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJgWP5vEoAsNsJYqCDMGNw
2 parents 8431714 + 6b2ed75 commit 86cb3c0

3 files changed

Lines changed: 44 additions & 8 deletions

File tree

‎CHANGELOG.md‎

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

2222
- fix(exec): **a script restated from a stale DESCRIBE now WARNs instead of silently reverting an earlier exec** (#261). A script drafted from a DESCRIBE taken before an earlier script of the batch ran put four old messages back, with check, mxbuild and lint green. New `project-bin/describe-baseline.sh stamp` writes `-- baseline: <Doc> sha256=<hash>` (plus `-- baseline-mxcli: <version>`) from a DESCRIBE at draft time; `exec.sh` runs `verify` only for a script that carries the header, so other scripts cost one grep and no mxcli call. It reports DRIFT with the first lines of the diff, STALEHEADER, and RESTAMP after an mxcli upgrade (DESCRIBE text may change, so that is not called drift). A re-run by the script's own last recorded write (the #269 ledger) and a fresh model are not drift. Nothing is refused and the exit codes do not change. Preflight STOP 21 gains one clause (`-- supersedes:`, `stamp`, exec.sh only warns; +21 words). Not-found DESCRIBE and `--version` output are captured from mxcli v0.26.0. Lands after the #269 PR; with it, supersedes draft #311. **Behaviour change to check in your project:** `exec.sh` output can carry `WARN: stale draft: …` lines, and the BUILD-LOG detail cell `WARN stale baseline: <docs>`; `MXTK_RESTATE_GUARD=off` skips the check. — AlvinnYeo (#261)
2323
- fix(exec): **re-running an older `mdlsource/` script over a newer owner's live work now WARNs instead of passing silently** (#269). Three field apps had 99/579, 130/357 and 38/159 documents created by more than one script, and a replay of an older one reverted the newer with exit 0 and every gate green. New `project-bin/script-owners.sh` maps each microflow, nanoflow, page and snippet to the scripts that create or restate it, in run order (digit runs compared as numbers, so `2-core/` runs before `11-fixes/`; `done-` ignored), and reads `-- supersedes:` / `-- superseded-by:` headers. `exec.sh` records every kept write in a machine-local last-writer ledger (`.claude/loop/script-owners/`, self-gitignored, compacted per write); `restore-mpr.sh` marks it on a manual restore. A replay WARNs only when the newer owner's write is live: ledger first, else one DESCRIBE per document, at most 5 per exec (the rest print `CONFLICT (not checked)`). A new owner without a supersedes header gets one `NOTE:` line on its first run, kept out of BUILD-LOG. Nothing is refused and the exit codes do not change. With no co-owner, `exec.sh` runs one grep over `mdlsource/` and no mxcli call. `gate-check.sh` prints the co-owned count when it is above 0. Part of the rebuilt draft #311 (with the #261 PR). **Behaviour change to check in your project:** `exec.sh` output can carry `WARN: restatement: …` and `NOTE: new owner of …` lines; the BUILD-LOG detail cell can carry `WARN reverts: <docs>`. Set `MXTK_RESTATE_GUARD=off` to skip the check. — MendixMau (#269)
24+
- fix(exec): **re-running an older `mdlsource/` script over a newer owner's live work now WARNs instead of passing silently** (#269). Three field apps had 99/579, 130/357 and 38/159 documents created by more than one script, and a replay of an older one reverted the newer with exit 0 and every gate green. New `project-bin/script-owners.sh` maps each microflow, nanoflow, page and snippet to the scripts that create or restate it, in run order (digit runs compared as numbers, so `2-core/` runs before `11-fixes/`; `done-` ignored), and reads `-- supersedes:` / `-- superseded-by:` headers. `exec.sh` records every kept write in a machine-local last-writer ledger (`.claude/loop/script-owners/`, self-gitignored, compacted per write); `restore-mpr.sh` marks it on a manual restore. A script counts as run when it has a ledger row, a `done-` name, or an applied `docs/BUILD-LOG.md` row, so a fresh clone or cloud session (empty ledger) still warns on a replay over committed newer work; a script nobody ran yet (draft-ahead) stays quiet. The ledger cannot see Studio Pro edits or a `git pull`/`checkout` of the `.mpr`. A replay WARNs only when the newer owner's write is live: ledger first, else one DESCRIBE per document, at most 5 per exec (the rest print `CONFLICT (not checked)`). A new owner without a supersedes header gets one `NOTE:` line on its first run, kept out of BUILD-LOG. Nothing is refused and the exit codes do not change. With no co-owner, `exec.sh` runs one grep over `mdlsource/` and no mxcli call. `gate-check.sh` prints the co-owned count when it is above 0. Part of the rebuilt draft #311 (with the #261 PR). **Behaviour change to check in your project:** `exec.sh` output can carry `WARN: restatement: …` and `NOTE: new owner of …` lines; the BUILD-LOG detail cell can carry `WARN reverts: <docs>`. Set `MXTK_RESTATE_GUARD=off` to skip the check. — MendixMau (#269)
2425
- fix(exec): **a pre-exec `mxcli check` refusal now records its reason in the BUILD-LOG row, and the preflight STOP table gains rows 29-32** (#445). The 🚫 row said only "mxcli check failed pre-exec", so the reason for 3 field refusals was lost (the issue suspects MDL-PAGEARG01, in mxcli since about v0.19); exec.sh now keeps the output of the one check run it already makes, still printed live, and appends `; check: <first error line>` (rule id first, ANSI and CR stripped, pipes escaped, cut at 160 bytes on a UTF-8 boundary). New STOP rows: a constant in a nanoflow (CE0117), `dynamicimage` on the React client (CE0582), a data-view attribute binding across 2+ associations (CE1613), a widget `show page` argument with no context object or besides it (MDL-PAGEARG01). Golden input: two real mxcli v0.26.0 check captures (mxcli's own PAGEARG01 test and a parse error), not the field output. BUG-70 notes that v0.26.0 `check` now refuses its shape. Test: `tests/wave2/test-exec-check-refusal.sh` — MendixMau (field 2026-10-17)
2526
- fix(exec): **`exec.sh` exit codes now mean what they say (#443, #448).** A clean build with a lint rise exited 1 like a failed gate, and an UNVERIFIED gate exited 0 like a pass: in one field build 57 of 58 clean builds exited 1, agents learned to ignore 1, and 10 UNVERIFIED runs read as success. Now `0` applied and gate passed · `1` not applied or rolled back (and PARTIAL, whatever mxcli exited) · `2` usage, nothing touched · `4` applied, gate passed, lint only (LINT ROSE/BLIND; last line `gate passed, lint only`) · `5` applied, UNVERIFIED (also `ALLOW_UNVERIFIED=1`). An mxbuild exit 1/3 whose errors file holds only a generic deploy-stage message (`Compilation of the app bundle failed.`, `An error occurred while ...`) and no model problem is retried once, like an empty one, but not again by the gate when the baseline's retry already failed with the same text; a version mismatch still is not. No extra mxbuild on the happy path (2); worst case 3. Defined in the `exec.sh` header, mirrored in `iterative-build-loop.md`; `doctor.sh --fix-property-sets` reads 4 as kept, `sync-project.sh` names the fix for a hand-edited copy; `test-exec-gate-retry.sh` F–L pin it. **Behaviour change to check in your project:** a wrapper that tests exec.sh's exit code now sees 4 for a lint-only rise (was 1) and 5 for UNVERIFIED (was 0); a PARTIAL run never exits 4 or 5. — MendixMau (field 2026-10-17)
2627
- fix(status): **`bin/status.sh` (full and `--brief`) prints one `CWD` line when the session runs outside the project folder, and the README quick start says to launch the lead session from the project folder** (#447). Claude Code finds `.claude/agents/` by walking up from the launch folder, so a lead started in a sibling folder ran a whole Stage 5 build (110 execs) on general-purpose agents and nothing said why. The check is two `pwd -P` calls; only the warning path asks `_common.sh`'s `mxtk_walk_root` which project the cwd belongs to. `CONVERSION-RUNBOOK.md` now says `<project-root>` instead of "the workspace". Test: `tests/wave2/test-status-session-cwd.sh`; `test-status-existing-app.sh` now runs status.sh from the project root, as a session does — MendixMau (field 2026-10-17)

‎project-bin/script-owners.sh‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
# before 10-b; no `sort -V`, older macOS sort lacks it) and a leading `done-` ignored
3232
# (iterative-build-loop.md renames an executed script done-<name>).
3333
#
34-
# "O's write is live". Neither S nor O has ever run on this machine → S is new: nothing. Else the
34+
# "O's write is live". Neither S nor O has ever run → S is new: nothing. "Has run" is any of: a
35+
# ledger row, a `done-` file name, or a docs/BUILD-LOG.md row naming it in backticks whose result
36+
# says applied (the done-drift-check.sh pattern). The last two are committed, so a fresh clone or
37+
# cloud session, whose ledger is empty, still sees a replay over committed newer work. Else the
3538
# LAST-WRITER LEDGER: last writer is S or a script before S → O's work is not in the model. Else ONE
3639
# DESCRIBE per document (absent → nothing to revert, e.g. a fresh model), at most 5 per check; the
3740
# rest print as UNCHECKED. No ./mxcli → REVERT. The ledger knows only exec.sh's writes: restore-mpr.sh
38-
# appends a RESTORE row and rows before the last one are ignored (DESCRIBE decides again); a
39-
# Studio Pro edit is invisible to it.
41+
# appends a RESTORE row and rows before the last one are ignored (DESCRIBE decides again). It cannot
42+
# see a Studio Pro edit, nor a `git pull` / `git checkout` that changes the .mpr.
4043
#
4144
# LEDGER: <root>/.claude/loop/script-owners/written.tsv, epoch <tab> key <tab> KIND Module.Name
4245
# (key = root-relative path, done- removed), or epoch <tab> RESTORE <tab> <snapshot>. MACHINE-LOCAL,
@@ -156,8 +159,13 @@ so_last_writer() { # $1 = root, $2 = "KIND Module.Name"; rows before the last R
156159
[ -f "$1/$LEDGER_REL" ] || return 0
157160
awk -F'\t' -v d="$2" '$2 == "RESTORE" { w = "" } $3 == d { w = $2 } END { if (w != "") print w }' "$1/$LEDGER_REL"
158161
}
159-
so_has_run() { # $1 = root, $2 = ledger key → true when that script has any ledger row
160-
[ -f "$1/$LEDGER_REL" ] && awk -F'\t' -v k="$2" '$2 == k { f = 1; exit } END { exit !f }' "$1/$LEDGER_REL"
162+
so_has_run() { # $1 = root, $2 = root-relative script path → true when it has run (see header)
163+
local b; b="$(basename "$2")"
164+
case "$b" in done-*) return 0 ;; esac
165+
if [ -f "$1/$LEDGER_REL" ] && awk -F'\t' -v k="$(so_sortkey "$2")" '$2 == k { f = 1; exit } END { exit !f }' "$1/$LEDGER_REL"; then
166+
return 0
167+
fi
168+
[ -f "$1/docs/BUILD-LOG.md" ] && awk -F'|' -v n="\`$b\`" 'index($3, n) && $5 ~ /applied/ { f = 1; exit } END { exit !f }' "$1/docs/BUILD-LOG.md"
161169
}
162170
so_rel() { # $1 = script, $2 = root → root-relative path, or "" outside the root
163171
local abs; abs="$(cd "$(dirname "$1")" 2>/dev/null && pwd)/$(basename "$1")"
@@ -220,7 +228,7 @@ case "$cmd" in
220228
[ -f "${2:-}" ] || usage
221229
S="$2"; ROOT="$(so_root "${3:-}")"
222230
S_REL="$(so_rel "$S" "$ROOT")"; S_KEY="$(so_key "$S")"
223-
S_RAN=0; [ -n "$S_REL" ] && so_has_run "$ROOT" "$(so_sortkey "$S_REL")" && S_RAN=1
231+
S_RAN=0; [ -n "$S_REL" ] && so_has_run "$ROOT" "$S_REL" && S_RAN=1
224232
DOCS="$(so_docs "$S" | awk -F'\t' '$4 != "create" { print $1 " " $2 }' | LC_ALL=C sort -u)"
225233
[ -n "$DOCS" ] || exit 0
226234
# Only scripts containing a restated document's bare name are lexed (quoted or not, it is in
@@ -237,7 +245,7 @@ case "$cmd" in
237245
# rc 0: O's work on doc $1 is not in the model; 1: it is (or unknown); 2: DESCRIBE cap reached.
238246
not_live() { # $1 = "KIND Module.Name", $2 = O
239247
local w live rc=1
240-
if [ "$S_RAN" = 0 ] && ! so_has_run "$ROOT" "$(so_sortkey "$2")"; then return 0; fi # S is new
248+
if [ "$S_RAN" = 0 ] && ! so_has_run "$ROOT" "$2"; then return 0; fi # S is new
241249
case "$NL_SEEN" in *"|$1="*) rc="${NL_SEEN#*"|$1="}"; return "${rc%%|*}" ;; esac
242250
w="$(so_last_writer "$ROOT" "$1")"
243251
if [ -n "$w" ] && [ -n "$S_REL" ] && { [ "$w" = "$(so_sortkey "$S_REL")" ] || so_before "$w" "$S_REL"; }; then

‎tests/wave2/test-restatement-guard.sh‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ OUT="$(rchk mdlsource/11-fixes/b.mdl)"; RC=$?
6868
[ "$RC" -eq 0 ] && has "forward exec of 11-fixes: NOTE, older owner 2-core" "$OUT" "NOTE MICROFLOW Sales.ACT_ApprovalStep_Reject mdlsource/2-core/a.mdl older owner" || bad "11-fixes rc $RC: $OUT"
6969
hasnt " not called a replay" "$OUT" "REVERT"
7070
OUT="$(rchk mdlsource/ph/done-10-b.mdl)"; RC=$?
71-
[ "$RC" -eq 0 ] && has "forward exec of 10-b: older owner 9-a" "$OUT" "older owner mdlsource/ph/9-a.mdl" || bad "10-b rc $RC: $OUT"
71+
[ "$RC" -eq 0 ] && hasnt "re-run of done-10-b (it has run): 9-a is older, not a replay" "$OUT" "REVERT" || bad "10-b rc $RC: $OUT"
7272

7373
# ── check + ledger, without an mxcli ─────────────────────────────────────────
7474
echo "-- check and ledger"
@@ -116,6 +116,23 @@ T="$WORK/twotree"; mkdir -p "$T/app/mdlsource"; cp "$REJ" "$T/app/mdlsource/05-r
116116
OUT="$(bash "$OWNERS" count "$T" 2>&1)"
117117
[ "$OUT" = "1 1" ] && ok "two-tree: app/mdlsource/ found (1 of 1 co-owned)" || bad "two-tree count '$OUT'"
118118

119+
echo "-- fresh clone (empty ledger): committed evidence that the newer owner ran"
120+
F="$WORK/clone"; mkdir -p "$F/mdlsource" "$F/docs"
121+
cp "$REJ" "$F/mdlsource/05-reject.mdl"
122+
{ echo "-- supersedes: 05-reject.mdl"; fix "A reason is required."; } > "$F/mdlsource/done-09-reject-fix.mdl"
123+
fchk() { ( cd "$F" && PROJECT_ROOT="$F" bash "$OWNERS" check "$1" "$F" ) 2>&1; }
124+
OUT="$(fchk mdlsource/05-reject.mdl)"; RC=$?
125+
[ "$RC" -eq 1 ] && has "done-09 supersedes 05, replay 05, no ledger: REVERT" "$OUT" "REVERT MICROFLOW Sales.ACT_ApprovalStep_Reject mdlsource/done-09-reject-fix.mdl" || bad "done- evidence rc $RC: $OUT"
126+
mv "$F/mdlsource/done-09-reject-fix.mdl" "$F/mdlsource/09-reject-fix.mdl"
127+
OUT="$(fchk mdlsource/05-reject.mdl)"; RC=$?
128+
[ "$RC" -eq 0 ] && [ -z "$OUT" ] && ok "09 never run (draft-ahead), no ledger: quiet" || bad "draft-ahead rc $RC: $OUT"
129+
printf '| when (ISO-8601 local) | script | gate | result | detail |\n|---|---|---|---|---|\n| 2026-10-20T10:00:00+0000 | `09-reject-fix.mdl` | pass | ✅ applied | mxbuild clean |\n' > "$F/docs/BUILD-LOG.md"
130+
OUT="$(fchk mdlsource/05-reject.mdl)"; RC=$?
131+
[ "$RC" -eq 1 ] && has "BUILD-LOG ✅ applied row for 09, no ledger: REVERT" "$OUT" "REVERT MICROFLOW Sales.ACT_ApprovalStep_Reject mdlsource/09-reject-fix.mdl" || bad "BUILD-LOG evidence rc $RC: $OUT"
132+
printf '| when (ISO-8601 local) | script | gate | result | detail |\n|---|---|---|---|---|\n| 2026-10-20T10:00:00+0000 | `09-reject-fix.mdl` | fail | ❌ gate failed | script rolled back |\n' > "$F/docs/BUILD-LOG.md"
133+
OUT="$(fchk mdlsource/05-reject.mdl)"; RC=$?
134+
[ "$RC" -eq 0 ] && [ -z "$OUT" ] && ok "a rolled-back BUILD-LOG row is not 'has run': quiet" || bad "rolled-back row rc $RC: $OUT"
135+
119136
# ── fixture project for live + exec.sh ───────────────────────────────────────
120137
P="$WORK/proj"
121138
mkdir -p "$P/bin" "$P/mprcontents" "$P/mdlsource" "$P/live"
@@ -158,6 +175,7 @@ MXCLI
158175
cat > "$WORK/mxbuild" <<'MXB'
159176
#!/usr/bin/env bash
160177
OUT=""; for a in "$@"; do case "$a" in --write-errors=*) OUT="${a#--write-errors=}" ;; esac; done
178+
if [ "${FAIL_GATE:-0}" = 1 ]; then printf '{"problems":[{"severity":"Error","errorCode":"CE1234","message":"boom"}]}' > "$OUT"; exit 0; fi
161179
[ -n "$OUT" ] && printf '{"problems":[]}' > "$OUT"; exit 0
162180
MXB
163181
chmod +x "$P/bin/"*.sh "$P/mxcli" "$WORK/mxbuild"
@@ -212,6 +230,15 @@ hasnt "happy path: no WARN/NOTE" "$OUT" "WARN: restatement"
212230
grep -q "mdlsource/01-solo.mdl MICROFLOW Sales.ACT_Solo" "$P/.claude/loop/script-owners/written.tsv" 2>/dev/null \
213231
&& ok "a kept write is recorded in the ledger" || bad "no ledger row for the kept write"
214232

233+
echo "-- exec.sh: its own rollback writes no RESTORE marker"
234+
printf 'create or modify microflow "Sales"."ACT_Broken" ()\nbegin\nend;\n/\n' > "$C/02-broken.mdl"
235+
LGP="$P/.claude/loop/script-owners/written.tsv"
236+
OUT="$(FAIL_GATE=1 run mdlsource/02-broken.mdl)"; RC=$(cat "$WORK/rc")
237+
[ "$RC" -eq 1 ] && has "[setup] the failed gate rolled the write back" "$OUT" "Auto-restored from" || bad "[setup] rollback rc $RC: $(tail -3 "$WORK/out")"
238+
[ -f "$LGP" ] && ! grep -q 'RESTORE' "$LGP" && ok "rollback: no RESTORE row in the ledger" || bad "rollback wrote a RESTORE row: $(cat "$LGP" 2>/dev/null)"
239+
hasnt "rollback: the rolled-back script is not recorded" "$(cat "$LGP" 2>/dev/null)" "02-broken.mdl"
240+
rm -f "$C/02-broken.mdl"
241+
215242
echo "-- exec.sh: 05, then 09 (supersedes 05), replay 05, restore, replay 05"
216243
cp "$REJ" "$C/05-reject.mdl"
217244
{ echo "-- supersedes: 05-reject.mdl"; fix "A reason is required."; } > "$C/09-reject-fix.mdl"

0 commit comments

Comments
 (0)