Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions db/activity_outbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package db
import (
"encoding/json"
"fmt"
"log"
"log/slog"
)

// activityOutboxMaxAttempts is how many times a row may fail AppendActivity
Expand Down Expand Up @@ -94,7 +94,7 @@ func (s *ExplorationStore) FlushActivityOutbox() (int, error) {
_ = tx.Rollback()
next := it.attempts + 1
if next >= activityOutboxMaxAttempts {
log.Printf("[activity] outbox %d for exploration %d dropped after %d attempts: %v", it.id, s.expID, next, err)
slog.Error("[activity] outbox entry dropped", "outbox_id", it.id, "exploration_id", s.expID, "attempts", next, "err", err)
if _, delErr := s.db.Exec(`DELETE FROM activity_outbox WHERE id=$1`, it.id); delErr != nil {
return stored, delErr
}
Expand Down
4 changes: 2 additions & 2 deletions db/companies.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"errors"
"fmt"
"log"
"log/slog"
"net"
"strings"
"unicode/utf8"
Expand Down Expand Up @@ -583,7 +583,7 @@ const malformedIPAssetsSampled = 5
// per-request response (company deletion, scopesentry sync, agent asset writes).
func logAttributionWarning(warning string) {
if warning != "" {
log.Printf("[assets] %s", warning)
slog.Warn("[assets] " + warning)
}
}

Expand Down
10 changes: 5 additions & 5 deletions db/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"log/slog"
"strings"
"time"

Expand Down Expand Up @@ -247,19 +247,19 @@ func (d *DB) DeleteNotificationChannel(ctx context.Context, id int64) error {
func RecordNotificationEventTx(ctx context.Context, tx *sql.Tx, kind string, findingID int64, snap notify.Snapshot) bool {
raw, err := json.Marshal(snap)
if err != nil {
log.Printf("[notify] failed to serialize delivery event finding=%d: %v", findingID, err)
slog.Error("[notify] failed to serialize delivery event", "finding", findingID, "err", err)
return false
}
if _, err := tx.ExecContext(ctx, `SAVEPOINT notify_event`); err != nil {
log.Printf("[notify] failed to create savepoint finding=%d: %v", findingID, err)
slog.Error("[notify] failed to create savepoint", "finding", findingID, "err", err)
return false
}
if _, err := tx.ExecContext(ctx, `INSERT INTO notification_events(kind,finding_id,snapshot) VALUES($1,$2,$3)`,
kind, findingID, string(raw)); err != nil {
log.Printf("[notify] failed to write delivery event finding=%d (finding record unaffected): %v", findingID, err)
slog.Error("[notify] failed to write delivery event (finding record unaffected)", "finding", findingID, "err", err)
// Roll back to the savepoint, rescuing the transaction from the aborted state.
if _, rbErr := tx.ExecContext(ctx, `ROLLBACK TO SAVEPOINT notify_event`); rbErr != nil {
log.Printf("[notify] failed to roll back to savepoint finding=%d: %v", findingID, rbErr)
slog.Error("[notify] failed to roll back to savepoint", "finding", findingID, "err", rbErr)
}
return false
}
Expand Down
6 changes: 3 additions & 3 deletions db/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"log/slog"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -306,7 +306,7 @@ func (d *DB) InitSecrets(keyDir string) error {
if err != nil {
return err
}
log.Printf("[secrets] at-rest encryption ready; backfill encrypted %d plaintext value(s)", n)
slog.Info("[secrets] at-rest encryption ready", "backfilled_plaintext_values", n)
activeSecretBox.Store(box)
sub := deriveSubKey(key, trafficTraceDomain)
trafficTraceKey.Store(&sub)
Expand Down Expand Up @@ -362,7 +362,7 @@ func loadSecretKey(ctx context.Context, conn *sql.Conn, keyDir string) ([]byte,
_ = os.Remove(path)
return nil, fmt.Errorf("write secret key: %w", err)
}
log.Printf("[secrets] new secret key written to %s", path)
slog.Info("[secrets] new secret key written", "path", path)
return key, nil
}

Expand Down
4 changes: 2 additions & 2 deletions intercept/intercept.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"log/slog"
"net"
"regexp"
"strconv"
Expand Down Expand Up @@ -309,7 +309,7 @@ func (i *Interceptor) loadLocked() error {
if err != nil {
if !i.loadFailed {
i.loadFailed = true
log.Printf("[intercept] the rule store cannot be read; every tool call is denied until it can: %v", err)
slog.Error("[intercept] the rule store cannot be read; every tool call is denied until it can", "err", err)
}
return err
}
Expand Down
18 changes: 9 additions & 9 deletions llmpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"iter"
"log"
"log/slog"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -106,18 +106,18 @@ func (p *Pool) Stream(ctx context.Context, req llm.CompletionRequest) iter.Seq2[
}
lastErr = failed
if tripped, msg := p.health.RecordCall(ctx, m.ID, true, false, failed); tripped {
log.Printf("[llmpool] profile %q(%s) breaker tripped: %s", m.Name, m.Model, msg)
slog.Warn("[llmpool] profile breaker tripped", "profile", m.Name, "model", m.Model, "reason", msg)
}
if i+1 < len(order) {
n := order[i+1]
log.Printf("[llmpool] LLM failover: %q(%s) → %q(%s), reason: %s",
m.Name, m.Model, n.Name, n.Model, trimErr(failed))
slog.Warn("[llmpool] LLM failover", "from_profile", m.Name, "from_model", m.Model,
"to_profile", n.Name, "to_model", n.Model, "reason", trimErr(failed))
}
}
if lastErr == nil {
lastErr = ErrExhausted
}
log.Printf("[llmpool] failover chain exhausted (all %d profiles failed), last error: %s", len(order), trimErr(lastErr))
slog.Error("[llmpool] failover chain exhausted, all profiles failed", "profiles", len(order), "last_err", trimErr(lastErr))
yield(llm.StreamEvent{}, fmt.Errorf("%w: %v", ErrExhausted, lastErr))
}
}
Expand Down Expand Up @@ -145,18 +145,18 @@ func (p *Pool) Complete(ctx context.Context, req llm.CompletionRequest) (llm.Mes
}
lastErr = err
if tripped, msg := p.health.RecordCall(ctx, m.ID, false, false, err); tripped {
log.Printf("[llmpool] profile %q(%s) breaker tripped: %s", m.Name, m.Model, msg)
slog.Warn("[llmpool] profile breaker tripped", "profile", m.Name, "model", m.Model, "reason", msg)
}
if i+1 < len(order) {
n := order[i+1]
log.Printf("[llmpool] LLM failover: %q(%s) → %q(%s), reason: %s",
m.Name, m.Model, n.Name, n.Model, trimErr(err))
slog.Warn("[llmpool] LLM failover", "from_profile", m.Name, "from_model", m.Model,
"to_profile", n.Name, "to_model", n.Model, "reason", trimErr(err))
}
}
if lastErr == nil {
lastErr = ErrExhausted
}
log.Printf("[llmpool] failover chain exhausted (all %d profiles failed), last error: %s", len(order), trimErr(lastErr))
slog.Error("[llmpool] failover chain exhausted, all profiles failed", "profiles", len(order), "last_err", trimErr(lastErr))
return llm.Message{}, "", llm.Usage{}, fmt.Errorf("%w: %v", ErrExhausted, lastErr)
}

