Configuration Reference
Exact public configuration coverage for the supported PatchPatrol workflow.
Configuration Reference
Use this page when you need the exact public configuration contract for the supported PatchPatrol workflow after the quickstart path is already in place.
If you need the canonical support contract for runtime baselines and deployment modes before choosing settings, start with Supported runtime and operating modes.
Source of truth: this page is derived from shipped PatchPatrol contracts in patchpatrol/config.py and the checked-in configuration references that narrow those contracts to the supported public surface.
This is the baseline public configuration surface. For operator-tuned controls and explicitly scoped legacy compatibility entries, read the companion Advanced configuration page.
When the same setting exists in both an environment variable and the CLI, the CLI flag is the direct override. Use the CLI reference for command flags and Policy controls for change guidance.
Repo-local defaults with .ai-review.yml
PatchPatrol also supports an optional repo-root .ai-review.yml for versioned
safe defaults. Resolution order is explicit:
- built-in defaults
.ai-review.yml- environment variables
- CLI overrides
Version 1 of .ai-review.yml intentionally supports only stable safe
defaults and bounded prompt-only review rules that teams are most likely to
version with the repository.
Supported defaults fields:
modelproviderfail_onfail_on_partial_coveragereview_context_modeincremental_modeinclude_globsexclude_globsfeedback_moderemediation_modeenable_final_summaryenable_review_lensesreview_lenses
Supported review.rules fields:
id: required stable identifier, up to 128 characters, using letters, numbers,.,_,:, and-severity: optional prompt-priority label:error,warning, orinfoscope: optional list of repository-path glob patterns; omitted or empty scope applies the rule to every reviewed pathinstruction: required non-empty review instruction, up to 1000 characters
PatchPatrol retains at most 50 repo-local rules from the policy file and renders at most 12 matched rules per prompt/chunk. Rules are prompt-only review constraints: they guide provider attention, but findings still require concrete diff/context evidence and do not become deterministic fail gates.
For the admin workflow, audit output, disablement behavior, and concrete privacy/testing/dependency/architecture examples, use Repository-aware rules.
Secrets, endpoint URLs, allowlist controls, output paths, numeric diff bounds,
and executable hooks are intentionally outside the version 1 repo-local policy
contract.
Example:
version: 1
defaults:
provider: openai
model: gpt-4o-mini
fail_on: high
feedback_mode: artifact-only
remediation_mode: off
review_context_mode: diff-only
incremental_mode: auto
include_globs:
- src/**
exclude_globs:
- vendor/**
- node_modules/**
review:
rules:
- id: require-regression-tests-for-runtime-behavior
severity: warning
scope:
- "patchpatrol/**/*.py"
instruction: "When runtime behavior changes, verify that tests cover the pre-fix failure mode and observable behavior."Accepted findings with .ai-review-baseline.yml
PatchPatrol also supports an optional checked-in repo-root
.ai-review-baseline.yml for accepted findings.
This file is distinct from .ai-review.yml:
- use
.ai-review.ymlfor safe repo-local defaults such as provider, model, and review bounds - use
.ai-review-baseline.ymlonly for accepted findings that should stop tripping rollout gates while still remaining visible in artifacts
Version 1 is intentionally narrow and deterministic:
- the file name is fixed at the repository root
- entries live under
suppressions - each entry requires an exact finding
fingerprint - each entry requires a human-readable
reason
Example:
version: 1
suppressions:
- fingerprint: 0123456789abcdef
reason: Accepted historical issue while rollout stays in advisory modeOn the next run, PatchPatrol applies the baseline before AI_REVIEW_FAIL_ON
evaluation. That means fail-on policy evaluates only unsuppressed findings after
baseline matching. Suppressed findings do not disappear silently: the artifacts
still expose suppression evidence in markdown and JSON metadata so operators can
see what matched and why.
Use the Developer Quickstart when you want the
public artifact workflow for finding and copying a fingerprint, and use
Policy controls when you are deciding whether
accepted findings should remain advisory or block CI.
Provider and Runtime
| Variable | Default | Supported values or posture | Public meaning |
|---|---|---|---|
AI_REVIEW_MODEL | deepseek-coder-v2:16b | Non-empty model identifier | Selects the review model used for run and readiness checks. |
AI_REVIEW_PROVIDER | ollama | ollama, openai, mock | Chooses the provider path: Ollama, OpenAI-compatible endpoints, or mock iteration. |
AI_REVIEW_STRUCTURED_OUTPUT_MODE | json | json, json_schema, auto | Controls the review-call output request shape. json preserves the baseline JSON-object contract. json_schema and auto can request strict JSON-schema output for OpenAI-compatible review calls and safely fall back to JSON-object mode when the endpoint rejects schema mode. |
OLLAMA_HOST | http://127.0.0.1:11434 | Valid http or https URL | Endpoint used when AI_REVIEW_PROVIDER=ollama. |
OPENAI_BASE_URL | unset | Required when AI_REVIEW_PROVIDER=openai; valid http(s) API root without query or fragment | Points PatchPatrol at a customer-controlled/self-hosted OpenAI-compatible endpoint or the official OpenAI API fallback. |
OPENAI_API_KEY | unset | Secret value when the endpoint requires auth | Supplies bearer-token auth for OpenAI-compatible requests. |
OPENAI_ORGANIZATION | unset | Optional header value | Adds the OpenAI-Organization header when the endpoint supports it. |
OPENAI_PROJECT | unset | Optional header value | Adds the OpenAI-Project header when the endpoint supports it. |
AI_REVIEW_OUTPUT_DIR | .ai-review | Writable path | Controls where PatchPatrol writes ai-review.md, ai-review.json, ai-review.html, and related artifacts. |
AI_REVIEW_TIMEOUT_SECONDS | unset | Positive integer or unset | Sets a provider-neutral request timeout and takes precedence over OLLAMA_TIMEOUT_SECONDS. |
OLLAMA_TIMEOUT_SECONDS | unset | Positive integer or unset | Backwards-compatible timeout alias for the Ollama path; ignored when AI_REVIEW_TIMEOUT_SECONDS is set. |
AI_REVIEW_TRANSPORT_RETRY_MAX_ATTEMPTS | 2 | Positive integer; 1 disables retry | Bounds retryable provider and GitLab transport attempts for CI predictability. |
Structured-output mode
AI_REVIEW_STRUCTURED_OUTPUT_MODE affects review calls only:
json: the default JSON-object request shape and validation/retry path.json_schema: for OpenAI-compatible review calls, requests strict structured output with the PatchPatrol report schema. If the endpoint returns a clear unsupported-schema response, PatchPatrol retries that review call with JSON-object mode.auto: currently uses the same OpenAI-compatible schema request and deterministic unsupported-schema fallback asjson_schema.
Ollama review calls keep the broadly compatible JSON path. PatchPatrol records
only compact mode counters and reason codes under meta.limits; it does not
persist raw prompts or provider request payloads in review artifacts.
Self-Hosted License
Non-dry-run review work with AI_REVIEW_PROVIDER=ollama or
AI_REVIEW_PROVIDER=openai requires a valid Self-Hosted License before source
or diff extraction and before provider calls. Configure exactly one runtime
source:
| Variable | Default | Public meaning |
|---|---|---|
PATCHPATROL_LICENSE | unset | Signed License payload supplied through a masked/protected CI variable or secret manager. |
PATCHPATROL_LICENSE_FILE | unset | Path to a mounted secret file containing the Signed License payload. |
If both variables are set, PatchPatrol reports LICENSE_SOURCE_AMBIGUOUS and
exits 12. An unreadable file reports LICENSE_FILE_READ_FAILED; a missing
source for real-provider review work reports LICENSE_MISSING. License inputs
are runtime-only and do not belong in .ai-review.yml or GitLab component
inputs.
Validate the configured source without running a review or calling a provider:
ai-review license inspect --jsonInspection exits 0 only when the license is valid. Every other License Status
exits 12 and returns non-sensitive JSON with stable LICENSE_* reason codes.
Mock-provider runs, dry-runs that stop before provider calls, and non-chat
readiness checks remain available without a license.
Review Bounds and Semantic Context
| Variable | Default | Supported values or posture | Public meaning |
|---|---|---|---|
AI_REVIEW_MAX_DIFF_BYTES | 65536 | Positive integer, unset, or empty string | Caps total diff bytes considered for review. |
AI_REVIEW_MAX_FILES | 20 | Positive integer, unset, or empty string | Caps how many changed files PatchPatrol selects for review. |
AI_REVIEW_MAX_CHUNKS | 16 | Positive integer, unset, or empty string | Caps the number of reviewable chunks after filtering and ordering. |
AI_REVIEW_MAX_FILE_DIFF_BYTES | 16384 | Positive integer, unset, or empty string | Caps diff size per file chunk and omits oversized files with reason metadata. |
AI_REVIEW_CONTEXT_MODE | diff-only | diff-only, diff+semantic | Chooses plain diff review or the best-effort semantic precheck path. |
AI_REVIEW_REPOSITORY_CONTEXT | on | on, off | Controls repository-aware prompt context. Unset behaves as on. Set off to disable repo-local rules, supporting code context, and repository overview while keeping normal diff review and diff-derived preflight hints active. It does not override AI_REVIEW_CONTEXT_MODE; use diff-only too when avoiding semantic diagnostics in prompt context. |
AI_REVIEW_INCREMENTAL_MODE | auto | auto, always, never | Controls whether GitLab MR reruns can review only the delta since the last PatchPatrol-reviewed head SHA. |
AI_REVIEW_SEMANTIC_TOTAL_TIMEOUT_SECONDS | 20 | Positive integer | Sets the total timeout budget for semantic precheck work when diff+semantic is enabled. |
AI_REVIEW_MAX_SUPPORTING_CONTEXT_BYTES | 65536 | Positive integer | Caps the bounded supporting context carried into semantic-aware prompts. |
AI_REVIEW_ENABLE_LENSES | false | true or false | Enables optional high-stakes review lens passes. Disabled by default; configured lenses still run only when deterministic heuristics select them. |
AI_REVIEW_LENSES | correctness,security,test-integrity,migration-rollout,external-contract | Comma-separated lens list | Limits which lenses may run when AI_REVIEW_ENABLE_LENSES=true. migration/rollout is accepted as an alias for migration-rollout. |
These review bounds are built-in defaults for the supported baseline path when
the environment variable is left unset. Raise them explicitly for larger runs,
or clear a specific bound by setting its environment variable to an empty
string when you are deliberately opting out and want an unbounded/None
posture.
For the operational difference between diff-only and diff+semantic, read
Review context mode.
Optional high-stakes review lenses
Review lenses are disabled by default. When enabled, PatchPatrol can run additional bounded provider calls for configured lenses only when deterministic signals match touched paths, repo-local review rules, preflight hints, or high-stakes file patterns.
Supported lenses are correctness, security, test-integrity,
migration-rollout, and external-contract. Each lens uses the same visible
diff/chunk, prompt-context byte budget, strict JSON validation, line anchoring,
corrective retry, and invalid-output fallback behavior as the base review.
Lens findings merge into the standard report and still go through dedupe,
validation, suppressions, and artifact rendering.
Cost and latency increase with the number of executed lens calls. A run may execute no lens calls when heuristics do not match; a chunked high-stakes diff can execute one or more additional provider calls per matching chunk. Enable lenses for high-stakes categories such as auth, billing, migrations, tests, or external API contracts rather than as a default for every repository.
Lens visibility is recorded in ai-review.json under meta.limits with fields
such as review_lenses_selected, review_lens_execution_count,
review_lens_attempts, review_lens_fallback_count, review_lens_reason_codes,
and review_lens_usage when the provider reports usage.
Incremental GitLab MR review
AI_REVIEW_INCREMENTAL_MODE affects GitLab MR runs only:
auto: default. If PatchPatrol can read a prior reviewed head SHA from its owned MR summary note, resolve that SHA, and confirm it is an ancestor of the current head, the provider reviews only the new delta.always: uses the same safe incremental checks asauto; unsafe ranges still fall back to full MR review with explicit metadata.never: disables incremental provider scope.
Incremental review does not change GitLab line anchoring. PatchPatrol keeps the
full MR diff refs for inline eligibility and records the decision under
meta.incremental_review in ai-review.json.
Delivery and Policy Controls
| Variable | Default | Supported values or posture | Public meaning |
|---|---|---|---|
AI_REVIEW_FAIL_ON | none | none, blocker, high, medium | Chooses which validated finding severities turn ai-review run into a non-zero gate. |
AI_REVIEW_FAIL_ON_PARTIAL_COVERAGE | false | true or false | Fails the run when omitted chunks are present, even if no severity threshold was hit. |
AI_REVIEW_ENABLE_FINAL_SUMMARY | false | true or false | Enables an extra summary-only model pass that can refine top issues without changing deterministic findings. |
AI_REVIEW_REMEDIATION_MODE | off | off, briefs, suggestions | Enables optional advisory remediation output. briefs derives human-reviewed fix briefs from validated, unsuppressed findings. suggestions also permits safe suggested replacements in artifacts and GitLab suggestion blocks when a high-confidence, narrow, anchored suggested_patch is available. PatchPatrol does not commit, push, or modify repository state. |
AI_REVIEW_HTML_REPORT | true | true or false | Adds static ai-review.html output for browser review or PDF printing; set to false or use ai-review run --no-html-report to suppress it for a run. |
AI_REVIEW_FEEDBACK_MODE | artifact-only | artifact-only, mr, mr-manual | Keeps the blessed artifact-first baseline or turns on GitLab merge request delivery. |
AI_REVIEW_GITLAB_INLINE_DISCUSSIONS | true | true or false | When MR delivery is active, decides whether PatchPatrol also posts eligible inline discussions. |
AI_REVIEW_ALLOW_DRAFT_MR_FEEDBACK | false | true or false | Allows MR delivery on draft or WIP merge requests for the current run. |
AI_REVIEW_MANUAL_FEEDBACK_AUTHORIZED | false | true or false | Explicitly authorizes mr-manual delivery when CI metadata alone should not decide it. |
AI_REVIEW_PROVIDER_ALLOWLIST_BASE_URLS | unset | Comma-separated exact normalized http(s) base URLs | Optional provider endpoint allowlist; when set, non-mock provider calls must match one listed base URL. |
Optional provider allowlist
Set the allowlist to the exact normalized provider base URL when you want PatchPatrol to restrict non-mock provider calls to known endpoints:
OPENAI_BASE_URL="https://llm-gateway.internal/v1"
AI_REVIEW_PROVIDER_ALLOWLIST_BASE_URLS="https://llm-gateway.internal/v1"OLLAMA_HOST="http://ollama.internal:11434"
AI_REVIEW_PROVIDER_ALLOWLIST_BASE_URLS="http://ollama.internal:11434/"If AI_REVIEW_PROVIDER_ALLOWLIST_BASE_URLS is unset or empty, PatchPatrol skips endpoint allowlist enforcement. If it is set and the normalized provider endpoint does not match, the trust gate blocks before remote calls.
If you are wiring the first supported public path, start with Admin Quickstart and return here for the exact variable contract.
Exit Semantics
Most teams only need a short mental model for exit behavior:
0: no configured gate was tripped.12: Self-Hosted License evaluation blocked real-provider review work before provider calls.10:AI_REVIEW_FAIL_ONorAI_REVIEW_FAIL_ON_PARTIAL_COVERAGEtriggered a review gate.11: PatchPatrol stopped before remote calls because the trust gate blocked execution.8: invalid-output fallback occurred.
Public Boundary
AI_REVIEW_POST_MR_NOTEis retained as a backwards-compatible alias for existing installs and maps toAI_REVIEW_FEEDBACK_MODE=mrthroughAI_REVIEW_FEEDBACK_MODEresolution.- Variables not listed on this page and not covered on the companion page are outside the published public contract.
Use Policy controls when you are choosing how strict those gates should be, and use the CLI reference when you need the matching command-line overrides.
Return to Reference.