Help us shape the future of Go! Take the 2026 Go Developer Survey

integration

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package integration previews merges in a private object database. It never shares writable Git state with the user's repository. This is filesystem isolation, not an OS security sandbox; executing candidate code is opt-in.

The Candidate built here is the one "candidate" across Radar: evidence pins its identity as a CandidateCheckpoint when recording executions, and verification accepts only records bound to that exact checkpoint.

Index

Constants

View Source
const (
	StageCombine = "combine"
	StageAnalyze = "analyze"
	StageTest    = "test"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	// Source is the repository the objects were copied from.
	Source string
	// Dir is the private repository holding the candidate checkout.
	Dir       string
	Base      string
	Inputs    []string
	Commit    string
	Tree      string
	Conflicts []string
}

Candidate is the combined commit built from pinned inputs in a private Git repository. Commit and Tree are empty when Conflicts is not. Close removes the private repository; the source repository is never written.

func BuildCandidate

func BuildCandidate(ctx context.Context, root, base string, branches []string) (*Candidate, error)

BuildCandidate pins base and branches to commit SHAs and merges the branches, in order, onto the base in a private repository. Without branches the candidate is the base itself. Textual conflicts are reported in Conflicts rather than as an error. The caller must Close the candidate.

func (*Candidate) Close

func (c *Candidate) Close() error

Close removes the private repository. It is safe to call more than once.

type Check

type Check = gate.Check

type ExecutionEvidence

type ExecutionEvidence struct {
	PlanRecord           *evidence.Record              `json:"plan_record,omitempty"`
	ExecutionError       string                        `json:"execution_error,omitempty"`
	SelectionID          string                        `json:"selection_id,omitempty"`
	CWD                  string                        `json:"cwd,omitempty"`
	Observation          evidence.CandidateObservation `json:"observation"`
	ID                   string                        `json:"id"`
	CandidateCommit      string                        `json:"candidate_commit"`
	CandidateTree        string                        `json:"candidate_tree"`
	Base                 string                        `json:"base"`
	Inputs               []string                      `json:"inputs"`
	PlanDigest           string                        `json:"plan_digest,omitempty"`
	Command              []string                      `json:"command"`
	Status               model.Status                  `json:"status"`
	ExitCode             int                           `json:"exit_code"`
	OutputDigest         string                        `json:"output_digest"`
	StartedAt            string                        `json:"started_at"`
	DurationMS           int64                         `json:"duration_ms"`
	SourceAfterExecution string                        `json:"source_after_execution"`
}

ExecutionEvidence binds an observation to the combined tree and ordered inputs. Individual branch evidence is deliberately never consumed.

type Options

type Options struct {
	SuggestTests           bool
	Suite                  string
	CWD                    string
	Policy                 *gate.Policy
	Plan                   *planning.Plan
	Base                   string
	Branches               []string
	Verify, AllowExecution bool
	Command                []string
	Timeout                time.Duration
	PlanDigest             string
	// MaxCommands bounds a selected suite after grouping (default 16).
	MaxCommands int
	// Progress, when set, hears what the gate is doing so a terminal can
	// show it live. It is presentation only and never affects the report.
	Progress func(Step)
	// contains filtered or unexported fields
}

type Report

type Report struct {
	VerificationProposal *testselection.Proposal `json:"verification_proposal,omitempty"`
	// Selection is the bounded execution plan for a --suite mode, including
	// omitted commands and the reasons a required command did not run.
	Selection       *testselection.Selection `json:"selection,omitempty"`
	Selected        []string                 `json:"selected_tests,omitempty"`
	Executions      []ExecutionEvidence      `json:"executions,omitempty"`
	Gate            gate.Result              `json:"gate"`
	Coverage        []gate.Coverage          `json:"coverage"`
	Plan            *planning.Report         `json:"plan,omitempty"`
	Status          model.Status             `json:"status"`
	Base            string                   `json:"base"`
	Inputs          []string                 `json:"inputs"`
	CandidateCommit string                   `json:"candidate_commit,omitempty"`
	CandidateTree   string                   `json:"candidate_tree,omitempty"`
	Conflicts       []string                 `json:"conflicts"`
	Changed         []string                 `json:"changed"`
	Affected        []string                 `json:"affected"`
	// AffectedBy maps each affected file to the changed files it reaches
	// through inferred import dependencies.
	AffectedBy  map[string][]string `json:"affected_by,omitempty"`
	Checks      []Check             `json:"checks"`
	Findings    []model.Finding     `json:"findings"`
	Diagnostics []model.Diagnostic  `json:"diagnostics"`
	Execution   *ExecutionEvidence  `json:"execution,omitempty"`
	Limitations []string            `json:"limitations"`
	// ContractObligations lists base contract declarations the candidate
	// removed, narrowed, moved or retired; see contracts.ObligationChange.
	ContractObligations []contracts.ObligationChange `json:"contract_obligations,omitempty"`
	// DeclaredBindings counts the declared contract bindings analyzed, so a
	// passing contract check with nothing declared is not shown as a check.
	DeclaredBindings int `json:"-"`
	// contains filtered or unexported fields
}

func Analyze

func Analyze(ctx context.Context, c *Candidate, o Options) (Report, error)

Analyze checks a built candidate: contracts, discovered relationships, dependency impact, test selection and, when authorized, execution. o.Base and o.Branches are ignored; the candidate's pinned inputs are analyzed.

func Preview

func Preview(ctx context.Context, root string, o Options) (Report, error)

Preview builds the candidate for o.Base and o.Branches, analyzes it and removes the private repository before returning.

type Step

type Step struct {
	Repo  string // workspace repository ID, set by multi-repository callers
	Stage string // StageCombine, StageAnalyze or StageTest
	// Index and Total place a test command (1-based) in the selection.
	Index, Total int
	Command      []string
}

Step is one progress notification.

type UnsupportedEntryError

type UnsupportedEntryError struct {
	Path   string
	Unsafe error
}

UnsupportedEntryError reports a tree entry the private candidate cannot reproduce faithfully: a symlink, a submodule or an unsafe path.

func (*UnsupportedEntryError) Error

func (e *UnsupportedEntryError) Error() string

func (*UnsupportedEntryError) Unwrap

func (e *UnsupportedEntryError) Unwrap() error

Jump to

Keyboard shortcuts

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