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 ¶
const ( // AttributionIsolated: the smallest reproducing subsets were found and // every smaller subset ran and passed. AttributionIsolated = "isolated" // AttributionBase: the failure reproduces on the base without any branch. AttributionBase = "base" // AttributionInconclusive: the budget ran out, or a smaller subset could // not be compared (error, timeout, different failure, conflict). AttributionInconclusive = "inconclusive" )
Attribution outcomes. Only "isolated" names branches as observed causes.
const ( SubsetReproduced = "reproduced" SubsetPassed = "passed" SubsetDifferentFailure = "different_failure" SubsetNotComparable = "not_comparable" )
Subset run results.
const ( StageCombine = "combine" StageAnalyze = "analyze" StageTest = "test" // StageAttribute reruns a failed command on fewer branches. StageAttribute = "attribute" )
const DefaultAttributionRuns = 8
DefaultAttributionRuns is a suggested budget when opting in to observed attribution: enough for every subset of three branches. The CLI defaults to zero additional executions; callers must explicitly request this budget.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attribution ¶ added in v0.2.0
type Attribution struct {
FindingID string `json:"finding_id"`
SelectionID string `json:"selection_id,omitempty"`
Command []string `json:"command"`
CWD string `json:"cwd"`
Outcome string `json:"outcome"`
Evidence model.Evidence `json:"evidence"`
// Reproducing lists the smallest subsets, as indexes into Report.Inputs,
// that reproduced the failure. With outcome isolated they are minimal.
Reproducing [][]int `json:"reproducing"`
Runs []SubsetRun `json:"runs"`
Explanation string `json:"explanation"`
}
Attribution reruns one failed command on the base plus subsets of the input branches. Every run is a single observation of a separately built candidate; a flaky test can make a subset look clean or broken.
func RunObservedAttribution ¶ added in v0.2.0
func RunObservedAttribution(ctx context.Context, c *Candidate, r Report, o Options) ([]Attribution, error)
RunObservedAttribution runs bounded diagnostic subset executions after Fast Gate has completed. It neither repeats analysis nor changes the report's verdict, checks, selection or execution evidence. The caller retains and closes c, and may publish the gate before starting this separate path. Execution requires the same explicit authorization as Analyze. The supplied report and its failed observations must belong to this exact pinned candidate.
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 ¶
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 BuildDirtyCandidate ¶ added in v0.2.0
func BuildDirtyCandidate(ctx context.Context, root, base string, branches []string, snapshots []DirtySnapshot) (*Candidate, error)
BuildDirtyCandidate overlays faithful snapshots on their pinned heads in private repositories, then reuses the ordinary candidate merge engine. Every dirty input is a deterministic synthetic commit bound to its digest.
type DirtySnapshot ¶ added in v0.2.0
type DirtySnapshot struct {
Worktree string `json:"worktree"`
Branch string `json:"branch,omitempty"`
// InputIndex associates a snapshot with a pinned input; -1 requests unique matching.
InputIndex int `json:"input_index"`
Head string `json:"head"`
Digest string `json:"digest"`
Staged []string `json:"staged"`
Unstaged []string `json:"unstaged"`
Untracked []string `json:"untracked"`
// contains filtered or unexported fields
}
DirtySnapshot pins the final saved worktree state and its separate index provenance. Contents are private to the builder and never serialized.
func ObserveDirty ¶ added in v0.2.0
func ObserveDirty(ctx context.Context, w gitrepo.WorktreeStatus) (DirtySnapshot, error)
ObserveDirty captures twice, including index blob identities and saved file bytes. A changing, unreadable or unsupported snapshot is never verified.
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
// AttributionRuns, when positive, reruns each failed command on the base
// plus subsets of the branches, within the same time budget, spending at
// most this many executions. It requires Verify. Set zero for Fast Gate,
// then call RunObservedAttribution separately after publishing its result.
AttributionRuns 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"`
// Attributions rerun failed commands on subsets of the branches.
Attributions []Attribution `json:"observed_attributions,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 ¶
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 ¶
Preview builds the candidate for o.Base and o.Branches, analyzes it and removes the private repository before returning.
func (Report) ObservedAttribution ¶ added in v0.2.0
func (r Report) ObservedAttribution(findingID string) *Attribution
ObservedAttribution returns the attribution recorded for a finding.
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 SubsetRun ¶ added in v0.2.0
type SubsetRun struct {
// Branches are indexes into Report.Inputs; empty means the base alone.
Branches []int `json:"branches"`
Inputs []string `json:"inputs"`
CandidateCommit string `json:"candidate_commit,omitempty"`
CandidateTree string `json:"candidate_tree,omitempty"`
Conflicts []string `json:"conflicts,omitempty"`
Status model.Status `json:"status"`
ExitCode int `json:"exit_code"`
OutputDigest string `json:"output_digest,omitempty"`
FailedCases []string `json:"failed_cases,omitempty"`
Result string `json:"result"`
Error string `json:"error,omitempty"`
}
SubsetRun is one execution of the failed command on base plus Branches.
type UnsupportedEntryError ¶
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