Documentation
¶
Overview ¶
Package trust provides the boolean-combinator trust-decision framework for the maintainer-watcher-github-pr. Callers compose leaves with And, Or, and Not to express compound trust policies without modifying the watcher core.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type And ¶
type And []Trust
And succeeds only if every member succeeds. Evaluates ALL members (no short-circuit) to produce a complete audit trail. An empty And returns vacuous success — callers must ensure non-empty slices for security-relevant decisions (startup validation enforces this).
type Func ¶
Func adapts a plain function to the Trust interface. Useful for inline trust checks without struct boilerplate.
type Or ¶
type Or []Trust
Or succeeds if any member succeeds. Evaluates ALL members (no short-circuit) to produce a complete audit trail. An empty Or returns vacuous failure — callers must ensure non-empty slices for security-relevant decisions.
type PR ¶
type PR struct {
AuthorLogin string
// HeadRepoFullName is the head repository's `owner/repo` full name as
// GitHub reports it (`pr.head.repo.full_name`). Empty when the head repo
// is unknown — a deleted fork, or a PR derived from the Search API, which
// does not carry it.
HeadRepoFullName string
// BaseRepoFullName is the base repository's `owner/repo` full name
// (`pr.base.repo.full_name`). Empty when unknown.
BaseRepoFullName string
}
PR is the trust-evaluation input derived from a GitHub pull request. Only the fields needed for trust decisions are included.
type Result ¶
Result captures a trust decision and a human-readable description. The description is the audit trail: why was this PR trusted or denied?
type Trust ¶
Trust is the single-method trust-decision interface. Each implementation returns both an outcome (trusted/denied) and a human-readable description forming the audit trail for the decision.
func NewAuthorAllowlist ¶
NewAuthorAllowlist returns a Trust leaf that grants trust by exact GitHub login membership (case-sensitive byte equality).
Fail-safe rules:
- Empty members list → always denies.
- PR with empty AuthorLogin → always denies (author unknown).
Operators are responsible for matching GitHub's stored casing.
func NewSameRepo ¶ added in v0.16.0
func NewSameRepo() Trust
NewSameRepo returns a Trust leaf that grants trust only when the pull request's head repository is the base repository it targets.
An author login is not an ownership proof: a workflow running in a fork that opens a pull request against upstream renders as the same login (for example `github-actions[bot]`), so trusting that login alone would let a fork pull request be auto-reviewed. Comparing the head and base repository full names closes that hole.
Fail-safe rules:
- Unknown head repo (empty HeadRepoFullName) → always denies.
- Unknown base repo (empty BaseRepoFullName) → always denies.
- Both empty never compares equal: the emptiness checks run first.
The comparison is exact byte equality, matching NewAuthorAllowlist's handling of logins.