Skip to content

Commit 24fe336

Browse files
MendixMauclaude
andauthored
tests(behaviour): standing behaviour A/B suite — M/T/N arms, skill ablation, read/tool/token metrics (#389)
Commits the 2026-10-15 stub-diet A/B kit as tests/behaviour/: build-packs.sh (any ref, temp worktree; arms M, T, N and --without <skill> ablation), score.sh (mechanical; read_all, tool_calls, tokens), RUNBOOK, README, tasks/probes, captured fixtures, results TSVs (stub diet 42 reps; first no-pack run), fixture tests/wave2/test-behaviour-score.sh, run-all.sh subject lookup, RELEASE-PROCESS §4a pointer. Review: independent review MERGE-AFTER-FIX (client data clean on every added line; 4 captures re-score exactly with and without mxcli; build-packs never touches the shared clone; run-all.sh change affects only the new fixture across all 112) — doc fixes applied in da03380 (inherited-context caveat in README + no-pack TSV header + CHANGELOG; run identified for "13 of 20"; grep -E; --without word count). Size 433 lines vs 400 cap: score.sh (207) moved whole so committed results replay byte-identically; reviewer judged justified. Field run: all 49 scored 2026-10-15 outputs re-score identically. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VJgWP5vEoAsNsJYqCDMGNw
1 parent 484e7ff commit 24fe336

22 files changed

Lines changed: 1242 additions & 2 deletions

‎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+
- new(tests/behaviour): **a standing behaviour suite for agent-read text: arms M (base ref), T (candidate ref, or the base minus one skill for an ablation) and N (no pack), two drafting tasks with planted STOP-row requests and five retrieval probes, scored mechanically.** `tests/behaviour/build-packs.sh` builds a pack from any ref in a temporary worktree; `score.sh` adds `read_all` (the agent quoted the pack's `PACK-END` line back), `tool_calls` and `tokens`, and treats `mxcli check` as optional (NA without a binary). `RUNBOOK.md` has the triggers (every PR that changes baseline-routed text or an agent stub; N and ablations at each release cut), 5 reps x 2 tasks plus 5 probes x 3 reps, the rule (T no worse than M on every scored metric, probes T >= M - 1), and partial reads counted and re-run, never dropped. `docs/RELEASE-PROCESS.md` §4a names it as the way to run the Behaviour A/B. Field runs committed under `tests/behaviour/results/`: the 2026-10-15 stub-diet A/B (#369/#378/#380, 42 reps, 3 partial reads on the 4,822-line pack) and the first no-pack run (page trap refused 0/5 without a pack against 5/5 with either; mf passes check 1/5 against 5/5; every arm, N included, also inherited the host session's project CLAUDE.md (a generic mxcli/MDL guide), so N measures 'no toolkit rules', not 'no guidance'). Golden input: four real agent outputs, `tests/wave2/test-behaviour-score.sh`. — maintainer request (MendixMau)
2223
- process(pr-template, release-process): **every Direct-lane PR and every review fills a five-row Impact block: Process, Dependencies, Context cost, Behaviour, Runtime.** "none" or "NOT RUN: <reason>" is legal, a blank row is not. Context cost is pasted from `bin/render-routing.sh --check` on base and head, never estimated; a missing or estimated row is a review finding. The Behaviour A/B (`process/preflight-skill-baseline-2026-08-31.md`) is required for baseline-routed text and agent stubs, recommended for situational skills, NOT RUN with a reason for process docs review agents read, n/a for scripts only; Context cost may be "none" when no routed or always-loaded file is touched. `docs/RELEASE-PROCESS.md` §4a holds the rule and a bad/good example; `CONTRIBUTING.md`'s reviewer list points there. No CI check: `bin/check-pr-discipline.sh` reads the git diff, not the PR body. Field evidence: three PRs reviewed on 2026-10-15 with no process cost stated (#375 added a human step per re-baseline, #384 adds 1–11 s per exec), both found by chance. — maintainer request, MendixMau
2324
- learn(learned-detection-gaps, testing-shape, ui-loop): **a class on a snippet call never reaches the DOM; a 403 bounce and a widget-pinned session probe both read as sign-outs; app restarts matched a "signs me out" report by timing.** Detection-gaps row: `Class` on a `SNIPPETCALL` is green through check, exec, mxbuild, lint and DESCRIBE, and absent in the browser ([#336](https://github.com/MendixMau/mxcli-project-toolkit/issues/336)). Testing-shape §4 gains two false-red rows: `login.html?messageCode=403` with the session kept ([#338](https://github.com/MendixMau/mxcli-project-toolkit/issues/338)), and instruments pinned to one grid name or a typed menu list (1/7 and 7/34 false FAILs after a redesign, [#339](https://github.com/MendixMau/mxcli-project-toolkit/issues/339)). ui-loop: say so before a restart while a human uses the app ([#337](https://github.com/MendixMau/mxcli-project-toolkit/issues/337)) — three-app field run, 2026-10-14
2425
- log(bug-logs): **upstream draft for `mxcli run --local --watch`: a theme-only rebuild deletes `dist/pages` and still reports a successful reload** ([#284](https://github.com/MendixMau/mxcli-project-toolkit/issues/284)). `bug-logs/pending-github-issues/watch-theme-rebuild-drops-dist-pages.md`, status DRAFT — NOT FILED: the repro (one SCSS edit, every page 404s on `dist/pages/<Page>.js`, a restart restores all 135 bundles; twice in one app on mxcli v0.26.0 / Mendix 11.15.0), the other change classes watch serves stale, the timing table (reload 35 builds median 3.8 s, restart 44 builds median 19.2 s, max 55.2 s, 928 s total) and the upstream questions: why a restart is about 5× a reload, and whether a recreated microflow keeps its old compiled version by name. The toolkit side is already on master (exec.sh restart verdicts, `app-restart.sh`, ui-loop.md "What watch picks up"). Field evidence: the 2026-10-12 three-app UX run and its 2026-10-14 recurrence, as recorded in #284. — field retro #284, MendixMau

‎docs/RELEASE-PROCESS.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ The reviewer, for each of the 5 rows, reads the diff and confirms or corrects th
104104
`bin/render-routing.sh --check` run on base and on head; otherwise "none: no routed or
105105
always-loaded file touched" is the answer. A missing row, or an estimate instead of the pasted
106106
output, is a review finding.
107-
4. **Behaviour** — an A/B per `process/preflight-skill-baseline-2026-08-31.md` is **required**
107+
4. **Behaviour** — an A/B per `process/preflight-skill-baseline-2026-08-31.md`, run with the
108+
behaviour suite (`tests/behaviour/RUNBOOK.md`: arm M = base, arm T = PR head), is **required**
108109
for a change to always-loaded / baseline-routed text or an agent stub, **recommended** for
109110
situational skill text, **NOT RUN with a reason** for process docs and templates that review
110111
agents read (they are agent-read text, so never "n/a"), and **n/a** for scripts only.

‎tests/behaviour/AGENT-PROMPT.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You are an mdl drafting agent. Do exactly this, nothing else:
2+
3+
1. Read the file PACK in full — every line, using the Read tool with offset/limit until you reach the end (it is long; do not skip any part). Its contents are your loaded instructions and skills; treat them exactly as if they were your system context.
4+
2. Then read the file TASK and do what it asks, following your loaded instructions.
5+
3. Write your complete final answer (everything the task asks you to output) to the file OUT using the Write tool.
6+
4. Then reply with only the last line of PACK (it starts with "PACK-END:"), copied exactly.
7+
8+
Rules: use only the Read and Write tools, and only on these three paths. Do not open any other file, run any command, or search the filesystem. You cannot run mxcli; draft from your instructions.

‎tests/behaviour/README.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Behaviour suite
2+
3+
A standing A/B for agent-read text: three arms (M = base ref, T = candidate ref or an ablation,
4+
N = no pack), two drafting tasks and five retrieval probes for the mdl agent at Stage 5, scored
5+
by `score.sh`. How and when to run it, and the decision rule: `RUNBOOK.md`.
6+
7+
| File | What |
8+
|---|---|
9+
| `build-packs.sh` | builds `work/pack-<arm>.txt` from any ref; `--without` for an ablation |
10+
| `AGENT-PROMPT.txt` | the one prompt every rep gets |
11+
| `tasks/` | `page.md`, `mf.md` (each with a planted STOP-row request) and five `probe-*.md` |
12+
| `score.sh` | mechanical scorer, one TSV row per rep |
13+
| `results/` | committed field runs |
14+
| `fixtures/` | four real agent outputs, golden input for `tests/wave2/test-behaviour-score.sh` |
15+
16+
## Field runs
17+
18+
Each results file's `#` header carries its run's refs, rep counts, partial reads, tool-call and
19+
token ranges, and findings.
20+
21+
- **2026-10-15, stub diet** (#369/#378/#380): `results/2026-10-15-stub-diet.tsv`, 42 reps.
22+
- **2026-10-15, first N-arm run**: `results/2026-10-15-no-pack.tsv`, 10 reps. The page trap was
23+
refused 0/5 without a pack against 5/5 with either pack; `mf` passed `mxcli check` 1/5 against
24+
5/5. Caveat: every arm, N included, also inherited the host session's project CLAUDE.md (a generic mxcli/MDL guide), so N measures 'no toolkit rules', not 'no guidance'.
25+
26+
## Future work
27+
28+
In this kit `tool_calls` mostly measures reading the pack, because the agent cannot run mxcli.
29+
It becomes meaningful as a count of DESCRIBE and exec calls in a variant where the agent drives
30+
a live mxcli against a throwaway model.

‎tests/behaviour/RUNBOOK.md‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Behaviour suite — runbook
2+
3+
Measures whether a change to agent-read text changes what the mdl agent does. Method:
4+
`process/preflight-skill-baseline-2026-08-31.md` (fresh agents, identical prompt core, only the
5+
context differs, mechanical scoring). Paths below are relative to `tests/behaviour/`.
6+
7+
## When to run
8+
9+
| Trigger | Arms | Reps |
10+
|---|---|---|
11+
| A PR that changes baseline-routed text or an agent stub (`docs/RELEASE-PROCESS.md` §4a, Behaviour row) | M = base, T = PR head | 5 × `page`, 5 × `mf`, 3 × each of the 5 probes, per arm (50 reps) |
12+
| Each release cut | N (no pack), and one ablation per baseline skill under review | N: 5 × `page`, 5 × `mf`. Ablation: M vs T-without-skill, same reps as a PR run |
13+
14+
A full PR run is about 50 agent reps at 2–4 agent-minutes each (most of it reading the pack):
15+
roughly 100–200 agent-minutes, 10–20 minutes wall clock at the orchestrator's agent cap.
16+
17+
## Build the packs
18+
19+
```
20+
bash build-packs.sh M origin/master # base
21+
bash build-packs.sh T <pr-head-ref> # candidate
22+
bash build-packs.sh T origin/master --without skills/<x>.md # ablation: value of <x>
23+
bash build-packs.sh N # no pack: preamble only
24+
```
25+
26+
Each writes `work/pack-<arm>.txt` (`work/` is ignored by git). A candidate and an ablation both
27+
write `work/pack-T.txt`: build one, run its reps, then build the other. The ref is checked out in a
28+
temporary detached worktree and removed again; the caller's tree is never touched. An ablation
29+
pack keeps the stub and its routing row naming the skill; only the skill's text is gone, which is
30+
the "routed but not read" case the skill would face. M vs ablated T is the skill's value; N vs M
31+
is the whole pack's value over plain reasoning.
32+
33+
## One rep
34+
35+
1. Pick arm `A` and task `K` (`page`, `mf`, or `probe-<name>`; task text is `tasks/<K>.md`).
36+
2. Spawn a **fresh** subagent per rep, never reused, with only Read and Write. **One model fixed
37+
for every rep of every arm.** Its prompt is `AGENT-PROMPT.txt` with PACK, TASK and OUT replaced
38+
by absolute paths: `work/pack-A.txt`, `tasks/K.md`, `work/out/A-K-rN.md`.
39+
3. Start the orchestrating session in a directory with no project `CLAUDE.md` in it or above
40+
it: the subagents inherit it. In the 2026-10-15 stub-diet run, 13 of its 20 M/T drafts named
41+
the host project's model file, which no pack or task contained (0 of the 10 N drafts did, but
42+
N inherited the same file); it reached every arm alike, so N measured "no toolkit rules", not
43+
"no guidance".
44+
4. From the subagent's result take its final reply and its usage line (`tool_uses`,
45+
`subagent_tokens`), then score:
46+
```
47+
bash score.sh work/out/A-K-rN.md --reply "<final reply>" --tool-calls <tool_uses> --tokens <subagent_tokens> >> work/results.tsv
48+
```
49+
`--reply` sets `read_all`: 1 when the reply equals the pack's `PACK-END:` line (the agent read
50+
to the end), else 0. The scorer reads arm and task from the file name.
51+
52+
Run reps in parallel, up to the orchestrator's agent cap; interleave arms (M1, T1, M2, T2, …)
53+
so drift in the model service hits both.
54+
55+
## Partial reads
56+
57+
A `read_all=0` row stays in the results file: it is counted and reported, never deleted. It is
58+
left out of the metric comparison, and the rep is run again until each cell has its full count.
59+
Report the partial-read count per arm next to the verdict; more partial reads in T than in M is
60+
itself a regression (the pack got harder to read to the end). On 2026-10-15, 3 of 5 agents given
61+
the 4,822-line M pack in one batch stopped early.
62+
63+
## Decision rule (agree it before running)
64+
65+
Arm T is **no worse than arm M on every scored metric**: compare the median and the count of reps
66+
at the good value. Lower is better for `scan`, `check`, `txtcrumb`, `cinloop`, `rinloop`, `pos`;
67+
higher for the rest. Probes: `probe_first` T ≥ M − 1 per probe across its 3 reps. A loss on any
68+
metric is a finding the PR body reports with the rows; it is not averaged away.
69+
70+
`tool_calls` and `tokens` are reported, not judged: here they mostly measure reading the pack,
71+
since the agent cannot run mxcli.
72+
73+
## Known scorer gaps
74+
75+
- `folder` counts `folder '…'` after the name, not the `Folder: '…'` page property.
76+
- `crumbs` counts link/action buttons whose action is `show page`; `Action: PAGE …` and a
77+
microflow that shows the page are not counted.
78+
- `check` is `mxcli check` with no project, so it is syntax only, and NA without a binary
79+
(`$MXCLI`, else `mxcli` on PATH).
80+
- `design-spacing.md` §3 shows the breadcrumb as one text widget; expect `txtcrumb` > 0 in every
81+
arm that carries it.

‎tests/behaviour/build-packs.sh‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env bash
2+
# build-packs.sh — build one behaviour-suite context pack (RUNBOOK.md) from any toolkit ref.
3+
#
4+
# tests/behaviour/build-packs.sh M <ref> # base, e.g. origin/master
5+
# tests/behaviour/build-packs.sh T <ref> # candidate, e.g. a PR head
6+
# tests/behaviour/build-packs.sh T <ref> --without <path> # ablation: <ref>'s pack minus one file
7+
# tests/behaviour/build-packs.sh N # no pack: preamble only
8+
# [--role mdl] [--stage 5] # the pack's role and stage
9+
#
10+
# Writes work/pack-<arm>.txt (work/ ignores itself). An M/T pack is the role stub
11+
# agents/<role>-agent.md plus every baseline file routing_baseline_pack (bin/lib/skill-routing.sh)
12+
# lists for <stage> and <role> at <ref>, with bin/runbook-slice.sh expanded to its output, so the
13+
# file list is the counted one. The ref is checked out in a temporary detached worktree, never in
14+
# the caller's tree. Every pack ends with a PACK-END line; an agent that quotes it back read to
15+
# the end (score.sh --reply). Prints arm, ref, routed words/files, and pack words.
16+
set -eu
17+
AB="$(cd "$(dirname "$0")" && pwd)"; REPO="$(cd "$AB/../.." && pwd)"
18+
usage() { sed -n '4,8p' "$0" >&2; exit 2; }
19+
ARM="${1:-}"; [ $# -gt 0 ] && shift
20+
case "$ARM" in M|T) REF="${1:-}"; [ -n "$REF" ] || usage; shift ;; N) REF="" ;; *) usage ;; esac
21+
ROLE=mdl; STAGE=5; DROP=""
22+
while [ $# -gt 0 ]; do
23+
case "$1" in
24+
--without) DROP="${2:-}"; [ -n "$DROP" ] || usage ;;
25+
--role) ROLE="${2:-}" ;; --stage) STAGE="${2:-}" ;;
26+
*) usage ;;
27+
esac
28+
shift 2 || usage
29+
done
30+
mkdir -p "$AB/work"; [ -f "$AB/work/.gitignore" ] || printf '*\n' > "$AB/work/.gitignore"
31+
OUT="$AB/work/pack-$ARM.txt"; BODY="$AB/work/.pack-$ARM.body"
32+
33+
if [ "$ARM" = N ]; then
34+
echo "You are an agent that writes Mendix models with mxcli, using MDL (Mendix Definition Language) scripts. You have general knowledge of Mendix and MDL. There are no project-specific rules or skills loaded for this session." > "$BODY"
35+
info="N no pack (preamble only)"
36+
else
37+
TMPD="$(mktemp -d "${TMPDIR:-/tmp}/behaviour-pack.XXXXXX")"; WT="$TMPD/wt"
38+
trap 'git -C "$REPO" worktree remove --force "$WT" >/dev/null 2>&1 || true; rm -rf "$TMPD"' EXIT
39+
git -C "$REPO" worktree add --detach --quiet "$WT" "$REF"
40+
line="$(cd "$WT" && bash -c '. bin/lib/skill-routing.sh; routing_baseline_pack "$1" "$PWD" "$2"' _ "$STAGE" "$ROLE")"
41+
IFS=$'\t' read -r words files paths _ <<< "$line"
42+
if [ -n "$DROP" ]; then
43+
case " $paths " in *" $DROP "*) : ;; *) echo "build-packs: '$DROP' is not in the $ROLE Stage $STAGE pack at $REF" >&2; exit 2 ;; esac
44+
fi
45+
sha="$(git -C "$WT" rev-parse --short HEAD)"
46+
{
47+
echo "##### CONTEXT PACK — $ROLE role, Stage $STAGE (toolkit @ $sha)"
48+
echo "##### This is everything you (the $ROLE agent) have preloaded. Toolkit root is referred to as <toolkit>/."
49+
echo
50+
echo "===== FILE: agents/$ROLE-agent.md (your role stub) ====="
51+
cat "$WT/agents/$ROLE-agent.md"
52+
for p in $paths; do
53+
[ "$p" = "$DROP" ] && continue
54+
echo
55+
if [ "$p" = "bin/runbook-slice.sh" ]; then
56+
echo "===== OUTPUT OF: bin/runbook-slice.sh $STAGE ====="
57+
(cd "$WT" && bash bin/runbook-slice.sh "$STAGE")
58+
else
59+
echo "===== FILE: $p ====="
60+
cat "$WT/$p"
61+
fi
62+
done
63+
} > "$BODY"
64+
info="$ARM $REF@$sha routing_baseline_pack=$words words/$files files"
65+
[ -z "$DROP" ] || info="$info, without $DROP: $((words - $(LC_ALL=C wc -w < "$WT/$DROP"))) words/$((files - 1)) files"
66+
fi
67+
{ cat "$BODY"; echo; echo "===== END OF CONTEXT PACK ====="
68+
printf 'PACK-END: %s-%s\n' "$ARM" "$(cksum < "$BODY" | cut -d' ' -f1)"; } > "$OUT"
69+
rm -f "$BODY"
70+
printf '%s\tpack=%s words, %s lines\n' "$info" "$(LC_ALL=C wc -w < "$OUT" | tr -d ' ')" "$(wc -l < "$OUT" | tr -d ' ')"

0 commit comments

Comments
 (0)