Commit Graph
100 Commits
Author SHA1 Message Date
owenrees 80cb033077 Add theme slugs, kinds and link provenance (#192)
* add function for upgrading a user's plan in interactive Elixir

* Add theme slugs, kinds and link provenance

Themes gain a stable slug, an optional description and a kind so the app can
tell material, motif and technique labels apart. Slugs are generated from the
name on first save and keep their value when the theme is renamed, so links to
a theme stay valid.

Endgame-to-theme links now record their source (derived, curated or community)
and creation time. Existing links are backfilled as curated. A derived pass can
therefore replace only its own links, leaving human work untouched.

The admin index shows each theme's kind and its coverage across the library.
Creating a theme name requires the manage_themes capability, and members get an
unauthorized error instead, ahead of the suggestion flow.

Closes #185
2026-11-17 20:46:43 +01:00
owenrees 7209923de7 Align board file labels with their squares 2026-11-17 15:13:47 +01:00
owenrees f4ff1e00fb Move colour mode and Discord controls into the mobile menu 2026-11-17 15:05:02 +01:00
owenrees 514c6ac924 Add Discord invite link to navbar and footer 2026-11-17 15:00:38 +01:00
owenrees e0b446bbfb Weight puzzle selection and stop repeats inside a session (#183)
Selection took a hard rating band (medium = user rating ± 100), removed
everything attempted in the last 30 days, and drew uniformly from what was
left. Because the bulk importer gives every endgame in a batch the same
rating, the band held either the whole library or — once a user's rating
drifted past it — only the endgames that user had already played. With
`fresh` empty, the fallback re-drew from the same band ignoring recency, so
recently played puzzles came straight back. An empty band used a
deterministic nearest-match, alternating between the same two puzzles.

Difficulty is now a bias rather than a filter: candidates are weighted by
`exp(-|rating - target| / spread)` and drawn with an exponential race, so
the whole library stays reachable and a thin region around the user's rating
can never empty the pool. `easy` and `hard` keep one-sided guards so the
labels stay honest. When every candidate is excluded, selection serves the
least recently attempted endgame instead of a random recent one.

Sessions now carry the ids they have served, which fixes the observed
in-session repeat (only the current puzzle used to be excluded), and guest
training gets the same treatment. The 30-day window is configurable as the
repeat window and is now named in GLOSSARY.md, distinct from the rating
window and from the tablebase cooldown.

Difficulty copy is qualitative, since the band numbers no longer describe
how selection works.
2026-11-17 14:28:24 +01:00
owenrees fa1fef7b62 Launch amendments: one login, crawler policy, and asset caching (#180)
* lesson library shown as com,ing soon. re-enable learngin strip

* replace learning strip text with a lasker quote

* remove admin login endpoint

* fix crawler directives and prelaunch login

- noindex the authenticated scope and the 404 catch-all, and cover the
  mailing-list confirmation redirect
- emit noindex, nofollow from the robots meta and /health, and assert
  public pages stay indexable and followable
- stop inventing lastmod values in the sitemap
- log in through /users/log-in during prelaunch now that the admin login
  endpoint is gone; drop create_admin/2 and its orphaned tests

* update caching length to 1 year - name change will invalidate cache

* remove logger

* fix tablebase path breaking tests

* test: check cache headers without requiring built assets

CI's test job does not run mix assets.build, so /assets/css/app.css is a
404 there. Committed piece art is already content-hashed and takes the same
Plug.Static cache option, so the test no longer needs a build step and
passes on a fresh checkout.
2026-11-17 12:55:47 +01:00
owenrees 37e0ac8e56 Transactional mail, crawler metadata, and asset measurement (#179)
* Send transactional email from no-reply@mail.innersquare.app

Centralise the sender identity, reply-to address and SES configuration set in Chesstrainer.Mail so no notifier can drift. Add MAIL_REDIRECT_TO for smoke tests and a mix mail.check task that exercises the SES mailbox simulators, and document the setup in the deploy guide and .env.example.

* Tighten crawler metadata and keep play pages out of search

Canonical URLs no longer carry query strings, public pages get an OG image, WebSite JSON-LD and a per-page language, and the sitemap dates the landing page only. Play and guest-training routes are marked noindex so tens of thousands of near-identical pages stay out of the index.

* Measure built asset sizes with mix assets.sizes

Report raw, gzip and brotli sizes for built JS and CSS, and record the current numbers plus the board-code split recommendation in docs/assets.md.
2026-11-17 10:29:45 +01:00
owenrees b33c5e334a Update to OTP 29 / Elixir 1.20 and refresh dependencies (#175) 2026-11-15 09:34:15 +01:00
owenrees aebb2aecfb Fix the error-state regressions from the #164 verification (#171) (#173)
T8: the invalid-FEN flash is generic; the client message and FEN go to the
log. A2: an expired confirmation link says so and lands on log-in, where an
unconfirmed account resends the email. W3: the connection banner gains Reload
and Home actions. D1: a failed export logs and redirects to the data tab with
a support address instead of a bare 500. D2: an unknown export format renders
the styled 404. H1: the empty-database home CTA points at the guest trainer
instead of auth-gated /endgames. X2/X3: the importer hides inspect(reason)
behind generic copy and logs it.

Adds coverage for the T8 copy, A2 destination, D2 404 page, H1 CTA and the W3
actions; the H1 tests now restore the curated-code override so async page
tests cannot poison each other.
2026-11-13 16:46:29 +01:00
owenrees 8934d191ad Record the launch observability decision and verify the error states (#172)
ADR 0012 states the launch bar, the deferred error tracking/metrics/log
shipping with a concrete revisit trigger for each, and the accepted risk of
journald plus off-box backups.

The verification page walks the #162 checklist against a local MIX_ENV=prod
build with forced failures: Postgres stopped, missing tablebase, empty pool,
expired tokens and exhausted guest budget. 14 rows pass, 6 fail; the eight
regressions are filed in #171. The audit's X1 row is corrected: an unknown
play code already returns the styled 404 page.
2026-11-13 16:10:42 +01:00
owenrees 021e412167 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.
2026-11-13 15:36:59 +01:00
owenrees 0563b5aca2 Audit the user-facing error states (#162) (#169)
Records 35 states across play, sessions, accounts, mailing list, site-level, data and admin surfaces, each with its trigger, today's copy, a verdict and a concrete action. Calls out the five places where an internal detail can reach rendered HTML, and closes with the sign-off checklist for #164.
2026-11-13 15:04:30 +01:00
owenrees 0ae4c5b6fd Record the probe outage drill and its outcome (#168)
Adds the stop-Phoenix drill to the runbook, using forced probe runs so the
outage stays under a minute, and a dated drill log with the first run's
results. The log notes that the manual probe was started twice during the
outage, which is why two notifications arrived for one down/up transition.
2026-11-13 14:48:01 +01:00
owenrees b41c8bf1a6 Fix deploy docs: Bot Fight Mode status and probe reinstall (#167)
* Record that Bot Fight Mode is off

Both docs still claimed Bot Fight Mode was enabled. It is off; the Caddy
origin allowlist stays in force. Neither CI nor the on-box probe can get
past it on the free plan, so re-enabling needs the changes tracked in #153.

* Note that the probe must be installed to two places

The timer runs /usr/local/sbin/chesstrainer-probe, not the copy under
/opt/chesstrainer/src. Say so next to the install block, as the backup
section already does, so a changed deploy/probe does not silently drift
from what the timer runs.
2026-11-13 13:57:33 +01:00
owenrees 69b89f68ef Add a public health probe and monitoring runbook (#166)
* move theme picker position in add endgames form

* Add branded favicons and web manifest

- Replace the placeholder favicon with the knight mark: .ico (16/32/48),
  SVG, and 16/32 PNGs.
- Add opaque apple-touch and Android launcher icons plus a site
  webmanifest naming the app and using the brand palette.
- Link the icon set, manifest, and theme-color from the root layout and
  the 404/500 pages.
- Whitelist the new static files in static_paths/0 and the prelaunch
  allowlist so they are served in production and behind the gate.
- Sync the coming-soon site's favicon.ico and drop the unused Phoenix
  logo.

* Add a public health probe and monitoring runbook

Probe https://<PHX_HOST>/health through Cloudflare every two minutes and
report to a healthchecks.io check. A healthy run posts the raw health JSON;
a tablebase mismatch is a green check-in with the mismatch recorded; a
non-200, non-JSON, down database or network failure posts one fail ping with
the response body and a loopback cross-check as evidence.

--dry-run evaluates the success, degraded, fail, non-JSON and unreachable
fixtures without reading config or touching the network. The runbook covers
the healthchecks.io check, install, what /health proves, Beszel's blind spot
and the drills.

* Fix theme picker search after moving it into the endgame form

The picker moved inside the endgame form, which nested the component's
own <form>. Browsers, and the LiveView test DOM, drop a nested form along
with its phx-change and phx-submit bindings, so the search box did nothing
and three form tests lost their #theme-form selector.

The component now renders no form: phx-change sits on the search input,
which works both inside the endgame form and standalone on the bulk
importer. The unreachable create_theme_from_search handlers go away; theme
creation uses the existing button. Tests search through the input and
click that button.
2026-11-13 13:24:35 +01:00
owenrees f27e16af1d Allow bulk importer through prelaunch gate (#159)
The new EndgameLive.Import view was missing from the prelaunch allowlist, so PRELAUNCH=true redirected it to the home page.
2026-11-12 22:58:34 +01:00
owenrees fddb94e2bd Add admin bulk FEN importer (#156)
* change position of theme picker

* Add admin bulk FEN importer

Paste FENs, resolve results from the local Syzygy tablebase only, preview each line's status, and bulk insert with themes and a batch rating.
2026-11-12 22:44:13 +01:00
owenrees 20b53dae6f Show rating changes on puzzle completion (#146) (#154)
* Show rating changes in flashes and session UI (#146)

- Flash the new rating and delta on every rated completion, with a
  dedicated success flash kind for solved puzzles
- Move flash notifications to the top-left
- Add a colour-coded rating-change pill and show the current rating with
  the session's net change in the train session bar
- Show the user's rating and change beside the puzzle rating after an
  attempt, and show the finishing rating in the last-session summary

* fix header component and start reusing it

* Hide the sign-up link on the prelaunch admin login

The header refactor dropped the @prelaunch guard, so the gated admin login linked to the public registration page again.
2026-11-12 21:13:54 +01:00
owenrees 9e76045862 Automate, verify, and ship database backups off-box (#145) (#152)
The VPS now takes a daily logical dump, verifies it, encrypts it, and hands
it to a workstation; a monthly drill proves the archive restores.

- deploy/backup: pg_dump -Fc plus pg_dumpall --globals-only, pg_restore -l
  and globals-role checks before anything is promoted, row counts for the
  drill, sha256, age encryption into offsite/, retention (3d plaintext,
  14d encrypted, 5 pre-deploy sets), JSON logging and a healthchecks.io
  heartbeat
- systemd service and timer (03:15 UTC, Persistent, jittered) plus an
  OnFailure unit that logs a distinct event
- deploy/activate takes a pre-deploy dump after extracting and before
  flipping current, because migrations run in ExecStartPre; a failed dump
  aborts the activation, with SKIP_PRE_DEPLOY_BACKUP=1 as the escape hatch
- deploy/workstation/backup-pull: rsync the encrypted archives over SSH,
  verify by decrypting and checking the inner sha256, retain 7d/4w/6m, and
  fail when the newest archive is older than 48h
- deploy/workstation/backup-drill: restore the newest archive into a
  throwaway postgres:18.6, replay the globals dump as the same superuser,
  assert both roles, compare users/endgames/attempts, and append the result
  to drills.log
- user units for the daily pull and monthly drill, with a shared OnFailure
  alert template
- docs: install, key handling, retention, restore, disaster recovery, a run
  by hand section, monitoring and troubleshooting

Verified against production: the first backup completed and pinged the
heartbeat, the pull verified the archive, and the drill restored
users=1 endgames=39 attempts=0, matching the live database.
2026-11-11 22:59:54 +01:00
owenrees 624ddab644 Admin panel, login throttling, and Cloudflare edge hardening (#150)
* Document the remote shell for production user management

* add sitemap to footer links

* remove border under theme selection

* Add admin theme and user management (#144)

Add /admin/themes CRUD and /admin/users list/detail with role and plan editing, guarded by a shared Policy module. Include last-super-admin and self-role protections plus structured id-only admin logs.

Also add admin invitations, confirmation resends and password-reset emails, which work in development through the Swoosh mailbox before SES is configured.

* Rate-limit password logins and emit auth events (#142)

Add a two-bucket login throttle (5 failures per login, 10 per IP in a 15-minute window) and a shared client-address helper for controllers and LiveViews. Blocked attempts skip the database and bcrypt.

Log auth.login.failed and auth.login.throttled warnings with boot-scoped HMAC addresses only, and stop repeated confirmation emails on unconfirmed login attempts.

* Harden the production login edge for Cloudflare

Document the layered login defence: the app throttle is primary, Caddy must pass Cloudflare's CF-Connecting-IP to the app, and Cloudflare edge rate limiting covers request floods.

Update the reference Caddyfile to accept only Cloudflare ranges and reject direct-to-origin traffic, and document the exact Cloudflare dashboard rules.

* Document 10-second Cloudflare rate-limit window

Cloudflare may only offer a 10-second period. Keep the edge rule at 10 login POSTs per 10 seconds per IP and rely on the app's 15-minute login/address throttle for credential guessing.

* Document Cloudflare limits for LiveView registration

Registration submits over the shared LiveView socket, so a Cloudflare rule on POST /users/register will not count account creations. Note the app-level throttle/Turnstile options instead.

* Document current Cloudflare free-plan edge controls

Record the production setup: Cloudflare-only Caddy origins, Bot Fight Mode, and the 10-second login flood rule (10 POSTs per 10 seconds, 10-second block). Clarify that the application's 15-minute throttle remains the real credential lockout.

* Auto-refresh Cloudflare CIDRs for Caddy

Move the origin allowlist into a generated cloudflare-ranges.caddy imported by Caddy. Add an hourly systemd timer and script that fetch Cloudflare's v4/v6 lists, reject malformed responses, validate the candidate Caddyfile, and reload Caddy only when the ranges change. Restore the previous file on validation or reload failure.

* Document Cloudflare CIDR refresher setup and operations

Record the installed paths, permissions, timer checks, manual run, update procedure, and the direct-on-VPS setup fallback when the deploy directory is absent.
2026-11-11 21:27:59 +01:00
owenrees 202b9b1f6a Add structured production logging (#105, #107) (#141)
* Update README.md

* Add structured JSON production logging (#105)

* Log requests and background failures (#107)

* Document production logging and the VPS runbook
2026-11-10 22:00:05 +01:00
owenrees f8897fa5ae Add French legal notice and complete privacy disclosures (#134)
- Add /mentions-legales (LCEN art. 6-III): publisher, SIRET, VAT status,
  publication director, and host details
- Name the data controller in the privacy policy and the terms
- Disclose Hetzner/Cloudflare hosting, third-country transfers, the CDN
  security cookie, and backup/suppression-list retention
- Remove the children section; the age floor now lives in the terms
- State that request logs are kept by the providers, not by us
- Mirror all changes in the pre-launch static site

The publisher address is a placeholder pending a domiciliation address.
2026-11-10 11:41:40 +01:00
owenrees 73ba25afe3 Add cookieless Matomo analytics and opt-out (#131) (#133)
* Align Postgres version on 18.6

* Document production tablebase path and permissions

* Add cookieless Matomo analytics with opt-out (#131)
2026-11-10 10:12:48 +01:00
owenrees be57f21729 Add manual CD dispatch and deployment docs (#128) 2026-11-10 09:29:20 +01:00
owenrees ee687dfb2d update with deploy job 2026-11-10 09:27:40 +01:00
owenrees fa90e1102d pin action versions 2026-11-10 09:15:06 +01:00
owenrees 2821f8e984 Avoid stale _build cache in CI 2026-11-10 08:49:53 +01:00
owenrees fda52dd2e7 Install npm assets in CI release build and pin Node 2026-11-10 08:47:46 +01:00
owenrees 7463784e03 update checkout version 2026-11-10 08:43:02 +01:00
owenrees f024bc608d Make endgame fixtures generate unique FENs 2026-11-10 08:42:29 +01:00
owenrees f12ae0b81f Add CI workflow with test and release build (#127) 2026-11-10 08:34:44 +01:00
owenrees 8b25020737 Document SECRET_KEY_BASE requirements 2026-11-09 22:31:07 +01:00
owenrees 56d51347b9 Add JSON health check with database and tablebase status (#106) 2026-11-09 22:24:09 +01:00
owenrees 4c39f231f1 Document VPS provisioning and guard the service before first release (#125) 2026-11-09 22:19:20 +01:00
owenrees b1767e5fbc Add production release and VPS deploy artifacts (#123, #124) 2026-11-09 22:03:54 +01:00
owenrees 3a849ddff0 update matomo env vars 2026-11-09 20:52:37 +01:00
owenrees 79782dc778 prelaunch env var prevents the site from being operational 2026-11-09 20:49:25 +01:00
owenrees 9d3dd426db update static site with privacy and terms 2026-11-09 20:24:28 +01:00
owenrees cae4e35a70 Set up SES mail delivery and harden the mailing list (#120)
* setup basic SES email sending

* basic honeypot form form submission
2026-11-09 16:38:55 +01:00
owenrees 5b3241ae1f Feature/static (#118)
* commented out lesson and learning strip until lessons are established

* reword the hero section

* change layout and working on puzzle section - remove top div as it was
redundant

* amend flash message on replay

* switch cancel session for return home

* remove system theme toggle since this is the default, leaving only light
and dark toggles

* add keyboard and screen reader support for play (#72)

First draft covering the accessibility work in #72:\n\n- labelled SAN/UCI move input, validated against the tablebase and applied\n  by the board hook, plus an accessible promotion picker\n- live-region announcements for moves, checks, checkmates and solve/fail,\n  and a hidden text summary of the position\n- accessible labels, focus ring, skip link, keyboard-friendly review table\n  and non-colour grade cues\n- WCAG AA text contrast roles and a responsive play surface\n- regression tests for move entry, announcements and link-style CTAs

* static pre-release page
2026-11-09 12:50:04 +01:00
owenrees 805c2f1150 Accessibility: keyboard move entry and screen reader support (#72) (#115)
* commented out lesson and learning strip until lessons are established

* reword the hero section

* change layout and working on puzzle section - remove top div as it was
redundant

* amend flash message on replay

* switch cancel session for return home

* remove system theme toggle since this is the default, leaving only light
and dark toggles

* add keyboard and screen reader support for play (#72)

First draft covering the accessibility work in #72:\n\n- labelled SAN/UCI move input, validated against the tablebase and applied\n  by the board hook, plus an accessible promotion picker\n- live-region announcements for moves, checks, checkmates and solve/fail,\n  and a hidden text summary of the position\n- accessible labels, focus ring, skip link, keyboard-friendly review table\n  and non-colour grade cues\n- WCAG AA text contrast roles and a responsive play surface\n- regression tests for move entry, announcements and link-style CTAs
2026-11-09 12:09:07 +01:00
owenrees 8df7ac982c change header and paragraph sizes 2026-11-09 10:12:02 +01:00
owenrees aa9c882b08 update brand 2026-11-09 08:32:50 +01:00
owenrees eaf72a7686 add sitemap, robots, and noindex admin routes (#85)
Serve a runtime sitemap.xml with the indexable marketing pages only; endgame play pages are left out to avoid indexing tens of thousands of near-identical pages. Generate robots.txt at runtime so it points at the sitemap on the deployment's host, and send X-Robots-Tag: noindex from every /admin response.
2026-11-06 23:04:10 +01:00
owenrees 924a3e08dc add mailing list signup with email confirmation (#67) 2026-11-06 22:37:40 +01:00
owenrees b54fb0a6d7 show logged-in player count in landing hero
Count distinct users with a session token valid within the 14-day window and use it for the hero players-training stat. The learning strip keeps the total player count.

Also load the split seed modules in seeds_test and drop an invalid 8-piece seed FEN so precommit passes.
2026-11-06 22:11:06 +01:00
owenrees 46bc27f614 change header size and rating placement 2026-11-06 22:03:24 +01:00
owenrees f2d886d602 add visual rating guide (#48) 2026-11-06 21:52:07 +01:00
owenrees 64a9210580 change stats 2026-11-06 21:48:12 +01:00
owenrees 5c8d2494b6 seed Lucena endgame 2026-11-06 21:34:51 +01:00
owenrees 1003ec203a reorder seed so that themes can be added to seed endgames 2026-11-06 21:25:11 +01:00
owenrees f9340fb57b add small board to show fen string on endgame add 2026-11-06 21:19:25 +01:00
owenrees c71f465487 Add user profile hub with account, settings and data export (#103) 2026-11-06 21:13:37 +01:00
owenrees f5efcde5ca back home button on daily puzzle 2026-11-06 19:51:27 +01:00
owenrees bf176ebd42 show error page puzzle link only for premium users 2026-11-06 15:47:53 +01:00
owenrees 785e403370 404 and 500 drafts 2026-11-06 15:42:52 +01:00
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