Branching zones G9b: stop persisting current_room / room_seq_json

The two legacy columns are no longer needed at runtime. CurrentRoom is
derived from len(VisitedNodes)-1 on read (lockstep with what the
dual-write era stored), and RoomSeq is a transient in-memory field
populated only when a fresh run is started.

- INSERT, SELECT, and UPDATE statements drop the two columns. The
  schema still carries them — they retire in G9c.
- scanZoneRun derives CurrentRoom and falls back to a linear-derived
  CurrentNode only if a row predates the G4 dual-write deploy.
- markRoomCleared rewritten to walk the registered graph (first
  outgoing edge / dead-end completion). Tests that use it as an
  end-to-end run driver continue to pass.
- advanceZoneRunNode drops its current_room dual-write.
- adventure_activity_unified reads visited_nodes for the daily
  "X/N rooms" progress fragment.
- Camp boss-room test pivots to setting current_node directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-05-09 17:21:33 -07:00
parent 103cf30987
commit a5c0a83e2a
4 changed files with 69 additions and 51 deletions

View File

@@ -300,7 +300,7 @@ func renderForkPrompt(zone ZoneDefinition, pf pendingFork) string {
}
// recordRoomCleared appends the current room to rooms_cleared and
// bumps last_action_at, without advancing current_room/current_node.
// bumps last_action_at, without advancing current_node.
// Used by the graph-mode fork path: clearing the room is a separate
// step from choosing where to go next. Returns the updated DungeonRun
// snapshot reloaded post-write so callers see fresh fields.
@@ -377,9 +377,8 @@ func completeRunAtNode(runID string, boss bool) error {
}
// advanceZoneRunNode moves a run to nextNode: appends to visited_nodes,
// sets current_node, bumps current_room (legacy dual-write), and
// clears any pending fork prompt. Caller is expected to have already
// called recordRoomCleared for the prior node.
// sets current_node, and clears any pending fork prompt. Caller is
// expected to have already called recordRoomCleared for the prior node.
func advanceZoneRunNode(runID, nextNode string) error {
r, err := getZoneRun(runID)
if err != nil {
@@ -390,16 +389,14 @@ func advanceZoneRunNode(runID, nextNode string) error {
}
visited := append(r.VisitedNodes, nextNode)
visitedJSON, _ := json.Marshal(visited)
nextRoom := r.CurrentRoom + 1
_, err = db.Get().Exec(`
UPDATE dnd_zone_run
SET current_node = ?,
visited_nodes = ?,
current_room = ?,
node_choices = '{}',
last_action_at = CURRENT_TIMESTAMP
WHERE run_id = ?`,
nextNode, string(visitedJSON), nextRoom, runID)
nextNode, string(visitedJSON), runID)
return err
}