e426186e46
- Added `ROBOMP_ISSUE_INDEX_SYNC_SECONDS` configuration and lifecycle-managed issue indexing through startup/shutdown hooks. - Added issue/PR index tables with FTS5 triggers plus upsert and keyword/filter search helpers for indexed records. - Added GitHub backend/proxy support for `IssueIndexEntry` and issue-index page retrieval, including webhook ingestion and periodic watermark-driven sync. - Updated `gh_search_issues` to prefer local index queries when synchronized and added `search_commits` host tool with query modes and validation.
113 lines
3.3 KiB
Python
113 lines
3.3 KiB
Python
"""Structural protocol shared by `GitHubClient` and `GitHubProxyClient`.
|
|
|
|
Callers (worker, host tools, tasks, server, CLI) reference `GitHubBackend`
|
|
so they accept either the direct PAT-bearing REST client or the HMAC-RPC
|
|
proxy client without changing signatures. Both impls return the same typed
|
|
dataclasses (`IssueInfo`, `RepoInfo`, …) defined in `github_client`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from typing import Any, Protocol
|
|
|
|
from robomp.github_client import (
|
|
CommentInfo,
|
|
IssueIndexEntry,
|
|
IssueInfo,
|
|
IssueSummary,
|
|
PullRequestFileInfo,
|
|
PullRequestInfo,
|
|
PullRequestReviewInfo,
|
|
ReactionInfo,
|
|
RepoInfo,
|
|
ReviewCommentInfo,
|
|
)
|
|
|
|
|
|
class GitHubBackend(Protocol):
|
|
"""Methods every caller in roboomp uses against GitHub."""
|
|
|
|
# ---- reads ----
|
|
async def get_repo(self, repo: str) -> RepoInfo: ...
|
|
|
|
async def get_issue(self, repo: str, number: int) -> IssueInfo: ...
|
|
|
|
async def list_closing_pull_requests(self, repo: str, number: int) -> tuple[int, ...]: ...
|
|
|
|
async def get_pull_request(self, repo: str, number: int) -> PullRequestInfo: ...
|
|
|
|
async def list_pr_files(self, repo: str, pr_number: int) -> list[PullRequestFileInfo]: ...
|
|
|
|
async def list_issues(
|
|
self,
|
|
repo: str,
|
|
*,
|
|
state: str = "open",
|
|
limit: int = 30,
|
|
) -> list[IssueSummary]: ...
|
|
|
|
async def search_issues(self, repo: str, query: str, *, limit: int = 10) -> list[IssueSummary]: ...
|
|
async def list_issue_index_entries(
|
|
self,
|
|
repo: str,
|
|
*,
|
|
since: str | None = None,
|
|
page: int = 1,
|
|
per_page: int = 100,
|
|
) -> list[IssueIndexEntry]: ...
|
|
|
|
async def list_comments(self, repo: str, number: int) -> list[CommentInfo]: ...
|
|
|
|
async def list_review_comments(self, repo: str, pr_number: int) -> list[ReviewCommentInfo]: ...
|
|
|
|
async def list_pr_reviews(self, repo: str, pr_number: int) -> list[PullRequestReviewInfo]: ...
|
|
|
|
async def get_authenticated_login(self) -> str: ...
|
|
|
|
# ---- writes ----
|
|
async def post_comment(self, repo: str, number: int, body: str) -> CommentInfo: ...
|
|
|
|
async def open_pull_request(
|
|
self,
|
|
*,
|
|
repo: str,
|
|
head: str,
|
|
base: str,
|
|
title: str,
|
|
body: str,
|
|
draft: bool = False,
|
|
maintainer_can_modify: bool = True,
|
|
) -> PullRequestInfo: ...
|
|
|
|
async def request_reviewers(
|
|
self,
|
|
*,
|
|
repo: str,
|
|
pr_number: int,
|
|
reviewers: list[str] | None = None,
|
|
team_reviewers: list[str] | None = None,
|
|
) -> None: ...
|
|
|
|
async def add_issue_labels(self, repo: str, number: int, labels: list[str]) -> tuple[str, ...]: ...
|
|
async def remove_issue_label(self, repo: str, number: int, label: str) -> None: ...
|
|
|
|
async def submit_pr_review(
|
|
self,
|
|
*,
|
|
repo: str,
|
|
pr_number: int,
|
|
body: str,
|
|
event: str,
|
|
comments: list[Mapping[str, Any]],
|
|
) -> PullRequestReviewInfo: ...
|
|
|
|
async def add_assignees(self, repo: str, number: int, assignees: list[str]) -> None: ...
|
|
|
|
async def list_comment_reactions(self, repo: str, comment_id: int) -> tuple[ReactionInfo, ...]: ...
|
|
|
|
async def close_issue(self, repo: str, number: int, *, reason: str = "completed") -> None: ...
|
|
|
|
|
|
__all__ = ["GitHubBackend"]
|