attest.code_review¶
Code review mode, importable as from attest.code_review import ....
Inputs¶
ReviewOutput
pydantic-model
¶
Bases: BaseModel
Fields:
-
output_type(OutputType) -
text(str) -
diffs(dict[str, str]) -
changed_files(list[str] | None) -
reads(list[FileRead]) -
question(str | None) -
group_name(str | None)
FileRead
pydantic-model
¶
PullRequest
pydantic-model
¶
Bases: BaseModel
Fields:
-
diffs(dict[str, str]) -
changed_files(list[str]) -
title(str) -
description(str) -
commit_messages(list[str])
Building runs¶
to_run
¶
to_run(
output: ReviewOutput,
*,
limits: EvidenceLimits | None = None,
guidelines: ReviewGuidelines | None = None,
) -> Trajectory
Build the run for a review output; evidence comes only from tool calls.
to_run_with_omissions
¶
to_run_with_omissions(
output: ReviewOutput,
*,
limits: EvidenceLimits | None = None,
guidelines: ReviewGuidelines | None = None,
) -> RunWithOmissions
Build the run for a review output and list which files had content left out and why.
guidelines, when given, are added as a read_guidelines step so claims citing a rule
can be checked.
EvidenceLimits
pydantic-model
¶
Bases: BaseModel
How many characters of diff one file, and one whole run, may put into evidence.
Config:
frozen:True
Fields:
-
max_file_chars(int) -
max_run_chars(int)
Omission
pydantic-model
¶
Bases: BaseModel
A file whose diff was summarized, cut or left out of the evidence, and why.
Config:
frozen:True
Fields:
-
path(str) -
reason(OmissionReason) -
changed_lines(int) -
omitted_hunks(int)
detect_answer_kind
¶
Pick "code" or "factual" from the run's tool calls. Makes no model calls.
Reviewing a pull request¶
review
¶
review(
pr: PullRequest,
outputs: Sequence[ReviewOutput] | None = None,
*,
evaluate: Evaluator,
guidelines: GuidelinesInput = None,
follow_guidelines: bool = True,
modes: Mapping[str, GateMode] | None = None,
deep: bool = True,
limits: EvidenceLimits | None = None,
) -> ReviewResult
Scan the pull request for injection once, then grade and gate each output on its evidence.
With no outputs, attest writes the review itself, following guidelines.
guidelines are the team's review rules (markdown paths or text). They are evidence, so an
issue citing one can be checked, and follow_guidelines drops outputs that break one. Without
them, attest's own reviewer follows the built-in general standard, and outputs are checked
for faithfulness only. Outputs without their own diffs or
changed-file list use the pull request's. evaluate turns a run into a Report with a
faithfulness result, and modes overrides the default gate mode per output type.
ReviewResult
pydantic-model
¶
Bases: BaseModel
Fields:
-
decisions(list[OutputDecision]) -
injection(CheckResult) -
guidelines(ReviewGuidelines | None) -
written(bool) -
warnings(list[str]) -
outputs(list[ReviewOutput])
filter
¶
Return the outputs this review kept, in their original order.
OutputDecision
pydantic-model
¶
write_review
¶
write_review(
pr: PullRequest,
*,
guidelines: GuidelinesInput = None,
limits: EvidenceLimits | None = None,
) -> list[ReviewOutput]
Review a pull request: issues, one summary per changed file, and an overview.
Guidelines¶
load_guidelines
¶
Resolve guidelines from a path, markdown text, a list of paths, or None for the default.
ReviewGuidelines
pydantic-model
¶
Bases: BaseModel
Fields:
Guideline
pydantic-model
¶
Checking and gating¶
check_code_injection
¶
check_code_injection(
pr: PullRequest,
outputs: list[ReviewOutput] | None = None,
*,
deep: bool = True,
budget_chars: int = 8000,
) -> CheckResult
Scan a pull request for text planted to steer an automated reviewer.
gate
¶
gate(
report: Report,
output_type: OutputType | str,
*,
mode: GateMode | str | None = None,
injection: CheckResult | None = None,
paths: list[str] | None = None,
output_index: int | None = None,
) -> GateDecision
Decide whether to keep one review output.
reasons lists the findings that drop it. notes lists findings shown beside it that do not.
Findings against the built-in general standard are always notes; only your own rules drop.
A claim no verifier judged (a failed or skipped call) drops the output in every mode.