gates

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package gates ports the two parallel `.ai()` post-processing passes from the Python PR-AF pipeline: the merge-blocker gate (merge_gate.py) and the comment polish pass (polish.py). Both fan out one AI call per item, preserve input order, and degrade gracefully on per-item failure.

Merge gate — a separate lens from severity. Severity asks "how bad is this issue?"; the merge gate asks "must this be fixed BEFORE the PR ships, or can it ship and be addressed in a follow-up?". Failure mode: default to blocking=false on every error path, because a false negative (a real blocker slips through as advisory) is recoverable by human review, whereas a false positive (advisory issue flagged blocking) erodes trust and blocks merge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyFindings

func ClassifyFindings(ctx context.Context, app AICaller, findings []schemas.ScoredFinding) []schemas.ScoredFinding

ClassifyFindings ports merge_gate.classify_findings: one AI call per finding, fired in parallel, original order preserved. Returns a NEW slice with Blocking and BlockingReason populated; the input slice and its elements are not mutated (pure, mirroring pydantic model_copy).

Concurrency: Python uses asyncio.gather WITHOUT return_exceptions, but _gate_one catches every exception internally and never raises, so no error ever propagates through gather. The faithful Go mirror is a WaitGroup writing into a pre-indexed results slice — order is positional, not completion-order.

func PolishComments

func PolishComments(ctx context.Context, app AICaller, comments []schemas.GitHubComment) []schemas.GitHubComment

PolishComments ports polish.polish_comments: rewrite each comment body in parallel, original order preserved. Returns a NEW slice; each comment's Body is replaced with the rewritten text while every other field (Path, Line, Side) is copied unchanged — path preservation is guaranteed structurally here, and callout/markdown preservation is enforced by the polish system prompt. Pure — the input slice and its elements are not mutated.

Concurrency mirrors classify_findings: Python's asyncio.gather never sees an exception because _polish_one catches its own AI errors, so a WaitGroup over a pre-indexed results slice is the faithful order-preserving fan-out.

Types

type AICaller

type AICaller interface {
	AI(ctx context.Context, prompt string, opts ...ai.Option) (*ai.Response, error)
}

AICaller is the minimal one-method seam the two `.ai()` gates drive. It is appx.AIer's one method, so the review's App satisfies it unchanged and tests supply a fake. This is the Go analogue of Python's `app.ai(prompt, system=..., response_format="json")`: the system prompt is passed as ai.WithSystem and JSON mode as ai.WithJSONMode.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL