tools: the details group, the leak scenario's props and three fault classes (#22)

tools/details.test.mjs is the slice's WS acceptance: the five intents and
their codes, a grow push clear of a wall, a squeeze in a corridor too narrow
for the grown token, stuck from a wall and from a GM placement cleared by a
removal and by a shrink, the GM source of a status, the caps and who reads
which bucket, and a restart that brings size, props and statuses back. Waits
use a cursor taken before the intent, so a repeated state cannot be matched
by an older frame.

The leak scenario gains a token in view with props in all three buckets, a
GM-sourced status, a resize, a wall over it and the clears; leakcheck refuses
the `gm` bucket (GM_PROP), the `owner` bucket on a non-controller
(OWNER_PROP) and any `source` on a player status entry (STATUS_SOURCE), so
`fault.test.mjs` now asserts all twelve classes. The schema-version fixtures
in smoke/persistence move to 6, and mutation.sh gains am-au plus the renames.
This commit is contained in:
2026-11-15 11:02:43 +01:00
parent 20575f2147
commit e103c3ed5c
9 changed files with 530 additions and 25 deletions
+39 -1
View File
@@ -16,6 +16,9 @@
## OWN_VIEW the subject's own token position or its vision polygon is wrong
## OTHER_PLAYER another player's polygon, `mine` flag, explored cells or presence leaked
## EXPLORED the explored set differs from the recomputation / the clear-segment oracle
## OWNER_PROP the `owner` property bucket reached someone who does not control the token
## GM_PROP the `gm` property bucket reached a player at all
## STATUS_SOURCE a player frame carried the `source` of a status (5.5, 6.1 note 6)
## GEOMETRY the recomputed polygon disagrees with the clear-segment oracle (sanity)
## PROTOCOL a frame the catalogue does not allow, a bad `n` sequence, a missing hello block
##
@@ -37,6 +40,8 @@ type
hasVision: bool
visionRadius: Option[float]
radius: float
props: JsonNode ## the GM's three buckets (the truth for every bucket question)
statuses: seq[string] ## the status names the GM sees, in order
Truth = object
walls: seq[Wall]
@@ -129,6 +134,8 @@ proc applyGmTokens(truth: var Truth, m: JsonNode) =
m["flags"]["vision"].getBool,
radius: m["radius"].getFloat)
if m["vision_radius"].kind != JNull: t.visionRadius = some(m["vision_radius"].getFloat)
t.props = m["props"]
for st in m["statuses"]: t.statuses.add st["status"].getStr
truth.tokens[m["id"].getStr] = t
of "token_gone":
truth.tokens.del m["id"].getStr
@@ -266,7 +273,11 @@ proc main() =
var keys = initHashSet[string]()
keysDeep(m, keys)
for k in keys:
if k in BannedKeys: fail "WALLDATA", "player frame has wall-ish/GM-only key " & k
if k == "source":
# 5.5 / 6.1 note 6: a viewer sees the status, never what caused it.
fail "STATUS_SOURCE", "player frame carries a status source"
elif k in BannedKeys:
fail "WALLDATA", "player frame has wall-ish/GM-only key " & k
case t
of "ack":
# only a bad shape is interesting here; the driver already checked the outcomes it expected
@@ -277,6 +288,33 @@ proc main() =
fail "HIDDEN_TOKEN", "token " & id & " is not in the GM's truth"
continue
let actual = truth.tokens[id]
# props: the public bucket always, the owner bucket only for the controller, the gm bucket
# never (6.1 leak notes; the typed view has no field for it, so an injected fault shows here)
var buckets = initHashSet[string]()
if m.hasKey("props") and m["props"].kind == JObject:
for name, _ in m["props"]: buckets.incl name
if "gm" in buckets:
fail "GM_PROP", "token " & id & " carried the gm property bucket to a player"
# A frame that claims `mine` is the OTHER_PLAYER fault's shape: the bucket then matches the
# (wrong) claim, so the claim itself is what gets reported, not the bucket.
if "owner" in buckets and not (actual.controller == me) and not m["mine"].getBool:
fail "OWNER_PROP", "token " & id & " carried the owner bucket to a non-controller"
if actual.controller == me and "owner" notin buckets:
fail "OWNER_PROP", "the controller is missing the owner bucket of token " & id
if m.hasKey("props"):
for name in ["public", "owner"]:
if name notin buckets or not actual.props.hasKey(name): continue
if m["props"][name] != actual.props[name]:
fail (if name == "public": "OWN_VIEW" else: "OWNER_PROP"),
"token " & id & " has a " & name & " bucket that is not the truth"
# statuses: the names the GM sees, and nothing else on the entry
var gotStatuses: seq[string]
for st in m["statuses"]:
if st.len != 1: fail "STATUS_SOURCE", "a player status entry carries more than `status`"
gotStatuses.add st["status"].getStr
if gotStatuses != actual.statuses:
fail "OWN_VIEW", "token " & id & " statuses " & $gotStatuses & " != truth " &
$actual.statuses
if not samePos(m["pos"], actual.pos):
fail "OWN_VIEW", "token " & id & " position " & $m["pos"] & " != truth " &
$[actual.pos.x, actual.pos.y]