command

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: BSD-2-Clause Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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,
	mechanicalOverrideAuthors []string,
	stage string,
	maxSlugLen int,
	maxTitleLen int,
	taskSuffix string,
	targetVault string,
	maxAdditions int,
	maxChangedFiles int,
	metrics pkg.Metrics,
	retryGuard pkg.RetryGuard,
	overrideLedger pkg.OverrideLedger,
	coalescer coalesce.Coalescer,
	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)
  • in-flight duplicate (forced) → cdb.ErrCommandObjectSkipped from the guard
  • 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, deferred, inflight_skipped.

Types

type TriggerPRReviewCommand

type TriggerPRReviewCommand struct {
	URL string `json:"url"`
	// Force is the operator's explicit "review this now" request: it salts the
	// task identifier (bypassing controller dedupe) and bypasses the
	// oversized-PR park. It is NOT a webhook discriminator — the plain
	// /trigger endpoint also publishes Force=false.
	Force bool `json:"force,omitempty"`
	// Webhook marks a command the webhook handler published on a pull_request
	// event. Only the webhook path sets it; the operator /trigger endpoint
	// leaves it false, which is what keeps an explicit operator request from
	// being deferred to the poll path. Absent on messages published before the
	// field existed, so they decode as false and behave as operator requests.
	Webhook bool `json:"webhook,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