feat: bounded concurrent task dispatch in daemon (archie-core-u64)

Daemon previously processed one task at a time. Add bounded concurrent
dispatch for SQLite and NATS agent modes, reusing [containers].max_concurrency
(0 = unlimited). Same-repository tasks stay FIFO-serialized to avoid worktree
conflicts; different repositories now run concurrently.

Unblocks archie-core-l1q (NATS transport) and archie-core-g1l
(per-repo allow_concurrent override).
This commit is contained in:
sam committed 2026-07-24 07:42:13 +10:00
1 parent bef10c3ede
commit f8df051b19
25 files changed
+366 -137

No files matched your search

+10 -10
View File
@@ -67,10 +67,10 @@ func run() int {
}
stream, err := js.CreateOrUpdateStream(ctx, jetstream.StreamConfig{
Name: streamName,
Subjects: []string{"archie.task.>", "archie.agent.>"},
Storage: jetstream.FileStorage,
Retention: jetstream.WorkQueuePolicy,
Name: streamName,
Subjects: []string{"archie.task.>", "archie.agent.>"},
Storage: jetstream.FileStorage,
Retention: jetstream.WorkQueuePolicy,
Duplicates: dedupWindow,
})
if err != nil {
@@ -79,12 +79,12 @@ func run() int {
}
cons, err := stream.CreateOrUpdateConsumer(ctx, jetstream.ConsumerConfig{
Name: *consumer,
Durable: *consumer,
FilterSubject: arnats.SubjectAgentWildcard,
AckPolicy: jetstream.AckExplicitPolicy,
MaxDeliver: 3,
AckWait: ackWait,
Name: *consumer,
Durable: *consumer,
FilterSubject: arnats.SubjectAgentWildcard,
AckPolicy: jetstream.AckExplicitPolicy,
MaxDeliver: 3,
AckWait: ackWait,
InactiveThreshold: 24 * time.Hour,
})
if err != nil {
+8 -8
View File
@@ -14,6 +14,7 @@ import (
"path/filepath"
"syscall"
"github.com/moby/moby/client"
"github.com/samcharles93/archie-core/internal/agentexec"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/container"
@@ -21,7 +22,6 @@ import (
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/forge"
"github.com/samcharles93/archie-core/internal/nats"
"github.com/moby/moby/client"
"github.com/samcharles93/archie-core/internal/plugin"
"github.com/samcharles93/archie-core/internal/plugin/pluginextract"
@@ -138,7 +138,7 @@ func run() int {
defer dockerCli.Close()
containerPool, err = container.NewPool(ctx, container.Config{
Image: cfg.Containers.Image,
Image: cfg.Containers.Image,
MaxConcurrency: cfg.Containers.MaxConcurrency,
MaxUptime: cfg.Containers.MaxUptime.Std(),
PullPolicy: cfg.Containers.PullPolicy,
@@ -222,15 +222,15 @@ func run() int {
BotEmail: cfg.BotEmail,
BaseURL: cfg.Forge.Host,
},
Runtime: llm,
Agent: agentRunner,
Runtime: llm,
Agent: agentRunner,
Workflows: registry,
PluginRegistry: pluginReg,
Storage: storeBackend,
Log: log,
CustomStages: wfeval.Discover,
Nats: natsClient,
ContainerPool: containerPool,
Log: log,
CustomStages: wfeval.Discover,
Nats: natsClient,
ContainerPool: containerPool,
}
if err := d.Startup(ctx); err != nil {