Expand Down
4 changes: 2 additions & 2 deletions llmrec/context_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package llmrec

import (
"encoding/json"
"log"
"log/slog"
"os"
"strings"

Expand Down Expand Up @@ -169,6 +169,6 @@ func (r *Recorder) recordContext(taskID, worker string, m ContextMetrics, usage
Status: status,
})
if err != nil {
log.Printf("[llmcontext] insert: %v", err)
slog.Error("[llmcontext] insert failed", "err", err)
}
}
6 changes: 3 additions & 3 deletions llmrec/llmrec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/json"
"errors"
"iter"
"log"
"log/slog"
"strings"
"time"

Expand Down Expand Up @@ -363,7 +363,7 @@ func (r *Recorder) recordUsage(ctx context.Context, taskID string, expID int64,
Status: status,
})
if err != nil {
log.Printf("[llmusage] insert: %v", err)
slog.Error("[llmusage] insert failed", "err", err)
}
}

Expand Down Expand Up @@ -424,7 +424,7 @@ func (r *Recorder) record(req llm.CompletionRequest, session, taskID, worker, re
}

if err := r.pg.InsertLLMRecord(rec); err != nil {
log.Printf("[llmrec] insert: %v", err)
slog.Error("[llmrec] insert failed", "err", err)
}
}

Expand Down
Loading