File size: 1,120 Bytes
d61821a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Shared component contracts used to compose harness treatments."""

from __future__ import annotations

from dataclasses import dataclass
from pathlib import Path
from typing import Any, Protocol, Sequence


@dataclass(frozen=True, slots=True)
class Candidate:
    path: str
    line_start: int
    line_end: int
    text: str
    source: str
    score: float | None = None
    symbol: str | None = None
    metadata: dict[str, Any] | None = None


class Retriever(Protocol):
    def retrieve(self, query: str, limit: int) -> Sequence[Candidate]: ...


class GraphExpander(Protocol):
    def expand(self, candidates: Sequence[Candidate], hops: int) -> Sequence[Candidate]: ...


class ContextPacker(Protocol):
    def pack(self, candidates: Sequence[Candidate], token_budget: int) -> str: ...


class QueryPolicy(Protocol):
    def next_query(self, issue: str, observations: Sequence[str]) -> str | None: ...


class RepositoryEditor(Protocol):
    def apply_patch(self, repository: Path, patch: str) -> dict[str, Any]: ...


class Validator(Protocol):
    def validate(self, repository: Path) -> dict[str, Any]: ...