fix(archied): preserve channel turn ledger with remote gateway
This commit is contained in:
1 parent
3b85e67cb7
commit
a56414cf7a
2 files changed
+44
-5
No files matched your search
@@ -45,7 +45,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration/overlay"
|
||||
infraembedding "github.com/samcharles93/archie-core/internal/infrastructure/embedding"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/eventbus/nats"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
|
||||
infraMemory "github.com/samcharles93/archie-core/internal/infrastructure/memory"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/modelcatalog"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/sessioncurator"
|
||||
@@ -544,9 +543,8 @@ func (b *boot) setupLLMAndChat() error {
|
||||
return err
|
||||
}
|
||||
b.addCleanup(cleanup)
|
||||
if remote, ok := contract.(*gatewayrpc.Client); ok {
|
||||
b.chatSessionStore = remote
|
||||
}
|
||||
// Channel routers execute turns locally and need the SQLite TurnLedger.
|
||||
// The remote contract serves web chat; it must not replace their store.
|
||||
b.web.Chat = &webui.ChatService{Contract: contract, Updates: b.updateService}
|
||||
b.web.WorkRequests = b.chatTasks
|
||||
b.setupReadinessProbes()
|
||||
@@ -1016,7 +1014,7 @@ func (b *boot) setupCurators(ctx context.Context) {
|
||||
// doesn't declare Manifest.Skills, per curator not per instance.
|
||||
Skills: skillcurator.NewStore(skillsRoot),
|
||||
// Conversations backs the session-memory curator; b.chatSessionStore
|
||||
// is set by setupLLMAndChat, which Run() calls before setupCurators.
|
||||
// is opened by openChatSessions before setupCurators.
|
||||
Conversations: sessioncurator.NewAdapter(b.chatSessionStore, b.cfg.BotUser),
|
||||
LLM: curatorLLMRunner{rt: b.llm},
|
||||
// b.chatModels.ActiveModel() is the same source sendChatTurn uses
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package archied
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
"github.com/samcharles93/archie-core/internal/webui"
|
||||
)
|
||||
|
||||
func TestRemoteChatCompositionPreservesChannelTurnLedger(t *testing.T) {
|
||||
cfg := config.Config{DBPath: filepath.Join(t.TempDir(), "tasks.db")}
|
||||
cfg.Services.Gateway.Target = "127.0.0.1:1"
|
||||
st, err := store.Open(t.Context(), cfg.DBPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = st.Close() })
|
||||
b := &boot{cfg: cfg, st: st, log: slog.Default(), web: &webui.Server{Cfg: config.NewHolder(cfg)}}
|
||||
t.Cleanup(b.cleanup)
|
||||
if err := b.openChatSessions(t.Context()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sessions := b.chatSessionStore
|
||||
if err := b.setupLLMAndChat(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if b.chatSessionStore != sessions {
|
||||
t.Fatal("remote web chat replaced the channel conversation store")
|
||||
}
|
||||
ledger, ok := b.chatSessionStore.(gateway.TurnLedger)
|
||||
if !ok {
|
||||
t.Fatal("channel conversation store does not implement TurnLedger")
|
||||
}
|
||||
if err := ledger.RecoverTurns(t.Context(), "test-owner"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user