Skip to content

Commit 62af781

Browse files
committed
merge: #378 review fixes (slice not double-counted; slice carries verdicts + §3b ownership)
2 parents a406512 + 394f132 commit 62af781

6 files changed

Lines changed: 128 additions & 7 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
- chore(context): **a routing row can be on demand for one role: `mdl?` in the agents column — mdl at Stage 5 reads 43,352 → 30,400 words, review 31,934 → 30,018.** The tier column is per row, so a row one role needs every session and another needs once per module was baseline for both. The `<role>?` token keeps a baseline row in that role's stub, among the on-demand rows (trigger only, still findable), and out of its always-read set and word count; the Role(s) column names it (`review (mdl: on demand)`, `every role except mdl, review (on demand for those)`), and the agent audit refuses a `?` on a non-baseline row or beside its own plain token. Applied for mdl to module-review, ui-loop, teamserver-alignment, learned-css-that-never-applied and skills-over-scripts; for review to teamserver-alignment and skills-over-scripts. Baseline total unchanged (73,233). Behaviour A/B owed before merge — context-cost research (r-stub-diet, T1)
2323
- chore(context): **helpers read the runbook slice for their stage, and the runbook no longer carries a copy of the baseline table — mdl at Stage 5 reads 56,236 → 43,352 words; baseline 75,028 → 73,233.** `skills/conversion-runbook.md` held a fourth rendered copy of the baseline routing table (README, ROUTING.md and every project's CLAUDE.local.md carry it too); it is out of the render surfaces and replaced by a one-line pointer. New `bin/runbook-slice.sh <stage>` prints §1b plus that stage's section, using the span logic gate-check already had (now `bin/lib/runbook-span.sh`, shared). The runbook routing row is split: lead, ba and architect keep the runbook; mdl, gate, test and review get the slice, and `render-routing.sh --check` counts the slice's printed words for them, so the per-role numbers stay honest. New `tests/bench/trim-noloss.sh` checks that every removed line is found again or is a still-routed table row. Behaviour A/B owed before merge — context-cost research (r-stub-diet, T2+T3)
24+
- chore(context): **helpers read the runbook slice for their stage, and the runbook no longer carries a copy of the baseline table — mdl at Stage 5 reads 56,236 → 43,352 words; baseline 75,028 → 73,233.** `skills/conversion-runbook.md` held a fourth rendered copy of the baseline routing table (README, ROUTING.md and every project's CLAUDE.local.md carry it too); it is out of the render surfaces and replaced by a one-line pointer. New `bin/runbook-slice.sh <stage>` prints §1b plus that stage's section, using the span logic gate-check already had (now `bin/lib/runbook-span.sh`, shared). The runbook routing row is split: lead, ba and architect keep the runbook; mdl, gate, test and review get the slice, and `render-routing.sh --check` counts the slice's printed words for them, so the per-role numbers stay honest. New `tests/bench/trim-noloss.sh` checks that every removed line is found again or is a still-routed table row. Behaviour A/B (5 reps × 2 tasks + 5 probes × 3 reps, sonnet): trimmed pack no worse than master on every scored metric — planted STOP refused 10/10 each arm, mxcli-check parse failures page 2/5 vs 3/5, retrieval probes 15/15. — context-cost research (r-stub-diet, T2+T3)
2425
- process(build): **Stage 5 drafts the ready set in parallel and applies serially.** The runbook dispatch row said "sequential within a module", which serialised drafting even for independent scripts; it now points to `iterative-build-loop.md` → Gate cost, the single statement of the rule. The unit is the build-plan row: every `BUILD` row whose "Depends on" rows are all applied, minus overlapping writers (two rows that replace, alter or drop+create the same document never share a ready set, and no row is drafted while it overlaps a queued unapplied one; `brd-to-build-plan.md` has Produces name every document a row writes), runs at once, its scripts in order, one `mdl-agent` per script. Applies stay one at a time through `bin/exec.sh`, and the ready set is recomputed after each. A queued draft made before a sibling apply landed is re-checked with `mxcli diff --format struct` (preflight STOP rule 23); any removal line (checked against `describe` per BUG-146) or STOP rule 21 target means re-draft, never patch, because a stale restatement of a shared document is exactly rule 21's silent seed-call loss and passes `check --references`. Report `ready set N, drafted N, applied k`; the `mdl-agent` template says a drafter never applies and never depends on an unapplied draft. Field evidence: none yet. — MendixMau
2526
- fix(platform-link): **CLI commits now show their changed documents in Studio Pro History.** Studio Pro's History → Model changes pane reads a `ModelChanges` array from the commit's `refs/notes/mx_metadata` note. Trap 6c's hand-written template set it to `[]`, so every mxcli/agent commit showed "Model changes 0" (field project: 270 of 270 notes empty). New `project-bin/mx-metadata-note.py` (stdlib only) computes the array from the commit's changed `.mxunit` files, in Studio Pro's entry shape: Status, UnitID, UnitType, UnitName and Module (walked up the `.mpr` Unit tree). It has `changes` / `write` / `backfill` / `sync <remote>` subcommands. `install-project-hooks.sh` now also installs post-commit and post-rewrite hooks that write the note and never block, and `--check` covers them, so `sync-project.sh` rolls them out to wired projects. Notes are published with `mx-metadata-note.py sync <remote>` after the branch push. Push config is never touched. With mxcli v0.26+ in the project root the hooks call `mxcli git note --write` instead (mendixlabs/mxcli#1337); the Python script is the fallback for older pins, and on 160 field commits both wrote the same 3,594 entries. Trap 6c rewritten. Measured against Studio Pro's own notes, 51 commits in 5 apps: 3387/3389 entries exact on all five fields. Field run on a 357-commit Mendix 11.15.0 app: 158 notes backfilled and pushed, and Studio Pro History lists the documents per revision. Review fixes: an earlier revision added `HEAD` + the notes ref to `remote.<r>.push`. It was dropped because any push refspec replaces `push.default`. A branch tracking a differently named upstream got a new same-named branch on Team Server where `simple` refuses, a missing local notes ref failed the whole push, and nobody knows whether Studio Pro's own push reads that config. The installer now only fetches the remote's notes (non-forced). It removes that exact `HEAD` + notes pair if present, and leaves and reports any other entry. `sync` handles a remote with no notes ref (it used to exit 1) and retries a rejected push once after re-merging. A note that already lists changes (Studio Pro's) is never overwritten by `write`/`backfill` without `--force`, and `sync` keeps a colleague's non-empty note over ours. The mxcli probe greps `git note --help` for `--write`. Hooks and docs call the script through `resolve_py`. Fixture `tests/wave2/test-mx-metadata-note.sh` (40 cases, over real captured template units; single- and two-tree layouts, amend, backfill and `--force`, push exit codes identical to a no-hooks clone, leftover-refspec cleanup, sync to an empty remote and its retry, notes fetch at install, a diverged notes merge; green under `init.defaultBranch` master and main). — field project (Mendix 11.15 app), MendixMau
2627
- learn(fixture-seeding): **explore the data structure first, choose rows by use case, scan actions for resets before any run.** Two seeding runs on public template apps: seeding raised journey passes 33 -> 58 and 20 -> 51 of the same sets (FAIL 93 -> 68, 163 -> 132; INVALID unchanged), and a "Reset all demodata" journey wiped accounts so 104 of 127 journeys reported `The username or password you entered is incorrect`, identical on empty and seeded databases. Skill gains three questions a seed must answer, a use-case checklist, a destructive-action scan, a generic traps table with symptoms, measured expectations and a denominator checklist; routing trigger now fires on seed/test/demo data and empty pages. Independent review fixes: object ids follow the Mendix bigint pattern with a business-key guard (no uuids), associations are seeded where the page's path stores them, four new traps (enum names, inheritance chain, calculated attributes, view/external entities), and the port-offset and container-label traps moved to `harness-architecture.md`. — MendixMau

‎bin/lib/runbook-span.sh‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# One copy, so the three never disagree about where a section starts or ends.
88
#
99
# What a stage session needs is §1b (the Live Checklist Protocol, which applies to every stage)
10-
# plus its own stage's section under §2. Stage headings are keyed on the " — " every one carries:
10+
# plus its own stage's section under §2. A helper reading through bin/runbook-slice.sh also gets
11+
# the gate-verdict table and §3b's ownership paragraph (runbook_verdicts_span, runbook_3b_owner_span).
12+
# Stage headings are keyed on the " — " every one carries:
1113
# "### Stage 0 runs in every entry mode" (under Entry Modes) also starts with "### Stage 0", and
1214
# matched first without it.
1315
#
@@ -37,6 +39,32 @@ runbook_stage_span() { runbook_span "$1" "^### Stage $2 — " "^###? "; }
3739
# runbook_1b_span <file> — the "A–B" span of "## 1b. …"
3840
runbook_1b_span() { runbook_span "$1" "^## 1b\\." "^## "; }
3941

42+
# runbook_span_through <file> <start-regex> <anchor-regex> — "A–B" from the start line through
43+
# the first line matching <anchor-regex> (inclusive), or through the line before the next heading
44+
# if the anchor is gone, so a reworded anchor shortens the span instead of running to EOF.
45+
runbook_span_through() {
46+
awk -v h="$2" -v a="$3" '
47+
!start && $0 ~ h { start = NR; next }
48+
start && $0 ~ a { end = NR; exit }
49+
start && /^#/ { end = NR - 1; exit }
50+
END { if (start) { if (!end) end = NR; printf "%d–%d", start, end } }' "$1" 2>/dev/null
51+
}
52+
53+
# Two spans every helper needs whatever its stage (review of PR #378):
54+
# runbook_verdicts_span <file> — the gate-verdict table under "### What a gate verdict means"
55+
# (PASS/PENDING/FAIL/WAIVED/MANUAL and their exit codes), through "An informational run …".
56+
runbook_verdicts_span() { runbook_span_through "$1" "^### What a gate verdict means" "^An informational run"; }
57+
# runbook_3b_owner_span <file> — §3b's "Ownership is split" paragraph and its bullets ("a helper
58+
# that hits a BRD-touching decision reports it to the lead"), through the next blank line.
59+
runbook_3b_owner_span() {
60+
awk '
61+
!in3b && /^## 3b\./ { in3b = 1; next }
62+
in3b && /^## / { exit }
63+
in3b && !start && /^\*\*Ownership is split/ { start = NR; next }
64+
start && /^[[:space:]]*$/ { end = NR - 1; exit }
65+
END { if (start) { if (!end) end = NR; printf "%d–%d", start, end } }' "$1" 2>/dev/null
66+
}
67+
4068
# runbook_print_span <file> <"A–B"> — the lines themselves.
4169
runbook_print_span() {
4270
local a b

‎bin/lib/skill-routing.sh‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ _routing_stage_arm() {
195195
#
196196
# One script row IS counted: bin/runbook-slice.sh. Its whole output is read into context —
197197
# it replaces the runbook for the helper roles — so it is counted as the words it prints for
198-
# <stage> (about 1.5k at Stage 5), not as zero and not as the script's own text. With an
198+
# <stage> (about 1.7k at Stage 5), not as zero and not as the script's own text. With an
199199
# unrecognised <stage> (the "full" pack) it is counted as the whole runbook, the upper bound.
200+
# When skills/conversion-runbook.md is itself in the pack (no <role>, or lead/ba/architect)
201+
# the slice counts 0: it prints a subset of a file already counted whole. Before this (review
202+
# of PR #378) the no-role full pack counted the runbook twice — 85,797 words, over the 80,000
203+
# budget, on gate-check's advisory line.
200204
_ROUTING_READ_SCRIPTS="bin/runbook-slice.sh"
201205
_routing_slice_words() { # _routing_slice_words <root> <stage> <full>
202206
if [ "$3" -eq 1 ]; then
@@ -208,7 +212,7 @@ _routing_slice_words() { # _routing_slice_words <root> <stage> <full>
208212
routing_baseline_pack() {
209213
local stage="$1" root="$2" role="${3:-}" words=0 files=0 paths="" p wc_out
210214
local name path when agents stages tier group
211-
local known_stages=" P 0 1 2 3 4 5 6 7 " full=0
215+
local known_stages=" P 0 1 2 3 4 5 6 7 " full=0 rb_counted=0 slice_words=0
212216
case "$known_stages" in *" $stage "*) : ;; *) full=1 ;; esac
213217
while IFS=$'\t' read -r name path when agents stages tier group; do
214218
[ "$tier" = "baseline" ] || continue
@@ -220,15 +224,21 @@ routing_baseline_pack() {
220224
p="$root/$path"
221225
[ -f "$p" ] || continue
222226
if [ "$path" = "$_ROUTING_READ_SCRIPTS" ]; then
223-
wc_out="$(_routing_slice_words "$root" "$stage" "$full")"
227+
# Held back until the loop ends: whether the runbook row is counted too is known only
228+
# then, whatever the TSV order.
229+
slice_words="$(_routing_slice_words "$root" "$stage" "$full")"
230+
[ -n "$slice_words" ] || slice_words=0
231+
wc_out=0
224232
else
233+
[ "$path" = "skills/conversion-runbook.md" ] && rb_counted=1
225234
wc_out="$(LC_ALL=C wc -w < "$p" 2>/dev/null | tr -d '[:space:]')" # LC_ALL=C: see BASELINE_BUDGET in render-routing.sh
226235
fi
227236
[ -n "$wc_out" ] || wc_out=0
228237
words=$((words + wc_out))
229238
files=$((files + 1))
230239
paths="$paths $path"
231240
done < <(routing_rows)
241+
[ "$rb_counted" -eq 1 ] || words=$((words + slice_words))
232242
if [ "$full" -eq 1 ]; then
233243
printf '%s\t%s\t%s\tfull\n' "$words" "$files" "${paths# }"
234244
else

‎bin/runbook-slice.sh‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env bash
22
# runbook-slice.sh — print the part of the conversion runbook a helper at one stage needs:
3-
# §1b (the Live Checklist Protocol, every stage) plus that stage's section under §2.
3+
# §1b (the Live Checklist Protocol, every stage) plus that stage's section under §2, then the
4+
# gate-verdict table and §3b's "Ownership is split" paragraph, which every helper needs too.
45
#
5-
# bin/runbook-slice.sh 5 # §1b + "### Stage 5 — Build"
6+
# bin/runbook-slice.sh 5 # §1b + "### Stage 5 — Build" + verdicts + §3b ownership
67
# bin/runbook-slice.sh build-ready # same as 5
78
# bin/runbook-slice.sh --spans 5 # only the line spans, as gate-check.sh prints them
89
#
@@ -13,6 +14,11 @@
1314
# same way bin/bug-lookup.sh turned the bug ledger into a lookup. Sections are found by heading
1415
# (bin/lib/runbook-span.sh, shared with gate-check.sh), never by line number.
1516
#
17+
# The two extra spans (review of PR #378): gate-agent reports PASS/PENDING/FAIL/WAIVED/MANUAL and
18+
# needs their exit codes; mdl and gate need "a helper that hits a BRD-touching decision reports it
19+
# to the lead" (§3b). Neither is in §1b or a stage section. If either anchor is gone the slice
20+
# still prints, with a line naming the section to read in the runbook, and warns on stderr.
21+
#
1622
# Exit: 0 printed · 1 usage · 2 runbook or heading not found
1723
set -eu
1824
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -39,7 +45,26 @@ if [ "$SPANS_ONLY" -eq 1 ]; then
3945
printf 'skills/conversion-runbook.md §1b lines %s + Stage %s lines %s\n' "$S1B" "$ST" "$SST"
4046
exit 0
4147
fi
42-
printf '<!-- skills/conversion-runbook.md §1b (lines %s) + Stage %s (lines %s), printed by bin/runbook-slice.sh -->\n\n' "$S1B" "$ST" "$SST"
48+
SVD="$(runbook_verdicts_span "$RB")"
49+
S3B="$(runbook_3b_owner_span "$RB")"
50+
printf '<!-- skills/conversion-runbook.md §1b (lines %s) + Stage %s (lines %s) + gate verdicts (lines %s) + §3b ownership (lines %s), printed by bin/runbook-slice.sh -->\n\n' \
51+
"$S1B" "$ST" "$SST" "${SVD:-not found}" "${S3B:-not found}"
4352
runbook_print_span "$RB" "$S1B"
4453
echo
4554
runbook_print_span "$RB" "$SST"
55+
echo
56+
if [ -n "$SVD" ]; then
57+
runbook_print_span "$RB" "$SVD"
58+
else
59+
echo "runbook-slice: '### What a gate verdict means' not found in $RB" >&2
60+
echo "(Gate verdict table not found — read \"What a gate verdict means\" in §2 of skills/conversion-runbook.md.)"
61+
fi
62+
echo
63+
echo "From §3b (Requirements drift-sync):"
64+
echo
65+
if [ -n "$S3B" ]; then
66+
runbook_print_span "$RB" "$S3B"
67+
else
68+
echo "runbook-slice: '**Ownership is split' not found under '## 3b.' in $RB" >&2
69+
echo "(Ownership paragraph not found — read §3b of skills/conversion-runbook.md.)"
70+
fi

‎tests/wave2/test-baseline-pack.sh‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,42 @@ MODE5="$(printf '%s' "$OUT5" | cut -f4)"
129129
&& ok "known stages 3 and 5 report no 'full' marker (three fields only)" \
130130
|| bad "a known stage carried a 'full' marker (3: '$MODE3', 5: '$MODE5')"
131131

132+
echo "== the runbook slice is never counted on top of the whole runbook (review of PR #378) =="
133+
# bin/runbook-slice.sh prints a subset of skills/conversion-runbook.md. A pack that already counts
134+
# the runbook whole (no role, or lead/ba/architect) must count the slice as 0 — the no-role full
135+
# pack once counted the runbook twice (85,797 words, over the 80,000 budget). Scratch runbook is
136+
# 50 words; the scratch slice prints 7.
137+
R2="$W/root2"; mkdir -p "$R2/skills" "$R2/bin"
138+
words 10 > "$R2/skills/always.md"
139+
words 50 > "$R2/skills/conversion-runbook.md"
140+
printf '#!/usr/bin/env bash\necho s1 s2 s3 s4 s5 s6 s7\n' > "$R2/bin/runbook-slice.sh"
141+
TSV2="$W/scratch-routing-2.tsv"
142+
cat > "$TSV2" <<'EOF2'
143+
# name path when agents stages tier group
144+
always skills/always.md always relevant all - baseline spine
145+
conversion-runbook skills/conversion-runbook.md any pipeline work lead,ba,architect P,0,1,2,3,4,5,6,7 baseline spine
146+
runbook-slice bin/runbook-slice.sh any pipeline work, as a helper mdl,gate,test,review P,0,1,2,3,4,5,6,7 baseline spine
147+
EOF2
148+
pack2() { MXTK_ROUTING_TSV="$TSV2" bash -c 'source "'"$SKILL_ROUTING"'"; routing_baseline_pack "$1" "$2" "$3"' _ "$1" "$R2" "${2:-}" | cut -f1; }
149+
[ "$(pack2 GARBAGE)" = "60" ] && ok "no-role full pack counts the runbook once (10+50=60), not runbook+slice" \
150+
|| bad "no-role full pack double-counts the runbook: got $(pack2 GARBAGE), wanted 60 (110 = runbook counted twice)"
151+
[ "$(pack2 5)" = "60" ] && ok "no-role stage-5 pack counts the runbook, not the slice on top (60)" \
152+
|| bad "no-role stage-5 pack: got $(pack2 5), wanted 60 (67 = slice added on top of the runbook)"
153+
[ "$(pack2 5 lead)" = "60" ] && ok "lead stage-5 pack: always + runbook (60)" \
154+
|| bad "lead stage-5 pack: got $(pack2 5 lead), wanted 60"
155+
[ "$(pack2 5 mdl)" = "17" ] && ok "mdl stage-5 pack: always + the slice's printed words (17)" \
156+
|| bad "mdl stage-5 pack: got $(pack2 5 mdl), wanted 17"
157+
[ "$(pack2 GARBAGE mdl)" = "60" ] && ok "mdl full pack: the slice is counted as the whole runbook, once (60)" \
158+
|| bad "mdl full pack: got $(pack2 GARBAGE mdl), wanted 60"
159+
# Same claim on the real table: the no-role full pack equals the sum of its .md files, exactly.
160+
REALOUT="$(MXTK_ROUTING_TSV="$TOOLKIT/bin/lib/skill-routing.tsv" bash -c 'source "'"$SKILL_ROUTING"'"; routing_baseline_pack GARBAGE "$1"' _ "$TOOLKIT")"
161+
REALW="$(printf '%s' "$REALOUT" | cut -f1)"; MDSUM=0
162+
for p in $(printf '%s' "$REALOUT" | cut -f3); do
163+
case "$p" in *.md) MDSUM=$((MDSUM + $(LC_ALL=C wc -w < "$TOOLKIT/$p" | tr -d ' '))) ;; esac
164+
done
165+
[ "$REALW" = "$MDSUM" ] && ok "real table: no-role full pack ($REALW) = its .md files alone, no slice on top" \
166+
|| bad "real table: no-role full pack $REALW != sum of its .md files $MDSUM (slice double-counted?)"
167+
132168
echo "== field run: the real toolkit table at every runbook stage returns a non-empty pack =="
133169
FIELD_OK=1
134170
for st in P 0 1 2 3 4 5 6 7; do

0 commit comments

Comments
 (0)