tools: WS probing and the token wire tests (#20)

tools/probing.test.mjs re-runs the M2 T8 probing test over the wire with a hostile
client: over-cap probes always get the one uniform nack (old position, no code), two
servers whose walls differ only beyond cap + token radius answer 90 identical
probes identically, and a wall inside that bound does change the replies, so the
harness is shown able to fail. It stays inside the 6.4 burst, so no probe is a rate
limit.

tools/tokens.test.mjs pins the wire behaviour of the slice: the 6.1 acks and codes,
the controller-only and GM-only rules, the connect resync order, the unnamed-player
gate, the door push and a restart.

tools/mutation.sh gains aa-af: the egress ignoring the view rule, gm_only and the
owner arm of the rule, a missing token_gone, a GM-only field in a player frame, and
explored forgetting cells.
This commit is contained in:
2026-11-15 09:35:29 +01:00
parent 959412ff09
commit cae20d7c89
3 changed files with 586 additions and 2 deletions
+24 -2
View File
@@ -12,6 +12,9 @@
# t: wall removal renumbers next_wall_id (the dense-id design, #3) | u: the id counter is not loaded from the DB
# v: the id counter is never written to the DB | w: a wall may stay open | x: zero-length walls accepted
# y: wall endpoints unchecked against the world bounds | z: door.set on a plain wall accepted | z2: persisted `open` loaded inverted
# aa: the egress sends every token (LOS and gm_only ignored) | ab: gm_only ignored in the view rule
# ac: a controlled token is not always visible | ad: no token_gone when a token leaves view
# ae: a player token frame carries the GM-only `kind` | af: explored forgets the cells outside the current polygon
# Parallel: MUTATION_JOBS (default nproc/4) jobs, each in its own temp copy + nimcache; output collected, printed in fixed order.
# Tests run with FFF_MUTATION=1 (iteration counts ~/10, see tests/testutil.nim scaled()); only test files holding an expected
# test are run per mutation (control runs all). Debug build. Wrapped in systemd-inhibit (sleep:idle) when that works.
@@ -54,7 +57,13 @@ LOG=$PWD/results/mutation.log
JOBS=${MUTATION_JOBS:-$(( $(nproc) / 4 ))}; [ "$JOBS" -ge 1 ] || JOBS=1
export FFF_MUTATION=1
T=$(mktemp -d -t fffmut.XXXXXX)
PIDS=()
PAA="the set of tokens follows the visibility rule"
AB="a gm_only token inside the LOS is not visible"
AC="a controlled token is always visible"
AD="leaving view sends"
AE="no GM-only field"
AF="moving adds cells and never forgets"
IDS=()
cleanup() { trap - EXIT INT TERM; local p; for p in "${PIDS[@]}"; do kill -TERM -- "-$p" 2>/dev/null; done; wait 2>/dev/null; rm -rf "$T"; }
trap cleanup EXIT; trap 'exit 130' INT; trap 'exit 143' TERM
NEW="shared endpoint: no leak at the vertex|'<' apex|every segment endpoint|rays nudged past a corner"
@@ -74,6 +83,12 @@ P="refill is continuous"
Q="reqId boundaries"
R="nine malformed frames are tolerated"
S="the frame counter starts at 1"
AA="the set of tokens follows the visibility rule"
AB="a gm_only token inside the LOS is not visible"
AC="a controlled token is always visible"
AD="leaving view sends"
AE="no GM-only field"
AF="moving adds cells and never forgets"
IDS=()
run() {
while [ "$(jobs -rp | wc -l)" -ge "$JOBS" ]; do wait -n; done
@@ -112,9 +127,16 @@ run x "zero-length walls accepted" server/world.nim 's/ (rec\.a\.x != rec\.b\.x
run y "wall endpoints unchecked against the world bounds" server/world.nim 's/p\.x >= 0 and p\.y >= 0 and p\.x <= sc\.w and p\.y <= sc\.h/p.x >= 0 and p.y >= 0/' "both endpoints must be inside"
run z "door.set accepted on a plain wall" server/world.nim '/if sc.walls\[idx.get\].kind != wkDoor: return waNotDoor/d' "wrong kinds are their own"
run z2 "persisted open state loaded inverted" server/world.nim 's/open: row\[6\] == "1",/open: row[6] == "0",/' "round-trip through a reload"
# slice 5 (#20): the view rule, the egress diff and the explored set
run aa "the egress ignores LOS, gm_only and ownership" server/views.nim 's/^ if not pv\.visibleTo(t, playerId): continue$/ if false: continue/' "$AA"
run ab "gm_only ignored by the view rule" server/vision.nim '/^ if t\.gmOnly: return false$/d' "$AB"
run ac "a controlled token is not always visible" server/vision.nim '/^ if t\.owner == playerId: return true$/d' "$AC"
run ad "no token_gone when a token leaves the view" server/views.nim 's/^ result\.add tokenGoneFrame(id)$/ discard/' "$AD"
run ae "a player token frame carries the GM-only kind" server/views.nim 's/ "statuses": \[\], "props": props/ "statuses": [], "props": props, "kind": "npc"/' "$AE"
run af "explored forgets cells outside the current polygon" server/vision.nim 's/^ for idx in added: pv\.explored\.incl idx$/ pv.explored = added/' "$AF"
wait
rc=0; : > "$LOG"
for id in control a b c d1 d2 e f g h i j k l m n o p q r s t u v w x y z z2; do
for id in control a b c d1 d2 e f g h i j k l m n o p q r s t u v w x y z z2 aa ab ac ad ae af; do
[ -f "$T/$id/res" ] && cat "$T/$id/res" >> "$LOG"
if [ -f "$T/$id/verdict" ]; then tee -a "$LOG" < "$T/$id/verdict"; [ "$(cat "$T/$id/rc")" = 0 ] || rc=1
else echo "$id: NO RESULT (job killed?)" | tee -a "$LOG"; rc=1; fi