Files
nisse/nisse-review/src/nisse_review/main.py
T
dongarandClaude Opus 5.5 a85e855fc2
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 2m22s
CI / e2e (pull_request) Successful in 4m20s
nisse-review: a stop ends a review in progress; quieter repo failures
SIGTERM used to stop only new rounds: a review in progress ran on until
systemd killed it 90s later. Now the scheduler's stop sets the driver's
cancel flag, so the run ends at its next turn, and a model call in flight
is broken off (Interruptible, raising Stopped from the signal handler, only
ever inside a model call). The item goes back to ready, with nothing
drafted posted and no failure counted; replies already posted carry their
markers and are not repeated.

intake.repo_failed is logged when a repository starts failing or the reason
changes, and intake.repo_ok when it lists again, not every round.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
2026-10-17 20:37:12 +00:00

51 lines
1.5 KiB
Python

"""Entry point for the review agent: loads its configuration, checks its
access, and reviews until told to stop."""
import os
import signal
import sys
from pathlib import Path
from types import FrameType
from nisse_core.config import ConfigError
from nisse_core.envfile import load_env_file
from nisse_core.gitea import GiteaError
from nisse_review.access import AccessRefused
from nisse_review.build import StartupError, build
from nisse_review.config import ReviewConfig
def main() -> int:
load_env_file(Path(os.environ.get("NISSE_ENV", ".env")).expanduser())
try:
config = ReviewConfig.load()
built = build(config)
except (ConfigError, StartupError, GiteaError) as exc:
print(f"nisse-review: {exc}", file=sys.stderr)
return 2
def shutdown(_signum: int, _frame: FrameType | None) -> None:
print("nisse-review: stopping", file=sys.stderr)
built.stop()
signal.signal(signal.SIGINT, shutdown)
signal.signal(signal.SIGTERM, shutdown)
print(
f"nisse-review: ready as {built.account}, reading "
+ (", ".join(built.repositories) or "no repositories"),
file=sys.stderr,
)
try:
built.scheduler.run_forever()
except AccessRefused as exc:
# R3: a grant made while it ran. It stops rather than review on.
print(f"nisse-review: stopping: {exc}", file=sys.stderr)
return 3
finally:
built.close()
return 0
if __name__ == "__main__":
sys.exit(main())