53 Commits
Author SHA1 Message Date
adamfandClaude Opus 5.5 7157c6649e CI: scratch directories per run, not per commit
Test and publish the site / test (push) Successful in 18s
Test and publish the site / publish (push) Successful in 8s
Test and publish the site / deploy (push) Successful in 1s
The build runner takes two jobs at once, so the same commit pushed to
two branches (main and a feature branch) ran its test job twice in
parallel against one src-<sha> directory, and each run's clean-up
deleted the other's source mid-test. Suffix the scratch directories
(and activity-tracker's throwaway Postgres and network) with the run id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 16:14:45 +00:00
adamfandClaude Opus 5.5 1ec6fb4f5a CI: test and publish on the build VM, deploy on stpvm
Test and publish the site / test (push) Successful in 5m28s
Test and publish the site / publish (push) Successful in 3m28s
Test and publish the site / deploy (push) Successful in 27s
test and publish (build, smoke test, push) move to stpbuild's runner
(label `build`); the two roll-out steps become a deploy job on stpvm
(`self-hosted`). The fetch is over HTTP with the job's own GITEA_TOKEN.

Also fix the roll-out's working directory: /home/adamf/deploy/web_server
no longer exists on stpvm; the stack lives in /home/adamf/deploy/stpweb.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 16:00:13 +00:00
adamfandClaude Opus 5.5 5ed1e0b89d CI: fetch from git.adam-french.co.uk instead of localhost
Test and publish the site / test (push) Successful in 1m40s
Test and publish the site / publish (push) Successful in 2m41s
Gitea runs on its own LXC, and stpvm's localhost:2222 forwarder to it is
being removed. stpvm pins git.adam-french.co.uk to the LXC's LAN IP in
/etc/hosts, so the self-hosted job reaches it directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 17:26:35 +00:00
adamf 89d604e076 wonderful strings 2026-10-29 22:51:38 +00:00
adamfandClaude Opus 5.5 cae5ec8e5a Keep site jobs across restarts, meter Claude spend, harden admin routes
Test and publish the site / test (push) Successful in 2m15s
Test and publish the site / publish (push) Successful in 9m5s
- internal/jobs replaces explain.Jobs: one registry for every kind of
  background job, with records in DATA_DIR/jobs. A job's draft is written
  before its commit, so a failed commit can be saved again (POST
  /jobs/<kind>/<key>/save) and a restart mid-commit resumes it, without
  paying Claude twice.
- Graceful shutdown: SIGTERM stops new jobs and waits SHUTDOWN_GRACE for
  running ones while still serving the pages that poll them.
- internal/usage records every Claude call's tokens and estimated cost in
  DATA_DIR/usage.jsonl; CLAUDE_MONTHLY_BUDGET refuses new jobs (429) once a
  month reaches it. The stats page shows the admin the spend.
- auth.SameOrigin refuses cross-origin writes to admin routes.
- The LeetCode importer runs the clone's script without the server's
  secrets in its environment.
- A sync that leaves HEAD where it was skips the re-index.
- docs_test.go checks README's route table against the routes, and the CLI
  page against the root README's commands.
- The repo is going private: Gitea links on the site are admin-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 22:10:01 +01:00
adamf 7638d88570 Refresh paper UI styling
Test and publish the site / test (push) Successful in 51s
Test and publish the site / publish (push) Successful in 1m39s
2026-10-23 20:00:46 +01:00
adamf a1a95c8963 Solved 2026-10-20 14:03:30 +01:00
adamfandClaude Opus 5.5 2ea9980d58 Add vim keys to the solve page's editor
Test and publish the site / test (push) Successful in 51s
Test and publish the site / publish (push) Successful in 1m16s
A Vim checkbox in the toolbar turns on @replit/codemirror-vim, off by
default and remembered in this browser like the split. A status line
under the editor shows the mode and the command being typed, and :w
saves as Save does. Run, Submit and Save keep their Ctrl keys in every
mode, since the page's keymap is at the highest precedence.

The vim extension sits in a Compartment, so turning it on or off keeps
the text and its history; the states kept for the other languages are
brought up to date when they are swapped back in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 14:00:29 +01:00
adamfandClaude Opus 5.5 3a8f651a6f Import LeetCode problems from a pasted link on the site
Test and publish the site / test (push) Successful in 1m9s
Test and publish the site / publish (push) Successful in 1m31s
The problem list's admin row gains a link box beside "Today's LeetCode":
POST /leetcode/import takes {url} and does what `usaco new
<leetcode-link>` does, through the same lib/leetcode.py run and "Start
<slug>" commit as the daily question, then opens the solve page. A
problem already in the repo is only opened.

leetcode.Slug reads the link as slug_of in lib/leetcode.py does: full
links with /description/ and query strings, www., no scheme, or a bare
slug. Anything else is a 400.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 13:02:11 +01:00
adamfandClaude Opus 5.5 ccf4e4dd74 Explain concepts on the site, and reuse their code from the CLI
Test and publish the site / test (push) Successful in 1m19s
Test and publish the site / publish (push) Successful in 1m31s
/usaco/concepts is a library of techniques Claude explained: the admin
asks by topic ("help explain fenwick trees") or pastes code they could
not follow, and gets an intuitive explanation with SVG diagrams plus a
C++ snippet in contest style. Given code, the walkthrough traces that
code and the snippet is a general version of it. Anyone can read the
library; generating, rewriting and deleting are admin-only.

Each concept is committed as concepts/<slug>/: concept.md (tags in a
header comment, then a # title), snippet.cpp (first line
"// concept: <slug>") and request.md (the question, for rewrites). The
slug is Claude's to pick, so a new concept's job is keyed by an id and
returns {slug} as its result; a taken slug gets -2, -3... rather than
overwriting. Rewriting starts from the saved question and version plus
a note on what to change. The index reads concepts into Index.Concepts,
with their date from git.

internal/concept shares explain's math and diagram rules, now split out
as explain.MathRules and explain.DiagramRules; the explain prompt is
byte-for-byte unchanged. Code fences in explanations are highlighted
with the same highlight.js setup as CodeBlock (web/src/highlight.js).

`usaco snippet` lists concepts, prints one's snippet, or pastes it into
a solution above main (or class Solution), keeping a .bak and refusing
a concept the file already has. In interactive mode it pastes into the
selection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 12:58:38 +01:00
adamfandClaude Opus 5.5 d4849859df Autocomplete and evaluate solutions on the solve page
Test and publish the site / test (push) Successful in 1m25s
Test and publish the site / publish (push) Successful in 1m51s
The editor's completion popup was on but empty for C++, since
@codemirror/lang-cpp has no completion source. web/src/completions.js
adds one: keywords, the STL, every name in the file (the template's
macros show their expansion, typedefs what they alias), members after
. and ->, and snippets for the loops and lambdas typed over and over.
Python gains the contest standard library and members after ., on top
of lang-python's builtins and local names. Nothing knows types, so
members are the common ones plus those already used in the file.

Evaluate (POST/GET /problems/<name>/evaluate) has Claude judge the
editor's code as a strong competitive programmer would before
submitting. It runs the saved tests on the runner first, as Submit
does, and gives Claude the verdicts and up to three failing cases. The
reply is a verdict, correctness, complexity against the constraints,
line-anchored issues and a traced counterexample (internal/evaluate).
The page shows it in an Evaluation tab of the results panel, marks the
issues in the editor beside the lint's for as long as their lines are
unchanged, and can load the counterexample as the custom input.

It is a background job the page polls, like explanations, but it
commits nothing: the code is a draft. explain.Jobs.StartWith keeps a
finished job's answer in memory until the next one or a restart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 12:46:54 +01:00
adamfandClaude Opus 5.5 c6b82588b1 Precompile bits/stdc++.h in the runner, and move it to clang-tidy 22
Test and publish the site / test (push) Successful in 1m25s
Test and publish the site / publish (push) Successful in 5m18s
The first publish failed its smoke test: on the production host
(2 slow cores) clang-tidy took over 30s on a two-line file and hit the
runner's 20s lint limit, and even a trivial build took 4s, nearly all
of it parsing <bits/stdc++.h>.

The runner image now precompiles that header for g++ (.gch) and clang
(.pch) with the flags the runner passes, and the runner uses them when
they are there. g++ lint gains -O2 so the build's header matches it.
Alpine 3.24's clang-tidy 22 walks far less of the system headers than
3.22's clang-tidy 20. Measured on the host: a build 3.9s to 0.6s, and
clang-tidy 32.5s to 4.3s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 11:43:04 +01:00
adamfandClaude Opus 5.5 af070ffcf9 Start the LeetCode daily question from the site
A "Today's LeetCode" button on the problem list (admin only) does what
`usaco daily` does: it asks LeetCode for the daily question, runs the
clone's lib/leetcode.py to import it into solving/ (statement, starter,
driver.h and the examples as tests), commits it as "Start <slug>" and
opens its solve page. A daily question already in the repo is only
opened. The importer stays the CLI's one script rather than a Go copy
of its driver generator, so the site image now has python3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 11:29:39 +01:00
adamfandClaude Opus 5.5 c972fa9fd9 Run and lint solutions on the site
Test and publish the site / test (push) Successful in 1m23s
Test and publish the site / publish (push) Failing after 4m22s
A new admin-only solve page, /p/<name>/solve, edits a problem's code in
C++ or Python (a dropdown switches between them), runs it on custom
input or against the saved tests with per-test verdicts (AC, WA, RE,
TLE, unchecked) and compile errors, marks lint diagnostics in the
editor, and saves the code back as a commit ("Edit <name>"). Drafts
stay in the browser per problem and language until saved. LeetCode
problems are C++ only, since their tests run through driver.h.

