Autocomplete and evaluate solutions on the solve page
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]>
This commit is contained in:
@@ -0,0 +1,322 @@
|
||||
// Package evaluate has Claude judge the code in the solve page's editor, as
|
||||
// a strong competitive programmer would before submitting it: is it right,
|
||||
// is it fast enough for the constraints, which lines are wrong, and is
|
||||
// there a small input that breaks it.
|
||||
//
|
||||
// The code is a draft, so unlike an explanation or a review nothing is
|
||||
// committed. The answer is kept in memory with the source it judged
|
||||
// (explain.Jobs.StartWith), and the page anchors each issue to its line in
|
||||
// the editor.
|
||||
//
|
||||
// Claude is given the saved tests' verdicts from the runner along with the
|
||||
// code, because a test that fails is a fact it should not have to work out,
|
||||
// and one that passes is evidence it can weigh.
|
||||
package evaluate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"adam-french.co.uk/usaco-site/internal/claude"
|
||||
"adam-french.co.uk/usaco-site/internal/explain"
|
||||
"adam-french.co.uk/usaco-site/internal/runner"
|
||||
)
|
||||
|
||||
// Input is what Claude is told.
|
||||
type Input struct {
|
||||
Name string
|
||||
Statement string
|
||||
Examples []explain.Example
|
||||
Lang string // runner.Cpp or runner.Python
|
||||
Source string
|
||||
LeetCode bool // the source is a class Solution run through driver.h
|
||||
Note string // what the admin wants checked: "worried about overflow"
|
||||
// Run is the saved tests' outcome, nil when they were not run; RunNote
|
||||
// says why not.
|
||||
Run *runner.RunResponse
|
||||
RunNote string
|
||||
}
|
||||
|
||||
// Issue is one problem in the code, anchored to a line of it.
|
||||
type Issue struct {
|
||||
Line int `json:"line"`
|
||||
Severity string `json:"severity"`
|
||||
Title string `json:"title"`
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
|
||||
// Counterexample is an input the code gets wrong; all blank when Claude has
|
||||
// none it is sure of.
|
||||
type Counterexample struct {
|
||||
Input string `json:"input"`
|
||||
Expected string `json:"expected"`
|
||||
Why string `json:"why"`
|
||||
}
|
||||
|
||||
// Result is the reply's shape; Schema is the same thing for the API.
|
||||
type Result struct {
|
||||
Verdict string `json:"verdict"`
|
||||
Summary string `json:"summary"`
|
||||
Correctness string `json:"correctness"`
|
||||
Complexity string `json:"complexity"`
|
||||
Issues []Issue `json:"issues"`
|
||||
Counterexample Counterexample `json:"counterexample"`
|
||||
Style string `json:"style"`
|
||||
}
|
||||
|
||||
// Evaluation is what the job keeps and the page shows: the reply, and the
|
||||
// source it is about, so the page can tell when the editor has moved on.
|
||||
type Evaluation struct {
|
||||
Result
|
||||
Lang string `json:"lang"`
|
||||
Source string `json:"source"`
|
||||
Model string `json:"model"`
|
||||
At time.Time `json:"at"`
|
||||
// Tests is the run's one-line outcome ("3/4 passed"), or why there was
|
||||
// none.
|
||||
Tests string `json:"tests"`
|
||||
}
|
||||
|
||||
// Verdicts, and how they read on the page.
|
||||
var Verdicts = map[string]string{
|
||||
"correct": "Looks correct",
|
||||
"edge_cases": "Misses edge cases",
|
||||
"wrong": "Wrong",
|
||||
"too_slow": "Too slow",
|
||||
"incomplete": "Unfinished",
|
||||
}
|
||||
|
||||
func str(desc string) map[string]any { return map[string]any{"type": "string", "description": desc} }
|
||||
|
||||
// Schema constrains the reply to Result. Structured outputs need every
|
||||
// object closed and every property required.
|
||||
var Schema = map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"verdict": map[string]any{
|
||||
"type": "string",
|
||||
"enum": []string{"correct", "edge_cases", "wrong", "too_slow", "incomplete"},
|
||||
"description": "correct: you expect it to be accepted. edge_cases: the idea is right but some inputs break it (overflow, empty input, an off-by-one at a boundary). " +
|
||||
"wrong: the approach itself gives wrong answers. too_slow: right answers, but over the time or memory limit at the largest inputs. " +
|
||||
"incomplete: it does not compile, or is not a full attempt yet. When several apply, pick the first of wrong, too_slow, edge_cases.",
|
||||
},
|
||||
"summary": str("Markdown, one or two sentences: what the code does, as an algorithm, so they can check it was read right."),
|
||||
"correctness": str("Markdown. Why it is or is not correct. Account for every failing test. If it is wrong, say where the reasoning breaks; if it is right, give the argument briefly, especially for a greedy choice."),
|
||||
"complexity": str("Markdown. Time and memory as written, against what the constraints allow, with a rough operation count at the largest input."),
|
||||
"issues": map[string]any{
|
||||
"type": "array",
|
||||
"description": "Specific problems, most serious first: bugs, edge cases, overflow, undefined behaviour, needless slowness. Empty if there are none. Not style nitpicks.",
|
||||
"items": map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"line": map[string]any{"type": "integer", "description": "The source line it is on, as numbered in <code>. 0 if it is about the program as a whole."},
|
||||
"severity": map[string]any{"type": "string", "enum": []string{"error", "warning", "info"}, "description": "error: gives a wrong answer, crashes or times out on some valid input. warning: risky or fragile, but may be fine on this problem's tests. info: worth knowing, harmless here."},
|
||||
"title": str("Plain text, under ten words: shown inline in the editor."),
|
||||
"detail": str("Markdown. What goes wrong and on what input, and how to fix it. A corrected line or two is fine; never a whole solution."),
|
||||
},
|
||||
"required": []string{"line", "severity", "title", "detail"},
|
||||
"additionalProperties": false,
|
||||
},
|
||||
},
|
||||
"counterexample": map[string]any{
|
||||
"type": "object",
|
||||
"description": "A small input this code gets wrong, in exactly the problem's input format. All three blank unless you have traced the code on it and are sure.",
|
||||
"properties": map[string]any{
|
||||
"input": str("The input, exactly as the program would read it. Blank for none."),
|
||||
"expected": str("The correct output for that input, worked out carefully. Blank for none."),
|
||||
"why": str("Markdown, one or two sentences: what this code outputs instead, and why. Blank for none."),
|
||||
},
|
||||
"required": []string{"input", "expected", "why"},
|
||||
"additionalProperties": false,
|
||||
},
|
||||
"style": str("Markdown, two to four sentences: readability and contest habits worth changing, if any. Blank if there is nothing worth saying."),
|
||||
},
|
||||
"required": []string{"verdict", "summary", "correctness", "complexity", "issues", "counterexample", "style"},
|
||||
"additionalProperties": false,
|
||||
}
|
||||
|
||||
// The reply is short; the rest is room for adaptive thinking, which is
|
||||
// where the tracing happens.
|
||||
const maxTokens = 24000
|
||||
|
||||
// System is the same on every call, so it is cached.
|
||||
const System = `You are a strong competitive programmer reviewing someone's solution before they submit it. You get the problem, their code, and usually the verdicts from running it on their saved tests. Tell them whether it will be accepted and, if not, exactly why.
|
||||
|
||||
How to judge:
|
||||
- Decide correctness yourself. Trace the code on the examples and on small cases you construct, especially the boundaries: minimum sizes, all-equal values, the largest values, an empty answer.
|
||||
- The test verdicts are facts. A failing test proves a bug; explain every one. Passing tests are evidence, not proof: samples are small and weak.
|
||||
- Check the complexity against the constraints in the statement. Assume about 10^8 simple operations per second in C++ and 10^7 in CPython.
|
||||
- Look hard for what usually breaks accepted-looking code: int overflow where long long is needed, off-by-ones, state not reset between test cases, uninitialised values, out-of-bounds access, wrong output format, recursion depth (in Python especially), comparing floating point exactly, and slow I/O on big input.
|
||||
- Read the code as written, not as intended. Code that is unfinished or does not compile is incomplete.
|
||||
|
||||
Their setup:
|
||||
- C++ is built with g++ -std=c++17 -O2 -DLOCAL. LOCAL is defined only on their machine, never on the judge, so the DBG and print macros are no-ops there. Their template defines macros and typedefs such as ll, vi, pii, F(i, L, R) for (int i = L; i < R; i++), FE (<=), FD and FDE (counting down), ALL(c), SZ(c), pb, fi and se, REMAX and REMIN, takeI(n) (declares int n and reads it), takeL, takeV(v, n), whileZ (reads T and loops T times), YESNO(b), and STDIO(name), which reads name.in and writes name.out when run locally or on USACO. Treat these as ordinary code.
|
||||
- A LeetCode problem's code is the class Solution only; a driver reads the tests and calls it, so judge the method, not I/O.
|
||||
- Python reads with a tokens() helper over sys.stdin.buffer, and a stdio(name) helper redirects to name.in and name.out when that file exists.
|
||||
|
||||
How to answer:
|
||||
- The code is shown with line numbers. Every issue names the line it is on, as numbered there, so it can be marked in their editor.
|
||||
- Point at fixes; do not write their solution. A corrected line or two is fine.
|
||||
- Give a counterexample only if you have traced the code on it and are sure it fails, and you have worked out the right answer. Keep it small, and in exactly the input format. Otherwise leave it blank.
|
||||
- Be direct. If the code is right, say so plainly and keep the rest short; do not invent problems.
|
||||
- Write in plain prose, using markdown for emphasis, lists and inline code, and LaTeX between $...$ for math such as complexities ($O(n \log n)$); the page typesets it with KaTeX.`
|
||||
|
||||
// Prompt is the user message.
|
||||
func Prompt(in Input) string {
|
||||
var b strings.Builder
|
||||
fmt.Fprintf(&b, "<problem name=%q>\n%s\n</problem>\n", in.Name, strings.TrimSpace(in.Statement))
|
||||
for i, ex := range in.Examples {
|
||||
fmt.Fprintf(&b, "\n<example n=\"%d\">\n<input>\n%s\n</input>\n", i+1, strings.TrimRight(ex.In, "\n"))
|
||||
if ex.Out != "" {
|
||||
fmt.Fprintf(&b, "<output>\n%s\n</output>\n", strings.TrimRight(ex.Out, "\n"))
|
||||
}
|
||||
b.WriteString("</example>\n")
|
||||
}
|
||||
kind := ""
|
||||
if in.LeetCode {
|
||||
kind = " leetcode=\"true\""
|
||||
}
|
||||
fmt.Fprintf(&b, "\n<code lang=%q%s>\n%s</code>\n", in.Lang, kind, numbered(in.Source))
|
||||
b.WriteString("\n<test_run>\n" + runText(in.Run, in.RunNote) + "</test_run>\n")
|
||||
if note := strings.TrimSpace(in.Note); note != "" {
|
||||
fmt.Fprintf(&b, "\n<context>\n%s\n</context>\n", note)
|
||||
}
|
||||
b.WriteString("\nEvaluate my solution.")
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// numbered prefixes each line with its number, right-aligned, as an editor
|
||||
// gutter would show it.
|
||||
func numbered(src string) string {
|
||||
lines := strings.Split(strings.TrimRight(src, "\n"), "\n")
|
||||
w := len(fmt.Sprint(len(lines)))
|
||||
var b strings.Builder
|
||||
for i, line := range lines {
|
||||
fmt.Fprintf(&b, "%*d| %s\n", w, i+1, line)
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Caps on what a run puts in the prompt. A failing test bigger than
|
||||
// maxCase is a stress test: its verdict is worth stating, its text is not.
|
||||
const (
|
||||
maxCase = 2 << 10
|
||||
maxShown = 3
|
||||
maxCompiler = 4 << 10
|
||||
)
|
||||
|
||||
func runText(r *runner.RunResponse, note string) string {
|
||||
if r == nil {
|
||||
return note + "\n"
|
||||
}
|
||||
var b strings.Builder
|
||||
if !r.Compile.OK {
|
||||
b.WriteString("It did not compile:\n" + capped(r.Compile.Output, maxCompiler) + "\n")
|
||||
return b.String()
|
||||
}
|
||||
if len(r.Results) == 0 {
|
||||
return "It compiled. There are no saved tests to run.\n"
|
||||
}
|
||||
fmt.Fprintf(&b, "%s on the saved tests:\n", Outcome(r))
|
||||
for _, t := range r.Results {
|
||||
fmt.Fprintf(&b, "- test %s: %s in %d ms", t.Name, t.Verdict, t.TimeMs)
|
||||
if t.Message != "" {
|
||||
b.WriteString(" (" + t.Message + ")")
|
||||
}
|
||||
b.WriteString("\n")
|
||||
}
|
||||
shown := 0
|
||||
for _, t := range r.Results {
|
||||
if shown == maxShown {
|
||||
break
|
||||
}
|
||||
if t.Verdict == runner.Accepted || t.Verdict == runner.Unchecked {
|
||||
continue
|
||||
}
|
||||
shown++
|
||||
fmt.Fprintf(&b, "\n<failed_test name=%q verdict=%q>\n", t.Name, t.Verdict)
|
||||
if len(t.Input) > maxCase || (t.Expected != nil && len(*t.Expected) > maxCase) {
|
||||
b.WriteString("(too big to show)\n</failed_test>\n")
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(&b, "<input>\n%s\n</input>\n", strings.TrimRight(t.Input, "\n"))
|
||||
if t.Expected != nil {
|
||||
fmt.Fprintf(&b, "<expected>\n%s\n</expected>\n", strings.TrimRight(*t.Expected, "\n"))
|
||||
}
|
||||
fmt.Fprintf(&b, "<got>\n%s\n</got>\n", capped(strings.TrimRight(t.Output, "\n"), maxCase))
|
||||
if t.Stderr != "" {
|
||||
fmt.Fprintf(&b, "<stderr>\n%s\n</stderr>\n", capped(strings.TrimRight(t.Stderr, "\n"), maxCase))
|
||||
}
|
||||
b.WriteString("</failed_test>\n")
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Outcome is a run's one-line result: "3/4 passed", or "2 ran" when no
|
||||
// test had an expected output.
|
||||
func Outcome(r *runner.RunResponse) string {
|
||||
if !r.Compile.OK {
|
||||
return "did not compile"
|
||||
}
|
||||
passed, checked := 0, 0
|
||||
for _, t := range r.Results {
|
||||
if t.Verdict != runner.Unchecked {
|
||||
checked++
|
||||
}
|
||||
if t.Verdict == runner.Accepted {
|
||||
passed++
|
||||
}
|
||||
}
|
||||
if checked == 0 {
|
||||
return fmt.Sprintf("%d ran, unchecked", len(r.Results))
|
||||
}
|
||||
return fmt.Sprintf("%d/%d passed", passed, checked)
|
||||
}
|
||||
|
||||
func capped(s string, n int) string {
|
||||
if len(s) <= n {
|
||||
return s
|
||||
}
|
||||
return s[:n] + "\n(cut)"
|
||||
}
|
||||
|
||||
// Generate asks Claude and returns the evaluation.
|
||||
func Generate(ctx context.Context, a explain.Asker, in Input, now time.Time) (*Evaluation, error) {
|
||||
var r Result
|
||||
err := a.JSON(ctx, claude.Request{System: System, User: Prompt(in), Schema: Schema, MaxTokens: maxTokens}, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tests := in.RunNote
|
||||
if in.Run != nil {
|
||||
tests = Outcome(in.Run)
|
||||
}
|
||||
return &Evaluation{Result: clean(r, in.Source), Lang: in.Lang, Source: in.Source, Model: a.Model(), At: now, Tests: tests}, nil
|
||||
}
|
||||
|
||||
// clean keeps the reply inside what the page can show: lines that exist,
|
||||
// severities it knows, and a counterexample only when it is whole.
|
||||
func clean(r Result, src string) Result {
|
||||
lines := strings.Count(strings.TrimRight(src, "\n"), "\n") + 1
|
||||
issues := []Issue{}
|
||||
for _, is := range r.Issues {
|
||||
if is.Line < 0 || is.Line > lines {
|
||||
is.Line = 0
|
||||
}
|
||||
switch is.Severity {
|
||||
case "error", "warning", "info":
|
||||
default:
|
||||
is.Severity = "info"
|
||||
}
|
||||
if strings.TrimSpace(is.Title) != "" || strings.TrimSpace(is.Detail) != "" {
|
||||
issues = append(issues, is)
|
||||
}
|
||||
}
|
||||
r.Issues = issues
|
||||
if strings.TrimSpace(r.Counterexample.Input) == "" || strings.TrimSpace(r.Counterexample.Expected) == "" {
|
||||
r.Counterexample = Counterexample{}
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package evaluate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"adam-french.co.uk/usaco-site/internal/claude"
|
||||
"adam-french.co.uk/usaco-site/internal/explain"
|
||||
"adam-french.co.uk/usaco-site/internal/runner"
|
||||
)
|
||||
|
||||
func ptr(s string) *string { return &s }
|
||||
|
||||
func TestPrompt(t *testing.T) {
|
||||
run := &runner.RunResponse{Compile: runner.Compile{OK: true}, Results: []runner.Result{
|
||||
{Name: "1", Verdict: runner.Accepted, TimeMs: 3},
|
||||
{Name: "2", Verdict: runner.WrongAnswer, TimeMs: 4, Input: "2\n", Output: "5\n", Expected: ptr("4\n")},
|
||||
{Name: "big", Verdict: runner.TimeLimit, TimeMs: 2000, Message: "exceeded 2s", Input: strings.Repeat("9 ", 2000)},
|
||||
}}
|
||||
p := Prompt(Input{
|
||||
Name: "moocast", Statement: "# Moocast\n\nCows.", Lang: runner.Cpp,
|
||||
Source: "int main() {\n return 0;\n}\n",
|
||||
Examples: []explain.Example{{In: "1\n", Out: "2\n"}},
|
||||
Note: " overflow? ",
|
||||
Run: run,
|
||||
})
|
||||
for _, want := range []string{
|
||||
"<problem name=\"moocast\">\n# Moocast\n\nCows.\n</problem>",
|
||||
"<example n=\"1\">\n<input>\n1\n</input>\n<output>\n2\n</output>",
|
||||
"<code lang=\"cpp\">\n1| int main() {\n2| return 0;\n3| }\n</code>",
|
||||
"1/3 passed on the saved tests:\n- test 1: AC in 3 ms\n- test 2: WA in 4 ms\n- test big: TLE in 2000 ms (exceeded 2s)\n",
|
||||
"<failed_test name=\"2\" verdict=\"WA\">\n<input>\n2\n</input>\n<expected>\n4\n</expected>\n<got>\n5\n</got>\n</failed_test>",
|
||||
"<failed_test name=\"big\" verdict=\"TLE\">\n(too big to show)\n</failed_test>",
|
||||
"<context>\noverflow?\n</context>",
|
||||
} {
|
||||
if !strings.Contains(p, want) {
|
||||
t.Errorf("prompt is missing %q:\n%s", want, p)
|
||||
}
|
||||
}
|
||||
|
||||
p = Prompt(Input{Name: "two-sum", Statement: "x", Lang: runner.Cpp, LeetCode: true, Source: "class Solution {};", RunNote: "The tests were not run: the code runner is not configured."})
|
||||
for _, want := range []string{
|
||||
"<code lang=\"cpp\" leetcode=\"true\">\n1| class Solution {};\n</code>",
|
||||
"<test_run>\nThe tests were not run: the code runner is not configured.\n</test_run>",
|
||||
} {
|
||||
if !strings.Contains(p, want) {
|
||||
t.Errorf("prompt is missing %q:\n%s", want, p)
|
||||
}
|
||||
}
|
||||
if strings.Contains(p, "<context>") {
|
||||
t.Errorf("a blank note still made a context block:\n%s", p)
|
||||
}
|
||||
|
||||
p = Prompt(Input{Name: "x", Lang: runner.Cpp, Source: "int main( {}", Run: &runner.RunResponse{Compile: runner.Compile{Output: "main.cpp:1: error"}}})
|
||||
if !strings.Contains(p, "It did not compile:\nmain.cpp:1: error\n") {
|
||||
t.Errorf("a compile error is not in the prompt:\n%s", p)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNumberedPadsToTheWidestLine(t *testing.T) {
|
||||
got := numbered(strings.Repeat("x\n", 10))
|
||||
if !strings.HasPrefix(got, " 1| x\n") || !strings.HasSuffix(got, "10| x\n") {
|
||||
t.Errorf("numbered = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutcome(t *testing.T) {
|
||||
r := &runner.RunResponse{Compile: runner.Compile{OK: true}, Results: []runner.Result{{Verdict: runner.Unchecked}, {Verdict: runner.Unchecked}}}
|
||||
if got := Outcome(r); got != "2 ran, unchecked" {
|
||||
t.Errorf("Outcome = %q", got)
|
||||
}
|
||||
if got := Outcome(&runner.RunResponse{}); got != "did not compile" {
|
||||
t.Errorf("Outcome = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// fakeAsker answers with r.
|
||||
type fakeAsker struct{ r Result }
|
||||
|
||||
func (fakeAsker) Model() string { return "fake-model" }
|
||||
func (f fakeAsker) JSON(_ context.Context, _ claude.Request, out any) error {
|
||||
*out.(*Result) = f.r
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestGenerateCleansTheReply(t *testing.T) {
|
||||
r := Result{
|
||||
Verdict: "wrong",
|
||||
Issues: []Issue{
|
||||
{Line: 2, Severity: "error", Title: "Overflow"},
|
||||
{Line: 99, Severity: "fatal", Title: "Past the end"},
|
||||
{Line: 1, Severity: "info"},
|
||||
},
|
||||
Counterexample: Counterexample{Input: "3\n", Why: "no expected output"},
|
||||
}
|
||||
now := time.Date(2026, 10, 20, 12, 0, 0, 0, time.UTC)
|
||||
run := &runner.RunResponse{Compile: runner.Compile{OK: true}, Results: []runner.Result{{Verdict: runner.Accepted}}}
|
||||
ev, err := Generate(context.Background(), fakeAsker{r}, Input{Lang: runner.Python, Source: "a\nb\n", Run: run}, now)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []Issue{{Line: 2, Severity: "error", Title: "Overflow"}, {Line: 0, Severity: "info", Title: "Past the end"}}
|
||||
if len(ev.Issues) != 2 || ev.Issues[0] != want[0] || ev.Issues[1] != want[1] {
|
||||
t.Errorf("issues = %+v, want %+v", ev.Issues, want)
|
||||
}
|
||||
if ev.Counterexample != (Counterexample{}) {
|
||||
t.Errorf("a counterexample with no expected output was kept: %+v", ev.Counterexample)
|
||||
}
|
||||
if ev.Lang != runner.Python || ev.Source != "a\nb\n" || ev.Model != "fake-model" || !ev.At.Equal(now) || ev.Tests != "1/1 passed" {
|
||||
t.Errorf("evaluation = %+v", ev)
|
||||
}
|
||||
// The page reads the reply's fields at the top level, beside lang.
|
||||
b, _ := json.Marshal(ev)
|
||||
if !strings.Contains(string(b), `"verdict":"wrong"`) || !strings.Contains(string(b), `"lang":"python"`) {
|
||||
t.Errorf("JSON = %s", b)
|
||||
}
|
||||
}
|
||||
|
||||
// Every property must be required and every object closed for structured
|
||||
// outputs, and the Go struct must read every field the schema asks for.
|
||||
func TestSchemaMatchesResult(t *testing.T) {
|
||||
var check func(path string, s map[string]any)
|
||||
check = func(path string, s map[string]any) {
|
||||
if s["type"] == "array" {
|
||||
check(path+"[]", s["items"].(map[string]any))
|
||||
return
|
||||
}
|
||||
if s["type"] != "object" {
|
||||
return
|
||||
}
|
||||
if s["additionalProperties"] != false {
|
||||
t.Errorf("%s is not closed", path)
|
||||
}
|
||||
props := s["properties"].(map[string]any)
|
||||
req := map[string]bool{}
|
||||
for _, r := range s["required"].([]string) {
|
||||
req[r] = true
|
||||
}
|
||||
for k, v := range props {
|
||||
if !req[k] {
|
||||
t.Errorf("%s.%s is not required", path, k)
|
||||
}
|
||||
check(path+"."+k, v.(map[string]any))
|
||||
}
|
||||
}
|
||||
check("", Schema)
|
||||
|
||||
b, _ := json.Marshal(Result{Issues: []Issue{{}}})
|
||||
var got map[string]any
|
||||
json.Unmarshal(b, &got)
|
||||
for k := range Schema["properties"].(map[string]any) {
|
||||
if _, ok := got[k]; !ok {
|
||||
t.Errorf("Result has no field for %q", k)
|
||||
}
|
||||
}
|
||||
for v := range Verdicts {
|
||||
found := false
|
||||
for _, e := range Schema["properties"].(map[string]any)["verdict"].(map[string]any)["enum"].([]string) {
|
||||
found = found || e == v
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("verdict %q is labelled but not in the schema", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ type Status struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
Started *time.Time `json:"started,omitempty"`
|
||||
Finished *time.Time `json:"finished,omitempty"`
|
||||
// Result is a finished StartWith job's answer.
|
||||
Result any `json:"result,omitempty"`
|
||||
}
|
||||
|
||||
// Jobs runs at most one explanation per problem at a time. An explanation
|
||||
@@ -34,6 +36,13 @@ type Jobs struct {
|
||||
// reports whether it started. fn's error is shown to the admin, so it must
|
||||
// be a message meant for them.
|
||||
func (j *Jobs) Start(name string, fn func() error) bool {
|
||||
return j.StartWith(name, func() (any, error) { return nil, fn() })
|
||||
}
|
||||
|
||||
// StartWith is Start for a job whose answer is kept here rather than
|
||||
// committed: a done job's Status carries it until the next job for name
|
||||
// starts, or the server restarts.
|
||||
func (j *Jobs) StartWith(name string, fn func() (any, error)) bool {
|
||||
j.mu.Lock()
|
||||
defer j.mu.Unlock()
|
||||
if j.m == nil {
|
||||
@@ -45,13 +54,13 @@ func (j *Jobs) Start(name string, fn func() error) bool {
|
||||
now := time.Now()
|
||||
j.m[name] = &Status{State: Running, Started: &now}
|
||||
go func() {
|
||||
err := fn()
|
||||
res, err := fn()
|
||||
j.mu.Lock()
|
||||
defer j.mu.Unlock()
|
||||
end := time.Now()
|
||||
s := &Status{State: Done, Started: &now, Finished: &end}
|
||||
s := &Status{State: Done, Started: &now, Finished: &end, Result: res}
|
||||
if err != nil {
|
||||
s.State, s.Error = Failed, err.Error()
|
||||
s.State, s.Error, s.Result = Failed, err.Error(), nil
|
||||
}
|
||||
j.m[name] = s
|
||||
}()
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"adam-french.co.uk/usaco-site/internal/claude"
|
||||
"adam-french.co.uk/usaco-site/internal/evaluate"
|
||||
"adam-french.co.uk/usaco-site/internal/runner"
|
||||
)
|
||||
|
||||
// The saved tests run first and Claude takes a minute or two after.
|
||||
const evaluateTimeout = 10 * time.Minute
|
||||
|
||||
// startEvaluate starts judging the editor's source and answers at once; the
|
||||
// page polls evaluateStatus, whose result is the evaluation. Nothing is
|
||||
// committed: the source is a draft, and the answer is about this version of
|
||||
// it only.
|
||||
func (s *Server) startEvaluate(ctx *gin.Context) {
|
||||
if s.Claude == nil {
|
||||
ctx.JSON(http.StatusServiceUnavailable, gin.H{"error": "Claude is not configured on this server (CLAUDE_API_KEY)"})
|
||||
return
|
||||
}
|
||||
body, p, l, ok := s.readCode(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if strings.TrimSpace(body.Source) == "" {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "the source is empty"})
|
||||
return
|
||||
}
|
||||
if len(body.Note) > maxNote {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "the note is too long"})
|
||||
return
|
||||
}
|
||||
if strings.TrimSpace(p.Statement) == "" && p.URL == "" {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "add the problem statement or a link to it first"})
|
||||
return
|
||||
}
|
||||
in := evaluate.Input{
|
||||
Name: p.Name, Statement: p.Statement, Examples: examples(p),
|
||||
Lang: body.Lang, Source: body.Source, LeetCode: l.leetcode, Note: body.Note,
|
||||
}
|
||||
link := p.URL
|
||||
if !s.evalJobs.StartWith(p.Name, func() (any, error) { return s.evaluate(in, link, l) }) {
|
||||
ctx.JSON(http.StatusConflict, gin.H{"error": "a solution is already being evaluated"})
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusAccepted, s.evalJobs.Get(p.Name))
|
||||
}
|
||||
|
||||
func (s *Server) evaluateStatus(ctx *gin.Context) {
|
||||
if p, ok := s.lookup(ctx, true); ok {
|
||||
ctx.JSON(http.StatusOK, s.evalJobs.Get(p.Name))
|
||||
}
|
||||
}
|
||||
|
||||
// evaluate is one job. Its error is shown to the admin, so every path
|
||||
// returns a message meant for them and logs the detail.
|
||||
func (s *Server) evaluate(in evaluate.Input, link string, l *layout) (*evaluate.Evaluation, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), evaluateTimeout)
|
||||
defer cancel()
|
||||
name := in.Name
|
||||
|
||||
// A fetched statement is not saved: that would be the only commit an
|
||||
// evaluation makes. Explain or Edit details keep one.
|
||||
if _, err := s.ensureStatement(ctx, "evaluate", name, &in.Statement, link); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
in.Run, in.RunNote = s.evaluationRun(ctx, name, in.Lang, in.Source, l)
|
||||
|
||||
ev, err := evaluate.Generate(ctx, s.Claude, in, time.Now())
|
||||
if err != nil {
|
||||
var f *claude.Failure
|
||||
if errors.As(err, &f) {
|
||||
log.Printf("[evaluate] %s: %s: %v", name, f.Msg, f.Err)
|
||||
return nil, f
|
||||
}
|
||||
log.Printf("[evaluate] %s: %v", name, err)
|
||||
return nil, errors.New("the evaluation could not be written")
|
||||
}
|
||||
return ev, nil
|
||||
}
|
||||
|
||||
// evaluationRun is Submit's run, for Claude to read. A run that cannot
|
||||
// happen costs the evaluation its test verdicts, not the evaluation: the
|
||||
// note says why, and goes to Claude in their place.
|
||||
func (s *Server) evaluationRun(ctx context.Context, name, lang, source string, l *layout) (*runner.RunResponse, string) {
|
||||
if s.Runner == nil {
|
||||
return nil, "The tests were not run: the code runner is not configured."
|
||||
}
|
||||
tests, err := readRunTests(l)
|
||||
if err != nil {
|
||||
log.Printf("[evaluate] %s: reading the tests: %v", name, err)
|
||||
return nil, "The tests were not run: they could not be read."
|
||||
}
|
||||
files, err := s.headers(l, lang)
|
||||
if err != nil {
|
||||
log.Printf("[evaluate] %s: reading the headers: %v", name, err)
|
||||
return nil, "The tests were not run: the headers could not be read."
|
||||
}
|
||||
c, cancel := context.WithTimeout(ctx, runTimeout)
|
||||
defer cancel()
|
||||
res, err := s.Runner.Run(c, runner.RunRequest{Lang: lang, Source: source, Files: files, IO: l.io, Tests: tests})
|
||||
if err != nil {
|
||||
log.Printf("[evaluate] %s: running the tests: %v", name, err)
|
||||
return nil, "The tests were not run: the code runner failed."
|
||||
}
|
||||
return &res, ""
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"adam-french.co.uk/usaco-site/internal/claude"
|
||||
"adam-french.co.uk/usaco-site/internal/evaluate"
|
||||
"adam-french.co.uk/usaco-site/internal/explain"
|
||||
)
|
||||
|
||||
// fakeEvaluator flags line 1 of whatever it is shown, or fails.
|
||||
type fakeEvaluator struct {
|
||||
user string
|
||||
fail bool
|
||||
}
|
||||
|
||||
func (f *fakeEvaluator) Model() string { return "fake-model" }
|
||||
func (f *fakeEvaluator) JSON(_ context.Context, req claude.Request, out any) error {
|
||||
f.user = req.User
|
||||
if f.fail {
|
||||
return &claude.Failure{Msg: "Claude declined to answer"}
|
||||
}
|
||||
*out.(*evaluate.Result) = evaluate.Result{
|
||||
Verdict: "edge_cases", Summary: "Prints zero.",
|
||||
Issues: []evaluate.Issue{{Line: 1, Severity: "error", Title: "Never reads n"}},
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type evalStatus struct {
|
||||
State string `json:"state"`
|
||||
Error string `json:"error"`
|
||||
Result *evaluate.Evaluation `json:"result"`
|
||||
}
|
||||
|
||||
func waitEvaluate(t *testing.T, r *gin.Engine, name string) evalStatus {
|
||||
t.Helper()
|
||||
for range 400 {
|
||||
var s evalStatus
|
||||
json.Unmarshal(do(r, "GET", "/usaco/api/problems/"+name+"/evaluate", "", true).Body.Bytes(), &s)
|
||||
if s.State != explain.Running {
|
||||
return s
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
}
|
||||
t.Fatal("evaluation still running")
|
||||
return evalStatus{}
|
||||
}
|
||||
|
||||
const evalBody = `{"lang":"cpp","source":"int main() {}\n","note":"is it fast enough?"}`
|
||||
|
||||
func TestEvaluateRefusals(t *testing.T) {
|
||||
r, repo, _ := setupRun(t)
|
||||
if rec := do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, true); rec.Code != 503 {
|
||||
t.Fatalf("no Claude = %d, want 503", rec.Code)
|
||||
}
|
||||
repo.srv.Claude = &fakeEvaluator{}
|
||||
if rec := do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, false); rec.Code != 401 {
|
||||
t.Fatalf("public evaluate = %d, want 401", rec.Code)
|
||||
}
|
||||
if rec := do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, true); rec.Code != 400 {
|
||||
t.Fatalf("no statement or link = %d, want 400: %s", rec.Code, rec.Body)
|
||||
}
|
||||
withStatement(t, r)
|
||||
if rec := do(r, "POST", "/usaco/api/problems/moocast/evaluate", `{"lang":"cpp","source":" \n"}`, true); rec.Code != 400 {
|
||||
t.Fatalf("empty source = %d, want 400", rec.Code)
|
||||
}
|
||||
if rec := do(r, "POST", "/usaco/api/problems/moocast/evaluate", `{"lang":"rust","source":"fn main() {}"}`, true); rec.Code != 400 {
|
||||
t.Fatalf("rust = %d, want 400", rec.Code)
|
||||
}
|
||||
if rec := do(r, "POST", "/usaco/api/problems/two-sum/evaluate", `{"lang":"python","source":"x"}`, true); rec.Code != 400 {
|
||||
t.Fatalf("python on LeetCode = %d, want 400", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateRunsTheTestsAndCommitsNothing(t *testing.T) {
|
||||
r, repo, fr := setupRun(t)
|
||||
fc := &fakeEvaluator{}
|
||||
repo.srv.Claude = fc
|
||||
withStatement(t, r)
|
||||
commits := len(repo.msg)
|
||||
|
||||
if rec := do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, true); rec.Code != 202 {
|
||||
t.Fatalf("evaluate = %d %s", rec.Code, rec.Body)
|
||||
}
|
||||
s := waitEvaluate(t, r, "moocast")
|
||||
if s.State != explain.Done || s.Result == nil {
|
||||
t.Fatalf("job = %+v", s)
|
||||
}
|
||||
ev := s.Result
|
||||
if ev.Verdict != "edge_cases" || ev.Lang != "cpp" || ev.Source != "int main() {}\n" || ev.Model != "fake-model" || ev.Tests != "1/1 passed" {
|
||||
t.Errorf("evaluation = %+v", ev)
|
||||
}
|
||||
if len(ev.Issues) != 1 || ev.Issues[0].Line != 1 {
|
||||
t.Errorf("issues = %+v", ev.Issues)
|
||||
}
|
||||
// Submit's run: the saved tests, with the headers.
|
||||
if fr.run == nil || len(fr.run.Tests) != 3 || fr.run.IO != "moocast" || fr.run.Files["debugging.h"] == "" {
|
||||
t.Errorf("run = %+v", fr.run)
|
||||
}
|
||||
for _, want := range []string{"walkie-talkies", "<code lang=\"cpp\">\n1| int main() {}\n</code>", "1/1 passed on the saved tests", "is it fast enough?"} {
|
||||
if !strings.Contains(fc.user, want) {
|
||||
t.Errorf("prompt is missing %q:\n%s", want, fc.user)
|
||||
}
|
||||
}
|
||||
if len(repo.msg) != commits {
|
||||
t.Errorf("an evaluation committed: %v", repo.msg[commits:])
|
||||
}
|
||||
}
|
||||
|
||||
func TestEvaluateWithoutARunner(t *testing.T) {
|
||||
r, repo, fr := setupRun(t)
|
||||
fc := &fakeEvaluator{}
|
||||
repo.srv.Claude = fc
|
||||
withStatement(t, r)
|
||||
|
||||
// A runner that fails costs the verdicts, not the evaluation.
|
||||
fr.err = errors.New("runner down")
|
||||
do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, true)
|
||||
if s := waitEvaluate(t, r, "moocast"); s.State != explain.Done || s.Result.Tests != "The tests were not run: the code runner failed." {
|
||||
t.Fatalf("with a failing runner = %+v", s)
|
||||
}
|
||||
|
||||
repo.srv.Runner = nil
|
||||
if c := getCodeReply(t, r, "moocast"); c.Runner {
|
||||
t.Fatal("runner still reported")
|
||||
}
|
||||
do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, true)
|
||||
s := waitEvaluate(t, r, "moocast")
|
||||
if s.State != explain.Done || !strings.Contains(fc.user, "the code runner is not configured") {
|
||||
t.Fatalf("with no runner = %+v\n%s", s, fc.user)
|
||||
}
|
||||
|
||||
fc.fail = true
|
||||
do(r, "POST", "/usaco/api/problems/moocast/evaluate", evalBody, true)
|
||||
if s := waitEvaluate(t, r, "moocast"); s.State != explain.Failed || s.Error != "Claude declined to answer" || s.Result != nil {
|
||||
t.Fatalf("a failed evaluation = %+v", s)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// Package handlers is the site's REST API: the problem list and pages (public
|
||||
// for solved problems, everything for the admin), the admin's edits, the
|
||||
// Claude explanations (explain.go) and recording reviews (review.go), the
|
||||
// solve page's code editing and runs (run.go), and the Gitea webhook that
|
||||
// tells the server to pull.
|
||||
// solve page's code editing and runs (run.go) and evaluations
|
||||
// (evaluate.go), and the Gitea webhook that tells the server to pull.
|
||||
package handlers
|
||||
|
||||
import (
|
||||
@@ -67,9 +67,9 @@ type Server struct {
|
||||
Runner Runner
|
||||
|
||||
idx atomic.Pointer[index.Index]
|
||||
// Separate, so a review and an explanation of one problem can run at
|
||||
// the same time.
|
||||
jobs, reviewJobs explain.Jobs
|
||||
// Separate, so a review, an explanation and an evaluation of one
|
||||
// problem can run at the same time.
|
||||
jobs, reviewJobs, evalJobs explain.Jobs
|
||||
}
|
||||
|
||||
// SetIndex swaps in a freshly built index. repo.Repo calls it (through
|
||||
@@ -111,6 +111,8 @@ func (s *Server) Routes(api *gin.RouterGroup) {
|
||||
admin.PUT("/problems/:name/code", s.saveCode)
|
||||
admin.POST("/problems/:name/run", s.run)
|
||||
admin.POST("/problems/:name/lint", s.lint)
|
||||
admin.POST("/problems/:name/evaluate", s.startEvaluate)
|
||||
admin.GET("/problems/:name/evaluate", s.evaluateStatus)
|
||||
admin.POST("/leetcode/daily", s.startDaily)
|
||||
api.POST("/hooks/gitea", s.webhook)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"adam-french.co.uk/usaco-site/internal/index"
|
||||
"adam-french.co.uk/usaco-site/internal/runner"
|
||||
)
|
||||
|
||||
@@ -159,6 +160,7 @@ func (s *Server) getCode(ctx *gin.Context) {
|
||||
"languages": l.languages(),
|
||||
"default": def,
|
||||
"runner": s.Runner != nil,
|
||||
"claude": s.Claude != nil,
|
||||
"code": code,
|
||||
})
|
||||
}
|
||||
@@ -248,44 +250,46 @@ type codeBody struct {
|
||||
// Mode and Input are for runs only.
|
||||
Mode string `json:"mode"`
|
||||
Input string `json:"input"`
|
||||
// Note is for evaluations only.
|
||||
Note string `json:"note"`
|
||||
}
|
||||
|
||||
// readCode reads and checks a solve page request against the problem's
|
||||
// layout. It has answered when ok is false.
|
||||
func (s *Server) readCode(ctx *gin.Context) (body codeBody, l *layout, ok bool) {
|
||||
p, ok := s.lookup(ctx, true)
|
||||
func (s *Server) readCode(ctx *gin.Context) (body codeBody, p *index.Problem, l *layout, ok bool) {
|
||||
p, ok = s.lookup(ctx, true)
|
||||
if !ok {
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
ctx.Request.Body = http.MaxBytesReader(ctx.Writer, ctx.Request.Body, maxRunBody)
|
||||
if err := ctx.ShouldBindJSON(&body); err != nil {
|
||||
var tooBig *http.MaxBytesError
|
||||
if errors.As(err, &tooBig) {
|
||||
ctx.JSON(http.StatusRequestEntityTooLarge, gin.H{"error": "the request is over 512 KB"})
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid JSON"})
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
if len(body.Source) > maxSource {
|
||||
ctx.JSON(http.StatusRequestEntityTooLarge, gin.H{"error": "the source is over 256 KB"})
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
if body.Lang != runner.Cpp && body.Lang != runner.Python {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "lang must be cpp or python"})
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
l, err := s.readLayout(p.Status, p.Name)
|
||||
if err != nil {
|
||||
log.Printf("[code] %s: %v", p.Name, err)
|
||||
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "the problem's files could not be read"})
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
if !l.allows(body.Lang) {
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{"error": "a LeetCode problem runs through its C++ driver only"})
|
||||
return body, nil, false
|
||||
return body, nil, nil, false
|
||||
}
|
||||
return body, l, true
|
||||
return body, p, l, true
|
||||
}
|
||||
|
||||
// headers are the files written next to a C++ source; Python needs none.
|
||||
@@ -333,7 +337,7 @@ func (s *Server) run(ctx *gin.Context) {
|
||||
if !s.runnerConfigured(ctx) {
|
||||
return
|
||||
}
|
||||
body, l, ok := s.readCode(ctx)
|
||||
body, _, l, ok := s.readCode(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
@@ -472,7 +476,7 @@ func (s *Server) lint(ctx *gin.Context) {
|
||||
if !s.runnerConfigured(ctx) {
|
||||
return
|
||||
}
|
||||
body, l, ok := s.readCode(ctx)
|
||||
body, _, l, ok := s.readCode(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
@@ -496,7 +500,7 @@ func (s *Server) lint(ctx *gin.Context) {
|
||||
// saveCode commits the editor's source as the problem's solution. An
|
||||
// unchanged source makes no commit: Mutate skips an empty diff.
|
||||
func (s *Server) saveCode(ctx *gin.Context) {
|
||||
body, _, ok := s.readCode(ctx)
|
||||
body, _, _, ok := s.readCode(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user