factory

package
v0.191.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: BSD-2-Clause Imports: 55 Imported by: 0

Documentation

Overview

Package factory wires all dependencies for the dark-factory application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateApproveCommand added in v0.17.15

func CreateApproveCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.ApproveCommand

CreateApproveCommand creates an ApproveCommand.

func CreateBitbucketServerProviderDeps added in v0.171.16

func CreateBitbucketServerProviderDeps(
	ctx context.Context,
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) providerDeps

CreateBitbucketServerProviderDeps returns Bitbucket Server REST API-backed implementations.

func CreateCancelCommand added in v0.62.0

func CreateCancelCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.CancelCommand

CreateCancelCommand creates a CancelCommand.

func CreateCombinedListCommand added in v0.17.25

func CreateCombinedListCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.CombinedListCommand

CreateCombinedListCommand creates a CombinedListCommand.

func CreateCombinedStatusCommand added in v0.17.25

func CreateCombinedStatusCommand(
	ctx context.Context,
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.CombinedStatusCommand

CreateCombinedStatusCommand creates a CombinedStatusCommand.

func CreateDiscordNotifier added in v0.171.16

func CreateDiscordNotifier(webhook string) notifier.Notifier

CreateDiscordNotifier creates a Discord notifier with the given webhook.

func CreateDoctorCommand added in v0.174.0

func CreateDoctorCommand(
	ctx context.Context,
	cfg config.Config,
	verifyingStaleHours int,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.DoctorCommand

CreateDoctorCommand creates a DoctorCommand with all required dependencies.

func CreateGitHubProviderDeps added in v0.171.16

func CreateGitHubProviderDeps(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) providerDeps

CreateGitHubProviderDeps returns GitHub gh-CLI-backed implementations.

func CreateHealthcheckCommand added in v0.179.0

func CreateHealthcheckCommand(
	ctx context.Context,
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.HealthcheckCommand

func CreateHealthcheckGate added in v0.181.0

func CreateHealthcheckGate(
	ctx context.Context,
	cfg config.Config,
	skipHealthcheck bool,
	projectName string,
	n notifier.Notifier,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) healthcheckgate.Gate

CreateHealthcheckCommand creates a HealthcheckCommand with the seven probes wired in fixed order: docker, image, boot, claude, mount, gh, notifications. The gh probe is appended only when cfg.PR is true; the notifications probe is appended only when at least one notification channel is configured. The factory is construction-only — instantiate concrete deps, pass them in, no branches. CreateHealthcheckGate builds the daemon-startup healthcheck gate. The gate's disabled/skip/cache logic lives in healthcheckgate.gate.Check; this factory only constructs collaborators (the underlying HealthcheckCommand, the file cache, the cache key, the notifier) and passes them in.

os.UserHomeDir error: failure is logged, then the gate falls back to a CWD-relative cache path. The cache is non-secret, non-critical, and write failures are tolerated by design; surfacing the error here is enough — refusing to start the daemon over a cache-dir resolution miss would be worse than the silent fallback.

func CreateKillCommand added in v0.84.0

func CreateKillCommand(_ config.Config) cmd.KillCommand

CreateKillCommand creates a KillCommand that stops the running daemon.

func CreateListCommand added in v0.17.15

func CreateListCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.ListCommand

CreateListCommand creates a ListCommand.

func CreateLocker added in v0.3.0

func CreateLocker(dir string) lock.Locker

CreateLocker creates a Locker for the specified directory.

func CreateNotifier added in v0.48.0

func CreateNotifier(telegram, discord notifier.Notifier) notifier.Notifier

CreateNotifier creates a Notifier based on the provided Telegram and Discord notifiers.

func CreateOneShotRunner added in v0.31.0

func CreateOneShotRunner(
	ctx context.Context,
	cfg config.Config,
	ver string,
	autoApprove bool,
	skipPreflight bool,
	sources config.FieldSources,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) runner.OneShotRunner

CreateOneShotRunner creates an OneShotRunner that drains the queue and exits.

func CreateProcessor added in v0.3.1

func CreateProcessor(
	ctx context.Context,
	cfg ProcessorConfig,
	projectName project.Name,
	promptManager *prompt.Manager,
	releaser git.Releaser,
	versionGetter version.Getter,
	wakeup <-chan struct{},
	brancher git.Brancher,
	prCreator git.PRCreator,
	prMerger git.PRMerger,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
	n notifier.Notifier,
	containerCounter executor.ContainerCounter,
	containerLock containerlock.ContainerLock,
	executionChecker executor.ExecutionChecker,
	dirtyFileChecker processor.DirtyFileChecker,
	gitLockChecker processor.GitLockChecker,
	preflightChecker preflight.Checker,
	onIdle processor.NothingToDoCallback,
) processor.Processor

CreateProcessor creates a Processor that executes queued prompts.

func CreatePromptCompleteCommand added in v0.69.0

func CreatePromptCompleteCommand(
	ctx context.Context,
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
	forceRelease bool,
) cmd.PromptCompleteCommand

CreatePromptCompleteCommand creates a PromptCompleteCommand.

func CreatePromptShowCommand added in v0.25.0

func CreatePromptShowCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.PromptShowCommand

CreatePromptShowCommand creates a PromptShowCommand.

func CreateRejectCommand added in v0.134.0

func CreateRejectCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.RejectCommand

CreateRejectCommand creates a RejectCommand.

func CreateRequeueCommand added in v0.17.15

func CreateRequeueCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.RequeueCommand

CreateRequeueCommand creates a RequeueCommand.

func CreateRunner added in v0.2.25

func CreateRunner(
	ctx context.Context,
	cfg config.Config,
	ver string,
	skipPreflight bool,
	skipHealthcheck bool,
	sources config.FieldSources,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) runner.Runner

CreateRunner creates a Runner that coordinates watcher and processor using the provided config.

func CreateScenarioListCommand added in v0.131.0

func CreateScenarioListCommand(_ config.Config) cmd.ScenarioListCommand

CreateScenarioListCommand creates a ScenarioListCommand.

func CreateScenarioShowCommand added in v0.131.0

func CreateScenarioShowCommand(_ config.Config) cmd.ScenarioShowCommand

CreateScenarioShowCommand creates a ScenarioShowCommand.

func CreateScenarioStatusCommand added in v0.131.0

func CreateScenarioStatusCommand(_ config.Config) cmd.ScenarioStatusCommand

CreateScenarioStatusCommand creates a ScenarioStatusCommand.

func CreateServer added in v0.7.0

func CreateServer(
	ctx context.Context,
	port int,
	inboxDir string,
	inProgressDir string,
	completedDir string,
	logDir string,
	promptManager *prompt.Manager,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
	projectMaxContainers int,
	projectName project.Name,
) server.Server

CreateServer creates a Server that provides HTTP endpoints for monitoring.

func CreateSpecApproveCommand added in v0.17.23

func CreateSpecApproveCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecApproveCommand

CreateSpecApproveCommand creates a SpecApproveCommand.

func CreateSpecCompleteCommand added in v0.23.2

func CreateSpecCompleteCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecCompleteCommand

CreateSpecCompleteCommand creates a SpecCompleteCommand.

func CreateSpecGenerator added in v0.18.1

func CreateSpecGenerator(
	ctx context.Context,
	cfg config.Config,
	containerImage string,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
	slugMigrator slugmigrator.Migrator,
	promptManager *prompt.Manager,
) generator.SpecGenerator

CreateSpecGenerator creates a SpecGenerator using the Docker executor.

func CreateSpecListCommand added in v0.17.23

func CreateSpecListCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecListCommand

CreateSpecListCommand creates a SpecListCommand.

func CreateSpecMarkPromptedCommand added in v0.172.0

func CreateSpecMarkPromptedCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecMarkPromptedCommand

CreateSpecMarkPromptedCommand creates a SpecMarkPromptedCommand.

func CreateSpecRejectCommand added in v0.134.0

func CreateSpecRejectCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecRejectCommand

CreateSpecRejectCommand creates a SpecRejectCommand.

func CreateSpecShowCommand added in v0.25.0

func CreateSpecShowCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecShowCommand

CreateSpecShowCommand creates a SpecShowCommand.

func CreateSpecStatusCommand added in v0.17.23

func CreateSpecStatusCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecStatusCommand

CreateSpecStatusCommand creates a SpecStatusCommand.

func CreateSpecUnapproveCommand added in v0.78.0

func CreateSpecUnapproveCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.SpecUnapproveCommand

CreateSpecUnapproveCommand creates a SpecUnapproveCommand.

func CreateSpecWatcher added in v0.18.1

func CreateSpecWatcher(
	cfg config.Config,
	gen generator.SpecGenerator,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) specwatcher.SpecWatcher

CreateSpecWatcher creates a SpecWatcher that triggers generation when a spec appears in inProgressDir.

func CreateStatusCommand added in v0.8.0

func CreateStatusCommand(
	ctx context.Context,
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.StatusCommand

CreateStatusCommand creates a StatusCommand.

func CreateTelegramNotifier added in v0.171.16

func CreateTelegramNotifier(token, chatID string) notifier.Notifier

CreateNotifier creates a Notifier from config, or a no-op if no channels are configured. CreateTelegramNotifier creates a Telegram notifier with the given token and chatID.

func CreateUnapproveCommand added in v0.77.0

func CreateUnapproveCommand(
	cfg config.Config,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) cmd.UnapproveCommand

CreateUnapproveCommand creates an UnapproveCommand.

func CreateWatcher added in v0.3.1

func CreateWatcher(
	inProgressDir string,
	inboxDir string,
	promptManager *prompt.Manager,
	wakeup chan<- struct{},
	debounce time.Duration,
	currentDateTimeGetter libtime.CurrentDateTimeGetter,
) watcher.Watcher

CreateWatcher creates a Watcher that normalizes filenames on file events.

func CreateWorkflowExecutor added in v0.119.3

func CreateWorkflowExecutor(
	pr bool,
	brancher git.Brancher,
	prCreator git.PRCreator,
	prMerger git.PRMerger,
	autoMerge bool,
	autoRelease bool,
	projectName project.Name,
	promptManager *prompt.Manager,
	releaser git.Releaser,
	autoCompleter spec.AutoCompleter,
	promptDirPrefixes []string,
	fileMover prompt.FileMover,
) processor.WorkflowExecutorProvider

CreateWorkflowExecutor creates a WorkflowExecutorProvider that dispenses the appropriate WorkflowExecutor for a given workflow.

func EffectiveMaxContainers added in v0.89.0

func EffectiveMaxContainers(projectMax, globalMax int) int

EffectiveMaxContainers returns the per-project limit when set (> 0), otherwise falls back to the global limit. A per-project value MAY exceed the global limit. This is intentional: e.g. dark-factory itself uses maxContainers: 5 so it can self-update even when 3 other containers are already running.

func LogEffectiveConfig added in v0.111.0

func LogEffectiveConfig(
	cfg config.Config,
	globalCfg globalconfig.GlobalConfig,
	globalFilePresent bool,
	sources config.FieldSources,
	projectEnv map[string]string,
)

LogEffectiveConfig emits a single slog.Info "effective config" line describing the resolved settings that drive daemon/run behavior. This is purely diagnostic; no value is mutated.

maxContainersSource is resolved from sources.MaxContainers when set (e.g. "arg", "project"); otherwise falls back to inline detection using cfg.MaxContainers and globalFilePresent:

  • "project" when cfg.MaxContainers > 0
  • "global" when cfg.MaxContainers <= 0 AND globalFilePresent is true
  • "default" when cfg.MaxContainers <= 0 AND globalFilePresent is false

Types

type ProcessorConfig added in v0.184.0

type ProcessorConfig struct {
	// Directories
	InProgressDir      string
	CompletedDir       string
	LogDir             string
	SpecsInboxDir      string
	SpecsInProgressDir string
	SpecsCompletedDir  string
	SpecsRejectedDir   string
	PromptDirPrefixes  []string

	// Container
	ContainerImage string
	Model          string
	ClaudeDir      string
	Env            map[string]string
	ExtraMounts    []config.ExtraMount
	HideGit        bool

	// Git / VCS
	NetrcFile     string
	GitconfigFile string

	// Workflow
	Workflow         config.Workflow
	PR               bool
	AutoMerge        bool
	AutoRelease      bool
	VerificationGate bool

	// Validation
	ValidationCommand      string
	ValidationPrompt       string
	TestCommand            string
	AdditionalInstructions string

	// Resource limits
	MaxContainers      int
	MaxPromptDuration  time.Duration
	DirtyFileThreshold int
	AutoRetryLimit     int

	// Timing
	QueueInterval time.Duration
	SweepInterval time.Duration
}

ProcessorConfig groups the config-derived inputs to CreateProcessor. Previously these 25 fields were positional params of CreateProcessor, duplicated across CreateRunner and CreateOneShotRunner — silent drift between the two call sites was a real bug class. Grouping them into a struct makes the call sites identical and adding a new field a one-line change. Infra deps (PromptManager, Releaser, Brancher, etc.) remain separate args so wiring stays visible at the call site.

func (ProcessorConfig) EffectiveHideGit added in v0.187.7

func (p ProcessorConfig) EffectiveHideGit() bool

EffectiveHideGit mirrors config.Config.EffectiveHideGit for the subset of fields carried on ProcessorConfig (Workflow + HideGit). The factory builds the ProcessorConfig from a config.Config, so the result must agree — both are reduced to one canonical formula. The `hotpath-hidegit-check` precommit gate rejects the inline expansion in pkg/ to prevent drift.

Jump to

Keyboard shortcuts

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