Code never runs in the site, which holds the Claude, Gitea and S3
secrets. A separate runner service (cmd/usacorunner, Dockerfile.runner)
does it in a container meant to have no environment, an internal-only
network, a read-only root apart from /tmp, and memory, CPU and pids
limits, with tini to reap orphans. Runs copy the CLI: the same g++
flags with -DLOCAL and the repo's headers, <io>.in on disk and on
stdin, <io>.out or stdout as the output, and usaco test's comparison.
Unlike the CLI they have CPU, memory, file and wall-clock limits.

C++ lint is g++'s warnings plus clang-tidy with a new .clang-tidy
(bugprone, performance and a few readability checks; template.cpp is
clean). Python lint is a syntax check plus ruff. template.py is the
Python starter, with a stdio() helper like template.rs's.

CI builds, smoke-tests and rolls out the runner image before the site.
The web_server stack needs a usaco-runner service before that rollout
can succeed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 11:24:22 +01:00
adamfandClaude Opus 5.5 107ecab9da Record review audio in the browser
Test and publish the site / publish (push) Successful in 35s
Test and publish the site / test (push) Successful in 44s
The review panel can now record from the microphone as well as take a
file. The take is made with MediaRecorder at 32 kbps, which is plenty
for speech and puts the 25 MB limit at over an hour; it stops itself
just short of that. It is named .webm (Chrome, Firefox) or .m4a
(Safari) to match its container, since the server picks the format by
extension, so the backend is unchanged.

