kernel

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package kernel holds the shared domain value objects — PR, Message, Event, Sender, ReviewState — and the cross-domain enums used by the notification, review, and routing domains.

It is the pure center of the hexagon: it imports nothing from other internal/... packages (a depguard rule enforces this) and carries no persistence, transport, or SDK concerns. Types arrive here as their owning domains migrate onto the DDD/fx architecture; notification (Phase 5) is the first to populate it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Provider   Provider
	Kind       EventKind
	Repository string

	PR PR

	Sender Sender
}

Event is the immutable, provider-neutral record of an incoming pull-request-related webhook, detached from any HTTP payload type. The inbound adapter builds it — mapping provider vocabulary to a Kind and resolving Sender.IsBot — and handlers inspect only the neutral fields to decide whether to run.

type EventKind added in v0.22.0

type EventKind int

EventKind is the provider-neutral classification of an inbound pull-request webhook. Each inbound adapter maps its provider's own vocabulary (event names, action strings, review states, draft gating) onto one of these kinds; handlers match on the kind alone and never see provider verbs.

The zero value KindUnknown marks a payload no handler acts on — the adapter returns it for draft opens, synchronize/label churn, plain-issue comments, and anything unmapped, so the dispatcher debug-logs no_handler exactly as before.

const (
	KindUnknown EventKind = iota
	KindOpened
	KindReadyForReview
	KindClosed
	KindMerged
	KindConvertedToDraft
	KindApproved
	KindChangesRequested
	KindCommented
	KindReviewCommented
)

Recognised event kinds. KindReviewCommented is distinct from KindCommented: a submitted review carrying only comments finishes the PR's review session, whereas a line/conversation comment (or an edited review) does not.

func (EventKind) String added in v0.22.0

func (k EventKind) String() string

String returns the neutral log token for the kind, used in the ignored-event log contract (the kind field).

type PR

type PR struct {
	Number int
	Title  string
	URL    string
	Author string
	Merged bool
	Draft  bool
	// Body is the PR description, consulted to tell a Dependabot/Renovate
	// security advisory from a routine bump.
	Body string
	// CreatedAt is the PR's open time, rendered as a localized date token in the
	// Slack context line. Zero when the payload omits it.
	CreatedAt time.Time
}

PR holds the pull-request fields the notification handlers and message composer read. It is detached from any webhook payload or persistence type.

type Provider added in v0.22.0

type Provider string

Provider is the git host a deployment serves and an event originates from. It is a named type rather than a bare string so a provider value can never be crossed with an arbitrary string: every call site names one of the constants below, and config, routing, and the inbound adapter share this one enum. The inbound adapter stamps it on every event so handlers, the store, and logs stay provider-agnostic.

const (
	ProviderGitHub    Provider = "github"
	ProviderBitbucket Provider = "bitbucket"
)

Recognised git providers. A deployment serves exactly one, selected by the required git_provider config key.

func (Provider) PullRequestWebURL added in v0.22.3

func (p Provider) PullRequestWebURL(repository string, number int) string

PullRequestWebURL builds the browser URL for a pull request from its repository slug and number. The store keeps no URL, so callers that hold only repo+number (the digest reminder, the reconciler's log lines) reconstruct it here. An unknown or zero-value provider falls back to the github.com form.

func (Provider) String added in v0.22.0

func (p Provider) String() string

String returns the wire/log token for the provider — the value used for the git_provider config key and the ignored-event log's provider field.

type Sender

type Sender struct {
	Login string
	IsBot bool
}

Sender identifies the actor that fired a webhook — the reviewer for review events, the PR author for opened events, etc. IsBot is resolved by the inbound adapter from the provider's own signal (GitHub's sender.type == "Bot"); the per-repo ignore-AI-reviews policy consults it without knowing any provider vocabulary.

Jump to

Keyboard shortcuts

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