refactor(archiegateway): own the chat task profiles; archied built a task creator it never read
deploy / plan (push) Successful in 7s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
deploy / gate (push) Canceled after 22s

This commit is contained in:
sam committed 2026-11-09 08:32:28 +11:00
1 parent 9616dd72ce
commit f5a04ce8c5
4 files changed
+13 -34

No files matched your search

+1 -1
View File
@@ -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"}
+1 -19
View File
@@ -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)
}
@@ -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)
@@ -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,
)
}