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:
2026-11-19 23:52:13 +01:00
parent c3c0a39188
commit a69563f701
8 changed files with 160 additions and 27 deletions
+7
View File
@@ -908,3 +908,10 @@ Each entry quotes the superseded statement (excerpt) and names the surviving rul
That is 5.8 [#42], which superseded both; this block fixed heights and units only, and what a
low wall hides (#44) and thickness (#45) were settled afterwards in 5.9 and 5.10." Historical
provenance only; the surviving rules are current §1, §5.7, §5.8, §5.9, §5.10.
17. **All marker deletes in the derived transaction (2026-11-19, #60).** Old §8: "marker
inserts/deletes are derived player memory and ride the mutation's `NORMAL` transaction (the
same one as the explored chunks)". Narrowed after the #60 crash review: a cause-change delete
rides the wall row's `FULL` transaction (inserts stay `NORMAL`), because a crash between the
two would restore the marker with the new geometry and reveal a position the player never saw.
Surviving rules: current §5.8, §8.
+11 -6
View File
@@ -664,10 +664,11 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
`''` is not a legal label (`1..64`) and `0` is not a legal height (`> 0`), so a sentinel would
make the load path lie about the domain.
- **Startup and write timing:** `marker_seen` rows are loaded per player with the explored chunks
before the first connection (like `explored.restore`); marker inserts/deletes are derived player
memory and ride the mutation's `NORMAL` transaction (the same one as the explored chunks), never
the `FULL` authoring one. They run before the ack, after the wall row commits, so a retraction's
`del` can never precede the wall change it reports.
before the first connection (like `explored.restore`); marker inserts are derived player memory
and ride the mutation's `NORMAL` transaction (the same one as the explored chunks), never the
`FULL` authoring one, while a cause-change delete rides the wall row's `FULL` transaction so it
cannot outlive the wall change across a crash. They run before the ack, after the wall row
commits, so a retraction's `del` can never precede the wall change it reports.
- Startup: load everything into memory, recompute vision for all players (prototype does, in one
transaction) so `vision` is never stale vs walls. Startup loads the scene, its tokens and every
stored `explored_chunk` and `marker_seen` row before the first connection (`explored.restore`), so
@@ -1044,7 +1045,9 @@ What a wall's behaviour is made of. Heights are 5.7; what a low wall does to sig
`player_marker` is turned off, the wall stops being a window (a switch or `sight_dir` change),
or its geometry moves (`a`/`b`, `thickness`, `position`). A retraction reveals only that the GM
changed something there, never a new position: a moved wall re-earns its marker only when the
player sees the new geometry. Retraction never un-explores a cell and never revokes a tile.
player sees the new geometry. The retraction delete commits with the wall row, so a crash
between the wall change and the derived-memory write cannot restore the stale marker either.
Retraction never un-explores a cell and never revokes a tile.
- **Wire [FIXED (owner-delegated), #48; shape #49].** The message is the dotless server noun
`marker`: `{full:bool, set:[{id, pos}], del:[id]}`, mirroring `encountered`'s full/set/del
spelling, with `pos` in integer px (the wall's drawn midpoint, rounded once) and `id` an opaque
@@ -2013,7 +2016,9 @@ copy/export stable).
removed player takes their markers, a removed scene takes them through its walls, and a removed
wall retracts its marker for everyone (5.8's retraction rule; the composite FK is why a marker
can never dangle). The other retraction causes (`player_marker` off, no longer a window,
geometry moved) are a deliberate delete in the update path, not an FK.
geometry moved) are a deliberate delete in the update path, not an FK; that delete commits in
the same FULL transaction as the wall row, so a crash before the derived-memory write cannot
restore a marker with the changed wall's new geometry.
- **Migration [FIXED (owner decision), 2026-11-17, #49].** Step 8 (4.4) rebuilds `wall` and maps
every existing row to today's behaviour (`thickness 0`, `position center`, both block switches
1, `sight_dir both`, `player_marker`/`secret`/`locked` 0, `height`/`label` NULL; `kind='door'`
+3 -1
View File
@@ -462,7 +462,9 @@ from the prototype, what was missing, what the M3 build added, and the tools it
and marked solid wall as the negative controls. The WS group `tools/markers.test.mjs` proves the
four retraction causes (del only), a fresh id on re-earn, no re-send of an untouched marker, no
`set` and `del` for one id in a frame, no explored write from a pure retraction, and durability
of the deletes across a restart.
of the deletes across a restart. A `LEAK_FAULT=markerCrash` hook quits in a `-d:leakfault` build
between the wall commit and the derived write; after a restart the changed wall's marker is gone
for all four causes while the untouched window's marker is restored (the positive control).
- **Wall fields, storage and migration (#49).** Three gates. **Leak:** `BannedAlways` contains every
wall field name (`thickness`, `position`, `height`, `blocks_sight`, `blocks_movement`, `sight_dir`,
`player_marker`, `door`, `open`, `secret`, `locked`, `label`, `a`, `b`), so any of them in a player