praf

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: 30 Imported by: 0

Documentation

Overview

Package praf is review: pr-af, the pull-request reviewer, as a program codeaf carries and runs, and nothing else can. It takes one brief — a GitHub pull request, or the current branch's — checks the pull request out in a folder of its own, plans which parts of the change to review, sends a reviewer at each, challenges what they found against the code, looks for gaps, and ends with one review. It posts nothing; posting a review it wrote is a second, separate run (`/review post <report>`) that the person says yes to.

IT WAS A SEPARATE PROGRAM. pr-af (github.com/Agent-Field/pr-af) was an AgentField node: a control plane carried its calls, a router key it held paid for its models, and a coding-agent binary ran each of its reviewers. Its Go port was copied into codeaf once, at the tag codeaf-absorb (docs/design/pr-review/ABSORB.md); its algorithm — the intake, the review plan, the dimension reviewers, the evidence, challenge, cross-reference and coverage passes, the prompts — is in the packages below this one and is its own. What it runs on is codeaf's: the agent loop sec runs on too (internal/agentsession), over the run's model API, with every limit and figure review's own (limits.go).

IT HAS NO ENTRY POINT OF ITS OWN. What codeaf needs of it is a delegate.Delegate value, and its command's body takes a delegate.Host, which only codeaf makes: `/review` in the chat, `codeaf review` at a shell, and `propose_task` with `via: "review"`.

Index

Constants

View Source
const Name = "review"

Name is the program's name: its chat command and its shell verb.

Variables

View Source
var Program = delegate.Delegate{
	Name:    Name,
	Summary: "a code review of a GitHub pull request",
	Guide:   programguide.Review,
	Lands:   delegate.LandsText,

	DefaultBrief: "current branch",

	Words: true,
	Args:  "[<pull request>] [what to focus on] | post <report>",

	Asked: asksForReview,

	Title:      title,
	Unattended: Unattended,

	FollowUp: "If it found anything, offer the person two next steps and wait for their answer: posting this review " +
		"to the pull request as it stands (only after they say yes to posting, propose review with the brief " +
		"`post <the review-report.json path from the account>`), or handing the blocking findings to senior-dev as " +
		"one task that fixes them in this folder when it is the pull request's checkout, naming which. " +
		"Propose neither before they say yes to it.",
	ModelFlag:           "model",
	AuxiliaryModelFlags: []string{"light"},
	CrewFlags:           crewFlags,
	StageWords:          stageWords,
	Present:             presentActions,
	Default:             "run",
	Page:                Name,
	Commands:            []delegate.Command{runCommand},
}

Program is review as codeaf carries it.

View Source
var Stages = []string{
	stageStarting, stageIntake, stageAnatomy, stagePlan, stageReview, stageFilter,
	stageEvidence, stageChallenge, stageDeepen, stageCrossRef, stageObligations,
	stageCoverage, stageReport,
}

Stages is every stage a review reports, in the order it reaches them.

View Source
var Unattended = delegate.Ceilings{CostUSD: 5, Hours: 2}

Unattended is a review's own ceilings, which stop a run nobody is watching. pr-af's served node capped a review at $2 and an hour, and real reviews of mid-sized pull requests measured 35 to 70 minutes; these leave headroom for a stronger model and a large change until reviews through codeaf are measured.

Functions

This section is empty.

Types

type ReportCoverage

type ReportCoverage struct {
	Complete           bool   `json:"complete"`
	FailedSessions     int    `json:"failed_sessions"`
	FailedCalls        int    `json:"failed_calls"`
	DegradedDimensions int    `json:"degraded_dimensions"`
	BudgetExhausted    bool   `json:"budget_exhausted"`
	StoppedAt          string `json:"stopped_at,omitempty"`
	Note               string `json:"note,omitempty"`
}

Coverage is separate from execution status: an assembled partial review can end successfully, but a saved or posted report must keep its missing work.

type Request

type Request struct {
	// Posting is a `post <report>` brief, and Post the saved review it names.
	// THEY ARE TWO FIELDS so a bare `post` is a post that names nothing, which
	// ends asking for the report, never a review of the current branch that
	// spends money nobody asked to spend.
	Posting bool
	Post    string
	// Target is the pull request named outright; zero when the brief leaves it
	// to the folder's current branch.
	Target Target
	// Focus is what the reviewers should weigh: the brief without its pull
	// request, "" for none.
	Focus string
}

Request is one run's brief, read.

func ReadBrief

func ReadBrief(brief string, origin func() (owner, repo string, ok bool)) Request

ReadBrief reads a brief. origin answers the folder's GitHub owner/repo for a bare #N; it may be nil, and it is only asked when the brief has nothing fuller. A brief that names no pull request is a review of the current branch's, with the whole brief as its focus.

type Saved

