Make tablebase and empty-pool failures recoverable (#163) (#170)

Tablebase failures now render one message per class, with a Retry action
when fetching again can help. The generic class no longer interpolates
inspect(reason) into the page; the reason goes to the log instead.
Positions outside the tablebase offer the next puzzle (in a session) or the
existing back link, rather than a futile retry.

Train's no-puzzles and exhausted-difficulty flashes become in-page states
with Retry and Change difficulty. The guest pool gets the same treatment,
and GuestLimits.remaining/1 lets a guest see the wall, or the empty pool,
without spending a puzzle.
This commit is contained in:
2026-11-13 15:36:59 +01:00
committed by GitHub
parent 0563b5aca2
commit 021e412167
11 changed files with 476 additions and 133 deletions
+12
View File
@@ -37,9 +37,21 @@ defmodule Chesstrainer.GuestLimitsTest do
assert {:ok, 4} = GuestLimits.take(@other, @today)
end
test "remaining reports the budget without consuming it" do
assert {:ok, 5} = GuestLimits.remaining(@address, @today)
assert {:ok, 5} = GuestLimits.remaining(@address, @today)
assert {:ok, 4} = GuestLimits.take(@address, @today)
assert {:ok, 4} = GuestLimits.remaining(@address, @today)
for _ <- 1..4, do: assert({:ok, _} = GuestLimits.take(@address, @today))
assert {:limit_reached, _} = GuestLimits.remaining(@address, @today)
end
test "does not limit a missing address" do
assert {:ok, nil} = GuestLimits.take(nil, @today)
assert {:ok, nil} = GuestLimits.take(nil, @today)
assert {:ok, nil} = GuestLimits.remaining(nil, @today)
end
test "reset clears spent budgets" do