Documentation
¶
Overview ¶
Package assemble builds the baum.review/1 generation bundle for one pull request on this machine, with no model call. It runs the same steps in the same order as the hosted assembler, over the same bundle package, with local sources: the user's clone through gitlocal instead of the hosted mirrors, GitHub through the user's own token instead of synchronized rows, and the coding-agent sessions in the home directory instead of uploaded traces.
The sources are small interfaces, so a test builds a complete bundle without a network. Assemble also writes the checkout archive and the description image archive that "baum internal generate" hands to its agent; "baum bundle" discards them. The checkout export matters to the bundle itself, since a file the checkout budget omits makes its hunks textless. A facts assembly (Request.Facts), which no model reads, exports nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrImageTooLarge = errors.New("image over the size limit")
ErrImageTooLarge is what an ImageFetcher returns for an image over the byte limit it was given.
Functions ¶
This section is empty.
Types ¶
type Assembler ¶
type Assembler struct {
GitHub GitHub
Git Git
Sessions Sessions
Images ImageFetcher
// Fetcher fetches a pull request commit the clone lacks from the remote
// whose URL names the pull request's repository. Nil fetches nothing, and
// a missing commit is a MissingCommitError with the fetch to run.
Fetcher Fetcher
// Redactor masks the bundle's text; nil builds the default one.
Redactor *bundle.Redactor
// Warn receives one line for each input that was left out and why; nil
// discards them. Bundle JSON never goes here.
Warn io.Writer
}
Assembler holds the sources of one assembly. A nil Sessions finds no sessions and a nil Images downloads no description image.
type Fetcher ¶
type Fetcher interface {
ResolvePull(ctx context.Context, pr gitlocal.PullRequest) (gitlocal.Pull, error)
}
Fetcher brings a pull request's missing base and head commits into the clone, under refs/baum/pull/<N>/ and from the remote the request names; *gitlocal.Repo implements it. It changes no other ref, the index or the working tree.
type Git ¶
type Git interface {
// ResolveCommit expands a commit id the clone holds; a commit it lacks
// is gitlocal.ErrObjectNotFound. It never fetches.
ResolveCommit(ctx context.Context, id string) (string, error)
// RemoteURLs lists the clone's configured remote URLs, from its
// configuration only.
RemoteURLs(ctx context.Context) ([]gitlocal.Remote, error)
// Commits lists the commits reachable from head and not from base,
// oldest first.
Commits(ctx context.Context, base, head string) ([]gitlocal.Commit, error)
// Compare diffs the merge base of base and head against head.
Compare(ctx context.Context, base, head string) (bundle.Comparison, error)
// TextPatch diffs paths between exactly the two commits given.
TextPatch(ctx context.Context, baseOID, headOID string, paths ...string) ([]byte, error)
// Blob reads a file at a commit; a missing one is bundle.ErrNotFound.
Blob(ctx context.Context, commitOID, path string) ([]byte, error)
bundle.PinnedExport
}
Git reads the pull request's commits out of the local clone; *gitlocal.Repo implements it. Every method reads objects only: none changes the clone's refs, index or working tree.
type GitHub ¶
type GitHub interface {
Fetch(ctx context.Context, repo github.Repository, number int, opts github.FetchOptions) (github.Evidence, error)
}
GitHub reads one pull request's metadata, checks and conversation; *github.Client implements it.
type GroupMember ¶
GroupMember is one member of a review group, assembled on its own.
type GroupResult ¶
type GroupResult struct {
Result
// HunkMembers names, for each hunk of the merged diff, the members whose
// own diff holds it, in member order: a change two members both make is
// one hunk of both.
HunkMembers map[string][]int
}
GroupResult is the merged bundle of a review group.
func MergeGroup ¶
func MergeGroup(ctx context.Context, name string, members []GroupMember, previous *bundle.PreviousVersion, caps bundle.Caps, redactor *bundle.Redactor) (GroupResult, error)
MergeGroup merges the members' bundles, each assembled, redacted and fitted on its own, into the bundle of the group's combined review:
- the pull request header is the first member's (its number, branches and SHAs), titled with the group's name, with a body listing every member and its description, and every member's commits;
- the diff holds every member's hunks in member order, a hunk ID the earlier member already holds listed once;
- checks, conversation, threads, sessions and references are the union, each identifier once; description images are left out;
- FileComparisons holds one comparison per member, from its merge base, with its file changes before deduplication;
- previous is the group's latest version, its sections keeping only the pull requests still in the group.
The merged bundle is fitted to caps again and digested. The name is redacted like any other text; the members' text already is.
type ImageFetcher ¶
ImageFetcher downloads one description image from the signed URL GitHub rendered for it, reading at most maxBytes.
func NewHTTPImageFetcher ¶
func NewHTTPImageFetcher(transport http.RoundTripper) ImageFetcher
NewHTTPImageFetcher downloads description images over HTTPS. GitHub renders each image's source already signed, so the request carries no credentials of its own (the user's token is what asked GitHub for the signed source), and only GitHub's upload and asset hosts are contacted, redirects included. A nil transport is http.DefaultTransport.
type Limits ¶
type Limits struct {
Caps bundle.Caps
Checkout bundle.CheckoutConfig
// MaxImages and MaxImageBytes bound the description images downloaded.
MaxImages int
MaxImageBytes int64
}
Limits are the caps one assembly runs within.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits are the limits with no override in the config file.
func LimitsFrom ¶
LimitsFrom reads limits from caps by the names of config.CapDefaults. A name missing from caps is zero, which the bundle package reads as its own "unlimited" or "none" for that cap, so pass config.Config.EffectiveCaps.
type LocalSessions ¶
type LocalSessions struct {
// Dir is the clone, or a directory inside it.
Dir string
// Stores narrows or redirects the session stores, and carries the
// directories the repository used to live at.
Stores sessions.Options
// Warn receives a line for each store file that could not be read.
Warn io.Writer
}
LocalSessions finds the sessions recorded on this machine for the clone containing Dir, through locallink.BuildSessionEvidence.
type MissingCommitError ¶
type MissingCommitError struct {
// Role is "head" or "base".
Role string
SHA string
Number int
// BaseRef is the base branch's name.
BaseRef string
// Remote is the clone's remote whose URL names the pull request's
// repository; "" when none does, and Repository is then named in the hint.
Remote string
Repository string
// Fetch is why fetching the commit failed; nil when it was not fetched.
Fetch error
}
MissingCommitError reports a pull request commit that is not in the clone, either because the assembly had no Fetcher or because fetching it failed.
func (*MissingCommitError) Error ¶
func (e *MissingCommitError) Error() string
func (*MissingCommitError) Unwrap ¶
func (e *MissingCommitError) Unwrap() []error
type Request ¶
type Request struct {
Repository github.Repository
Number int
Limits Limits
// Previous is the pull request's current document, in the form the
// hosted builder carries it into the next version's bundle; nil when
// there is none, as for "baum internal bundle".
Previous *bundle.PreviousVersion
// Checkout, when not nil, receives the checkout archive "baum internal generate"
// reads: a gzip-compressed tar holding the head/ and merge-base/ trees,
// as bundle.UnpackCheckout unpacks it. Nil exports the same trees to
// nowhere, since what the budget omits still shapes the bundle.
Checkout io.Writer
// Attachments, when not nil, receives the description images as a plain
// tar of attachments/<id>.<ext>, as bundle.UnpackAttachments unpacks it.
Attachments io.Writer
// Facts builds the bundle a pull request's facts are read from
// (review.BuildFacts), which no model reads: the head/ and merge-base/
// trees are not exported and no description image is downloaded, so
// hunks keep their text whatever the checkout budget, and the bundle has
// no attachments. Checkout and Attachments must then be nil.
Facts bool
}
Request names the pull request and the limits its bundle is built within.
type Result ¶
type Result struct {
// Bundle is the redacted, trimmed bundle with its Digest and
// MaskedSpanCount set.
Bundle bundle.Bundle
// JSON is the bundle as written: the encoding the digest is the SHA-256
// of, plus a final newline.
JSON []byte
// Head, Base and MergeBase are the commits the bundle describes.
Head, Base, MergeBase string
// Images are the description images in the attachments archive.
Images []bundle.DescriptionImage
}
Result is an assembled bundle.
type Sessions ¶
type Sessions interface {
Evidence(ctx context.Context, commits []gitlocal.Commit, maxPrompts, maxCommandEvents int) ([]bundle.Session, error)
}
Sessions finds the coding-agent sessions linked to the pull request's commits, as the bundle's sessions, unredacted: the assembler's redaction masks them with the rest of the bundle.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assembletest builds the synthetic inputs of bundle assembly tests: a git clone whose pull request exercises every kind of change, a fake GitHub that returns evidence for it, and a fake session source.
|
Package assembletest builds the synthetic inputs of bundle assembly tests: a git clone whose pull request exercises every kind of change, a fake GitHub that returns evidence for it, and a fake session source. |