Commit Graph
114 Commits
Author SHA1 Message Date
owenrees b17f346b25 Show tablebase moves during review (#65) (#102)
* engine 8+ tablebase adr

* Show tablebase moves during review (#65)

- group reviewed moves by winning/drawn/losing and make each row playable
- move review navigation under the board with start/end jumps
- give review a full-height scrollable tablebase pane
2026-11-06 15:31:11 +01:00
owenrees bd8be4d10d Privacy and terms pages with config-driven branding (#91)
* comment out begin with basics until lessons are on the way

* route to footer link dead views

* proposed >7 piece engame processing

* basic privacy and terms pages with default text

* add branding to config and reference across the site

* disclose guest puzzle limit in privacy policy (#87)
2026-11-06 13:56:20 +01:00
owenrees 6a4288bb6c split endgame seed files by result 2026-11-06 12:49:03 +01:00
owenrees dda588da06 Feature/guest trainer (#89)
* add anonymous guest training with a daily puzzle limit

- /guest-train serves random endgames with no difficulty picker; signed-in
  visitors are redirected to /train
- guests get 5 puzzles per UTC day, keyed by an in-memory HMAC of the client
  address; the raw address is never stored or logged
- a sign-up wall replaces the next puzzle once the budget is spent
- move the endgame library behind auth so guests cannot browse it
- privacy disclosure tracked in #87

* remove chess-test endpoint and liveview
2026-11-06 12:06:32 +01:00
owenrees 2c5e290e66 remove roadmap and todo in favour of project based overview 2026-11-06 10:41:08 +01:00
owenrees 2f3f39a21d show live player count on landing page 2026-11-05 16:40:58 +01:00
owenrees 8d1876b13b show date, hide puzzle search for non premium 2026-11-05 16:14:04 +01:00
owenrees 0453e97897 update navbar and footer links
- point Puzzle Search at the endgames list
- list the signed-in username after Settings and Log out
- replace the footer's landing anchors with privacy and terms links
- align the landing-page test with the new footer
2026-11-05 15:52:56 +01:00
owenrees 1b44dae378 let the difficulty picker be closed
Add an X in the corner and a Cancel button, both returning home, so a user
who opens /train without wanting a session is not stuck in the modal.
2026-11-05 15:50:17 +01:00
owenrees 84eee4057e restyle flash toasts and auto-dismiss them
- use brand info/error colours that pass AA contrast in both modes
- dismiss flashes on click on controller pages, where no LiveView handles it
- auto-dismiss real flashes after a few seconds
- keep connection notices pinned until the connection recovers
2026-11-05 15:44:42 +01:00
owenrees 55d2e2a913 add puzzle training sessions with difficulty and ratings
- /train starts an ephemeral session by choosing easy/medium/hard, banded
  relative to the user's current rating (band width configurable)
- session timer, average per-puzzle time, net rating gain and per-puzzle delta
- next puzzle, plus review and retry reused from the play surface
- explicit stop/start: stopping returns to the difficulty picker
- puzzle rating shown once a puzzle completes, and a side-to-move indicator
- extract the play logic/markup into shared PlayCore and PlayComponents so the
  standalone play view and sessions share one implementation
- sticky footer; glossary entries for Difficulty and Session; ADR 0009
2026-11-05 15:44:11 +01:00
owenrees c95173cda8 password reset flow 2026-11-05 14:19:49 +01:00
owenrees e89df68e7d email signup up flow in dev mode, therefore in place for prod 2026-11-05 14:11:12 +01:00
owenrees 6b0e0ed352 add margin top to subtitle 2026-11-05 13:57:15 +01:00
owenrees 93806b9ab2 landing page (#63)
* remove daisyui and rebuild styles

* very basic setup of new design - missing components etc

* basic navbar with reusable landing components

* basic puzzle of the day

* update todos

* update todos

* add curated landing puzzle cards with selectable board (#55)

* update with footer

* add button to solve today's puzzle

* Make landing page a dead view

Render the home page from PageController with a static board preview, link puzzle cards and CTAs to public-code play routes, count puzzles from the DB, and add a global footer.

* Serve a marketing-only JS bundle on the landing page

Build a small marketing entry point with phoenix_html and the plain-DOM navbar, select it on controller-rendered pages, and keep the full LiveView bundle for LiveView pages.

* Add landing page SEO metadata

Replace the Phoenix default title with a descriptive Lucid Chess title, and add description, canonical, Open Graph, and Twitter card tags to the landing page.

* Complete the hero copy block

Add the spark icon primitive and the Endgames, made clear eyebrow. The primary CTA keeps linking to the active puzzle rather than scrolling to the board.

* Add a persisted global daily puzzle

Assign one endgame per UTC day in a daily_puzzles table with a unique date, preferring endgames unused in the last 30 days and falling back to any. Concurrent first requests insert with on-conflict-ignore and read the winning row. The landing board now shows the daily puzzle.

* remove unused CSS, nav links, time pill

* allow devices to connect to dev server by changing IP address to 0.0.0.0

* Restore the colour-mode switch and add a dark palette

* Use brand colour tokens on the play page

* self host fonts  - closes issue #62

* begin splitting CSS into modules

* remove hover on hero chessboard, split more css modules

* remove interactivity from hero chessboard

* update todo
2026-11-05 13:52:14 +01:00
owenrees fd6277ef92 add initial todo and roadmap 2026-11-04 20:18:31 +01:00
owenrees 1012c74d60 Let users delete their account from settings (#46) 2026-11-04 19:59:12 +01:00
owenrees 49736d186c Add public codes for player URLs and admin endgame search
Player-facing endgame links now use a 10-character Crockford base32 public code instead of the database UUID; admin routes keep the UUID. Existing rows are backfilled by migration, and the admin Show page displays and copies the code.

The admin endgame index gains its own search box: exact database id, exact public code, or a FEN / FEN fragment. A single match opens the endgame; multiple matches list below; nothing found says so.

Closes #44
Closes #45
2026-11-03 22:46:38 +01:00
owenrees 160e8629b7 Add rating window and time-based RD inflation (#41) 2026-11-03 22:20:02 +01:00
owenrees 4a36ffd2e6 Rate users and endgames with Glicko (#40) 2026-11-03 22:04:51 +01:00
owenrees a3fb878383 Record per-user Attempt history (#39) 2026-11-03 21:50:55 +01:00
owenrees eea8e48685 Make the play screen current-user aware (#38) 2026-11-03 21:41:56 +01:00
owenrees fdaf00e3b4 install Glicko lib 2026-11-03 21:37:17 +01:00
owenrees 36ddcc43ae Document rating vocabulary in GLOSSARY (#37) 2026-11-03 21:36:39 +01:00
owenrees 7cb7298236 Add user accounts, roles, and admin gating
- Scaffold password auth (email or username) with phx.gen.auth; no magic links
- Add role (member/moderator/admin/super_admin) and plan (free/premium) enums
- Gate /admin behind admin-or-above via plug + on_mount; hide the nav link
- Add mix accounts.promote for CLI role changes
- Disable email confirmation by confirming accounts at registration

Closes #3
2026-11-03 15:48:50 +01:00
owenrees 3b527d21ed Update domain docs for local tablebase routing (#32)
Redefine Tablebase and Cooldown in GLOSSARY.md for the local<=5 / Lichess 6-7 / cache-only-API split, and add Probe and Position key terms. Add ADR-0005 recording the source split and its latency-vs-footprint trade-off, and mark ADR-0001 superseded.
2026-11-03 14:49:07 +01:00
owenrees 8ba87d8efe Document TABLEBASE_PATH and local tablebase setup (#31)
Add docs/tablebases.md covering the local/Lichess routing, the TABLEBASE_PATH environment variable (dev vs VPS), the fetch/check mix tasks, boot logging, and the release build requirement. Link it from the README.
2026-11-03 14:36:14 +01:00
owenrees f37242ed29 Add local tablebase path config, fetch and check tasks (#31)
Read the local Syzygy directory from TABLEBASE_PATH so a dev machine and a VPS can point at their own copies. Add mix tablebase.fetch (downloads the 3/4/5 WDL+DTZ set, resumable) and mix tablebase.check (verifies it loads), plus a boot log reporting whether local tablebases are ready and the largest piece count.

Covers the codeable part of #31; installing on the VPS and setting TABLEBASE_PATH there remains a manual step.
2026-11-03 14:26:30 +01:00
owenrees cb35351f8c Wire Fathom into the local tablebase backend (#30)
Add Backend.Fathom: probes positions with five or fewer pieces via the Fathom NIF, maps WDL/DTZ to the trainer structs (flipping per-move perspective), generates SAN, sorts moves best-first, and falls back to Lichess on any failure. The local directory is configured with TABLEBASE_PATH; local answers are no longer cached.

Add Tablebase.normalize_wdl/1 and flip/1, plus tests for the WDL mapping, SAN, checkmate, fallback, and a cache-free end-to-end local probe.
2026-11-03 14:23:46 +01:00
owenrees e60c161a3a Add a Fathom Syzygy probe NIF (#29)
Vendor the MIT-licensed Fathom C source and compile it into a Rustler NIF (native/fathom_nif). The NIF exposes init/1 (point Fathom at a tablebase directory) and probe/1 (raw WDL/DTZ/move results for a FEN); probes are serialised because Fathom's root probe is not thread safe, and run as dirty NIFs.

Add KRvK/KQvK 3-piece WDL+DTZ fixtures and an integration test proving a known KRvK probe returns Win, DTZ 23 and 15 moves.
2026-11-03 13:41:54 +01:00
owenrees 3fadd4397c Key the tablebase cache by position instead of full FEN (#28)
Add FEN.position_key/1 (board, side, castling and en-passant; clocks dropped) and have Tablebase.new/1 key cache reads and writes on it, so transpositions and clock-only differences share an entry. The Lichess category is a position property, so dropping the clocks is safe.

Update the cache docs and tests, and give the play fixture's after_first/after_losing distinct positions since they previously differed only by the halfmove clock.
2026-11-03 13:09:45 +01:00
owenrees 515196857f Route tablebase lookups through a piece-count backend seam (#27)
Add a Backend behaviour, a Lichess implementation, and a Router that picks a backend by piece count: five or fewer to the local slot, six or seven to the remote slot, and eight or more short-circuited as not covered with no network call. Both slots point at Lichess for now; the local Syzygy backend replaces the local slot when it lands.

Map :not_covered to the existing 'not covered by the tablebase' message.
2026-11-03 12:51:08 +01:00
owenrees ec657c3424 Simplify the Tablebase struct to the fields the grader reads (#26)
Drop dtm/dtc from Tablebase and Tablebase.Move; the local Syzygy backend cannot produce them and nothing reads them. The Lichess parser now maps only category, checkmate and moves (with per-move category, dtz, san and uci), and the struct-shape tests follow.
2026-11-03 12:41:28 +01:00
owenrees ff7adcf308 Reject out-of-range endgame FENs at entry (#25)
Add FEN.piece_count/1 and reject positions with more than 7 pieces in the Endgame changeset, so an 8+ piece FEN fails at entry instead of saving and then blocking at play.

Accumulate all FEN issues rather than letting a later check overwrite an earlier one, and guard the seed FENs with a test (dropping the out-of-range seed that bypassed the changeset).
2026-11-03 12:18:22 +01:00
owenrees dd060531d3 Copy FEN to clipboard from the endgame view (#33)
* display fen string under engame data and add hook to copy to clipboard

* split seed data across files
2026-11-03 12:00:35 +01:00
owenrees a5bb1cb670 Scale the tablebase cache to ~100k entries (#24)
* Slim the cached tablebase value to the fields the trainer reads (#20)

* Sample for LFU eviction instead of scanning the cache (#21)

* Make cache size configurable and back up daily off-peak (#22)

* Document the cache design in the glossary and an ADR (#23)

* Address cache-scaling code review findings
2026-11-02 23:02:01 +01:00
owenrees fa71783e55 Show best moves and the optimal line in review
Closes #19
2026-11-02 21:45:06 +01:00
owenrees 36548ece8d Add the replay plan 2026-11-02 21:26:20 +01:00
owenrees 1e62b13d94 Show the full game and review it after an attempt
Closes #18
2026-11-02 21:26:20 +01:00
owenrees 6d0d750ca7 Default new endgames to rating 1500
Closes #17
2026-11-02 21:26:19 +01:00
owenrees 7658450573 Full-width list/show pages and trim the admin table
List and show pages now use a wide container (max-w-7xl) while the form and
play pages keep the narrow column. The admin table drops Fen, Message, Notes,
Attempted and Solved — all already shown on the show page — so it fits
without right-overflow.

Closes #16
2026-11-02 11:04:04 +01:00
owenrees 49c3cddffb Group and filter the player endgame picker
The player-facing /endgames list now groups endgames under collapsible Key
headers and supports the same Theme/Key filtering as the admin list, showing
each endgame's Themes. The filter/group state is shared with the admin list
via ChesstrainerWeb.EndgameList.

Closes #14
2026-11-02 10:24:29 +01:00
owenrees d231860f14 Search, filter and group the admin endgames list
The admin list now groups endgames under collapsible Key headers and can be
filtered by Theme (search + tappable chips) and Key. Group counts and
filtering run in SQL, and a group's endgames are fetched only when it is
expanded, so the list stays fast as the dataset grows.

- Add Endgames.list_keys/0, list_key_groups/1 and list_endgames_for_key/2.
- Add the shared ChesstrainerWeb.EndgameList filter bar and grouped list
  component (to be reused by the player picker).
- Rework EndgameLive.Index around server-side group state.

Closes #15
2026-11-02 10:21:22 +01:00
owenrees ca65207baa Derive canonical material Key from the FEN
The Endgame key is now a canonical, colour-agnostic material signature derived
from the FEN instead of a hand-typed field: each side's pieces, strongest side
first by material value (e.g. "KQ v KR"). This fixes the seed ordering
inconsistency and guarantees the key always matches the position.

- Add Chesstrainer.Key.from_fen/1.
- Compute the key in the Endgame changeset; drop the manual input and its
  regex validation.
- Index endgames.key and derive keys in the seeds.
- Document the Key term and the decision (ADR 0003).

Closes #13
2026-11-02 09:22:01 +01:00
owenrees cd2e7f0164 Rename Tag to Theme across code and schema
Rename the endgame-label concept from Tag to Theme to match the glossary:
the context becomes Chesstrainer.Themes, the schema Chesstrainer.Themes.Theme,
and the Endgame association is :themes. The category enum
(endgame/opening/tactic) is preserved.

Rewrite the original migrations in place so themes / endgames_themes
(with theme_id) are created directly, instead of adding a transition
migration.

Closes #12
2026-11-02 09:14:17 +01:00
owenrees 645f65f2a3 Add multi-theme tagging to endgames in the admin
#11: endgames can carry multiple themes (endgame tags) chosen from a
searchable, autocompleting picker with inline creation. Tags are staged
in the form and saved atomically, so they work on both New and Edit.

Tag names are trimmed and case-insensitively unique per category. Admin
Show and Index display themes, and the seeds ship a starter vocabulary.

The theme picker has its own form: LiveView requires phx-change inputs to
live inside a form, and a separate theme form keeps Enter from
submitting the endgame form.
2026-11-01 22:22:09 +01:00
owenrees be23f1d7f8 Play draw endgames and solve on a rule draw
#10: drawn positions are graded against the draw as the target — a move
that keeps it passes, a losing move fails, and a rule draw reported by
chess.js (insufficient material, repetition, or 50-move) solves the
puzzle. The promotion cutoff now applies only to win puzzles.
2026-11-01 22:04:21 +01:00
owenrees c5989628bc End the attempt on solve or fail and count attempts
#9: solve the puzzle on checkmate or a winning promotion, fail
immediately on a losing move (revealing the missed best move), and
increment times_attempted when an attempt starts and times_solved when
it is solved. Terminal states lock play; reset starts a new attempt.
2026-11-01 22:01:19 +01:00
owenrees 248504cc58 Play the opponent's optimal defence after a passing move
#8: after a passing move, fetch the post-move position's tablebase and
reply with moves[0] (the defender's optimal defence). The client applies
and animates the reply, reports the resulting FEN, and the server fetches
that position's tablebase before resuming the user's turn.

Losing moves and terminal positions do not trigger a reply; a failed
post-reply fetch blocks the attempt. The board stays locked during the
reply round-trip so play cannot get out of sync.
2026-11-01 21:45:32 +01:00
owenrees cadc842010 update docs with static analysis tools 2026-11-01 21:40:29 +01:00