Documentation
¶
Overview ¶
Package domain defines the diagnostics domain's ports, DTOs, and constants — the operator-tooling contracts (preflight doctor, config CLI, smoke delivery). It imports only the standard library, the shared kernel, and the validation and routing domains.
Index ¶
- Variables
- type ConfigSnapshot
- type Doctor
- type EntrySource
- type LockGateway
- type LockPlan
- type Section
- type Signer
- type Smoke
- type SmokeCleanup
- type SmokeConfig
- type SmokeMappings
- type SmokeMessage
- type SmokeMessages
- type SmokeReactionCheck
- type SmokeReactions
- type SmokeReactionsConfig
- type SmokeResult
- type WebhookSender
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMapping means the repository is absent from mappings. Returned // before any network call so the operator fixes config first. ErrNoMapping = errors.New("smoke: repository not present in mappings") // ErrSignatureRejected means the server answered 401 — the secret this // command signed with does not match the one the server runs with. ErrSignatureRejected = errors.New("smoke: server rejected the signature") // ErrUnreachable means the POST never reached a server. ErrUnreachable = errors.New("smoke: could not reach the server") // ErrUnexpectedStatus means the server answered with a non-200, non-401 code. ErrUnexpectedStatus = errors.New("smoke: unexpected response status") )
Sentinel errors let callers render clear remediation messages and pick exit codes without parsing strings or leaking a stack trace.
Functions ¶
This section is empty.
Types ¶
type ConfigSnapshot ¶
type ConfigSnapshot struct {
ConfigFile string
DatabaseURL string
Domain string
MessageTTLDays int
WebhookSecretSet bool
SlackTokenSet bool
GitHubTokenSet bool
DatabaseOpenable bool
DatabaseDetail string
Entries []routingdomain.Entry
HasPathRules bool
}
ConfigSnapshot carries the facts the doctor validates about the runtime configuration — never raw secret values, only whether each is set. Built by the infrastructure layer from config.Config so the application stays free of config/store imports.
type Doctor ¶
Doctor runs the preflight checks and returns one Section per group. A non-empty target additionally validates that repository against Slack/GitHub.
type EntrySource ¶
type EntrySource interface {
Entries() []routingdomain.Entry
}
EntrySource provides the current mapping entries to config-CLI use cases. The routing Provider satisfies this interface.
type LockGateway ¶
type LockGateway interface {
Plan(entries []routingdomain.Entry, force bool) (LockPlan, error)
Commit(successes []validationdomain.EntryResult, stale []string) error
CommitTargeted(entry routingdomain.Entry) error
}
LockGateway abstracts the config lock file. Plan reads the lock and diffs it against the current entries; Commit merges successful validation results into the lock (recording each entry's hash + validation time) and drops stale keys; CommitTargeted records a single explicit entry's successful validation.
type LockPlan ¶
type LockPlan struct {
ToValidate []routingdomain.Entry
Stale []string
}
LockPlan is the result of diffing the mappings against the lock: the entries that need (re)validation and the stale lock keys no longer backed by an entry.
type Section ¶
type Section struct {
Name string
Checks []validationdomain.CheckResult
}
Section is a named group of preflight checks the doctor emits.
type Smoke ¶
type Smoke interface {
Run(ctx context.Context, target string, withReactions bool) (SmokeResult, error)
}
Smoke runs a synthetic webhook delivery (optionally replaying review reactions) against the live endpoint and reports what it observed.
type SmokeCleanup ¶
type SmokeCleanup interface {
DeletePR(ctx context.Context, repository string, prNumber int) error
}
SmokeCleanup deletes the synthetic pull_requests row the smoke run causes the server to create. It is called deferred so cleanup runs on every exit path once the PR number is known.
type SmokeConfig ¶
type SmokeConfig struct {
WebhookURL string
WebhookSecret string
IgnoreAIReviews bool
// Reactions mirrors the server's reaction configuration.
Reactions SmokeReactionsConfig
// Now supplies the clock used to derive a unique PR number per run.
Now func() time.Time
}
SmokeConfig carries the parameters that drive a smoke run. All are derived from config / environment at wiring time; the application layer stays free of config imports.
type SmokeMappings ¶
type SmokeMappings interface {
Get(ctx context.Context, repository string) (routingdomain.RepoMapping, error)
}
SmokeMappings resolves a repository to its routing mapping.
type SmokeMessage ¶
SmokeMessage is the stored-message view smoke reads after delivery.
type SmokeMessages ¶
type SmokeMessages interface {
Messages(ctx context.Context, repository string, prNumber int) ([]SmokeMessage, error)
}
SmokeMessages reads the stored messages for a PR.
type SmokeReactionCheck ¶
SmokeReactionCheck is the outcome of one lifecycle step: the event that was replayed, the emoji the server was expected to add, and whether the Slack readback confirmed it. VerifyErr is set when the reaction could not be read back at all (e.g. the bot token lacks reactions:read) — distinct from a confirmed absence.
type SmokeReactions ¶
type SmokeReactions interface {
Reactions(ctx context.Context, channel, ts string) ([]string, error)
}
SmokeReactions reads the reaction emoji names on a Slack message.
type SmokeReactionsConfig ¶
type SmokeReactionsConfig struct {
Enabled bool
NewPR string
MergedPR string
Approved string
Commented string
RequestChange string
BotReview string
}
SmokeReactionsConfig mirrors config.Reactions without importing the config package.
type SmokeResult ¶
type SmokeResult struct {
Repository string
Channel string
PRNumber int
Title string
Timestamp string
URL string
// ReactionsRequested is true when the caller asked for the lifecycle pass.
ReactionsRequested bool
// ReactionsEnabled mirrors the server's reactions.enabled. When a caller
// requests reactions but this is false, the lifecycle is skipped.
ReactionsEnabled bool
Reactions []SmokeReactionCheck
// IgnoreAIReviews and BotReviewMarker let the CLI explain why the bot-review
// step was skipped.
IgnoreAIReviews bool
BotReviewMarker string
}
SmokeResult describes a completed delivery run.