Whichever recording is chosen, recorded or picked, gets a player to
check it before sending. Closing the panel mid-take discards it and
releases the microphone. Recording needs HTTPS or localhost; elsewhere
the button is disabled with a note saying why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 10:32:46 +01:00
adamfandClaude Opus 5.5 4dc8d1674c Tidy the site's problem pages and typeset math in explanations
Test and publish the site / test (push) Successful in 1m10s
Test and publish the site / publish (push) Successful in 1m29s
The problem page's Explain and recording-review forms took most of the
first screen, above the solution. They now fold into the admin bar with
the editor, one open at a time; a running job is reported in the bar,
so a form can be closed while it works.

The problem list is grouped by month when sorted by recency, as one
card per month with divided rows, laid out on a fixed grid so rows
line up on a phone. Empty status tabs are hidden.

Rust solutions are now highlighted, the file picker is styled like the
other buttons, header links no longer break mid-word on a phone, and
keyboard focus is visible.

Markdown everywhere now goes through one renderer that typesets
$...$, $$...$$ and ```math with KaTeX. The explanation prompt asked for
$...$ only when the statement used it, so formulas came out as inline
code; it now asks for LaTeX for math and code spans for code, and the
review prompt does the same for complexities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 02:19:24 +01:00
adamfandClaude Opus 5.5 63608f130c Review recorded explanations of a solution on the site
Test and publish the site / test (push) Successful in 2m4s
Test and publish the site / publish (push) Successful in 1m44s
The admin can upload a recording of themselves explaining a problem's
solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and
get interview-style feedback, committed as reviews/<id>.md so every
attempt is kept.

Claude can't take audio, so the recording is transcribed first by an
OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY,
with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler
words and when complexity first comes up are measured from the word
timestamps and given to Claude with the timestamped transcript, the
statement and optionally the code. The reply covers the verdict, scores
in five areas, the approach and its complexity, missed edge cases,
delivery and what to work on.

Recordings are kept for playback in an S3 bucket (Garage) when the
S3_* settings are given, and are thrown away otherwise. Reviews are
admin-only. The job runs in the background like Explain, and the
statement fetch and save-error handling are now shared between the two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 01:56:55 +01:00
adamf 1bcb2a20de new problem 2026-10-19 21:22:21 +01:00
adamfandClaude Opus 5.5 210c7c38f7 Add in-progress problems and saved test outputs
Test and publish the site / publish (push) Successful in 51s
Test and publish the site / test (push) Successful in 49s
excel-sheet, min-effort-path and queue-with-stack (Rust) and
set-xor-min, plus expected outputs for and-or-sort, minus-two and
moo-language-school.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:18:08 +01:00
adamfandClaude Opus 5.5 1aee0050a0 Add Rust support: usaco lang, lint, and main.rs problems
Brings in the stashed Rust work, merged onto the current CLI. A
problem's language is whichever source it has (main.cpp or main.rs);
'usaco lang' sets the default for new problems (.lang, or $USACO_LANG),
and 'new --rust/--cpp' picks per problem. template.rs is a paste-ready
Rust template whose stdio() uses <io>.in/.out when present and
stdin/stdout otherwise.

run/test now feed <io>.in on stdin and capture stdout when the program
doesn't write <io>.out itself, so Codeforces-style solutions work too.
'reset <name> rust|cpp' switches a problem's language (template is
still an alias), and --debug builds Rust with overflow checks and debug
assertions. 'usaco lint' runs clippy through a generated, gitignored
Cargo.toml that also gives rust-analyzer a project; done/skip/undo
keep it in step. LeetCode imports stay C++.

Also: done stages solved/ and solving/ separately, so a problem that
was never committed from solving/ still gets its "Solve" commit, and
the site lists main.rs ahead of other files like it does main.cpp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:17:50 +01:00
adamfandClaude Opus 5.5 e821df15f4 Import LeetCode problems with usaco new <link> / usaco daily
Test and publish the site / test (push) Successful in 35s
Test and publish the site / publish (push) Successful in 29s
usaco new <leetcode-link> (alias: from) and usaco daily fetch a problem
from LeetCode's GraphQL API and write problem.md, main.cpp (template
header + LeetCode's C++ starter), a generated driver.h that runs the
solution on LeetCode-format input, and the examples as tests with the
expected outputs from the statement. leetcode.h holds ListNode/TreeNode
and the parse/print helpers; everything local sits behind #ifdef LOCAL
so main.cpp stays submittable.

reset re-fetches the starter code for LeetCode problems, the REPL's new
selects the imported problem, and usaco.zsh turns off globbing so a
pasted ?envType=... link works unquoted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:12:16 +01:00
adamfandClaude Opus 5.5 995b44a57a Add an Explain button that has Claude explain a problem
Test and publish the site / publish (push) Successful in 8m15s
Test and publish the site / test (push) Successful in 5m51s
When stuck, the admin can ask Claude for an intuitive explanation of a
problem. It is committed as explain.md and shown as folded sections, so
the reader opens only as much as they need: the key observation, hints
that get stronger, the approach, a walkthrough with an SVG diagram per
step, complexity, pitfalls and a pseudocode sketch.

- internal/claude: streamed call with a JSON-schema reply, high effort,
  the server-side refusal fallback, fixed error messages and logged
  token usage. CLAUDE_API_KEY and CLAUDE_MODEL (default claude-opus-5-5);
  without a key only this feature is off.
- internal/explain: the prompt, the schema, rendering to markdown, and
  a per-problem job tracker. The request starts a job and the page polls,
  since a call outlasts nginx's 120s timeout.
- internal/statement: fetches statements from LeetCode's GraphQL API and
  USACO's problem pages. Others (Codeforces is behind Cloudflare) are
  pasted.
- problem.md holds the statement, editable from the meta editor and
  shown only to the admin. Diagrams are sanitized with DOMPurify.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 20:38:15 +01:00
adamfandClaude Opus 5.5 f0e10d2a58 Roll out under .compose.lock and drop the Docker API pin
Test and publish the site / test (push) Successful in 11s
Test and publish the site / publish (push) Successful in 3s
env-apply was removed from web_server, so its run/lock no longer exists
and the roll-out step failed with "cannot open lock file". Take
.compose.lock, which web_server's deploy and maintenance workflows hold.
The DOCKER_API_VERSION=1.41 pin was for the Pi's Docker 20.10; the host
now runs Docker 29.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 18:07:36 +01:00
adamfandClaude Opus 5.5 3e2b52fdb2 Describe the CI host as stpvm, not the Pi
Test and publish the site / test (push) Successful in 1m29s
Test and publish the site / publish (push) Failing after 2s
The site and its runner moved from the arm64 Pi to stpvm (x86-64,
Docker 29), so the comments about the build host, its Docker version
and the image architecture were wrong.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 17:58:03 +01:00
adamfandClaude Opus 5.5 675410729e Link the site to the repo on Gitea
Test and publish the site / test (push) Successful in 39s
Test and publish the site / publish (push) Successful in 50s
A Source link in the header, and on the CLI page links to the script,
lib/cmd, usaco.zsh, the README, the template and debugging.h, plus the
clone URL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 23:45:50 +01:00
adamfandClaude Opus 5.5 cbf5cc32b7 Add a CLI guide page to the website
Test and publish the site / test (push) Successful in 32s
Test and publish the site / publish (push) Successful in 1m0s
/usaco/cli summarises the ./usaco commands, setup, a typical session and
interactive mode, linked from the header. It's a hand-written copy of the
README (the Docker build context is site/, so it can't import it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 23:27:39 +01:00
adamfandClaude Opus 5.5 ac66ad6b03 Tidy the usaco CLI: prefixes everywhere, LOCAL debug builds, git-based dates
- done/skip/undo accept unique prefixes like every other command
- builds define LOCAL (-I repo root): the template includes debugging.h
  and enables DBG/printV only locally, so main.cpp is submittable as-is
- run/build/test --debug (or USACO_DEBUG=1): ASan/UBSan + _GLIBCXX_DEBUG
- list/stats date problems by git history, not mtimes reset by checkouts
- template/tpl is now an alias of reset (which gains -y); fixes template
  dropping the STDIO line
- run shows <io>.out via detect_io instead of the first *.out
- debugging.h: size_t loop indices (no -Wsign-compare noise)
- zsh completion for i/cat/copy; README covers test, io, reset, --debug
- ignore a.out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 22:39:16 +01:00
adamfandClaude Opus 5.5 1c647072c5 Add usaco sync; track saved test outputs
Test and publish the site / test (push) Successful in 4m29s
Test and publish the site / publish (push) Successful in 1m25s
The website commits too, so `usaco sync` pulls its edits before pushing.
tests/*.out were swallowed by the *.out rule; they are expected outputs
the site shows, so re-include them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 21:51:34 +01:00
adamfandClaude Opus 5.5 6d956f1c76 Add the website: Go server + Vue SPA in site/, with CI
A standalone container for web_server, shaped like job-tracker: serves
/usaco/ with solved problems public and solving/skipped plus edits
(status, link, notes) for the site admin. Git is the only store: the
server clones adamf/usaco from Gitea, pulls on the push webhook, and
commits edits back. CI builds the image only when site/ changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 21:51:34 +01:00
adamf 440d51caba new problems 2026-09-25 22:31:50 +01:00
adamf fe0b8be533 Solve nezzar-and-lucky-number 2026-09-24 17:06:59 +01:00
adamf 25ba615045 update template to codeforces compliant 2026-09-24 15:49:13 +01:00
adamf c09007a751 Solve odd-divisor 2026-09-24 15:45:55 +01:00
adamf 8ac02faee4 Solve the-cake-is-a-lie 2026-09-24 15:29:15 +01:00
adamf ef9a67918e More questions 2026-09-24 13:32:35 +01:00
adamf 218fd77c8c More problems, update template 2026-09-24 13:29:53 +01:00
adamfandClaude Code c5efae17e4 Document cat, copy, and interactive REPL in README
Co-Authored-By: Claude Code <[email protected]>
2026-09-24 13:15:32 +01:00
adamfandClaude Code 1b78b35876 Add usaco interactive REPL with current-problem context
Co-Authored-By: Claude Code <[email protected]>
2026-09-24 13:12:37 +01:00
adamfandClaude Code 26a9c969bd Add usaco cat and copy commands
Co-Authored-By: Claude Code <[email protected]>
2026-09-24 12:51:33 +01:00
adamf 0b2113f577 Solve reflection 2026-09-22 21:51:16 +01:00
adamf df25347183 Solve purchasing-milk 2026-09-22 21:51:16 +01:00
adamf b7786bc4ce Solve moocast 2026-09-22 21:51:16 +01:00
adamf efafed7e91 Solve measuring-traffic 2026-09-22 21:51:16 +01:00
adamf 128448ebed Solve longest-common-subsequence 2026-09-22 21:51:16 +01:00
adamf 17a4768bc8 Solve largest-rectangle-in-histogram 2026-09-22 21:51:16 +01:00
adamf 616f6d0493 Solve kayaking 2026-09-22 21:51:16 +01:00
adamf b3e3693e16 Solve diamond-collector 2026-09-22 21:51:16 +01:00
adamf 2829480c87 new template 2026-09-22 17:59:52 +01:00
adamf 8e44324146 new problems 2026-09-20 23:31:20 +01:00
adamf afdab7d4bd Separate lib, new problems and script for web 2026-08-26 22:25:19 +01:00
adamf 6fd6d70b04 Vibe code scripts to edit and add usaco solutions 2026-08-25 00:45:15 +01:00
adamf a79ff12290 Current work 2026-08-03 19:03:58 +01:00
adamf b48299efb7 first commit 2026-08-03 19:03:02 +01:00