command

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: 16 Imported by: 0

Documentation

Overview

Package command defines the TriggerPRReviewCommand payload and its Kafka sender for the github-pr watcher's request topic.

Index

Constants

View Source
const TriggerPRReviewCommandOperation base.CommandOperation = "trigger-pr-review"

TriggerPRReviewCommandOperation is the Kafka command operation for triggering a single-PR review. Wire string: "trigger-pr-review".

Variables

This section is empty.

Functions

func NewTriggerPRReviewCommandExecutor

func NewTriggerPRReviewCommandExecutor(
	ghClient pkg.GitHubClient,
	createSender task.CreateCommandSender,
	taskCreationFilter filter.TaskCreationFilter,
	trustDecision trust.Trust,
	stage string,
	maxSlugLen int,
	maxTitleLen int,
	taskSuffix string,
	targetVault string,
	metrics pkg.Metrics,
	currentDateTime libtime.CurrentDateTimeGetter,
) cdb.CommandObjectExecutorTx

NewTriggerPRReviewCommandExecutor creates a cdb.CommandObjectExecutorTx that consumes TriggerPRReviewCommand messages and drives the single-PR review pipeline: GitHub fetch → filter → trust → downstream publish.

Exit-path mapping (per spec 066 § Desired Behavior 5):

  • invalid URL (Validate fails) → cdb.ErrCommandObjectSkipped
  • filter-rejected PR (filter.Skip==true) → cdb.ErrCommandObjectSkipped
  • untrusted author (trust.IsTrusted==false) → cdb.ErrCommandObjectSkipped
  • GitHub 5xx / network error → wrapped error (transient, retried)
  • trust infrastructure error → wrapped error (transient, retried)
  • downstream CreateTaskCommand send error → wrapped error (transient, retried)
  • success → nil, nil, nil

SendResultEnabled is false (spec Non-goal: fire-and-forget, no result topic). The github_pr_published metric is incremented from this executor (not the HTTP handler) with labels: create, skipped, kafka_error, trust_error.

Types

type TriggerPRReviewCommand

type TriggerPRReviewCommand struct {
	URL   string `json:"url"`
	Force bool   `json:"force,omitempty"`
}

TriggerPRReviewCommand is the payload for TriggerPRReviewCommandOperation. It is published to the github-pr watcher's request topic by the /trigger HTTP handler and consumed by the in-pod command consumer.

URL is the GitHub PR URL the operator wants reviewed. Force, when true, causes the executor to derive a salted TaskIdentifier via pkg.DeriveTaskIDForce (microsecond-resolution time nonce) so the agent controller's vault-file dedup skip does NOT fire and a fresh review task is created for the same head SHA (spec 069).

func (TriggerPRReviewCommand) Validate

func (cmd TriggerPRReviewCommand) Validate(ctx context.Context) error

Validate enforces the command's schema rules. URL must be non-empty and must parse to a GitHub-platform PR URL (same rules as the HTTP handler's parseAndValidateURL — see pkg/handler/trigger_handler.go). Non-GitHub platforms and unparseable URLs are rejected here so a buggy client that bypasses the HTTP layer cannot enqueue garbage.

type TriggerPRReviewCommandSender

type TriggerPRReviewCommandSender interface {
	SendCommand(ctx context.Context, cmd TriggerPRReviewCommand) error
}

TriggerPRReviewCommandSender sends TriggerPRReviewCommand payloads to Kafka. Calls Validate before publishing — a validation error is returned without touching Kafka.

func NewTriggerPRReviewCommandSender

func NewTriggerPRReviewCommandSender(
	commandCreator base.CommandCreator,
	initiator cqrsiam.Initiator,
	commandObjectSender cdb.CommandObjectSender,
) TriggerPRReviewCommandSender

NewTriggerPRReviewCommandSender creates a TriggerPRReviewCommandSender. The commandCreator and initiator are injected at construction time per the cqrs/docs/producing-commands.md "Factory Wiring" pattern (matches trading/frontend/command's reference impl) — built once at wiring, reused across every SendCommand call. The commandObjectSender wraps the Kafka sync producer.

Jump to

Keyboard shortcuts

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