M7.3: nisse-review's first slice
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m49s
CI / e2e (pull_request) Successful in 3m18s

A new package over nisse-core: it reviews every ready PR in the
repositories its account can read, and posts one COMMENT review.

- scheduler: each round, open PRs per readable repository (or the
  configured repositories); an item per PR, ready unless draft or WIP;
  closed with the PR. One review at a time, oldest first.
- reader: the repository at head and base from Gitea archives, unpacked
  and read in Python (read_file, list_files, search_code), and its issues;
  bound to the item's repository; no git, no shell.
- review: starts from the PR, commits, diff, comments, closed issues, CI;
  comment drafts a point on any existing line; post_review posts one
  COMMENT review at the head, inline where Gitea takes it, else as links in
  the summary. ask_expert; vault and memory (memory/nisse-review).
- L8: posting is an intent; recovery asks Gitea for the marked review and
  never posts twice; with Gitea down, the item waits.
- Failures retried, then said on the PR until the next push.
- Startup refuses an account that can push to or administer any repo.
- nisse-core gitea: readable_repositories, open_pull_requests, diff,
  commits, archive, issue, search_issues, reviews, post_review; PR fields.
- Bring-up: scripts/review-bringup.sh; nisse-review.example.yaml.
- Tests: unit over a fake Gitea and scripted model; a live test
  (NISSE_REVIEW_GITEA_TOKEN) reviews a PR in a fresh test repository.
- Docs: Development Plan M7.3, Tuning Guide (tuning.review.*).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
dongarandClaude Opus 5.5 committed 2026-10-13 22:34:02 +00:00
1 parent fc71d3da75
commit f59d974a95
24 files changed
+2330 -7

No files matched your search

+67
View File
@@ -319,3 +319,70 @@ def test_a_check_branch_is_made_through_the_api() -> None:
"eA==",
)
assert seen[1][:2] == ("DELETE", "/api/v1/repos/o/r/branches/chk")
def test_a_review_is_posted_as_a_comment_with_its_lines() -> None:
from nisse_core.gitea import LineComment
seen: dict = {}
def handler(request: httpx.Request) -> httpx.Response:
seen["url"] = str(request.url)
seen["body"] = json.loads(request.content)
return httpx.Response(200, json={"id": 31})
review = client(handler).post_review(
"o/r",
7,
body="ok",
commit="abc",
comments=[LineComment("a.py", 3, "here")],
)
assert review == 31
assert seen["url"].endswith("/repos/o/r/pulls/7/reviews")
assert seen["body"] == {
"event": "COMMENT",
"body": "ok",
"commit_id": "abc",
"comments": [{"path": "a.py", "new_position": 3, "body": "here"}],
}
def test_readable_repositories_page_to_the_end() -> None:
def handler(request: httpx.Request) -> httpx.Response:
page = int(request.url.params["page"])
count = PR_PAGE_SIZE if page == 1 else 2
return httpx.Response(
200, json=[{"full_name": f"o/r{page}-{n}"} for n in range(count)]
)
found = client(handler).readable_repositories()
assert len(found) == PR_PAGE_SIZE + 2 and found[-1] == "o/r2-1"
def test_a_pull_request_carries_what_a_review_needs() -> None:
def handler(request: httpx.Request) -> httpx.Response:
if request.url.path.endswith(".diff"):
return httpx.Response(200, text="diff --git a/x b/x\n")
return httpx.Response(
200,
json={
**pr_json(7, "fix"),
"title": "T",
"body": "B",
"user": {"login": "nisse-dev"},
"base": {"ref": "main"},
"draft": True,
},
)
gitea = client(handler)
pr = gitea.pull_request("o/r", 7)
assert (pr.title, pr.body, pr.author, pr.base, pr.draft) == (
"T",
"B",
"nisse-dev",
"main",
True,
)
assert gitea.pull_request_diff("o/r", 7) == "diff --git a/x b/x\n"
+1 -1
View File
@@ -6,7 +6,7 @@ from pathlib import Path
import nisse_core
AGENTS = ("nisse_dev", "nisse_ops")
AGENTS = ("nisse_dev", "nisse_ops", "nisse_review")
def test_core_imports_no_agent() -> None: