go-judge/client/syzojclient/api.md
2020-02-21 03:24:33 -05:00

3.1 KiB

SYZOJ judge-v3 Protocol

Overall

Transmission protocol: socket.io Encoding: msgpack encode

Connect: socket.io connect to syzoj.domain/socket.io/ namespace: judge

Queue (Infinite Loop):

  • C -> S: waitForTask token
  • S -> C (wait) (*): onTask task (msgpack)
  • Progress
    • C -> S: reportProgress token progress (msgpack)
    • C -> S: reportResult token result (msgpack)
  • C -> S: ack (*)

Progress:

  • Started progress
  • Compiled progress / result
    • If compile success, foreach test cases
    • Progress progress
  • Finished progress / result

Exceptions:

  • S onDisconnect: requeue task
  • S invalid token: no-op

Data Structures

token

judge_token in config.json

enums

ProblemType

1 - Standard
2 - AnswerSubmission
3 - Interaction

ProgressReportType

1 - Started
2 - Compiled
3 - Progress
4 - Finished
5 - Reported

TaskStatus

0 - Waiting
1 - Running
2 - Done
3 - Failed
4 - Skipped

TaskStatus Transition

Waiting
    -> Running
        -> Done
        -> Failed
    -> Skipped

TestcaseResultType

enum TestcaseResultType {
    Accepted = 1,
    WrongAnswer = 2,
    PartiallyCorrect = 3,
    MemoryLimitExceeded = 4,
    TimeLimitExceeded = 5,
    OutputLimitExceeded = 6,
    FileError = 7, // The output file does not exist
    RuntimeError = 8,
    JudgementFailed = 9, // Special Judge or Interactor fails
    InvalidInteraction = 10
}

task

interface {
    content: {
        taskId: string;
        testData: string;
        type: ProblemType;
        priority: number;
        param: {
            // shared
            language: string;
            code: string;
            timeLimit: number;    // ms
            memoryLimit: number;  // mb

            // standard
            fileIOInput?: string;  // Null indicates stdio.
            fileIOOutput?: string;
        }
    };
    // answer submission
    extraData?: Buffer;
}

progress / result (ProgressReportData)

interface {
    taskId: string;
    type: ProgressReportType;
    progress: {
        // compile
        status: TaskStatus;
        message: string;

        // overall
        error?: SystemError | TestDataError; // enum 0 / 1
        systemMessage?: string;
        compile?: CompilationResult
        judge?: {
            subtasks?: []{ // subtask result
                score?: number;
                cases: []{ // test case result
                    status: TaskStatus;
                    result?: TestcaseDetails;
                    errorMessage?: string;
                }
            }
        }
    }
}

CompilationResult

interface {
    status: TaskStatus;
    message?: string;
}

TestcaseDetails

interface {
    type: TestcaseResultType;
    time: number; // ms
    memory: number; // kb
    input?: FileContent;
    output?: FileContent; // Output in test data
    scoringRate: number; // e.g. 0.5
    userOutput?: string;
    userError?: string;
    spjMessage?: string;
    systemMessage?: string;
}

FileContent

interface FileContent {
    content: string,
    name: string
}