facts

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package facts is the structured snapshot of the world a decision reads (ADR-003: probed fresh before every decision, never trusted from an event). It holds labels, states, counts and check conclusions, never free text, so a ticket body cannot steer a decision (NFR-5).

Index

Constants

View Source
const StatusExpected = "expected"

StatusExpected is the status of a required check that has not reported: no check run or commit status of its name (and App, if it is bound to one) exists on the head yet.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name       string `json:"name"`
	Status     string `json:"status"`     // expected, queued, in_progress, completed
	Conclusion string `json:"conclusion"` // success, failure, neutral, cancelled, skipped, timed_out, action_required, ""
	Required   bool   `json:"required"`
	// App is the slug of the GitHub App that reported a check run, and AppID its id. Both are
	// empty for a commit status, which has no App. On an expected check AppID is the App the
	// requirement is bound to, if it is bound to one, and App is empty.
	App   string `json:"app,omitempty"`
	AppID int64  `json:"app_id,omitempty"`
}

Check is one check run or commit status on the pull request's head, or a required check that has not reported yet.

type Facts

type Facts struct {
	Ticket *Ticket `json:"ticket,omitempty"`
	PR     *PR     `json:"pr,omitempty"`
	Lane   *Lane   `json:"lane,omitempty"`
}

Facts is one consistent snapshot, recorded with the decision so it can be replayed.

func (Facts) CEL

func (f Facts) CEL() map[string]any

CEL is the facts as the guard environment sees them.

type Lane

type Lane struct {
	Paused        bool   `json:"paused"`
	PausedReason  string `json:"paused_reason,omitempty"`
	OpenProposals int    `json:"open_proposals"`
}

Lane is the lane's own state: whether a human or a stop condition paused it, and how many of its proposals are waiting on review (ADR-010).

type PR

type PR struct {
	Number  int     `json:"number"`
	State   string  `json:"state"` // open, closed
	Merged  bool    `json:"merged"`
	Draft   bool    `json:"draft"`
	Fork    bool    `json:"fork"`
	HeadSHA string  `json:"head_sha"`
	HeadRef string  `json:"head_ref"`
	Checks  []Check `json:"checks"`
	// RequiredUnknown is true when neither branch protection nor the rulesets could be read, so
	// no check is marked required and every check gates (CIState).
	RequiredUnknown  bool `json:"required_unknown,omitempty"`
	ChangesRequested bool `json:"changes_requested"`
	Approved         bool `json:"approved"`
}

PR is a pull request's structured state.

func (PR) CIState

func (p PR) CIState() string

CIState summarises the checks that gate the pull request: required ones if any are marked, otherwise all of them. It is pending until every gating check has concluded, which includes a required check that has not started.

func (PR) Failed

func (p PR) Failed() []string

Failed lists the gating checks that failed.

type Ticket

type Ticket struct {
	Key    string `json:"key"`              // the tracker's own key: owner/name#77, PLAT-881
	Number int    `json:"number,omitempty"` // a GitHub issue's number; 0 elsewhere
	// Repo is the repository the ticket itself names for its code, from a structured field its
	// tracker is configured to read; empty when it names none (ADR-002).
	Repo   string   `json:"repo,omitempty"`
	State  string   `json:"state"` // open, closed
	Labels []string `json:"labels"`
}

Ticket is an issue's structured state.

Jump to

Keyboard shortcuts

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