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:
@@ -158,6 +158,14 @@ proc derivedKind*(w: WallRec): string =
|
||||
else:
|
||||
"custom"
|
||||
|
||||
proc markerSig*(w: WallRec): string =
|
||||
## The marker cause signature of DESIGN 5.8: exactly the wall fields whose change retracts a
|
||||
## player marker — endpoints, thickness, placement, the `player_marker` switch and the derived
|
||||
## `window` gate. Height and label have no marker consequence and are deliberately absent. Shared
|
||||
## with `server/markers.nim` so the online retraction and the write-time delete cannot drift.
|
||||
$w.a.x & "," & $w.a.y & "," & $w.b.x & "," & $w.b.y & "," &
|
||||
$w.thickness & "," & $w.position & "," & $w.playerMarker & "," & derivedKind(w)
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------
|
||||
# The one expand-and-validate path for wall writes (DESIGN 5.8, 6.1 FIXED #49/#55)
|
||||
|
||||
@@ -485,12 +493,18 @@ proc addWall*(db: DbConn, sc: var SceneRec, rec: WallRec): Option[int] =
|
||||
proc updateWall*(db: DbConn, sc: var SceneRec, rec: WallRec): WallApply =
|
||||
## `wall.update` = full replacement of the patched row (`remove + add` for the 5.5 status rules,
|
||||
## which slice 5 re-evaluates). Clearing the door switch closes and de-secrets the wall.
|
||||
## A marker cause change (5.8, #60) takes the affected `marker_seen` rows in this same FULL
|
||||
## transaction: on a crash before the derived-memory write, a survivor would be restored on
|
||||
## restart with the NEW geometry, revealing a position the player never saw.
|
||||
let idx = wallIndex(sc, rec.id)
|
||||
if idx.isNone: return waNotFound
|
||||
let stored = normalize(rec)
|
||||
if not validWall(sc, stored): return waInvalid
|
||||
let sigChanged = markerSig(stored) != markerSig(sc.walls[idx.get])
|
||||
authoringTransaction(db):
|
||||
replaceRow(db, sc.id, stored)
|
||||
if sigChanged:
|
||||
db.exec(sql"DELETE FROM marker_seen WHERE scene_id = ? AND wall_id = ?", sc.id, stored.id)
|
||||
sc.walls[idx.get] = stored
|
||||
waOk
|
||||
|
||||
|
||||
Reference in New Issue
Block a user