factory

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package factory wires concrete dependencies for the github-update-go-agent binary.

All factory functions follow the Create* prefix convention and contain zero business logic — they compose constructors with config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAgent

func CreateAgent(
	claudeConfigDir claudelib.ClaudeConfigDir,
	agentDir claudelib.AgentDir,
	model claudelib.ClaudeModel,
	ghToken string,
	claudeEnv map[string]string,
	gitOps git.GitOps,
	ghCli updatepkg.GhCli,
	gateRunner updatepkg.GateRunner,
	claudeProber updatepkg.ClaudeProber,
	prTarget updatepkg.PRTarget,
	autoMergeLabel string,
	updateScope updatepkg.UpdateScope,
) *agentlib.Agent

CreateAgent assembles the three distinct phases (design § 4.2):

  • planning: claude-auth + gh-token preflights + Claude planning step (clone @ ref, detect gate targets, classify findings) → ## Plan
  • execution: claude-auth preflight + custom Go step embedding the Claude update sub-call (clone+branch, update+repair, gate verify, commit, push --no-follow-tags, gh pr create) → ## Result
  • ai_review: pure-Go verifier (PR state checked against configured PRTarget, fresh-worktree gate re-run, CHANGELOG, tag audit) → ## Review → human_review

func CreateAgentProvider

func CreateAgentProvider(
	claudeConfigDir claudelib.ClaudeConfigDir,
	agentDir claudelib.AgentDir,
	model claudelib.ClaudeModel,
	ghToken string,
	claudeEnv map[string]string,
	gitOps git.GitOps,
	ghCli updatepkg.GhCli,
	gateRunner updatepkg.GateRunner,
	claudeProber updatepkg.ClaudeProber,
	prTarget updatepkg.PRTarget,
	autoMergeLabel string,
	updateScope updatepkg.UpdateScope,
	createCmd updatepkg.CreateCommandFunc,
) agentlib.AgentProvider

CreateAgentProvider wires the per-task-type dispatch table.

  • task_type: github-update-go → the 3-phase updater agent
  • task_type: build-fix → the 3-phase build-fixer agent (second domain agent in this binary, per the 2026-08-22 architecture decision)
  • task_type: healthcheck / oauth-probe → shared liveness agent

Pure plumbing; no conditional, no error.

func CreateBuildFixAgent added in v0.12.0

func CreateBuildFixAgent(
	claudeConfigDir claudelib.ClaudeConfigDir,
	agentDir claudelib.AgentDir,
	model claudelib.ClaudeModel,
	ghToken string,
	claudeEnv map[string]string,
	gitOps git.GitOps,
	ghCli updatepkg.GhCli,
	claudeProber updatepkg.ClaudeProber,
	createCmd updatepkg.CreateCommandFunc,
) *agentlib.Agent

CreateBuildFixAgent assembles the build-fixer's three phases (the second domain agent this binary hosts, per the 2026-08-22 architecture decision — shares the binary's core plumbing, no separate repo/deployment):

  • planning: claude-auth preflight + fix diagnosis step (clone @ episode SHA, verify green at HEAD, fetch failed logs, Claude classification into no_fix_needed / chain_update / file_spec / needs_input) → ## Fix Plan
  • execution: pure-Go hand-off step — chain_update emits a github-update-go task (CreateCommand), file_spec files the kind:bug spec on build-fixer/<sha-short>, dedup via branch existence → ## Fix Result
  • ai_review: pure-Go verifier (branch landed on origin / hand-off recorded) → ## Review → human_review

func CreateBuildFixChainEmitter added in v0.12.0

func CreateBuildFixChainEmitter(
	syncProducer libkafka.SyncProducer,
	topicPrefix base.TopicPrefix,
) updatepkg.CreateCommandFunc

CreateBuildFixChainEmitter wires the build-fixer's chain-to-updater emission: a CreateCommandFunc that publishes a github-update-go task via the controller's Kafka command bus (task.CreateCommandSender), exactly as the github-build watcher does for build-fix tasks. The producer is passed in pre-built — main.go is the single close owner: it creates the producer and its cleanup func closes it exactly once. The emitter must never close the producer itself — main's cleanup closes the same producer after the run, and sarama v1.60.2's AsyncClose is not idempotent: a second Close panics with "send on closed channel" in asyncProducer.shutdown. The nil decision lives in buildChainEmitter (nil createCmd when no brokers are configured), so the factory body stays pure composition with no error and no conditional. The Pattern B Job emits at most one downstream task per run.

func CreateClaudeProber added in v0.2.0

func CreateClaudeProber(claudeConfigDir claudelib.ClaudeConfigDir) updatepkg.ClaudeProber

CreateClaudeProber wires the claude-auth preflight prober.

func CreateClaudeRunner

func CreateClaudeRunner(
	claudeConfigDir claudelib.ClaudeConfigDir,
	agentDir claudelib.AgentDir,
	allowedTools claudelib.AllowedTools,
	model claudelib.ClaudeModel,
	env map[string]string,
) claudelib.ClaudeRunner

CreateClaudeRunner constructs a ClaudeRunner pre-configured with tools, model, working directory, and CLI environment.

func CreateFileResultDeliverer

func CreateFileResultDeliverer(filePath string) agentlib.ResultDeliverer

CreateFileResultDeliverer creates a ResultDeliverer that writes the agent's output back to a markdown file (local CLI mode). Uses the passthrough content generator (same rationale as Kafka).

func CreateGateRunner added in v0.2.0

func CreateGateRunner() updatepkg.GateRunner

CreateGateRunner wires the os/exec make gate runner.

func CreateGhCli added in v0.2.0

func CreateGhCli(ghToken string) updatepkg.GhCli

CreateGhCli wires the os/exec gh CLI seam with the resolved GitHub token.

func CreateGitOps added in v0.2.0

func CreateGitOps() git.GitOps

CreateGitOps wires the os/exec GitOps seam.

func CreateKafkaResultDeliverer

func CreateKafkaResultDeliverer(
	syncProducer libkafka.SyncProducer,
	topicPrefix base.TopicPrefix,
	taskID agentlib.TaskIdentifier,
	originalContent string,
	currentDateTime libtime.CurrentDateTimeGetter,
) agentlib.ResultDeliverer

CreateKafkaResultDeliverer creates a ResultDeliverer that publishes task updates to Kafka via CQRS commands. Uses the passthrough content generator — the agent framework's StepRunner already produces the full marshaled task in result.Output; the deliverer publishes it as-is and overrides status/phase frontmatter based on the result Status.

func CreateModuleResolver added in v0.18.0

func CreateModuleResolver() updatepkg.ModuleResolver

CreateModuleResolver wires the os/exec module-graph resolver used by ai_review to verify an external advisory's installed version.

func CreateSyncProducer

func CreateSyncProducer(
	ctx context.Context,
	brokers libkafka.Brokers,
) (libkafka.SyncProducer, error)

CreateSyncProducer creates a Kafka sync producer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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