Repository navigation
Expand file tree
/
Copy pathtypes.py
More file actions
102 lines (80 loc) · 3.43 KB
/
Copy pathtypes.py
File metadata and controls
102 lines (80 loc) · 3.43 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"""Shared dataclasses used across loopzero modules."""
from __future__ import annotations
from dataclasses import dataclass, field
BLOCKING = ("critical", "important") # finding severities that block readiness
class LoopZeroError(Exception):
"""Base class for typed loopzero failures; the message is user-facing."""
@dataclass(frozen=True)
class ResourceLimits:
memory_mb: int = 4096
file_mb: int = 2048
@dataclass(frozen=True)
class ReviewConfig:
model: str | None = None
effort: str | None = None
allowed_efforts: tuple[str, ...] = ()
@dataclass(frozen=True)
class Config:
repo: str # "owner/name"
base_branch: str # "main"
checks: tuple[str, ...] # shell commands run in sandbox, in order
required_ci: tuple[str, ...] # exact GitHub check names that must be green
merge_strategy: str # "squash" | "merge" | "rebase" | "queue" | "mergify"
reviewers: tuple[str, ...] # ordered preference: ("claude", "codex")
reviewer_ro_paths: tuple[str, ...] = () # reviewer CLI install/runtime paths
review_publishers: tuple[str, ...] = () # trusted GitHub logins, independent of CI token
review_chunk_bytes: int = 200_000
check_runner: tuple[str, ...] = ()
network: bool = False # allow network inside sandbox
env_allowlist: tuple[str, ...] = ("PATH", "HOME", "LANG", "LC_ALL", "TERM")
sandbox_ro: tuple[str, ...] = () # extra host paths exposed read-only in the sandbox
writable: tuple[str, ...] = () # host paths bound read-write (shared tool caches)
scratch: tuple[str, ...] = (".venv", ".ruff_cache", ".pytest_cache", "node_modules/.cache")
env: tuple[tuple[str, str], ...] = () # fixed variables set inside the sandbox; win over host
limits: ResourceLimits = ResourceLimits() # best-effort per-check resource limits
review: dict[str, ReviewConfig] = field(default_factory=dict)
mergify_queue: str | None = None
inputs: dict[str, tuple[str, ...]] = field(default_factory=dict)
trusted_base_revision: str | None = field(default=None, compare=False)
def is_check_exit_code(value: object) -> bool:
"""Recognize JSON integer exit codes without accepting booleans."""
return type(value) is int
@dataclass(frozen=True)
class CheckResult:
command: str
exit_code: int
duration_s: float
tail: str # last 40 lines of combined output, up to 16 KiB of UTF-8
input_key: str | None = None
reused_from: str | None = None
@dataclass(frozen=True)
class CheckReport:
head: str
dirty: bool
results: tuple[CheckResult, ...]
settings_sha256: str | None = None
@property
def ok(self) -> bool:
"""True when the report has results and every check exited 0."""
return bool(self.results) and all(result.exit_code == 0 for result in self.results)
@dataclass(frozen=True)
class Finding:
severity: str # "critical" | "important" | "suggestion"
path: str | None
line: int | None
title: str
body: str
@dataclass(frozen=True)
class ReviewResult:
family: str # "claude" | "codex"
head: str
kind: str # "primary" | "delta"
verdict: str # "approve" | "request_changes"
findings: tuple[Finding, ...]
raw: str # complete native envelope(s), retained privately; public views are sanitized
model: str | None = None
duration_s: float | None = None
provenance: dict[str, object] = field(default_factory=dict)
chunk_count: int = 1
effort: str | None = None
fallback: str = ""