filter

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package filter implements the TaskCreationFilter chain.

Package filter implements the TaskCreationFilter chain — predicates that decide whether a vault task should be created for a PR at all.

This is one of two decision chains in the watcher:

  1. TaskCreationFilter (this package): "should we create a task?"
  2. trust.Trust (sibling package): "given we create a task, should it auto-process or route to human_review?"

See docs/watcher-decision-chains.md for the full split rationale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseRepoAllowlist

func ParseRepoAllowlist(_ context.Context, raw string) ([]string, error)

ParseRepoAllowlist parses a comma-separated allowlist string into a slice of host-qualified repo keys. Whitespace is trimmed; empty entries are skipped. Returns (nil, nil) for empty input (allow-all). Entry well-formedness is NOT validated here — repoallowlist.IsAllowed handles malformed entries gracefully at match time (logs and skips).

Types

type PR

type PR struct {
	AuthorLogin string
	IsDraft     bool
	Title       string
	UpdatedAt   libtime.DateTime
	RepoKey     string
}

PR is the filter-evaluation input derived from a GitHub pull request. Only the fields needed for task-creation filter decisions are included.

type TaskCreationFilter

type TaskCreationFilter interface {
	// Skip returns true if the PR should be excluded from task creation.
	Skip(pr PR) bool
}

TaskCreationFilter decides whether a single PR should be skipped (no vault task created). Implementations return true to skip.

func NewAgeFilter

func NewAgeFilter(maxAge libtime.Duration, referenceTime libtime.DateTime) TaskCreationFilter

NewAgeFilter returns a filter that skips PRs whose UpdatedAt is older than (referenceTime - maxAge). A zero maxAge disables the filter.

referenceTime is the watcher's startTime — captured once at process start and threaded through factory.CreateWatcher. This avoids any CurrentDateTimeGetter injection: a watcher pod's lifetime is bounded by its restart cadence (hours), and the age filter's granularity is days, so sub-day clock drift is irrelevant.

func NewBotAuthorFilter

func NewBotAuthorFilter(allowlist []string) TaskCreationFilter

NewBotAuthorFilter returns a filter that skips PRs whose author matches any entry in the configured allowlist (exact match). An empty allowlist never skips.

func NewDraftFilter

func NewDraftFilter() TaskCreationFilter

NewDraftFilter returns a filter that skips draft PRs (the author is signaling "not ready for review"). GitHub's draft state is the primary signal; literal "WIP" prefixes in the title are handled by a separate WIP filter (see wip_title_filter.go when added).

func NewRepoAllowlistFilter

func NewRepoAllowlistFilter(allowlist []string) TaskCreationFilter

NewRepoAllowlistFilter returns a TaskCreationFilter that skips PRs whose RepoKey is not in the allowlist. An empty allowlist never skips (allow-all).

func NewWIPTitleFilter

func NewWIPTitleFilter() TaskCreationFilter

NewWIPTitleFilter returns a filter that skips PRs whose title starts with "WIP:" or "WIP ". The author has explicitly signaled the PR is not ready for review.

type TaskCreationFilterFunc

type TaskCreationFilterFunc func(pr PR) bool

TaskCreationFilterFunc adapts a function to the TaskCreationFilter interface (function-as-implementation, useful for inline filters).

func (TaskCreationFilterFunc) Skip

func (f TaskCreationFilterFunc) Skip(pr PR) bool

Skip implements TaskCreationFilter for the function adapter.

type TaskCreationFilters

type TaskCreationFilters []TaskCreationFilter

TaskCreationFilters is a slice composite: skip if ANY member votes skip. An empty slice never skips (no filters configured = process every PR).

func (TaskCreationFilters) Skip

func (fs TaskCreationFilters) Skip(pr PR) bool

Skip returns true if any contained filter votes skip. Iteration is short-circuit on first hit (filters are pure predicates with no side effects, so there is no audit-trail concern).

Jump to

Keyboard shortcuts

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