feat(walls): one-way sight per-viewer filter and ONEWAY fault (#58)

The vision fan blocks a sight-blocking one-way wall only for a viewer on
its blind side (sight_dir names it; left is the (-dy,dx) normal of a->b),
one sign test inline after the radius cull, so the hoisted wall list stays
viewer-independent. Movement never reads the direction: one-way walls block
both ways. Explored and tiles therefore differ by side and only ever grow.

- geometry: WallDir + Wall.sightDir + blindTo, filter in visibilityPolygon.
- worldmap: sight_dir mapping (movement mapping unchanged).
- vision: the ONEWAY leak-fault build drops sight_dir player-side.
- leakcheck: own side test for the fan and the clear-segment oracle; ONEWAY
  class detected against the sight_dir-dropped fan.
- leak scenario gains a one-way wall the subject sees across; fault test
  asserts exactly ONEWAY.
- oneway.test.mjs: both sides, tile sweep with its own oracle, flip with
  fixed endpoints, monotone explored/tiles, restart, two-way movement.
- docs: DESIGN 5.8 mechanism sentence corrected; TESTING #58 markers built.
- nginx harness: temp dirs created recursively (restart on one state dir).
This commit is contained in:
2026-11-19 22:57:39 +01:00
parent 0f3aa2300f
commit 9fcbe885c1
14 changed files with 649 additions and 78 deletions
+11 -3
View File
@@ -5,7 +5,8 @@
## Vision (5.1): one visibility polygon per token the player controls that carries the `vision` flag,
## cast from the token centre against the scene's blocking walls with the token's range (Q7: the
## token's `vision_radius` if it sets one, else the scene's `vision_radius_default`). Open doors do
## not block; geometry.nim does the casting.
## not block; geometry.nim does the casting. A sight-blocking one-way wall blocks only a viewer on
## its blind side (the side `sight_dir` names), one sign test inline after the radius cull (#58).
##
## Explored (5.1, 8): the union of the cells every polygon ever overlapped, per player, strictly
## per player (Q9 FIXED). It only grows: a wall edit or a door closing never un-explores. `cells`
@@ -20,7 +21,7 @@
## Change tracking: `ver` counts polygon changes (the client gets `vision` only when it changes, 6.4)
## and `fresh` holds the cells this mutation added (4.2 step 8: cleared after egress).
import std/[algorithm, math, sets]
import tokens, worldmap, geometry, world
import tokens, worldmap, geometry, world, faults
type
Poly* = object
@@ -48,8 +49,15 @@ proc cellOf*(sc: SceneRec, idx: int): (int, int) =
proc computePolys*(sc: SceneRec, tokens: seq[TokenRec], playerId: int): seq[Poly] =
## One polygon per token of this player that has vision, in token order (a stable wire order).
## The wall list is hoisted and viewer-independent: the one-way filter is inline in the ray fan
## (geometry.visibilityPolygon), one sign test per one-way wall per viewer (5.8, #58).
if playerId <= 0: return
let walls = geometryWalls(sc, forSight = true)
var walls = geometryWalls(sc, forSight = true)
when defined(leakfault):
# Negative control (DESIGN 10.3, TESTING 10.3): the ONEWAY fault drops `sight_dir` from the
# player-facing computation, so a sight-blocking one-way wall blocks both sides.
if faultActive("oneWay"):
for w in walls.mitems: w.sightDir = wdBoth
for t in tokens:
if t.owner != playerId or not t.hasVision: continue
result.add Poly(tokenId: t.id,