aireview 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +209 -79
- data/config/defaults.yml +6 -7
- data/lib/aireview/candidate_checker.rb +0 -1
- data/lib/aireview/cli.rb +91 -63
- data/lib/aireview/config.rb +42 -4
- data/lib/aireview/config_fallbacks.rb +8 -11
- data/lib/aireview/config_layers.rb +6 -4
- data/lib/aireview/config_loader.rb +31 -23
- data/lib/aireview/context_budget.rb +6 -2
- data/lib/aireview/context_builder.rb +1 -0
- data/lib/aireview/dry_run_report.rb +3 -0
- data/lib/aireview/github_client.rb +284 -0
- data/lib/aireview/jev_stage.rb +19 -2
- data/lib/aireview/llm_client.rb +8 -9
- data/lib/aireview/llm_router.rb +69 -90
- data/lib/aireview/model_candidate.rb +6 -3
- data/lib/aireview/model_pool.rb +6 -0
- data/lib/aireview/model_state.rb +5 -17
- data/lib/aireview/mr_parser.rb +44 -6
- data/lib/aireview/platform.rb +99 -0
- data/lib/aireview/publisher.rb +8 -7
- data/lib/aireview/review_comment_formatter.rb +158 -0
- data/lib/aireview/review_marker.rb +5 -1
- data/lib/aireview/review_pipeline.rb +24 -13
- data/lib/aireview/review_renderer.rb +33 -12
- data/lib/aireview/reviewer.rb +4 -5
- data/lib/aireview/stage_chains.rb +4 -0
- data/lib/aireview/version.rb +1 -1
- data/lib/aireview.rb +2 -1
- metadata +13 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 683eb62411053c4b3191312e3dd4c0eefc0d365f04e3f50bba6af101d9d424e8
|
|
4
|
+
data.tar.gz: 9c252acb6c8e94bdca1cc1d151e14628052c233d79866777b2a21c1f9d5751a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b3cd5ca1d824688bb9063bb3b9c1688ac04b960f182a1fd995f574dfa19354c550d4b006a2332a4906e7fe67f6957a9845fe820ee74d66b066a4abc1f28af1f
|
|
7
|
+
data.tar.gz: 4654c1269c4b302cd1e5f6797097231821ee8318cde27b5d6da52cc29b01121db13373697311997b4b20f08288bedf3c765c982f8d7ad59eea412304640120b2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
- The report always shows a `Models: generate — …, critique — …` line with the
|
|
6
|
+
models that answered each stage (without `api_base`, and with `skipped (no
|
|
7
|
+
candidates)` or `disabled` when Critique did not run), replacing the separate
|
|
8
|
+
`Fallback model used:` line.
|
|
9
|
+
- Removed multi-key environment variables (`GEMINI_API_KEYS`,
|
|
10
|
+
`OPENAI_API_KEYS`, `ANTHROPIC_API_KEYS`, `OPENROUTER_API_KEYS`): each
|
|
11
|
+
provider takes a single `*_API_KEY`. On daily quota exhaustion or a rate
|
|
12
|
+
limit after one retry, the router moves to the next model in the chain.
|
|
13
|
+
- GitHub pull requests: `aireview review https://github.com/owner/repo/pull/42`
|
|
14
|
+
reviews a pull request on github.com or GitHub Enterprise Server, and
|
|
15
|
+
`--post` keeps one updatable conversation comment, as on GitLab. The token
|
|
16
|
+
is `GITHUB_TOKEN`; `GITHUB_API_URL` overrides the API address,
|
|
17
|
+
`GITHUB_REVIEW_AUTHOR` names the comment author for tokens that cannot
|
|
18
|
+
read `/user` (the Actions `GITHUB_TOKEN`: `github-actions[bot]`). A
|
|
19
|
+
**Re-run** counts as a retry in `review_mode: once`; the "moved while
|
|
20
|
+
reviewing" check compares the merge base, so a push to the base branch
|
|
21
|
+
alone does not stop publishing. Files GitHub did not return (it lists at
|
|
22
|
+
most 3000) are counted under "Not reviewed". The README has a GitHub
|
|
23
|
+
Actions workflow. GitLab behaviour and review keys are unchanged.
|
|
24
|
+
- In a ranked pool (`rank: not_below_generate`) Critique no longer falls
|
|
25
|
+
back to the model that answered in Generate while a model its chain
|
|
26
|
+
prefers is only quarantined: it waits for that model when the wait plus a
|
|
27
|
+
full request (`llm.timeout`) fits into the time budget, and logs
|
|
28
|
+
`waiting … instead of critiquing with …`. Before, an overload during
|
|
29
|
+
Generate could turn the critique into a self-check by the same model. A
|
|
30
|
+
self-check remains when Generate answered with the strongest model, the
|
|
31
|
+
stronger ones are out until the end of the run, or `critique.start` names
|
|
32
|
+
that model; own chains and `rank: any` keep their order.
|
|
33
|
+
- `gem install aireview` works without configuring models: when
|
|
34
|
+
`AIREVIEW_DEFAULTS` is unset and neither `.aireview.yml`, the environment
|
|
35
|
+
nor `--generate-model`/`--critique-model` names a model, the gem's own `config/defaults.yml` is loaded
|
|
36
|
+
as the `bundled defaults` layer (the image defaults: the Gemini pool,
|
|
37
|
+
timeouts, language). Setups with models of their own are unchanged.
|
|
38
|
+
|
|
3
39
|
## 2.2.1
|
|
4
40
|
|
|
5
41
|
- OpenAI reasoning models (`o1`, `o3`, `gpt-5`…) and search models
|
data/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# aireview
|
|
2
2
|
|
|
3
|
-
`aireview` is a local CLI tool that reviews GitLab merge requests
|
|
4
|
-
of LLMs. It uses a two-pass review pipeline: the first pass finds candidate
|
|
3
|
+
`aireview` is a local CLI tool that reviews GitLab merge requests and GitHub
|
|
4
|
+
pull requests with the help of LLMs. It uses a two-pass review pipeline: the first pass finds candidate
|
|
5
5
|
findings, the second one critiques them and drops the weak or invalid ones.
|
|
6
6
|
|
|
7
7
|
The tool supports self-hosted GitLab and self-hosted Jira only. GitLab.com and
|
|
8
|
-
Jira Cloud are not supported.
|
|
8
|
+
Jira Cloud are not supported. Pull requests work on github.com and GitHub
|
|
9
|
+
Enterprise Server.
|
|
9
10
|
|
|
10
11
|
MVP flow:
|
|
11
12
|
|
|
12
|
-
1. Takes a GitLab merge request URL.
|
|
13
|
-
2. Fetches the MR metadata and changes from GitLab.
|
|
13
|
+
1. Takes a GitLab merge request URL or a GitHub pull request URL.
|
|
14
|
+
2. Fetches the MR metadata and changes from GitLab or GitHub.
|
|
14
15
|
3. Filters out ignored paths and scrubs secrets from the diffs.
|
|
15
16
|
4. Optionally enriches the prompt with context from a Jira issue.
|
|
16
17
|
5. Runs the Generate pass through RubyLLM to get an MR summary and candidate
|
|
@@ -22,9 +23,9 @@ MVP flow:
|
|
|
22
23
|
|
|
23
24
|
## Requirements
|
|
24
25
|
|
|
25
|
-
- Ruby
|
|
26
|
-
- Bundler
|
|
27
|
-
- A GitLab personal access token
|
|
26
|
+
- Ruby 4.0.10 or newer
|
|
27
|
+
- Bundler 4.0+ for the repository checkout; `gem install` needs no specific Bundler
|
|
28
|
+
- A GitLab personal access token, or a GitHub token for pull requests
|
|
28
29
|
- An API key for a remote LLM provider; a local Ollama needs no key
|
|
29
30
|
- Optionally, a Jira login and password
|
|
30
31
|
|
|
@@ -40,19 +41,19 @@ aireview --help
|
|
|
40
41
|
From a checkout of the repository:
|
|
41
42
|
|
|
42
43
|
```bash
|
|
43
|
-
bundle
|
|
44
|
-
bundle
|
|
44
|
+
bundle install
|
|
45
|
+
bundle exec bin/aireview --help
|
|
45
46
|
```
|
|
46
47
|
|
|
47
|
-
The examples below use `bundle
|
|
48
|
+
The examples below use `bundle exec bin/aireview`; with the gem
|
|
48
49
|
installed, replace it with plain `aireview`.
|
|
49
50
|
|
|
50
51
|
## Configuration
|
|
51
52
|
|
|
52
53
|
Secrets live in environment variables or in a local `.env` file. The models of
|
|
53
54
|
both stages come from the defaults shipped in the Docker image (see "Defaults
|
|
54
|
-
shipped in the image");
|
|
55
|
-
`.aireview.yml`:
|
|
55
|
+
shipped in the image"); a gem or a checkout falls back to the same file
|
|
56
|
+
until you set models of your own in `.env` or `.aireview.yml`:
|
|
56
57
|
|
|
57
58
|
```bash
|
|
58
59
|
GITLAB_URL=https://gitlab.company.com
|
|
@@ -61,24 +62,31 @@ JIRA_URL=https://jira.company.com
|
|
|
61
62
|
JIRA_LOGIN=user
|
|
62
63
|
JIRA_PASSWORD=xxx
|
|
63
64
|
GEMINI_API_KEY=xxx
|
|
64
|
-
GEMINI_API_KEYS=xxx,yyy
|
|
65
65
|
LLM_PROVIDER=gemini
|
|
66
66
|
LLM_TEMPERATURE=0
|
|
67
67
|
LLM_TIMEOUT=120
|
|
68
68
|
LLM_TIME_BUDGET=1800
|
|
69
69
|
LLM_HTTP_PROXY=http://127.0.0.1:8888
|
|
70
70
|
LLM_GENERATE_PROVIDER=gemini
|
|
71
|
-
LLM_GENERATE_MODEL=gemini-3.
|
|
71
|
+
LLM_GENERATE_MODEL=gemini-3.6-flash
|
|
72
72
|
LLM_GENERATE_FALLBACK_MODEL=gemini-3.8-flash
|
|
73
73
|
LLM_GENERATE_TEMPERATURE=0.3
|
|
74
74
|
LLM_CRITIQUE_PROVIDER=gemini
|
|
75
75
|
LLM_CRITIQUE_MODEL=gemini-3.8-flash
|
|
76
|
-
LLM_CRITIQUE_FALLBACK_MODEL=gemini-3.
|
|
76
|
+
LLM_CRITIQUE_FALLBACK_MODEL=gemini-3.6-flash
|
|
77
77
|
LLM_CRITIQUE_TEMPERATURE=0
|
|
78
78
|
REVIEW_LANGUAGE=ru
|
|
79
79
|
REVIEW_MODE=update
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
For GitHub pull requests the GitLab variables are not needed; the token is
|
|
83
|
+
`GITHUB_TOKEN` (a personal or fine-grained token with read access to the
|
|
84
|
+
code and pull requests, plus write access to pull requests for `--post`).
|
|
85
|
+
The API address comes from the pull request URL — `api.github.com` for
|
|
86
|
+
github.com, `https://<host>/api/v3` for GitHub Enterprise — unless
|
|
87
|
+
`GITHUB_API_URL` says otherwise. `GITHUB_REVIEW_AUTHOR` is needed for tokens
|
|
88
|
+
that cannot read their own user, see "A single comment per merge request".
|
|
89
|
+
|
|
82
90
|
The providers are `gemini`, `ollama`, `openai`, `anthropic` and
|
|
83
91
|
`openrouter`, and any OpenAI-compatible server of your own (vLLM, llama.cpp,
|
|
84
92
|
LM Studio) as `openai` with an `api_base`. The provider and the model of each
|
|
@@ -88,9 +96,9 @@ shared default when a stage has no provider of its own. Gemini and Ollama
|
|
|
88
96
|
are the ones the image defaults and the verified models are about; for the
|
|
89
97
|
others run `aireview models check` before relying on a model.
|
|
90
98
|
|
|
91
|
-
Each provider takes its
|
|
92
|
-
`GEMINI_API_KEY
|
|
93
|
-
`OPENROUTER_API_KEY
|
|
99
|
+
Each provider takes its key from its own variable:
|
|
100
|
+
`GEMINI_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`,
|
|
101
|
+
`OPENROUTER_API_KEY`; `LLM_API_KEY` is the shared fallback.
|
|
94
102
|
|
|
95
103
|
`REVIEW_LANGUAGE` (or `review_language` in `.aireview.yml`) sets the language
|
|
96
104
|
of the review: both the LLM answers and the headings of the rendered report.
|
|
@@ -107,18 +115,40 @@ Models, timeouts and the report language are baked into the image as
|
|
|
107
115
|
project in an organization has nothing to configure: no `.aireview.yml`, no
|
|
108
116
|
variables with model names. Changing the model for every project is one
|
|
109
117
|
edit of that file and a new image release. Outside the image the variable is
|
|
110
|
-
unset
|
|
111
|
-
`
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
unset; then the gem (or the checkout) uses its own `config/defaults.yml` as
|
|
119
|
+
the `bundled defaults` layer, but only while neither `.aireview.yml`, the
|
|
120
|
+
environment nor a CLI flag (`--generate-model`, `--critique-model`) names a
|
|
121
|
+
model (`llm.models` or a stage `model`). So
|
|
122
|
+
`gem install aireview` plus an API key is enough to run a review, and a
|
|
123
|
+
local setup with models of its own is not affected. Point
|
|
124
|
+
`AIREVIEW_DEFAULTS` at any file to get the image layer elsewhere. The
|
|
125
|
+
defaults define a shared pool of four Gemini models (see "Shared model
|
|
126
|
+
pool"): Generate starts from the second model (`gemini-3.8-flash`) and goes round the pool,
|
|
114
127
|
Critique takes the strongest live model not below the one Generate answered
|
|
115
128
|
with; every model of the pool is confirmed by `aireview models check` on
|
|
116
129
|
release.
|
|
117
130
|
|
|
131
|
+
What `config/defaults.yml` sets today (the file is the source of truth):
|
|
132
|
+
|
|
133
|
+
| Setting | Default |
|
|
134
|
+
|---|---|
|
|
135
|
+
| Model pool, strongest first | `gemini-4-hydrogen`, `gemini-3.8-flash`, `gemini-3.6-flash`, `gemini-3.5-flash-lite` (all `gemini`) |
|
|
136
|
+
| Generate | starts at `gemini-3.8-flash`, temperature 0.1 |
|
|
137
|
+
| Critique | first live model not below the one Generate answered with (`rank: not_below_generate`, `allow_weaker: false`), temperature 0 |
|
|
138
|
+
| Request timeout | 180 s per request, up to three attempts per model per stage |
|
|
139
|
+
| Time budget | 1800 s shared across the LLM stages, including retry waits |
|
|
140
|
+
| Overload quarantine | 120 s |
|
|
141
|
+
| Report language | `en` |
|
|
142
|
+
|
|
143
|
+
The default model pool only needs `GEMINI_API_KEY`;
|
|
144
|
+
GitLab access still requires `GITLAB_TOKEN`.
|
|
145
|
+
|
|
118
146
|
The configuration layers, weakest first:
|
|
119
147
|
|
|
120
148
|
1. built-in values (`Config::DEFAULTS`);
|
|
121
|
-
2. image defaults — the file from `AIREVIEW_DEFAULTS`;
|
|
149
|
+
2. image defaults — the file from `AIREVIEW_DEFAULTS`; without the variable,
|
|
150
|
+
the bundled `config/defaults.yml` when no upper layer (CLI included) names
|
|
151
|
+
a model;
|
|
122
152
|
3. the project's `.aireview.yml`;
|
|
123
153
|
4. environment variables (`LLM_GENERATE_MODEL` and the rest);
|
|
124
154
|
5. CLI flags (`--generate-model`, `--critique-model`, the temperatures).
|
|
@@ -154,7 +184,7 @@ every model, the layer it came from:
|
|
|
154
184
|
```
|
|
155
185
|
=== LLM SETTINGS ===
|
|
156
186
|
Config: image defaults /app/config/defaults.yml, .aireview.yml /app/.aireview.yml
|
|
157
|
-
Generate: gemini-3.
|
|
187
|
+
Generate: gemini-3.8-flash temperature=0.1 (model from image defaults, provider from image defaults)
|
|
158
188
|
fallbacks: gemini/gemini-3.6-flash -> ... (fallbacks from image defaults)
|
|
159
189
|
Critique: qwen2.5-coder:7b temperature=0 (model from .aireview.yml, provider from .aireview.yml)
|
|
160
190
|
Time budget: 1800s, overloaded quarantine: 120s
|
|
@@ -178,7 +208,7 @@ release at peak hours.
|
|
|
178
208
|
No model is probed before a review: there are no test requests to five
|
|
179
209
|
models per MR, availability is learned from the working requests — the first
|
|
180
210
|
Generate request is the probe, and what the router learns it remembers until
|
|
181
|
-
the end of the run (see "Fallback models
|
|
211
|
+
the end of the run (see "Fallback models"). The separate smoke test
|
|
182
212
|
of every model with both schemas (`aireview models check`) runs on an image
|
|
183
213
|
release and on a schedule, not on MRs.
|
|
184
214
|
|
|
@@ -316,7 +346,7 @@ run right away: the model gets one short retry (~30 s), then goes into
|
|
|
316
346
|
quarantine for two minutes while the request goes to the next model;
|
|
317
347
|
without a fallback model the router waits for the quarantine to end and
|
|
318
348
|
tries once more. Three requests per model per stage in total (see "Fallback
|
|
319
|
-
models
|
|
349
|
+
models"). Only the failed stage is repeated, not the whole run.
|
|
320
350
|
|
|
321
351
|
Project rules live in `.aireview.yml`. The `generate.model` and
|
|
322
352
|
`critique.model` settings are not inherited from the base `llm` settings: a
|
|
@@ -371,7 +401,7 @@ llm:
|
|
|
371
401
|
max_prompt_chars: 400000
|
|
372
402
|
generate:
|
|
373
403
|
provider: gemini
|
|
374
|
-
model: gemini-3.
|
|
404
|
+
model: gemini-3.6-flash
|
|
375
405
|
temperature: 0.3
|
|
376
406
|
fallbacks:
|
|
377
407
|
- gemini-3.8-flash
|
|
@@ -422,11 +452,10 @@ with an error instead of silently reviewing less. Raise the limits or extend
|
|
|
422
452
|
`ignore_paths`. `--dry-run` prints the sizes of every part and the coverage;
|
|
423
453
|
`--verbose` logs them during a real run.
|
|
424
454
|
|
|
425
|
-
### Fallback models
|
|
455
|
+
### Fallback models
|
|
426
456
|
|
|
427
|
-
The primary model can sit under load (503) for half a day
|
|
428
|
-
|
|
429
|
-
fallback model and a provider can have a fallback key:
|
|
457
|
+
The primary model can sit under load (503) for half a day or run out of its
|
|
458
|
+
daily quota. Neither is cured by waiting, so a stage can have fallback models:
|
|
430
459
|
|
|
431
460
|
- `llm.generate.fallbacks` / `llm.critique.fallbacks` in YAML or
|
|
432
461
|
`LLM_GENERATE_FALLBACK_MODEL` / `LLM_CRITIQUE_FALLBACK_MODEL` in the
|
|
@@ -435,14 +464,6 @@ fallback model and a provider can have a fallback key:
|
|
|
435
464
|
without it the stage provider is used. A fallback model can have its own
|
|
436
465
|
`max_prompt_chars`: when the assembled request does not fit, that model is
|
|
437
466
|
skipped, the context is not cut for it.
|
|
438
|
-
- `GEMINI_API_KEYS=key1,key2`: keys in order of preference; `GEMINI_API_KEY`
|
|
439
|
-
still works and means a single key. Google counts quotas per Google Cloud
|
|
440
|
-
project and per model, so a reserve key only makes sense from another
|
|
441
|
-
project. Use fallback credentials in compliance with the provider's quota
|
|
442
|
-
and billing terms: Google's
|
|
443
|
-
[API limitations](https://developers.google.com/terms#api_limitations)
|
|
444
|
-
forbid circumventing its limits regardless of the project's billing. Keys
|
|
445
|
-
live only in the environment, never in `.aireview.yml`.
|
|
446
467
|
|
|
447
468
|
#### Shared model pool
|
|
448
469
|
|
|
@@ -459,23 +480,32 @@ from model names:
|
|
|
459
480
|
llm:
|
|
460
481
|
provider: gemini
|
|
461
482
|
models: # order = priority for Critique
|
|
483
|
+
- gemini-4-hydrogen
|
|
462
484
|
- gemini-3.8-flash
|
|
463
|
-
- gemini-3.7-flash
|
|
464
485
|
- gemini-3.6-flash
|
|
465
486
|
- provider: ollama
|
|
466
487
|
model: qwen2.5-coder:7b
|
|
467
488
|
max_prompt_chars: 20000
|
|
468
489
|
generate:
|
|
469
|
-
start: gemini-3.
|
|
490
|
+
start: gemini-3.8-flash # Generate starts here, then downwards and round
|
|
470
491
|
critique:
|
|
471
492
|
rank: not_below_generate # or any — the chains are independent
|
|
472
493
|
allow_weaker: false # true — go below when nothing above is alive
|
|
473
494
|
```
|
|
474
495
|
|
|
475
|
-
Environment equivalents: `LLM_MODELS=gemini/gemini-
|
|
496
|
+
Environment equivalents: `LLM_MODELS=gemini/gemini-4-hydrogen,gemini/gemini-3.8-flash,…`,
|
|
476
497
|
`LLM_GENERATE_START`, `LLM_CRITIQUE_START`, `LLM_CRITIQUE_RANK`,
|
|
477
498
|
`LLM_CRITIQUE_ALLOW_WEAKER`. The rules:
|
|
478
499
|
|
|
500
|
+
- with the rank applied (`rank: not_below_generate`, both stages in the
|
|
501
|
+
pool), a critique by the same model that answered in Generate is the last
|
|
502
|
+
resort: when a model the critique chain puts before it is only
|
|
503
|
+
quarantined and a full request (`llm.timeout`) still fits into the time
|
|
504
|
+
budget after its release, Critique waits for it (the log says `waiting …
|
|
505
|
+
instead of critiquing with …`). A self-check remains when Generate
|
|
506
|
+
answered with the strongest model of the pool, the stronger ones are out
|
|
507
|
+
until the end of the run, or `critique.start` names that model itself;
|
|
508
|
+
stages with chains of their own and `rank: any` keep their order;
|
|
479
509
|
- no permitted live model for Critique and `allow_weaker: false` — the run
|
|
480
510
|
fails, candidates are not published without a critique; with
|
|
481
511
|
`allow_weaker: true` Critique goes below Generate and the report gets a
|
|
@@ -508,9 +538,9 @@ What happens on which error:
|
|
|
508
538
|
|
|
509
539
|
| Error | Reaction |
|
|
510
540
|
|---|---|
|
|
511
|
-
| Daily quota (`quotaId` like `…PerDay…` in Google's answer) | No retries: the
|
|
512
|
-
| Per-minute limit (429 with a "retry in N s" hint) | One retry after the hinted delay, then the
|
|
513
|
-
| Overloaded (503) or timeout | One short retry (~30 s), then a quarantine of `llm.overloaded_quarantine` / `LLM_OVERLOADED_QUARANTINE` (120 s by default) and the next model
|
|
541
|
+
| Daily quota (`quotaId` like `…PerDay…` in Google's answer) | No retries: the model is excluded until the end of the run so that Critique and the JSON repair do not hit it again, and the request goes to the next one. |
|
|
542
|
+
| Per-minute limit (429 with a "retry in N s" hint) | One retry after the hinted delay, then the model is quarantined for the hinted time and the request goes to the next one. |
|
|
543
|
+
| Overloaded (503) or timeout | One short retry (~30 s), then a quarantine of `llm.overloaded_quarantine` / `LLM_OVERLOADED_QUARANTINE` (120 s by default) and the next model. |
|
|
514
544
|
| The provider has no such model (the answer text names the model: retired, a typo, not pulled into Ollama) | No retries: the model is excluded until the end of the run, the request goes to the next one. A bare 404 without such text is fatal: a wrong `LLM_API_BASE` answers the same, and the next model will not help. |
|
|
515
545
|
| An invalid result (not JSON, not the schema, foreign ids in the verdicts) — and still invalid after one repair by the same model | The model is excluded for this stage, the stage starts over on the next model with the original request. For Critique the candidates already obtained are kept, Generate is not repeated. |
|
|
516
546
|
| Other API errors (context length, auth) | The run fails right away: a fallback model would answer the same. |
|
|
@@ -523,11 +553,11 @@ finite:
|
|
|
523
553
|
|
|
524
554
|
- **three requests per model per stage** (`MAX_ATTEMPTS_PER_MODEL`). Every
|
|
525
555
|
request sent counts regardless of its outcome, including the short retry
|
|
526
|
-
and the JSON repair;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
556
|
+
and the JSON repair; a quarantine does not reset it. Out of requests —
|
|
557
|
+
the model leaves the stage; a JSON repair without requests left is not
|
|
558
|
+
sent, and the result counts as invalid (see the table). When every model
|
|
559
|
+
of the stage is out or excluded, the stage ends at once, quarantines are
|
|
560
|
+
not waited for;
|
|
531
561
|
- **the time budget** of the LLM part of the run: `llm.time_budget` /
|
|
532
562
|
`LLM_TIME_BUDGET`, 1800 seconds by default. A pause or a quarantine wait
|
|
533
563
|
that does not fit into the remainder is skipped, the request timeout is
|
|
@@ -550,13 +580,12 @@ The review key (see "A single comment per merge request") is computed from
|
|
|
550
580
|
the configured primary model, not from the one that answered: a review made
|
|
551
581
|
by a fallback model is not rewritten on the next push without changes in the
|
|
552
582
|
MR, and adding a fallback model to a per-stage chain does not re-run the
|
|
553
|
-
review on every open MR.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
(`model=gemini/gemini-3.6-flash (2/5)`).
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
`--no-fallbacks` leaves one model and one key per stage.
|
|
583
|
+
review on every open MR. The report ends with a `Models: generate — …,
|
|
584
|
+
critique — …` line naming the models that answered; the log names, for every
|
|
585
|
+
stage, the model that answered and its place in the chain
|
|
586
|
+
(`model=gemini/gemini-3.6-flash (2/5)`). Key values never reach the log.
|
|
587
|
+
`--dry-run` prints the model chains, the time budget and the quarantine
|
|
588
|
+
length; `--no-fallbacks` leaves only the primary model per stage.
|
|
560
589
|
|
|
561
590
|
### Checking that findings point at the diff
|
|
562
591
|
|
|
@@ -702,13 +731,14 @@ unverifiable. Any other 422 is not retried.
|
|
|
702
731
|
## Usage
|
|
703
732
|
|
|
704
733
|
```bash
|
|
705
|
-
bundle
|
|
706
|
-
bundle
|
|
707
|
-
bundle
|
|
708
|
-
bundle
|
|
709
|
-
bundle
|
|
710
|
-
bundle
|
|
711
|
-
bundle
|
|
734
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123
|
|
735
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123 --post
|
|
736
|
+
bundle exec bin/aireview review https://github.com/owner/repo/pull/42 --post
|
|
737
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123 --no-jira
|
|
738
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123 --dry-run --verbose
|
|
739
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123 --generate-model gemini-3.6-flash --critique-model gemini-3.8-flash
|
|
740
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123 --generate-model gemini-3.6-flash --generate-temperature 0.3 --critique-model gemini-3.8-flash --critique-temperature 0
|
|
741
|
+
bundle exec bin/aireview review https://gitlab.company.com/team/project/-/merge_requests/123 --no-critique
|
|
712
742
|
```
|
|
713
743
|
|
|
714
744
|
- `--generate-model MODEL` overrides the model for the Generate pass only.
|
|
@@ -719,15 +749,15 @@ bundle _2.3.26_ exec bin/aireview review https://gitlab.company.com/team/project
|
|
|
719
749
|
- `--no-jira` turns off the Jira enrichment even when the MR carries an issue key.
|
|
720
750
|
- `--dry-run` prints the LLM settings, the context sizes and coverage, and the Generate prompt, plus the Critique prompt unless `--no-critique` is given.
|
|
721
751
|
- `--no-critique` skips the second pass and renders the Generate candidates directly.
|
|
722
|
-
- `--no-fallbacks` uses only the primary model
|
|
752
|
+
- `--no-fallbacks` uses only the primary model of each stage.
|
|
723
753
|
- `--review-mode MODE` sets the behaviour when a review has already been published: `update` or `once`.
|
|
724
754
|
- `--force` reviews again even when a review for this state of the MR is already published.
|
|
725
755
|
|
|
726
756
|
### Checking the models
|
|
727
757
|
|
|
728
758
|
```bash
|
|
729
|
-
bundle
|
|
730
|
-
bundle
|
|
759
|
+
bundle exec bin/aireview models check
|
|
760
|
+
bundle exec bin/aireview models check --config .aireview.yml --strict --verbose
|
|
731
761
|
```
|
|
732
762
|
|
|
733
763
|
Every model of both stage chains gets two small requests — one with the
|
|
@@ -741,8 +771,8 @@ per-minute limit gets one retry after the provider's hint.
|
|
|
741
771
|
|
|
742
772
|
```
|
|
743
773
|
Checking 5 model(s) with the generate and critique schemas
|
|
744
|
-
gemini/gemini-3.
|
|
745
|
-
gemini/gemini-3.
|
|
774
|
+
gemini/gemini-3.8-flash generate ok (4.6s)
|
|
775
|
+
gemini/gemini-3.8-flash critique ok (6.9s)
|
|
746
776
|
gemini/gemini-3.6-flash generate unverified: This model is currently experiencing high demand. …
|
|
747
777
|
gemini/gemini-9.9-nope generate missing: models/gemini-9.9-nope is not found for API version v1beta, …
|
|
748
778
|
ollama/qwen2.5-coder:7b generate skipped: Connection refused
|
|
@@ -802,12 +832,41 @@ attempt too. Outside of GitLab CI, `once` mode keeps skipping an existing
|
|
|
802
832
|
review. The `--force` flag repeats the review even when nothing has changed.
|
|
803
833
|
|
|
804
834
|
While the review is running, the merge request can move on. Before publishing,
|
|
805
|
-
`aireview` re-reads it and compares `sha`, the target branch
|
|
806
|
-
|
|
807
|
-
a comment must not end up holding a review of a diff that
|
|
835
|
+
`aireview` re-reads it and compares `sha`, the target branch and `diff_refs`:
|
|
836
|
+
if any of those changed (or `[skip review]` was added to the title), the result
|
|
837
|
+
is not published — a comment must not end up holding a review of a diff that
|
|
838
|
+
is no longer current. If only the title or description changed while the review
|
|
839
|
+
was running, the formed report is still published with a note that the text was
|
|
840
|
+
edited during the run. In `--post` mode, `[skip review]` in the fresh title
|
|
841
|
+
also skips the LLM run itself (useful after the initial 60-second CI wait).
|
|
808
842
|
The review text is printed to stdout before the publishing attempt, so it stays
|
|
809
843
|
in the job log. The previous comment is kept until the end of the next run.
|
|
810
844
|
|
|
845
|
+
On GitHub the same comment is a pull request conversation comment, and the
|
|
846
|
+
author is compared by login. A personal or fine-grained token reads its login
|
|
847
|
+
from `/user`. The Actions `GITHUB_TOKEN` and GitHub App installation tokens
|
|
848
|
+
cannot: set `GITHUB_REVIEW_AUTHOR` to the login the comments are posted as —
|
|
849
|
+
`github-actions[bot]` for `GITHUB_TOKEN`, `<app-slug>[bot]` for an App.
|
|
850
|
+
Without it such a token stops the run with an error rather than guessing: a
|
|
851
|
+
wrong author means the review is not found and a second one is posted. Every
|
|
852
|
+
workflow that comments with `GITHUB_TOKEN` writes as `github-actions[bot]`,
|
|
853
|
+
so a marked comment from another workflow of the repository would be taken
|
|
854
|
+
for the review.
|
|
855
|
+
|
|
856
|
+
A **Re-run** of the workflow counts as a retry in `once` mode
|
|
857
|
+
(`GITHUB_RUN_ATTEMPT` above 1). The "moved while reviewing" check compares
|
|
858
|
+
the merge base instead of the base branch tip: a push to the base branch
|
|
859
|
+
that does not change the pull request diff does not stop publishing, while
|
|
860
|
+
a merge of part of the pull request into the base branch does. When GitHub
|
|
861
|
+
returns fewer files than the pull request changes (it lists at most 3000),
|
|
862
|
+
the count of the missing ones is written under "Not reviewed". Comments
|
|
863
|
+
exceeding GitHub's 65,536-character limit are automatically fitted by
|
|
864
|
+
shortening the files list under "Not reviewed" (or the summary if
|
|
865
|
+
oversized) while keeping findings and result intact. On GitHub's files API,
|
|
866
|
+
pure file renames (`changes: 0` without a patch) count as having no text
|
|
867
|
+
changes; because Git does not count lines for binary files, byte modifications
|
|
868
|
+
in a renamed binary file also report zero changes.
|
|
869
|
+
|
|
811
870
|
## GitLab CI
|
|
812
871
|
|
|
813
872
|
For merge request pipelines `aireview` can run in a separate CI job, letting
|
|
@@ -830,12 +889,12 @@ aireview:
|
|
|
830
889
|
MR_URL: "$CI_MERGE_REQUEST_PROJECT_URL/-/merge_requests/$CI_MERGE_REQUEST_IID"
|
|
831
890
|
REVIEW_LANGUAGE: "ru"
|
|
832
891
|
LLM_PROVIDER: "gemini"
|
|
833
|
-
LLM_GENERATE_MODEL: "gemini-3.
|
|
892
|
+
LLM_GENERATE_MODEL: "gemini-3.6-flash"
|
|
834
893
|
LLM_CRITIQUE_MODEL: "gemini-3.8-flash"
|
|
835
894
|
LLM_TIMEOUT: "60"
|
|
836
895
|
LLM_HTTP_PROXY: "http://127.0.0.1:8888"
|
|
837
896
|
script:
|
|
838
|
-
- bundle
|
|
897
|
+
- bundle exec bin/aireview review "$MR_URL" --verbose
|
|
839
898
|
timeout: 45m
|
|
840
899
|
retry:
|
|
841
900
|
max: 1
|
|
@@ -849,7 +908,7 @@ is itself bounded by `LLM_TIME_BUDGET` (30 minutes by default, pauses and
|
|
|
849
908
|
fallback models included), the rest is reading the MR and Jira and
|
|
850
909
|
publishing.
|
|
851
910
|
|
|
852
|
-
Set secrets such as `GITLAB_TOKEN`, `GEMINI_API_KEY`
|
|
911
|
+
Set secrets such as `GITLAB_TOKEN`, `GEMINI_API_KEY` and
|
|
853
912
|
the optional Jira credentials in the GitLab CI/CD variables. If the job should publish the result
|
|
854
913
|
back to the merge request, add `--post` to the review command.
|
|
855
914
|
|
|
@@ -922,6 +981,77 @@ registry) → build and push → set the new tag in `stable`. The same check on
|
|
|
922
981
|
a schedule (once a day) is the early signal that the provider retired a
|
|
923
982
|
model — otherwise the first to learn about it is a live MR.
|
|
924
983
|
|
|
984
|
+
## GitHub Actions
|
|
985
|
+
|
|
986
|
+
A workflow for pull requests of the same repository:
|
|
987
|
+
|
|
988
|
+
```yaml
|
|
989
|
+
name: aireview
|
|
990
|
+
|
|
991
|
+
on:
|
|
992
|
+
pull_request:
|
|
993
|
+
types: [opened, synchronize, reopened, ready_for_review, edited]
|
|
994
|
+
|
|
995
|
+
permissions:
|
|
996
|
+
contents: read
|
|
997
|
+
pull-requests: write
|
|
998
|
+
|
|
999
|
+
concurrency:
|
|
1000
|
+
group: aireview-${{ github.event.pull_request.number }}
|
|
1001
|
+
cancel-in-progress: true
|
|
1002
|
+
|
|
1003
|
+
jobs:
|
|
1004
|
+
review:
|
|
1005
|
+
# Fork PRs get no secrets and a read-only token: skip them. Dependabot
|
|
1006
|
+
# PRs come from branches of this repo, pass the fork check, but get no
|
|
1007
|
+
# Actions secrets either: skip them too.
|
|
1008
|
+
if: >-
|
|
1009
|
+
github.event.pull_request.head.repo.full_name == github.repository &&
|
|
1010
|
+
github.actor != 'dependabot[bot]' &&
|
|
1011
|
+
!github.event.pull_request.draft &&
|
|
1012
|
+
!contains(github.event.pull_request.title, '[skip review]')
|
|
1013
|
+
runs-on: ubuntu-24.04
|
|
1014
|
+
timeout-minutes: 40
|
|
1015
|
+
steps:
|
|
1016
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1; for .aireview.yml
|
|
1017
|
+
with:
|
|
1018
|
+
persist-credentials: false
|
|
1019
|
+
- uses: ruby/setup-ruby@14594264cd68ce8a2345dd349bc3d138a4ef85c8 # v1.327.0
|
|
1020
|
+
with:
|
|
1021
|
+
ruby-version: '3.3'
|
|
1022
|
+
- run: gem install aireview -v '~> 2.3'
|
|
1023
|
+
- run: aireview review "$PR_URL" --post
|
|
1024
|
+
env:
|
|
1025
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
1026
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
1027
|
+
GITHUB_REVIEW_AUTHOR: github-actions[bot] # who GITHUB_TOKEN posts as
|
|
1028
|
+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
|
1029
|
+
REVIEW_MODE: update # once: one published review per PR, "Re-run jobs" refreshes it
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
The only secret to add is `GEMINI_API_KEY`: without `.aireview.yml` the gem
|
|
1033
|
+
takes its bundled defaults (the Gemini pool).
|
|
1034
|
+
|
|
1035
|
+
- `pull_request`, never `pull_request_target` with a checkout of the pull
|
|
1036
|
+
request head: `.aireview.yml` from the pull request can set provider
|
|
1037
|
+
addresses, so a fork could send the API key to a server of its own.
|
|
1038
|
+
- The URL goes through `env`, not through `${{ }}` inside `run:`, so that
|
|
1039
|
+
nothing from the event is pasted into the shell script.
|
|
1040
|
+
- `edited` reviews again after a title or description edit; when the edit
|
|
1041
|
+
does not reach the prompts, the key is the same and no LLM request is sent.
|
|
1042
|
+
- `timeout-minutes: 40` is `LLM_TIME_BUDGET` (30 minutes by default) plus
|
|
1043
|
+
reading and publishing.
|
|
1044
|
+
|
|
1045
|
+
`update` keeps the review current after every push that changes the diff.
|
|
1046
|
+
`once` is the cheaper option: one published review per pull request,
|
|
1047
|
+
refreshed with **Re-run jobs** when its inputs changed. Neither means exactly
|
|
1048
|
+
one LLM run: a run cancelled or failed before publishing leaves no review,
|
|
1049
|
+
so the next push runs the LLM again. `cancel-in-progress` drops a run
|
|
1050
|
+
overtaken by a push — it would usually not publish anyway — but requests
|
|
1051
|
+
already sent to the provider may still be billed. And a push between the
|
|
1052
|
+
"moved" check and the post can still leave a review of the previous diff
|
|
1053
|
+
until the next run replaces it.
|
|
1054
|
+
|
|
925
1055
|
## Docker
|
|
926
1056
|
|
|
927
1057
|
```bash
|
|
@@ -933,9 +1063,9 @@ docker run --rm --env-file .env -v "$PWD/.aireview.yml:/app/.aireview.yml:ro" ai
|
|
|
933
1063
|
## Testing
|
|
934
1064
|
|
|
935
1065
|
```bash
|
|
936
|
-
bundle
|
|
937
|
-
bundle
|
|
938
|
-
bundle
|
|
1066
|
+
bundle exec rspec
|
|
1067
|
+
bundle exec rspec spec/config_spec.rb
|
|
1068
|
+
bundle exec rspec spec/secret_scrubber_spec.rb
|
|
939
1069
|
```
|
|
940
1070
|
|
|
941
1071
|
## Notes
|
data/config/defaults.yml
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
# "Ollama models" with Gemini names.
|
|
15
15
|
#
|
|
16
16
|
# Model names come from the Gemini catalog (GET /v1beta/models), text models
|
|
17
|
-
# without "preview" in the name only;
|
|
18
|
-
# `aireview models check` with both schemas (2026-09-18)
|
|
17
|
+
# without "preview" in the name only; gemini-3.* models were confirmed by
|
|
18
|
+
# `aireview models check` with both schemas (2026-09-18); gemini-4-hydrogen
|
|
19
|
+
# was added on 2026-11-16.
|
|
19
20
|
|
|
20
21
|
review_language: en
|
|
21
22
|
|
|
@@ -29,17 +30,15 @@ llm:
|
|
|
29
30
|
overloaded_quarantine: 120
|
|
30
31
|
models:
|
|
31
32
|
- provider: gemini
|
|
32
|
-
model: gemini-
|
|
33
|
+
model: gemini-4-hydrogen
|
|
33
34
|
- provider: gemini
|
|
34
|
-
model: gemini-3.
|
|
35
|
+
model: gemini-3.8-flash
|
|
35
36
|
- provider: gemini
|
|
36
37
|
model: gemini-3.6-flash
|
|
37
|
-
- provider: gemini
|
|
38
|
-
model: gemini-3.5-flash
|
|
39
38
|
- provider: gemini
|
|
40
39
|
model: gemini-3.5-flash-lite
|
|
41
40
|
generate:
|
|
42
|
-
start: gemini-3.
|
|
41
|
+
start: gemini-3.8-flash
|
|
43
42
|
temperature: 0.1
|
|
44
43
|
critique:
|
|
45
44
|
rank: not_below_generate
|