File size: 1,852 Bytes
85f36c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7852159
 
85f36c8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from __future__ import annotations

from enum import Enum
from typing import Literal

from pydantic import BaseModel, Field


class RunStatus(str, Enum):
    queued = "queued"
    planning = "planning"
    branching = "branching"
    testing = "testing"
    judging = "judging"
    complete = "complete"
    failed = "failed"


class RunRequest(BaseModel):
    repository: str = Field(default="branchforge-labs/ledger-lite", max_length=200)
    issue: str = Field(min_length=12, max_length=4000)
    source: str | None = Field(default=None, max_length=30_000)
    tests: str | None = Field(default=None, max_length=30_000)
    mode: Literal["sample", "custom"] = "sample"


class Candidate(BaseModel):
    id: str
    name: str
    thesis: str
    risk: str
    source: str
    accent: str = "cyan"


class TestResult(BaseModel):
    passed: int
    total: int
    exit_code: int
    duration_ms: int
    stdout: str
    stderr: str = ""
    checkpoint: str
    runtime: Literal["nebius-sandbox", "local-fallback"]


class BranchResult(BaseModel):
    candidate: Candidate
    tests: TestResult
    score: int = 0
    verdict: Literal["winner", "viable", "rejected"] = "rejected"
    evidence: list[str] = Field(default_factory=list)
    diff: str = ""


class RunEvent(BaseModel):
    at_ms: int
    stage: RunStatus
    message: str


class RunRecord(BaseModel):
    id: str
    status: RunStatus
    request: RunRequest
    progress: int = 0
    events: list[RunEvent] = Field(default_factory=list)
    branches: list[BranchResult] = Field(default_factory=list)
    winner_id: str | None = None
    synthesis: str | None = None
    model: str = "nvidia/Nemotron-3_5-Lightning"
    provider: str = "Nebius Token Factory"
    planner_mode: str = "pending"
    judge_mode: str = "pending"
    sandbox_mode: str = "pending"
    error: str | None = None