factory

package
v0.22.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: BSD-2-Clause Imports: 20 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 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

View Source
const HumanReviewOwnerEnv = "HUMAN_REVIEW_OWNER"

HumanReviewOwnerEnv names the environment variable carrying the human owner this agent stamps onto every record it routes into human_review.

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,
	humanReviewOwner string,
) *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,
	humanReviewOwner string,
) 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,
	humanReviewOwner string,
) *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.

func HumanReviewOwnerWarning added in v0.21.11

func HumanReviewOwnerWarning(raw string) string

HumanReviewOwnerWarning returns the startup warning for a raw HUMAN_REVIEW_OWNER value, or "" when the value is usable.

It is a pure function rather than a logging call so this package stays free of I/O, and it exists at all so the two entry points cannot drift: the pod (main.go) and the local replay (cmd/run-task) each log what it returns. A warning that lived in one of them and not the other is how this change first shipped — the docs promised both, only one warned, and a local replay with the value unset silently composed no wrapper and left records unowned.

func IsHumanReviewOwnerValid added in v0.21.11

func IsHumanReviewOwnerValid(value string) bool

IsHumanReviewOwnerValid reports whether value, trimmed, is a usable owner login. main uses it to distinguish "unset" from "set but malformed" in its startup warning — the two need different operator actions, and a malformed value disables the stamp exactly as an unset one does.

func ResolveHumanReviewOwner added in v0.21.11

func ResolveHumanReviewOwner(env map[string]string) string

ResolveHumanReviewOwner returns the trimmed env[HumanReviewOwnerEnv], or the empty string when it is unset or is not a valid GitHub login.

There is deliberately no fallback name: the owner is a person, and hard-coding one here would make the deployment's behaviour depend on a name written into this repository rather than on its configuration. Empty disables the stamp, so an unconfigured agent behaves exactly as before this change — the record is routed to human_review and the controller's chokepoint clears the agent's assignee, leaving it unowned. main logs a warning in that case, so the misconfiguration is visible at startup rather than inferred later from records that lost their owner.

Types

This section is empty.

Jump to

Keyboard shortcuts

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