fix: marker_seen deletes commit with the wall change
A wall cause change (endpoint move, thickness/position, player_marker off, no longer window) committed the wall row in the FULL transaction while its marker_seen deletes rode the later NORMAL derived-memory transaction. A crash between them left the stale row, and restart restored the marker with the anchor recomputed from the NEW geometry, revealing a position the player never saw (DESIGN 5.8). updateWall now deletes the affected rows in the same FULL transaction as the replaced row, exactly as the composite FK cascade already does for wall.remove. The live del frames are unchanged and marker inserts stay in the derived transaction: wall+deletes commit, derived inserts, then ack. The marker cause signature moves to world.markerSig so the write-time delete and the online retraction cannot drift. Proof: a leakfault-only markerCrash hook quits between the wall commit and the derived write; tools/markers.test.mjs covers all four causes and restarts on a clean build, asserting no marker for the changed wall (no new anchor) and restoring the untouched window's marker as the positive control. Ref #60
This commit is contained in:
+12
-13
@@ -9,9 +9,10 @@
|
||||
##
|
||||
## The marker is per-player memory like explored: it is minted once, gets that player's own opaque
|
||||
## 12-character id (never the wall id), keeps the wall's drawn midpoint rounded once as its anchor,
|
||||
## and is persisted in `marker_seen` as part of the same derived-memory transaction as the explored
|
||||
## chunks (4.2 step 6). `vision.PlayerVision.markers` holds it in memory and `restore` loads it at
|
||||
## startup, before the first connection (4.4).
|
||||
## and is persisted in `marker_seen`: a cause-change retraction's delete commits with the wall row
|
||||
## itself (so a crash cannot restore it), while a mint rides the derived-memory transaction with the
|
||||
## explored chunks (4.2 step 6). `vision.PlayerVision.markers` holds it in memory and `restore` loads
|
||||
## it at startup, before the first connection (4.4).
|
||||
##
|
||||
## Lifetime (5.8, #60): walking away, a door and lost sight never retract a marker. The GM's causes
|
||||
## do: removing the wall, clearing `player_marker`, making the wall stop deriving `window`, or
|
||||
@@ -32,11 +33,9 @@ proc anchorOf*(w: WallRec): (int, int) =
|
||||
(int(round((w.a.x + w.b.x) / 2.0)), int(round((w.a.y + w.b.y) / 2.0)))
|
||||
|
||||
proc wallSig(w: WallRec): string =
|
||||
## Everything whose change retracts a marker (5.8, #60): endpoints, thickness, placement, the
|
||||
## `player_marker` switch and the derived `window` gate. Height and label have no marker
|
||||
## consequence and are deliberately absent.
|
||||
$w.a.x & "," & $w.a.y & "," & $w.b.x & "," & $w.b.y & "," &
|
||||
$w.thickness & "," & $w.position & "," & $w.playerMarker & "," & derivedKind(w)
|
||||
## Alias for the shared signature in `world` (5.8, #60): the write path deletes the persisted
|
||||
## rows by the same rule the online retraction uses.
|
||||
markerSig(w)
|
||||
|
||||
proc extentSeen*(pv: PlayerVision, a, b: Vec): bool =
|
||||
## True when any point of the wall's visible extent (the segment in this round) is inside one of
|
||||
@@ -128,11 +127,11 @@ proc writeNew*(db: DbConn, sceneId, playerId: int, fresh: var seq[(int, Marker)]
|
||||
fresh.setLen(0)
|
||||
|
||||
proc writeDead*(db: DbConn, playerId: int, dead: var seq[string]): int =
|
||||
## Deletes the markers the last refresh retracted for one player and clears the buffer. Same
|
||||
## transaction and ordering rule as `writeNew` (5.8, 4.2 step 6): derived player memory rides the
|
||||
## mutation's `NORMAL` transaction, after the wall row commits and before the ack, so a
|
||||
## retraction's `del` can never precede the wall change it reports. A wall removal already took
|
||||
## its rows through the composite FK cascade, so that delete is a no-op here (and still correct).
|
||||
## Deletes the markers the last refresh retracted for one player and clears the buffer. A wall
|
||||
## cause change already took its rows in the wall row's own `FULL` transaction (`world.updateWall`)
|
||||
## and a removal took its rows through the composite FK cascade, so this is normally a no-op; it
|
||||
## stays as the idempotent backstop for the live `del` frames, in the same `NORMAL` transaction and
|
||||
## ordering rule as `writeNew` (5.8, 4.2 step 6).
|
||||
if dead.len == 0: return 0
|
||||
let ps = db.prepare(DeleteSql)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user