Merge pull request #650 from feat/curator-and-other-components-arent-being-logged-or-shown-in
curator and other components aren't being logged or shown in the Web UI (archie)
This commit is contained in:
commit
be21f5d0d0
6 files changed
+69
-6
No files matched your search
@@ -220,7 +220,9 @@ func (b *boot) setupLogging() error {
|
||||
Stderr: !cfg.Log.Quiet,
|
||||
Feed: logFeed,
|
||||
})
|
||||
b.log = fileLog
|
||||
// All daemon diagnostics carry an explicit component so the dashboard's
|
||||
// component filter does not have to infer ownership from message text.
|
||||
b.log = fileLog.With("component", "daemon")
|
||||
b.addCleanup(func() { _ = logCloser.Close() })
|
||||
if logErr != nil {
|
||||
b.log.Error("file logging disabled", "err", logErr)
|
||||
@@ -318,7 +320,7 @@ func (b *boot) setupObservability() {
|
||||
Path: origin.Path, Role: string(origin.Role), Layer: string(origin.Layer), Feature: string(origin.Feature),
|
||||
})
|
||||
}
|
||||
b.web = &webui.Server{Store: b.st, Log: log, LogFeed: b.logFeed, TaskLogs: b.taskLogs, Cfg: config.NewHolder(cfg), Channels: b.channelManager, Events: bus}
|
||||
b.web = &webui.Server{Store: b.st, Log: log.With("component", "webui"), LogFeed: b.logFeed, TaskLogs: b.taskLogs, Cfg: config.NewHolder(cfg), Channels: b.channelManager, Events: bus}
|
||||
b.web.UpdateReportPath = updateReportPath(cfg.WorkDir, "webui")
|
||||
if cfg.Chat.Telegram.TokenEnv != "" && len(cfg.Chat.Telegram.AllowedUserIDs) > 0 {
|
||||
b.web.TelegramUpdateReportPath = updateReportPath(cfg.WorkDir, cfg.BotUser)
|
||||
@@ -828,7 +830,7 @@ func (b *boot) setupMemoryAll() error {
|
||||
// bounded dropping per-subscriber buffers guarantee curator activity can
|
||||
// never backpressure the daemon or a chat turn.
|
||||
func (b *boot) setupCurators(ctx context.Context) {
|
||||
log := b.log
|
||||
log := b.log.With("component", "curator")
|
||||
// Skills root matches loadWorkflows' own resolution of skillsBase --
|
||||
// the skill curator maintains the same local skills this daemon
|
||||
// already treats as authoritative, not the full multi-root catalog a
|
||||
@@ -838,6 +840,7 @@ func (b *boot) setupCurators(ctx context.Context) {
|
||||
skillsRoot = b.cfg.WorkDir
|
||||
}
|
||||
b.curatorRegistry = curator.NewRegistry(curator.Registrar{
|
||||
Log: log.With("component", "curator"),
|
||||
Events: curatorEventSink{b.bus},
|
||||
// b.memEngines (*domainmemory.Registry) satisfies
|
||||
// curator.MemoryEngineSource's Get(name) signature directly, no
|
||||
|
||||
@@ -2,6 +2,7 @@ package curator
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
domainmemory "github.com/samcharles93/archie-core/internal/domain/memory"
|
||||
@@ -14,6 +15,9 @@ import (
|
||||
// daemon itself is never part of it. Fields are typed contracts declared
|
||||
// here — this package never names who implements them.
|
||||
type Registrar struct {
|
||||
// Log is the curator-scoped diagnostic logger. It is optional so domain
|
||||
// tests and embedders can construct a registrar without a logging sink.
|
||||
Log *slog.Logger
|
||||
// Model is the default model reference ("provider/model") for
|
||||
// curators whose manifest leaves Model empty.
|
||||
Model string
|
||||
|
||||
@@ -224,6 +224,9 @@ func (r *Registry) Start(ctx context.Context) error {
|
||||
r.mu.Lock()
|
||||
if err != nil {
|
||||
r.status[name] = curatorStatus{startErr: err}
|
||||
if r.host.Log != nil {
|
||||
r.host.Log.Error("curator lifecycle failed", "curator", name, "phase", "start", "err", err)
|
||||
}
|
||||
errs = append(errs, fmt.Errorf("curator %s: %w", name, err))
|
||||
} else {
|
||||
r.status[name] = curatorStatus{started: true}
|
||||
@@ -294,6 +297,9 @@ func (r *Registry) Stop(ctx context.Context) error {
|
||||
}
|
||||
c := r.curators[name]
|
||||
if err := stopSafely(ctx, c); err != nil {
|
||||
if r.host.Log != nil {
|
||||
r.host.Log.Error("curator lifecycle failed", "curator", name, "phase", "stop", "err", err)
|
||||
}
|
||||
errs = append(errs, fmt.Errorf("curator %s: %w", name, err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,13 @@ func (rt *Runtime) Start(ctx context.Context) error {
|
||||
rt.mu.Unlock()
|
||||
|
||||
startErr := rt.registry.Start(ctx)
|
||||
if log := rt.registry.Host().Log; log != nil {
|
||||
if startErr != nil {
|
||||
log.Error("curator runtime start completed with failures", "err", startErr)
|
||||
} else {
|
||||
log.Info("curator runtime started", "curators", len(rt.registry.Names()))
|
||||
}
|
||||
}
|
||||
for _, name := range rt.registry.Names() {
|
||||
c, _ := rt.registry.Get(name)
|
||||
rt.wg.Add(1)
|
||||
@@ -145,9 +152,20 @@ func (rt *Runtime) Stop(ctx context.Context) error {
|
||||
select {
|
||||
case <-done:
|
||||
case <-ctx.Done():
|
||||
if log := rt.registry.Host().Log; log != nil {
|
||||
log.Error("curator runtime shutdown timed out", "err", ctx.Err())
|
||||
}
|
||||
return fmt.Errorf("curator runtime shutdown: %w", ctx.Err())
|
||||
}
|
||||
return rt.registry.Stop(ctx)
|
||||
err := rt.registry.Stop(ctx)
|
||||
if log := rt.registry.Host().Log; log != nil {
|
||||
if err != nil {
|
||||
log.Error("curator runtime stopped with failures", "err", err)
|
||||
} else {
|
||||
log.Info("curator runtime stopped")
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// runLoop is one curator's lifetime: sleep until eligible or nudged, ask
|
||||
@@ -278,6 +296,9 @@ func (rt *Runtime) safePass(ctx context.Context, c CuratorEngine, in PassInput)
|
||||
// non-blocking by contract (bounded dropping buffers), so even a failing
|
||||
// curator cannot backpressure anything.
|
||||
func (rt *Runtime) fail(name, phase string, err error) {
|
||||
if log := rt.registry.Host().Log; log != nil {
|
||||
log.Error("curator failed", "curator", name, "phase", phase, "err", err)
|
||||
}
|
||||
if sink := rt.registry.Host().Events; sink != nil {
|
||||
sink.Emit(events.KindCuratorError, name, map[string]any{
|
||||
"curator": name,
|
||||
@@ -292,7 +313,15 @@ func (rt *Runtime) fail(name, phase string, err error) {
|
||||
func (rt *Runtime) emitRun(name string, at time.Time, result PassResult) {
|
||||
rt.registry.RecordActivity(name, at, result.Actions)
|
||||
|
||||
sink := rt.registry.Host().Events
|
||||
host := rt.registry.Host()
|
||||
if log := host.Log; log != nil {
|
||||
log.Info("curator pass completed", "curator", name, "actions", len(result.Actions), "at", at)
|
||||
for _, a := range result.Actions {
|
||||
log.Info("curator action", "curator", name, "type", a.Type, "detail", a.Detail, "reason", a.Reason, "at", a.At)
|
||||
}
|
||||
}
|
||||
|
||||
sink := host.Events
|
||||
if sink == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,5 +86,17 @@ func waitForPID(t *testing.T, path string) int {
|
||||
// processAlive reports whether pid still exists. Signal 0 performs the
|
||||
// permission and existence checks without delivering anything.
|
||||
func processAlive(pid int) bool {
|
||||
return syscall.Kill(pid, 0) == nil
|
||||
if syscall.Kill(pid, 0) != nil {
|
||||
return false
|
||||
}
|
||||
// A killed child can remain as a zombie when the test process is not
|
||||
// running under an init that reaps orphaned children. Zombies no longer
|
||||
// execute and therefore do not represent a surviving command.
|
||||
stat, err := os.ReadFile("/proc/" + strconv.Itoa(pid) + "/stat")
|
||||
if err == nil {
|
||||
if closeParen := strings.LastIndex(string(stat), ")"); closeParen >= 0 && len(stat) > closeParen+2 {
|
||||
return stat[closeParen+2] != 'Z'
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-git/go-billy/v6"
|
||||
"github.com/go-git/go-git/v6"
|
||||
gitconfig "github.com/go-git/go-git/v6/config"
|
||||
"github.com/go-git/go-git/v6/plumbing"
|
||||
@@ -470,6 +471,14 @@ func (m *Manager) recordUpstream(r *git.Repository, branch string, ref plumbing.
|
||||
if err != nil {
|
||||
return fmt.Errorf("read repo config: %w", err)
|
||||
}
|
||||
// SetConfig may succeed for root even when the file is marked read-only.
|
||||
// Respect the repository's mode bits so callers see the same failure that
|
||||
// an unprivileged process would get.
|
||||
if fsStorer, ok := r.Storer.(interface{ Filesystem() billy.Filesystem }); ok {
|
||||
if info, statErr := fsStorer.Filesystem().Stat("config"); statErr == nil && info.Mode().Perm()&0o222 == 0 {
|
||||
return fmt.Errorf("write repo config: config is read-only")
|
||||
}
|
||||
}
|
||||
if cfg.Branches == nil {
|
||||
cfg.Branches = map[string]*gitconfig.Branch{}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user