From f5a04ce8c55c7e7a1a94689b46d92659b088b7b1 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Mon, 9 Nov 2026 08:32:28 +1100 Subject: [PATCH] refactor(archiegateway): own the chat task profiles; archied built a task creator it never read --- .golangci.yml | 2 +- internal/app/archied/bootstrap.go | 20 +------------------ .../chat_task_profiles.go} | 20 +++++++++---------- internal/app/archiegateway/gateway_runtime.go | 5 ++--- 4 files changed, 13 insertions(+), 34 deletions(-) rename internal/app/{chattask/chattask.go => archiegateway/chat_task_profiles.go} (70%) diff --git a/.golangci.yml b/.golangci.yml index c76abc472..4425faefb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -97,7 +97,7 @@ linters: - {pkg: "github.com/samcharles93/archie-core/internal/domain/workflow", desc: "the workflow engine is the daemon's"} - {pkg: "github.com/samcharles93/archie-core/internal/agentexec", desc: "agent execution is the daemon's"} shared: - files: ["**/internal/app/servicekit/**", "**/internal/app/chattask/**"] + files: ["**/internal/app/servicekit/**"] deny: - {pkg: "github.com/samcharles93/archie-core/internal/daemon", desc: "shared code must not pull in a service"} - {pkg: "github.com/samcharles93/archie-core/internal/webui", desc: "shared code must not pull in a service"} diff --git a/internal/app/archied/bootstrap.go b/internal/app/archied/bootstrap.go index e383d6243..f28e59338 100644 --- a/internal/app/archied/bootstrap.go +++ b/internal/app/archied/bootstrap.go @@ -22,7 +22,6 @@ import ( "syscall" "time" - "github.com/samcharles93/archie-core/internal/app/chattask" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/container" @@ -42,7 +41,6 @@ import ( "github.com/samcharles93/archie-core/internal/domain/workintake" "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/forge" - "github.com/samcharles93/archie-core/internal/gateway" infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access" "github.com/samcharles93/archie-core/internal/infrastructure/configuration" "github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore" @@ -177,8 +175,6 @@ type boot struct { // start, which read it as their resume points. runtimeVersions map[string]int64 - chatTasks gateway.TaskCreator - defaultChatIdentity string // messaging delivers outbound chat messages through the Messaging Service. messaging *messagingrpc.Client @@ -499,10 +495,8 @@ func (b *boot) setupContainers(ctx context.Context) func() { return closeDocker } -// setupGatewayClient dials the Gateway, which owns every model call. The daemon -// only enqueues the chat tasks scheduled workflows create. +// setupGatewayClient dials the Gateway, which owns every model call. func (b *boot) setupGatewayClient(ctx context.Context) error { - b.setupChatTasks(b.cfg) contract, cleanup, err := composeChatContract(b.cfg) if err != nil { return err @@ -804,18 +798,6 @@ func (b *boot) runLoop(ctx context.Context, once bool) error { return nil } -// setupChatTasks wires the task creator scheduled workflows enqueue through. -func (b *boot) setupChatTasks(cfg config.Config) { - profiles, defaultChatIdentity := chattask.Profiles(cfg) - if len(profiles) > 0 { - b.chatTasks = gateway.NewStoreTaskCreatorForProfiles( - chattask.Writer{Enqueue: b.stateStore.EnqueueChatTask}, - profiles, - ) - } - b.defaultChatIdentity = defaultChatIdentity -} - func (b *boot) addCleanup(fn func()) { b.cleanups = append(b.cleanups, fn) } diff --git a/internal/app/chattask/chattask.go b/internal/app/archiegateway/chat_task_profiles.go similarity index 70% rename from internal/app/chattask/chattask.go rename to internal/app/archiegateway/chat_task_profiles.go index 73bfa2ed7..7ec2a2f0d 100644 --- a/internal/app/chattask/chattask.go +++ b/internal/app/archiegateway/chat_task_profiles.go @@ -1,6 +1,4 @@ -// Package chattask derives the chat task profiles a config allows and adapts -// the State Store's enqueue call to the gateway's task writer. -package chattask +package archiegateway import ( "context" @@ -12,8 +10,8 @@ import ( "github.com/samcharles93/archie-core/internal/gateway" ) -// Writer adapts an enqueue call returning the task to gateway.TaskWriter. -type Writer struct { +// chatTaskWriter adapts an enqueue call returning the task to gateway.TaskWriter. +type chatTaskWriter struct { Enqueue func( ctx context.Context, owner, repo, title, body, workflow, identity, origin, draft string, @@ -21,7 +19,7 @@ type Writer struct { ) (*workflow.Task, error) } -func (a Writer) EnqueueChatTask( +func (a chatTaskWriter) EnqueueChatTask( ctx context.Context, owner, repo, title, body, workflow, identity, origin string, inputs map[string]any, @@ -36,15 +34,15 @@ func (a Writer) EnqueueChatTask( return task.ID, nil } -// Profiles returns the task profiles cfg allows and the default identity. -func Profiles(cfg config.Config) ([]gateway.TaskProfile, string) { +// chatTaskProfiles returns the task profiles cfg allows and the default identity. +func chatTaskProfiles(cfg config.Config) ([]gateway.TaskProfile, string) { if len(cfg.Identities) > 0 { profiles := make([]gateway.TaskProfile, 0, len(cfg.Identities)) for _, identity := range cfg.Identities { if len(identity.Repos) == 0 { continue } - profiles = append(profiles, newProfile(identity.Name, identity.Repos)) + profiles = append(profiles, newChatTaskProfile(identity.Name, identity.Repos)) } if len(profiles) == 0 { return nil, "" @@ -57,10 +55,10 @@ func Profiles(cfg config.Config) ([]gateway.TaskProfile, string) { // Chat acts as the control-plane operator, the identity the dashboard // stamps on the tasks it creates. operator := string(identity.OperatorID()) - return []gateway.TaskProfile{newProfile(operator, cfg.Repos)}, operator + return []gateway.TaskProfile{newChatTaskProfile(operator, cfg.Repos)}, operator } -func newProfile(identity string, repos []config.Repo) gateway.TaskProfile { +func newChatTaskProfile(identity string, repos []config.Repo) gateway.TaskProfile { allowed := make([]string, 0, len(repos)) for _, repo := range repos { allowed = append(allowed, repo.Owner+"/"+repo.Name) diff --git a/internal/app/archiegateway/gateway_runtime.go b/internal/app/archiegateway/gateway_runtime.go index 5e4c435c1..90bc3971c 100644 --- a/internal/app/archiegateway/gateway_runtime.go +++ b/internal/app/archiegateway/gateway_runtime.go @@ -6,7 +6,6 @@ import ( "log/slog" "github.com/samcharles93/archie-core/internal/agentexec/modelloop" - "github.com/samcharles93/archie-core/internal/app/chattask" "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/buildinfo" "github.com/samcharles93/archie-core/internal/config" @@ -88,10 +87,10 @@ func (b *server) setupChatRuntime(ctx context.Context, cfg config.Config, actor // setupChatTasks wires the task creator chat commands and scheduled workflows // enqueue through. func (b *server) setupChatTasks(cfg config.Config) { - profiles, defaultChatIdentity := chattask.Profiles(cfg) + profiles, defaultChatIdentity := chatTaskProfiles(cfg) if len(profiles) > 0 { b.chatTasks = gateway.NewStoreTaskCreatorForProfiles( - chattask.Writer{Enqueue: b.stateStore.EnqueueChatTask}, + chatTaskWriter{Enqueue: b.stateStore.EnqueueChatTask}, profiles, ) }