Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetVersion ¶
func SetVersion(v string)
Types ¶
type RulesSource ¶ added in v0.14.0
type RulesSource struct {
// Repo is "owner/name"; empty reads marge's own repository.
Repo string
// Ref is the branch the catalogue is read from.
Ref string
// Path reads a directory on disk instead of a repository, for
// developing a rule before it is merged.
Path string
}
RulesSource selects where the rule catalogue is read from.
type RunOptions ¶
type RunOptions struct {
DryRun bool
Watch bool
// NoTUI disables the live table and prints plain-text results to
// stdout once processing finishes.
NoTUI bool
// Quiet suppresses every human-readable line: the live table and the
// plain-text results on stdout as well as the progress and summary
// lines on stderr. The caller reads the outcome from the returned
// PRStatus instead. `marge serve` sets it because stdout is the MCP
// stdio transport there and must carry nothing but JSON-RPC. Quiet
// implies NoTUI.
Quiet bool
MergeAuto bool
// Team scopes the sweep to the repositories listed in that team's file
// in giantswarm/github. Empty means the query scope.
Team string
// Query is the GitHub search text of the query scope.
Query string
// Actions selects the sweep steps; see process.ParseActions.
Actions process.ActionSet
// CheckTimeout is how long one PR waits for pending checks; zero means
// no wait.
CheckTimeout time.Duration
// Policies is the sweep policy of the scope, resolved from the policy
// files by resolveScope before the sweep starts.
Policies *policy.Set
// Rules is the rule catalogue, loaded from marge's own repository
// before the sweep starts. Nil refuses every remedy and leaves
// classification, approval and merging unchanged.
Rules *rules.Catalogue
Org string
ReposFile string // repositories to scan instead of searching GitHub; see resolveScope
Grouping string
SecurityPatterns string
Cols []pr.TableColumn
}
RunOptions holds the configuration shared between the run and sweep commands.
type SweepConcurrency ¶ added in v0.13.0
SweepConcurrency is the concurrency section of a resolved policy.
type SweepPREntry ¶
type SweepPREntry struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
Number int `json:"number"`
Title string `json:"title"`
URL string `json:"url"`
Status string `json:"status"`
Detail string `json:"detail,omitempty"`
// Kind is the bot that authored the PR; UpdateType the size of the
// update it carries; Label the bot-prs-sweep/<class> label that is on
// the PR after the sweep, empty when nothing was written.
Kind string `json:"kind,omitempty"`
UpdateType string `json:"update_type,omitempty"`
Label string `json:"label,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
AgeDays int `json:"age_days,omitempty"`
// Rescue describes the most recent prior automated rescue attempt
// found on the PR (an ai-rescue marker comment), if any. Consumers
// dispatching rescue agents should skip entries with a non-stale
// failed rescue and escalate them to a human instead.
Rescue *SweepRescueInfo `json:"rescue,omitempty"`
// Reason says why an obsolete PR is obsolete: "superseded" or "no_op".
// Only set on entries in the obsolete list.
Reason string `json:"reason,omitempty"`
// Policy is the sweep policy this PR was decided under, so an outcome
// explains itself without the reader resolving the files again.
Policy *SweepPolicyInfo `json:"policy,omitempty"`
}
SweepPREntry represents a single PR in the sweep results.
type SweepPolicyInfo ¶ added in v0.13.0
type SweepPolicyInfo struct {
Sweep bool `json:"sweep"`
// UpdateTypes lists the update types that merge when green, per bot PR
// kind.
UpdateTypes map[string][]string `json:"update_types"`
Schedule bool `json:"schedule"`
Rescue SweepRescuePolicy `json:"rescue"`
Concurrency SweepConcurrency `json:"concurrency"`
ModelConfig string `json:"model_config,omitempty"`
SlackChannel string `json:"slack_channel,omitempty"`
// Sources names the files that produced the policy, in the order they
// were applied.
Sources []string `json:"sources,omitempty"`
}
SweepPolicyInfo is the JSON projection of a pr.Policy.
type SweepRepoFailure ¶ added in v0.12.0
SweepRepoFailure names a repository the sweep could not list.
type SweepRescueInfo ¶
type SweepRescueInfo struct {
Tool string `json:"tool,omitempty"`
Outcome string `json:"outcome"`
Reason string `json:"reason,omitempty"`
At string `json:"at,omitempty"`
// Stale is true when the PR content changed since the rescue attempt
// -- the attempt no longer describes the current code and the PR is
// fair game for another rescue.
Stale bool `json:"stale"`
// Rebased is true when the PR head moved since the rescue attempt but
// the change did not (a Renovate rebase onto a newer base): the marker
// still describes the current code and Stale is false.
Rebased bool `json:"rebased"`
}
SweepRescueInfo is the JSON projection of a pr.RescueMarker.
type SweepRescuePolicy ¶ added in v0.13.0
type SweepRescuePolicy struct {
Enabled bool `json:"enabled"`
Timeout string `json:"timeout,omitempty"`
Weekly int `json:"weekly"`
// BudgetPerRescueUSD and BudgetWeeklyUSD are what the team declared.
// BudgetEnforced says whether this build applies them; it is false
// until the platform accepts a budget on a run and reports the cost of
// a finished one.
BudgetPerRescueUSD float64 `json:"budget_per_rescue_usd,omitempty"`
BudgetWeeklyUSD float64 `json:"budget_weekly_usd,omitempty"`
BudgetEnforced bool `json:"budget_enforced"`
// RescuesDispatched says whether this build dispatches a rescue at all.
// While it is false Timeout and Weekly are declared and neither of them
// bounds anything.
RescuesDispatched bool `json:"rescues_dispatched"`
Confirm string `json:"confirm,omitempty"`
}
SweepRescuePolicy is the rescue section of a resolved policy.
type SweepResult ¶
type SweepResult struct {
Summary SweepSummary `json:"summary"`
// Rules says which rule catalogue the sweep ran, and what it could not
// use. An absent catalogue leaves every remedy refused.
Rules *SweepRules `json:"rules,omitempty"`
// Unhandled groups the failures no rule recognised, most frequent
// first. A signature here is what `marge rules draft` takes.
Unhandled []SweepUnhandled `json:"unhandled,omitempty"`
Merged []SweepPREntry `json:"merged,omitempty"`
SecurityFailures []SweepPREntry `json:"security_failures,omitempty"`
ActionRequired []SweepPREntry `json:"action_required,omitempty"`
// Stale lists failing PRs whose head is behind the base branch and whose
// every failing check is green on the base branch head: the failure was
// fixed on the base branch after the PR's last build. The remedy is a
// branch refresh (the refresh action), not a rescue, so they are excluded from
// action_required.
Stale []SweepPREntry `json:"stale,omitempty"`
// Refreshed lists stale PRs whose branch was updated from its base in
// this run. CI is running again; the next sweep decides what they are.
Refreshed []SweepPREntry `json:"refreshed,omitempty"`
// Cancelled lists failing PRs whose every failing check is a CircleCI
// build that CircleCI itself auto-cancelled: there is no verdict on the
// code yet. The remedy is a retry (the retry action), not a rescue, so
// they are excluded from action_required. A build cancelled behind a
// newer head is listed too but never retried: the new head's own build
// is the verdict.
Cancelled []SweepPREntry `json:"cancelled,omitempty"`
// Retried lists cancelled PRs whose workflow was rerun on the same
// commit in this run. CI is running again; the next sweep decides.
Retried []SweepPREntry `json:"retried,omitempty"`
// budget / spending-limit block prevented every job from starting. These
// are NOT failures: the remedy is to raise or await the Actions budget,
// so they are reported separately and excluded from action_required.
CIUnavailable []SweepPREntry `json:"ci_unavailable,omitempty"`
// CINoVerdict lists PRs whose every failing check established nothing
// about the code: a cancelled job, or a pipeline a CircleCI project
// setting refuses. These are NOT failures, and a security check in this
// shape is NOT a finding, so they are excluded from action_required and
// security_failures. Each entry's detail names its own remedy.
CINoVerdict []SweepPREntry `json:"ci_no_verdict,omitempty"`
// Obsolete lists bot PRs that are not worth fixing: a sibling PR carries
// a higher version of the same dependency, or the diff changes nothing
// that executes. Each entry's reason says which. The remedy is to close
// them, so they are excluded from action_required.
Obsolete []SweepPREntry `json:"obsolete,omitempty"`
// Waiting lists PRs whose required checks have not all reported: a
// required context is pending or was never reported. The sweep never
// merges past a required check; the next sweep decides.
Waiting []SweepPREntry `json:"waiting,omitempty"`
Skipped []SweepPREntry `json:"skipped,omitempty"`
// RepositoriesFailed lists the repositories whose PRs could not be
// listed, so a partial sweep is visible as such.
RepositoriesFailed []SweepRepoFailure `json:"repositories_failed,omitempty"`
}
SweepResult is the structured JSON output returned by the sweep MCP tool.
type SweepRules ¶ added in v0.14.0
type SweepRules struct {
// Source names the repository, ref and directory, or the local path.
Source string `json:"source"`
// Ref is the branch the catalogue was read from, absent for a local
// directory.
Ref string `json:"ref,omitempty"`
// Digest identifies the exact documents this sweep ran, whether they
// came from a repository or a local directory.
Digest string `json:"digest,omitempty"`
// Loaded counts the rules the sweep could use.
Loaded int `json:"loaded"`
// Skipped names the documents that failed to validate, with the reason.
// They cost their own rule and nothing more.
Skipped []SweepSkippedRule `json:"skipped,omitempty"`
// Error says why no catalogue could be read at all.
Error string `json:"error,omitempty"`
}
SweepRules reports the rule catalogue of one sweep.
type SweepSkippedRule ¶ added in v0.14.0
SweepSkippedRule is one document the catalogue could not use.
type SweepSummary ¶
type SweepSummary struct {
Total int `json:"total"`
Merged int `json:"merged"`
Failed int `json:"failed"`
SecurityFailures int `json:"security_failures"`
// Actions budget block. It is disjoint from Failed and SecurityFailures.
CIUnavailable int `json:"ci_unavailable"`
// CINoVerdict counts PRs whose every failing check established nothing
// about the code. It is disjoint from Failed and SecurityFailures.
CINoVerdict int `json:"ci_no_verdict"`
// Stale counts failing PRs whose failure is already fixed on the base
// branch (see SweepResult.Stale); Refreshed counts the stale PRs whose
// branch was updated in this run. Both are disjoint from Failed.
Stale int `json:"stale"`
Refreshed int `json:"refreshed"`
// Cancelled counts failing PRs whose failing builds CircleCI itself
// cancelled (see SweepResult.Cancelled); Retried counts the cancelled
// PRs whose builds were retried in this run. Both are disjoint from
// Failed.
Cancelled int `json:"cancelled"`
Retried int `json:"retried"`
// Obsolete counts bot PRs that are not worth fixing, whether a
// higher-version sibling replaced them or their diff changes nothing
// that executes. Disjoint from Failed.
Obsolete int `json:"obsolete"`
// Waiting counts PRs whose required checks have not all reported.
Waiting int `json:"waiting"`
Skipped int `json:"skipped"`
}
type SweepUnhandled ¶ added in v0.17.0
type SweepUnhandled struct {
Signature string `json:"signature"`
Checks []string `json:"checks"`
Count int `json:"count"`
PRs []string `json:"prs"`
// Excerpt is the log a rule would match against, from the first PR of
// the group. Empty when no rule asked for a log.
Excerpt string `json:"excerpt,omitempty"`
}
SweepSummary contains aggregate counts from the sweep.
Failed and SecurityFailures are disjoint: Failed counts only the non-security failure entries, so consumers can use Failed + SecurityFailures to get the total number of action-required PRs without double-counting. SweepUnhandled is one shape of failure the catalogue does not recognise, with the PRs that carry it.