type Saved struct {
	Program     string               `json:"program"`
	PullRequest SavedPullRequest     `json:"pull_request"`
	Focus       string               `json:"focus,omitempty"`
	Review      schemas.ReviewResult `json:"review"`
	Coverage    *ReportCoverage      `json:"coverage,omitempty"`
}

Saved is the review as review-report.json keeps it: the pull request it is of, down to the commit that was reviewed, and the review pr-af built, including the GitHub review a later `/review post` sends as it stands.

type SavedPullRequest

type SavedPullRequest struct {
	Owner   string `json:"owner"`
	Repo    string `json:"repo"`
	Number  int    `json:"number"`
	URL     string `json:"url"`
	Title   string `json:"title,omitempty"`
	HeadSHA string `json:"head_sha"`
}

SavedPullRequest is the pull request a saved review is of.

func (SavedPullRequest) Target

func (p SavedPullRequest) Target() Target

Target is the saved pull request as a Target.

type Target

type Target struct {
	Owner  string
	Repo   string
	Number int
}

Target is the pull request a brief names.

func (Target) String

func (t Target) String() string

String is the short form a person reads: owner/repo#N.

func (Target) URL

func (t Target) URL() string

URL is the canonical pull request URL, or "" for the zero Target.

Directories

Path Synopsis
Package afx holds small ergonomics over the AgentField Go SDK that every reasoner handler in the port reuses.
Package afx holds small ergonomics over the AgentField Go SDK that every reasoner handler in the port reuses.
Package appx declares the agent-capability seam the review's reasoners, gates and orchestrator are written against.
Package appx declares the agent-capability seam the review's reasoners, gates and orchestrator are written against.
Package blastradius ports pr_af/blast_radius.py: a file-level dependency graph built from Python import statements, used to find files that are affected by a change but not part of the changeset.
Package blastradius ports pr_af/blast_radius.py: a file-level dependency graph built from Python import statements, used to find files that are affected by a change but not part of the changeset.
Package diffengine ports src/pr_af/diff_engine.py — the deterministic (non-LLM) diff parser and clustering engine that feeds the anatomy phase.
Package diffengine ports src/pr_af/diff_engine.py — the deterministic (non-LLM) diff parser and clustering engine that feeds the anatomy phase.
Package evidence ports pr_af/evidence.py: ground-truth code extraction that grounds each finding in the actual repository source.
Package evidence ports pr_af/evidence.py: ground-truth code extraction that grounds each finding in the actual repository source.
Package fatal detects non-retryable harness failures (billing exhaustion, invalid credentials, disabled accounts, codex model/auth mismatches).
Package fatal detects non-retryable harness failures (billing exhaustion, invalid credentials, disabled accounts, codex model/auth mismatches).
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).
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).
Package github is a small REST client for the GitHub API used by the PR-AF review pipeline: fetch a PR (metadata + changed files + commits + unified diff), and post a review with inline comments.
Package github is a small REST client for the GitHub API used by the PR-AF review pipeline: fetch a PR (metadata + changed files + commits + unified diff), and post a review with inline comments.
Package harnessx is the single choke-point every PR-AF reasoner uses to call the AgentField harness.
Package harnessx is the single choke-point every PR-AF reasoner uses to call the AgentField harness.
Package orch is the PR-AF review orchestrator — the Go port of src/pr_af/orchestrator.py.
Package orch is the PR-AF review orchestrator — the Go port of src/pr_af/orchestrator.py.
Package prompts holds the byte-verbatim Go ports of every LLM prompt builder in PR-AF's Python source of truth: the reasoner system/task prompts in reasoners/harnesses.py, the merge-gate classification prompt in merge_gate.py, the polish prompt in polish.py, and the coverage-gap review prompt in orchestrator.py.
Package prompts holds the byte-verbatim Go ports of every LLM prompt builder in PR-AF's Python source of truth: the reasoner system/task prompts in reasoners/harnesses.py, the merge-gate classification prompt in merge_gate.py, the polish prompt in polish.py, and the coverage-gap review prompt in orchestrator.py.
Package reasoners ports the 16 router reasoners in src/pr_af/reasoners/harnesses.py (intake_phase … coverage_gate) to Go.
Package reasoners ports the 16 router reasoners in src/pr_af/reasoners/harnesses.py (intake_phase … coverage_gate) to Go.
Package schemas ports PR-AF's pydantic schema layer to Go: the input, pipeline, gate, and output structs plus the canonical severity vocabulary.
Package schemas ports PR-AF's pydantic schema layer to Go: the input, pipeline, gate, and output structs plus the canonical severity vocabulary.
Package scoring is the deterministic scoring engine for PR-AF — a byte-exact port of src/pr_af/scoring.py.
Package scoring is the deterministic scoring engine for PR-AF — a byte-exact port of src/pr_af/scoring.py.

Jump to

Keyboard shortcuts

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