Fix BD_ACTOR handling in direct mode paths

BUG: BD_ACTOR env var was only read in --no-db mode (lines 352-360)
and daemon RPC path. Normal direct mode and JSONL-only mode detection
paths fell back to $USER without checking BD_ACTOR.

Fix: Add explicit os.Getenv("BD_ACTOR") check in both:
- JSONL-only mode detection path (lines 393-402)
- Normal direct mode path (lines 440-450)

(gt-6r18e.2)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-30 16:07:39 -08:00
parent d40a08baf5
commit 952944e295
2 changed files with 848 additions and 847 deletions

View File

@@ -417,9 +417,11 @@ var rootCmd = &cobra.Command{
fmt.Fprintf(os.Stderr, "Error initializing JSONL-only mode: %v\n", err)
os.Exit(1)
}
// Set actor from flag, viper, or env
// Set actor for audit trail
if actor == "" {
if user := os.Getenv("USER"); user != "" {
if bdActor := os.Getenv("BD_ACTOR"); bdActor != "" {
actor = bdActor
} else if user := os.Getenv("USER"); user != "" {
actor = user
} else {
actor = "unknown"
@@ -462,13 +464,12 @@ var rootCmd = &cobra.Command{
}
}
// Set actor from flag, viper (env), or default
// Priority: --actor flag > viper (config + BD_ACTOR env) > USER env > "unknown"
// Note: Viper handles BD_ACTOR automatically via AutomaticEnv()
// Set actor for audit trail
// Priority: --actor flag > BD_ACTOR env > USER env > "unknown"
if actor == "" {
// Viper already populated from config file or BD_ACTOR env
// Fall back to USER env if still empty
if user := os.Getenv("USER"); user != "" {
if bdActor := os.Getenv("BD_ACTOR"); bdActor != "" {
actor = bdActor
} else if user := os.Getenv("USER"); user != "" {
actor = user
} else {
actor = "unknown"