Design decisions

34. Judge profiles (§9, 0.2.2, 2026-11-21)

  • 34.1 A judge is a profile, in its own crate. crates/cpl-judge holds the profile type, the built-ins (generic, codeforces, atcoder, cses, icpc, kattis, dmoj) and their selection. It depends on nothing, so the CLI, the wasm playground and the stress tools can share it; codegen takes only a cpl_codegen::Target (a header stamp and whether the judge's stack is deep), so it knows no judge by name. Reverse: fold the crate into cpl-cli and pass the limit alone.
  • 34.2 The flag beats the file, which beats the project, which beats generic. --judge, then a // judge: line (like // limits:), then judge = "<name>" under [judge] in the nearest cp.toml. [judge.<name>] tables change a built-in's fields or add one with extends, so a course's judge needs no code. Unknown names and keys are errors listing what is allowed. Reverse: drop a source from cpl_judge::resolve.
  • 34.3 The default stays generic, the old behaviour. g++ -std=c++17 -O2, an 8 MB stack and 64 KB: the floor most judges clear, so a file built with no profile is what 0.2.1 wrote plus one header line. Reverse: change the None arm of resolve.
  • 34.4 A profile records the judge's real command and says where each fact comes from. Flags are copied from the judge's published command (AtCoder's library and link flags left out); a fact that could not be read from a public source is marked unconfirmed in evidence, shown by cpl judges (the Codeforces page sits behind a browser check). Reverse: none needed; correct a fact when a source says so.
  • 34.5 (replaced by 31.4: every program runs on a thread with the profile's stack) Deep recursion skips its own stack only when the judge's stack is known to be deep. At least 256 MB or unlimited (codeforces links with a 256 MB stack, DOMjudge's runguard sets it unlimited); an undocumented stack counts as 8 MB. The switch is harmless where it is not needed, so the error is on the safe side. Reverse: Profile::deep_stack returning false.
  • 34.6 The source limit is the profile's, with a warning above 75%. The 48 KB warning of goal 5 for a 64 KB judge, scaled. The size line names the judge and the share used. Reverse: Profile::warn_at.
  • 34.7 Locally, a judge's flags are used as far as the compiler here accepts them. Each profile's command is probed once (an empty program built with -Werror); a rejected flag is dropped or given the older spelling of the same standard, and reported. A flag and its value (-x c++) and a --whole-archive span are probed as one. A Windows profile builds with a MinGW cross compiler when one is installed. This tests what the judge's flags mean for the generated code without the judge's exact compiler version; containers with those versions remain open. Reverse: probe nothing and require every flag.
  • 34.8 Every port under every profile's flags is a --full check. 1,799 compiles take about two and a half minutes on eight cores, too slow for --fast; --fast builds every port for every profile (size, stamp, stack rule) and compiles and runs the deep-recursion program under each. Reverse: move the ignored test into --fast.
  • 34.9 Local runs build a .cp file for its judge and run it on the judge's stack. run --release, test, stress and hunt resolve the file's profile, emit for it, build with its flags as the host g++ accepts them (the host compiler for a Windows judge) and wrap the binary in sh -c 'ulimit -s N' when N differs from the current limit; a stack the shell can't grant fails with exit 125 and names the judge. Goal 5 says local runs mimic the profile, and the stack is where they differed most (a recursion that fits 8 MB here could overflow a judge, and the reverse). The g++ -std=c++17 -O2 build keeps its precompiled header; other flag sets build without it. Reverse: build_judged back to compile_cpp(&emit_cpp(..)).
  • 34.10 The size report is measured on the file, by the code generator's own parts. The emitter keeps the text of each part it writes (the header, each runtime piece, the types, the globals, each fn, the top-level code), the report measures it as the file has it (narrowed when the file is) and calls the rest glue, so the parts add up to the file by construction. A fn is named as its source names it (Rooted.path), its instances summed. Shown on --size and on every build over the limit, the one time it is needed. Reverse: drop Emitter::chunks and cpl_codegen::sizes.
  • 34.11 cpl profile --native builds for the file's judge. It resolves the profile like cpl build, writes the counted C++ for that target (its thread stack, its OS's threads), builds with the judge's flags this compiler accepts and runs on the judge's stack, the same Profile::on_stack command the stress runner uses; a profile timed on another build can rank the lines differently. CXX still overrides the compiler. Reverse: emit_profiled without a target and g++ -std=c++17 -O2.
  • 34.12 cpl test gives MLE past the problem's memory limit. A case whose sampled peak memory (VmHWM, as bench reads it) is over the limit is MLE whatever it printed, as a judge stops it there; a time limit outranks it. Sampling can miss a peak in the last 0.3 ms of a run, so an MLE is certain and an ok is not proof. Reverse: drop Verdict::MemoryLimit and the check in run_cases.
  • 34.13 The comments on the C++ give way first, before the source in the header. A file over its judge's limit loses, in order, its comment lines (all but the header at the top; a comment after code stays), then the source in the header, then half its indentation. The contestant's own source says more on the judge's page than the generator's notes on its runtime, and both cost the same to the judge. Fitted::note says what was left out, for the CLI and the playground alike. Reverse: drop the uncommented rung in emit_within_for.
  • 34.14 cpl submit is cpl build then cpl test, and sends nothing. It takes no --judge: the file or project names its judge, so the build and the cases cannot disagree on one. No cases is a warning, not a failure, since many problems are tried before their samples are saved. It sends nothing because no judge we target offers a submission API it allows scripts to use, and a scraped login is a credential in a tool that must not hold one. Reverse: drop submit from cpl-cli.