Skip to content

Commit df19a4e

Browse files
committed
page-fidelity: review fixes — multi-line ALTER set, plural fold, re-styled buttons, quieter layout hint
- An ALTER `set (…) on w` segment ends at its `on`, `;`/`}` or the next ALTER operation, not at the first newline; the multi-line form dropped its caption. - Whole-word matching folds trailing s/es on both sides ("Orders" = "Order"). - An ALTER that sets ButtonStyle replaces the button's style class. - The "layout not in the input" hint prints only when a missed class looks like frame chrome (topbar/sidebar/rail/nav/menu/brand/region/layout/shell/...). - CHANGELOG: 11 pre-existing pairs, 10 unchanged. Fixture: alter-multiline-* (the review's counter-case) + inline probes; 68/68, 4 of the new assertions fail on the previous head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJgWP5vEoAsNsJYqCDMGNw
1 parent 944fce9 commit df19a4e

7 files changed

Lines changed: 100 additions & 10 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are.
1717

1818
## Unreleased
1919

20-
- fix(page-fidelity): **text is matched against what the page shows, on whole words; ButtonStyle counts as `btn btn-<style>`; layout chrome comes from the layout** ([#158](https://github.com/MendixMau/mxcli-project-toolkit/issues/158), [#157](https://github.com/MendixMau/mxcli-project-toolkit/issues/157)). Headings, actions and content were a substring test over the whole page MDL with 60% of the >3-char words enough, so a wireframe H2 "Product overview" counted as present on a page named `Product_Overview`, "Deactivate product" on a button captioned "Deactivate", and an "Add" button passed with no words to test. Each wireframe string is now matched per literal against the page's own captions — headings against Title/Content/non-button Captions, actions against button Captions, content against every displayed literal — on whole words, all of them for a label under three words; bindings keep the identifier corpus. An `actionbutton` now declares `btn` + `btn-<ButtonStyle>` (`btn-default` when DESCRIBE omits it), per the measured DOM contract in `learned-stylegallery.md`. The page's layout, when its MDL is in the input (`describe layout`), or `--chrome a,b`, adds to the fixed chrome set; without either nothing changes. Scores move: on 13 real or fixture page/wireframe pairs in the repo, 11 unchanged, a stub page 66%→39% (a "Waiting for customer" heading credited from `dgWaiting` + `CustomerQuery`), and the two new probe pairs; a field run on a live project is still owed. — MendixMau
20+
- fix(page-fidelity): **text is matched against what the page shows, on whole words; ButtonStyle counts as `btn btn-<style>`; layout chrome comes from the layout** ([#158](https://github.com/MendixMau/mxcli-project-toolkit/issues/158), [#157](https://github.com/MendixMau/mxcli-project-toolkit/issues/157)). Headings, actions and content were a substring test over the whole page MDL with 60% of the >3-char words enough, so a wireframe H2 "Product overview" counted as present on a page named `Product_Overview`, "Deactivate product" on a button captioned "Deactivate", and an "Add" button passed with no words to test. Each wireframe string is now matched per literal against the page's own captions — headings against Title/Content/non-button Captions, actions against button Captions, content against every displayed literal — on whole words, all of them for a label under three words; bindings keep the identifier corpus. An `actionbutton` now declares `btn` + `btn-<ButtonStyle>` (`btn-default` when DESCRIBE omits it), per the measured DOM contract in `learned-stylegallery.md`. The page's layout, when its MDL is in the input (`describe layout`), or `--chrome a,b`, adds to the fixed chrome set; without either nothing changes. Whole-word matching folds plurals (`Orders` = `Order`) on both sides, and multi-line ALTER `set (…) on w` statements count, including a ButtonStyle that replaces the old one. Scores move: of the 11 page/wireframe pairs already in the repo, 10 are unchanged and a stub page drops 66%→39% (a "Waiting for customer" heading credited from `dgWaiting` + `CustomerQuery`); the new probe pairs fail on the old scorer; a field run on a live project is still owed. — MendixMau
2121
- learn(testing-shape, test-result-audit): **three test-strength rules, each with a denominator: refusals probed on the server, every undeclared 4xx a failure, one clean-database final run** ([#172](https://github.com/MendixMau/mxcli-project-toolkit/issues/172)). A field comparison of two builds against one frozen spec found the toolkit build checked permission refusals only in the client (a hidden menu item), logged unexpected 400/422 responses as information, and reached 20/20 by stitching three runs. `testing-shape.md` §7 gains three report lines (`N of N restricted pairs probed server-side`, `undeclared 4xx/5xx: 0 of M requests — each fails its step`, `one clean-DB run <id>: N of N scenarios incl. timers, not stitched`); `test-result-audit.md` gains check 2e, which carries the reasons and the field evidence and asks for those numbers. Both baseline skills stay inside the 80,000-word baseline budget (79,997): the reasons live in the on-demand audit skill, and two redundant sentences in `testing-shape.md` §4's verdict paragraphs were folded (the empty-set corollary is stated in the Trace row, `harness-architecture.md` and `report-schema.md`). The backing inbox note is trimmed to its unpromoted "Keep" items. — MendixMau
2222
- learn(learned-detection-gaps, module-review): **two UI defects every model gate passes: a lazy-loaded combo box filter hides its preset, and a theme that pins row heights by position lets the next row cover an inserted widget** ([#299](https://github.com/MendixMau/mxcli-project-toolkit/issues/299)). Both passed check, mxbuild, lint and the scripted checks on a 127-module production app and were found only in the running app. Two register rows with the first oracle and the pre-build check (pluggable properties that change *when* data loads; grep the theme for fixed `height` on positional row classes before an insert), and two LOOK lines in `module-review.md` §4c with denominators (`N of N filters show their preset on first load`, `N of N widgets inserted into an existing container fully visible`). — jopterhorst
2323
- fix(app-restart, test-stack-up): **a port held by another process before `run --local` is named and reported as "instrument blocked" (exit 4), never killed** ([#262](https://github.com/MendixMau/mxcli-project-toolkit/issues/262)). Studio Pro had started its own runtime on the app/admin ports a restart needed; `mxcli run --local` then failed with "Authentication failed" (the admin API answering was Studio Pro's), the next journey ran against Studio Pro's runtime, and four more runs were NOT RUN. `app-restart.sh` now checks the app port and the admin port (record's `adminPort`, else app + 10) before stopping anything — a holder outside the recorded process tree exits 4 with its name, pid and parent — and again after the stop, where anything still holding a port is by definition not ours. `test-stack-up.sh` runs the same check wherever it would tell you to start `run --local` (`--no-docker`, no Docker daemon, `--check` with a leftover record), on the record's ports, `RUN_LOCAL_APP_PORT`/`RUN_LOCAL_ADMIN_PORT`, or mxcli's defaults 8080/8090. Holder lookup: lsof, then ss, then netstat + tasklist on Windows; unnamed holders still block when nothing of ours is running. Fixtures: `test-app-restart.sh` +2 cases (14 assertions, all fail on the old script), `test-stack-up-local.sh` T7 (4 of 6 fail on the old script). — AlvinnYeo

‎project-bin/page-fidelity.js‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ function mdlWidgets(mdl) {
568568
return { widgets: out, masked };
569569
}
570570

571+
// One ALTER `set` statement, on the MASKED text (string contents blank): from `set` to its
572+
// `on <widget>`, or — page-level, no `on` — to the `;`/`}` or the next ALTER operation that ends
573+
// it. NOT to the end of the line: mxcli accepts the parenthesised form over several lines
574+
// (`set (\n Caption = '…',\n ButtonStyle = Success\n) on btnApprove`), and a segment that
575+
// stopped at the first newline dropped that caption.
576+
const ALTER_OP = '\\b(?:set|insert|drop|replace)\\b';
577+
const SET_STMT = new RegExp('\\bset\\b((?:(?!' + ALTER_OP + ')[^;{}])*?)(?:\\bon\\s+"?([A-Za-z_][A-Za-z0-9_]*)"?|(?=[;}]|' + ALTER_OP + '))', 'gi');
578+
571579
function mdlTexts(mdl) {
572580
const { widgets, masked } = mdlWidgets(mdl);
573581
const t = { headings: [], actions: [], content: [] };
@@ -590,7 +598,7 @@ function mdlTexts(mdl) {
590598
}
591599
// ALTER … set (Caption = '…', …) on w / set Title = '…' (page-level, no `on`). mxcli
592600
// accepts `:` inside the parenthesised form too (`set (Content: '…') on brandText`).
593-
for (const m of masked.matchAll(/\bset\b([^;{}]*?)(?:\bon\s+"?([A-Za-z_][A-Za-z0-9_]*)"?|(?=[;}\n]))/gi)) {
601+
for (const m of masked.matchAll(SET_STMT)) {
594602
const seg = mdl.slice(m.index, m.index + m[0].length);
595603
const type = m[2] ? (kind[m[2]] || null) : null;
596604
for (const p of seg.matchAll(new RegExp('\\b(Title|Caption|Content|Label|Placeholder)\\s*[:=]\\s*' + LIT, 'gi')))
@@ -601,9 +609,14 @@ function mdlTexts(mdl) {
601609

602610
// The words a wireframe string must show: the >3-char words, or — when it has none ("New",
603611
// "OK", "Add") — all of its words, so a short label is matched instead of passing vacuously.
604-
const keyWords = txt => { const w = words(txt); return w.length ? w : norm(txt).split(' ').filter(Boolean); };
612+
// Whole words, with a light SYMMETRIC plural fold (applied to both sides): "Open tasks" is the
613+
// caption "Open task", "Orders" the title "Order", "Boxes" the label "Box". The substring test
614+
// credited those for free; whole-word matching without the fold read them as missing.
615+
const stem = w => w.length > 3 && /(ss|x|z|ch|sh)es$/.test(w) ? w.slice(0, -2)
616+
: w.length > 3 && /[^s]s$/.test(w) ? w.slice(0, -1) : w;
617+
const keyWords = txt => { const w = words(txt); return (w.length ? w : norm(txt).split(' ').filter(Boolean)).map(stem); };
605618
function makeHit(lits) {
606-
const sets = lits.map(l => new Set(norm(l).split(' ').filter(Boolean)));
619+
const sets = lits.map(l => new Set(norm(l).split(' ').filter(Boolean).map(stem)));
607620
return txt => {
608621
const w = keyWords(txt);
609622
if (!w.length) return true;
@@ -621,17 +634,23 @@ function makeHit(lits) {
621634
// the only way a page script styles a button. Link buttons are NOT mapped: their rendered
622635
// classes have not been measured.
623636
function buttonClasses(mdl) {
624-
const out = new Set();
625637
const { widgets, masked } = mdlWidgets(mdl);
626-
const kind = {};
638+
const kind = {}, style = {}; // style: actionbutton name -> its CURRENT ButtonStyle
627639
for (const w of widgets) {
628640
kind[w.name] = w.type;
629641
if (w.type !== 'actionbutton') continue;
630642
const st = w.props.match(/\bButtonStyle\s*:\s*"?([A-Za-z]+)"?/i);
631-
out.add('btn'); out.add('btn-' + (st ? st[1] : 'default').toLowerCase());
643+
style[w.name] = (st ? st[1] : 'default').toLowerCase();
632644
}
633-
for (const m of masked.matchAll(/\bset\b[^;{}]*?\bButtonStyle\s*[:=]\s*"?([A-Za-z]+)"?[^;{}]*?\bon\s+"?([A-Za-z_][A-Za-z0-9_]*)"?/gi))
634-
if (!kind[m[2]] || kind[m[2]] === 'actionbutton') { out.add('btn'); out.add('btn-' + m[1].toLowerCase()); }
645+
// An ALTER that sets ButtonStyle REPLACES the button's style (the old btn-<x> is gone from the
646+
// DOM); on a button not declared in the input it can only add.
647+
for (const m of masked.matchAll(SET_STMT)) {
648+
if (!m[2] || (kind[m[2]] && kind[m[2]] !== 'actionbutton')) continue;
649+
const st = m[1].match(/\bButtonStyle\s*[:=]\s*"?([A-Za-z]+)"?/i);
650+
if (st) style[m[2]] = st[1].toLowerCase();
651+
}
652+
const out = new Set();
653+
for (const k of Object.keys(style)) { out.add('btn'); out.add('btn-' + style[k]); }
635654
return out;
636655
}
637656

@@ -772,7 +791,8 @@ if (bareImg && s.bd.miss.some(r => r.image))
772791
' set them (ALTER PAGE … set ImageUrl = [Attr]) as another input');
773792
if (s.c.chrome.length) console.log(' chrome (layout-supplied, not scored): ' + s.c.chrome.join(' '));
774793
if (lay.found) console.log(' layout ' + lay.name + ' read from input: ' + lay.classes.size + ' class(es) treated as chrome');
775-
else if (lay.name && s.c.miss.length && !CHROME.length)
794+
// Only when a missed class LOOKS like frame chrome — a hint on every page with any miss is noise.
795+
else if (lay.name && !CHROME.length && s.c.miss.some(c => /(^|-)(topbar|sidebar|rail|nav|navbar|navigation|menu|menubar|brand|region|layout|shell|appbar|userchip|avatar)(-|$)/.test(c)))
776796
console.log(' layout ' + lay.name + ' is not in the input — if a missed class is one it renders, pass' +
777797
' `describe layout ' + lay.name + '` output as another input, or name it with --chrome a,b');
778798
if (wf.mockUsed.length) console.log(' bound-data mocks (wireframe-local, text not scored): ' + wf.mockUsed.join(' '));

‎tests/wave2/fixtures/page-fidelity-mocks/CAPTURE.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,14 @@ frame, with the layout's `region-topbar` / `region-sidebar` / `region-content` c
139139
Master: `71% classes 0/2` (the layout's region classes scored as the page's). Fixed, with the
140140
layout in the input or named with `--chrome`: `100% classes 0/0`, both reported as chrome.
141141
Without either, the default chrome set is unchanged and the classes are still owed.
142+
143+
## alter-multiline — review counter-case for the caption match (2026-10-13)
144+
145+
**Synthetic**, all three files: the independent review's counter-case, kept as written apart
146+
from the marker comments and the `btn btn-success` classes on the Approve button. It pins three
147+
things the first cut of the caption match got wrong: an ALTER `set (…) on w` spread over
148+
several lines (the segment ended at the first newline and dropped `'Approve order'`); a
149+
plural wireframe heading (`Orders`) against a singular title (`'Order'`), which whole-word
150+
matching without a plural fold read as missing; and a ButtonStyle set by that ALTER. Misses
151+
that remain are real: `Save changes` vs the caption `'Save'`, an icon-only Edit button with an
152+
empty caption, and `Recent activity`, whose second word is a bound parameter.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- SYNTHETIC: the parenthesised ALTER set form spread over several lines.
2+
alter page Shop.Order_Overview {
3+
set (
4+
Caption = 'Approve order',
5+
ButtonStyle = Success
6+
) on btnApprove
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- SYNTHETIC (review counter-case for #318): a page whose button captions differ from the
2+
-- wireframe's, a snippet heading, and a title in the singular. See CAPTURE.md.
3+
create page Shop.Order_Overview (
4+
Title: 'Order',
5+
Layout: Atlas_Core.Atlas_Default
6+
) {
7+
snippetcall sc1 (Snippet: Shop.SNIPPET_CustomerHeader)
8+
groupbox gbShip (Caption: 'Shipping') {
9+
dynamictext t2 (Content: 'Recent {1}', ContentParams: [{1} = Activity])
10+
}
11+
dynamictext intro (Content: 'Here you can review every open order for this customer')
12+
actionbutton btnSave (Caption: 'Save', Action: save_changes, ButtonStyle: Primary)
13+
actionbutton btnCancel (Caption: 'Cancel', Action: cancel_changes)
14+
actionbutton btnEdit (Caption: '', Icon: 'pencil', Action: show_page Shop.Order_NewEdit(Order: $currentObject))
15+
actionbutton btnApprove (Caption: 'Approve', Action: microflow Shop.ACT_Order_Approve(Order: $currentObject))
16+
}
17+
create snippet Shop.SNIPPET_CustomerHeader {
18+
dynamictext h (Content: 'Customer details', RenderMode: H2)
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<!-- SYNTHETIC wireframe (review counter-case for #318), paired with alter-multiline-*.mdl. -->
3+
<html><body><main>
4+
<h1>Orders</h1>
5+
<h2>Customer details</h2>
6+
<h2>Shipping</h2>
7+
<h3>Recent activity</h3>
8+
<p>Here you can review every open order for this customer.</p>
9+
<button>Save changes</button>
10+
<button>Cancel</button>
11+
<button>Edit</button>
12+
<button class="btn btn-success">Approve order</button>
13+
</main></body></html>

‎tests/wave2/test-page-fidelity-mocks.sh‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,26 @@ OUT17=$(cd "$TMP" && printf '%s\n' "$PAGEONLY" | node "$SUT" --no-log --chrome r
227227
has "--chrome names them instead" "$OUT17" "classes 0/0"
228228
has "--chrome classes are reported as chrome too" "$OUT17" "chrome (layout-supplied, not scored): region-sidebar region-content"
229229

230+
echo " -- a multi-line ALTER set, plurals, and a re-styled button (review of #318)"
231+
# alter-multiline-* is a SYNTHETIC counter-case (see CAPTURE.md). The first cut of the caption
232+
# match ended an ALTER `set` segment at the first newline and dropped 'Approve order'; and
233+
# whole-word matching read "Orders" against the title 'Order' as missing.
234+
AM="$FIX/alter-multiline"
235+
OUT18=$(cd "$TMP" && node "$SUT" --no-log "$AM.html" Order_Overview "$AM-page.mdl" "$AM-alter.mdl" 2>&1)
236+
echo "$OUT18" | sed 's/^/ | /'
237+
hasnt "a caption set by a multi-line ALTER is seen" "$OUT18" "action: Approve order"
238+
hasnt "a plural heading matches its singular title" "$OUT18" "heading: Orders"
239+
has "the multi-line ALTER's ButtonStyle is seen" "$OUT18" "classes 2/2"
240+
has "a different caption is still a miss" "$OUT18" "action: Save changes"
241+
RESTYLE="$TMP/restyle.mdl"
242+
printf "create page M.R (Title: 'R', Layout: Atlas_Core.Atlas_Default) {\n actionbutton bGo (Caption: 'Go', Action: close_page, ButtonStyle: Warning)\n}\nalter page M.R {\n set ButtonStyle = Success on bGo;\n}\n" > "$RESTYLE"
243+
printf '<main><h1>R</h1><button class="btn btn-warning">Go</button></main>' > "$TMP/restyle.html"
244+
OUT19=$(cd "$TMP" && node "$SUT" --no-log "$TMP/restyle.html" R "$RESTYLE" 2>&1)
245+
has "an ALTER that re-styles a button drops its old class" "$OUT19" "classes: btn-warning"
246+
hasnt "no layout hint when no missed class looks like chrome" "$OUT19" "is not in the input"
247+
hasnt "no layout hint for page classes (seg-tabs, dg-*)" "$OUT6" "is not in the input"
248+
has "the hint names the layout when region-* is missed" "$OUT16" "layout LayoutTest.App_Default is not in the input"
249+
230250
echo
231251
printf 'test-page-fidelity-mocks: %d passed, %d failed\n' "$PASS" "$FAIL"
232252
[ "$FAIL" -eq 0 ]

0 commit comments

Comments
 (0)