fix(doctor): use full AgentEnv for env-vars check

The env-vars check was using AgentEnvSimple which doesn't know the
actual TownRoot and BeadsDir paths. This could cause false positive
mismatches when comparing expected (empty paths) vs actual (real paths).

- Use config.AgentEnv with proper TownRoot and BeadsDir from CheckContext
- Rig-level roles resolve beads dir from rig path
- Update tests to use expectedEnv helper that generates full env vars

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
julianknutsen
2026-01-09 11:51:31 -08:00
committed by Steve Yegge
parent f1a2c56900
commit ce231a31af
2 changed files with 74 additions and 30 deletions

View File

@@ -2,8 +2,10 @@ package doctor
import (
"fmt"
"path/filepath"
"strings"
"github.com/steveyegge/gastown/internal/beads"
"github.com/steveyegge/gastown/internal/config"
"github.com/steveyegge/gastown/internal/session"
"github.com/steveyegge/gastown/internal/tmux"
@@ -95,8 +97,22 @@ func (c *EnvVarsCheck) Run(ctx *CheckContext) *CheckResult {
continue
}
// Get expected env vars based on role
expected := config.AgentEnvSimple(string(identity.Role), identity.Rig, identity.Name)
// Get expected env vars based on role, emulating real call sites
// Town-level roles use TownRoot for beads, rig-level roles use rig path
var beadsDir string
if identity.Rig != "" {
rigPath := filepath.Join(ctx.TownRoot, identity.Rig)
beadsDir = beads.ResolveBeadsDir(rigPath)
} else {
beadsDir = beads.ResolveBeadsDir(ctx.TownRoot)
}
expected := config.AgentEnv(config.AgentEnvConfig{
Role: string(identity.Role),
Rig: identity.Rig,
AgentName: identity.Name,
TownRoot: ctx.TownRoot,
BeadsDir: beadsDir,
})
// Get actual tmux env vars
actual, err := reader.GetAllEnvironment(sess)