Expand description
AI PatchSet Definition
A PatchSet represents a proposed set of code changes (diffs) generated
by an agent during a Run. It is the atomic unit of
code modification in the AI workflow — every change the agent wants to
make to the repository is packaged as a PatchSet.
§Relationships
Run ──patchsets──▶ [PatchSet₀, PatchSet₁, ...]
│
└──run──▶ Run (back-reference)- Run (bidirectional):
Run.patchsetsholds the forward reference (chronological generation history),PatchSet.runis the back-reference.
§Lifecycle
┌──────────┐ agent produces diff ┌──────────┐
│ (created)│ ───────────────────────▶ │ Proposed │
└──────────┘ └────┬─────┘
│
┌───────────────────┼───────────────────┐
│ validation/review │ │
▼ passes ▼ fails │
┌─────────┐ ┌──────────┐ │
│ Applied │ │ Rejected │ │
└─────────┘ └────┬─────┘ │
│ │
▼ │
agent generates new PatchSet │
appended to Run.patchsets │- Creation: The orchestrator calls
PatchSet::new(), which setsapply_statustoProposed. At this pointartifactisNoneandtouchedis empty. - Diff generation: The agent produces a diff against
commit(the baseline Git commit). It setsartifactto point to the stored diff content, populatestouchedwith a file-level summary, writes arationale, and records theformat. - Review / validation: The orchestrator or a human reviewer inspects the PatchSet. Automated checks (tests, linting) may run.
- Applied: If the diff passes, the orchestrator commits it to
the repository and transitions
apply_statustoApplied. - Rejected: If the diff fails validation or is rejected by a
reviewer,
apply_statusbecomesRejected. The agent may then generate a new PatchSet appended toRun.patchsets.
§Ordering
PatchSet ordering is determined by position in Run.patchsets. If a
PatchSet is rejected, the agent generates a new PatchSet and appends
it to the Vec. The last entry is always the most recent attempt.
§Content
The actual diff content is stored as an ArtifactRef (via the
artifact field), while TouchedFile (via the touched field)
provides a lightweight file-level summary for UI and indexing.
The format field indicates how to parse the artifact content
(unified diff or git diff). The rationale field carries the
agent’s explanation of what was changed and why.
Structs§
- Patch
Set - PatchSet object containing a candidate diff.
- Touched
File - Touched file summary in a patchset.
Enums§
- Apply
Status - Patch application status.
- Change
Type - Type of change for a file.
- Diff
Format - Diff format for patch content.