Document intentional error suppressions with comments (gt-zn9m)

All 156 instances of _ = error suppression in non-test code now have
explanatory comments documenting why the error is intentionally ignored.

Categories of intentional suppressions:
- non-fatal: session works without these - tmux environment setup
- non-fatal: theming failure does not affect operation - visual styling
- best-effort cleanup - defer cleanup on failure paths
- best-effort notification - mail/notifications that should not block
- best-effort interrupt - graceful shutdown attempts
- crypto/rand.Read only fails on broken system - random ID generation
- output errors non-actionable - fmt.Fprint to io.Writer

This addresses the silent failure and debugging concerns raised in the
issue by making the intentionality explicit in the code.

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-25 23:14:13 -08:00
parent 99b1a11cbd
commit 34b5a3bb8d
41 changed files with 134 additions and 133 deletions

View File

@@ -90,20 +90,20 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
return fmt.Errorf("creating session: %w", err)
}
// Set environment
// Set environment (non-fatal: session works without these)
_ = t.SetEnvironment(sessionID, "GT_RIG", r.Name)
_ = t.SetEnvironment(sessionID, "GT_CREW", name)
// Set CLAUDE_CONFIG_DIR for account selection
// Set CLAUDE_CONFIG_DIR for account selection (non-fatal)
if claudeConfigDir != "" {
_ = t.SetEnvironment(sessionID, "CLAUDE_CONFIG_DIR", claudeConfigDir)
}
// Apply rig-based theming (uses config if set, falls back to hash)
// Apply rig-based theming (non-fatal: theming failure doesn't affect operation)
theme := getThemeForRig(r.Name)
_ = t.ConfigureGasTownSession(sessionID, theme, r.Name, name, "crew")
// Set up C-b n/p keybindings for crew session cycling
// Set up C-b n/p keybindings for crew session cycling (non-fatal)
_ = t.SetCrewCycleBindings(sessionID)
// Wait for shell to be ready after session creation

View File

@@ -135,7 +135,7 @@ func runCrewRefresh(cmd *cobra.Command, args []string) error {
return fmt.Errorf("creating session: %w", err)
}
// Set environment
// Set environment (non-fatal: session works without these)
_ = t.SetEnvironment(sessionID, "GT_RIG", r.Name)
_ = t.SetEnvironment(sessionID, "GT_CREW", name)
@@ -224,7 +224,7 @@ func runCrewRestart(cmd *cobra.Command, args []string) error {
t.SetEnvironment(sessionID, "GT_RIG", r.Name)
t.SetEnvironment(sessionID, "GT_CREW", name)
// Apply rig-based theming (uses config if set, falls back to hash)
// Apply rig-based theming (non-fatal: theming failure doesn't affect operation)
theme := getThemeForRig(r.Name)
_ = t.ConfigureGasTownSession(sessionID, theme, r.Name, name, "crew")

View File

@@ -94,7 +94,7 @@ func runCrewStatus(cmd *cobra.Command, args []string) error {
untracked = gitStatus.Untracked
}
// Mail status
// Mail status (non-fatal: display defaults to 0 if count fails)
mailDir := filepath.Join(w.ClonePath, "mail")
mailTotal, mailUnread := 0, 0
if _, err := os.Stat(mailDir); err == nil {

View File

@@ -175,11 +175,11 @@ func startDeaconSession(t *tmux.Tmux) error {
return fmt.Errorf("creating session: %w", err)
}
// Set environment
// Set environment (non-fatal: session works without these)
_ = t.SetEnvironment(DeaconSessionName, "GT_ROLE", "deacon")
_ = t.SetEnvironment(DeaconSessionName, "BD_ACTOR", "deacon")
// Apply Deacon theme
// Apply Deacon theme (non-fatal: theming failure doesn't affect operation)
theme := tmux.DeaconTheme()
_ = t.ConfigureGasTownSession(DeaconSessionName, theme, "", "Deacon", "health-check")
@@ -208,7 +208,7 @@ func runDeaconStop(cmd *cobra.Command, args []string) error {
fmt.Println("Stopping Deacon session...")
// Try graceful shutdown first
// Try graceful shutdown first (best-effort interrupt)
_ = t.SendKeysRaw(DeaconSessionName, "C-c")
time.Sleep(100 * time.Millisecond)

View File

@@ -141,7 +141,7 @@ func stopSession(t *tmux.Tmux, sessionName string) error {
return nil // Already stopped
}
// Try graceful shutdown first (Ctrl-C)
// Try graceful shutdown first (Ctrl-C, best-effort interrupt)
if !downForce {
_ = t.SendKeysRaw(sessionName, "C-c")
time.Sleep(100 * time.Millisecond)

View File

@@ -62,7 +62,7 @@ func runInit(cmd *cobra.Command, args []string) error {
return fmt.Errorf("creating %s: %w", dir, err)
}
// Create .gitkeep to ensure directory is tracked if needed
// Create .gitkeep to ensure directory is tracked if needed (non-fatal)
gitkeep := filepath.Join(dirPath, ".gitkeep")
if _, err := os.Stat(gitkeep); os.IsNotExist(err) {
_ = os.WriteFile(gitkeep, []byte(""), 0644)

View File

@@ -241,7 +241,7 @@ func init() {
mailSendCmd.Flags().BoolVar(&mailWisp, "wisp", true, "Send as wisp (ephemeral, default)")
mailSendCmd.Flags().BoolVar(&mailPermanent, "permanent", false, "Send as permanent (not ephemeral, synced to remote)")
mailSendCmd.Flags().BoolVar(&mailSendSelf, "self", false, "Send to self (auto-detect from cwd)")
_ = mailSendCmd.MarkFlagRequired("subject")
_ = mailSendCmd.MarkFlagRequired("subject") // cobra flags: error only at runtime if missing
// Inbox flags
mailInboxCmd.Flags().BoolVar(&mailInboxJSON, "json", false, "Output as JSON")
@@ -949,6 +949,6 @@ func runMailReply(cmd *cobra.Command, args []string) error {
// generateThreadID creates a random thread ID for new message threads.
func generateThreadID() string {
b := make([]byte, 6)
_, _ = rand.Read(b)
_, _ = rand.Read(b) // crypto/rand.Read only fails on broken system
return "thread-" + hex.EncodeToString(b)
}

View File

@@ -118,11 +118,11 @@ func startMayorSession(t *tmux.Tmux) error {
return fmt.Errorf("creating session: %w", err)
}
// Set environment
// Set environment (non-fatal: session works without these)
_ = t.SetEnvironment(MayorSessionName, "GT_ROLE", "mayor")
_ = t.SetEnvironment(MayorSessionName, "BD_ACTOR", "mayor")
// Apply Mayor theme
// Apply Mayor theme (non-fatal: theming failure doesn't affect operation)
theme := tmux.MayorTheme()
_ = t.ConfigureGasTownSession(MayorSessionName, theme, "", "Mayor", "coordinator")
@@ -151,7 +151,7 @@ func runMayorStop(cmd *cobra.Command, args []string) error {
fmt.Println("Stopping Mayor session...")
// Try graceful shutdown first
// Try graceful shutdown first (best-effort interrupt)
_ = t.SendKeysRaw(MayorSessionName, "C-c")
time.Sleep(100 * time.Millisecond)
@@ -230,7 +230,7 @@ func runMayorRestart(cmd *cobra.Command, args []string) error {
}
if running {
// Stop the current session
// Stop the current session (best-effort interrupt before kill)
fmt.Println("Stopping Mayor session...")
_ = t.SendKeysRaw(MayorSessionName, "C-c")
time.Sleep(100 * time.Millisecond)

View File

@@ -406,7 +406,7 @@ func init() {
func loadMoleculeCatalog(workDir string) (*beads.MoleculeCatalog, error) {
var townRoot, rigPath, projectPath string
// Try to find town root
// Try to find town root (non-fatal: falls back to local formulas)
townRoot, _ = workspace.FindFromCwd()
// Try to find rig path

View File

@@ -177,7 +177,7 @@ bonded_at: %s
opts := beads.InstantiateOptions{Context: ctx}
steps, err := b.InstantiateMolecule(proto, child, opts)
if err != nil {
// Clean up the child container on failure
// Clean up the child container on failure (best-effort cleanup)
_ = b.Close(child.ID)
return fmt.Errorf("instantiating bonded molecule: %w", err)
}
@@ -481,7 +481,7 @@ squashed_at: %s
return fmt.Errorf("creating digest: %w", err)
}
// Add the digest label
// Add the digest label (non-fatal: digest works without label)
_ = b.Update(digestIssue.ID, beads.UpdateOptions{
AddLabels: []string{"digest"},
})

View File

@@ -166,7 +166,7 @@ func runMoleculeShow(cmd *cobra.Command, args []string) error {
// Parse steps
steps, parseErr := beads.ParseMoleculeSteps(mol.Description)
_ = source // Used below in output
_ = source // silence unused warning; used in output formatting below
// For JSON, include parsed steps
if moleculeJSON {

View File

@@ -269,7 +269,7 @@ func init() {
// Reject flags
mqRejectCmd.Flags().StringVarP(&mqRejectReason, "reason", "r", "", "Reason for rejection (required)")
mqRejectCmd.Flags().BoolVar(&mqRejectNotify, "notify", false, "Send mail notification to worker")
_ = mqRejectCmd.MarkFlagRequired("reason")
_ = mqRejectCmd.MarkFlagRequired("reason") // cobra flags: error only at runtime if missing
// Status flags
mqStatusCmd.Flags().BoolVar(&mqStatusJSON, "json", false, "Output as JSON")

View File

@@ -106,7 +106,7 @@ func runMqIntegrationCreate(cmd *cobra.Command, args []string) error {
// 3. Push to origin
fmt.Printf("Pushing to origin...\n")
if err := g.Push("origin", branchName, false); err != nil {
// Clean up local branch on push failure
// Clean up local branch on push failure (best-effort cleanup)
_ = g.DeleteBranch(branchName, true)
return fmt.Errorf("pushing to origin: %w", err)
}
@@ -299,7 +299,7 @@ func runMqIntegrationLand(cmd *cobra.Command, args []string) error {
fmt.Printf("Merging %s to main...\n", branchName)
mergeMsg := fmt.Sprintf("Merge %s: %s\n\nEpic: %s", branchName, epic.Title, epicID)
if err := g.MergeNoFF("origin/"+branchName, mergeMsg); err != nil {
// Abort merge on failure
// Abort merge on failure (best-effort cleanup)
_ = g.AbortMerge()
return fmt.Errorf("merge failed: %w", err)
}
@@ -313,7 +313,7 @@ func runMqIntegrationLand(cmd *cobra.Command, args []string) error {
if err := runTestCommand(r.Path, testCmd); err != nil {
// Tests failed - reset main
fmt.Printf(" %s Tests failed, resetting main...\n", style.Bold.Render("✗"))
_ = g.Checkout("main")
_ = g.Checkout("main") // best-effort: need to be on main to reset
resetErr := resetHard(g, "HEAD~1")
if resetErr != nil {
return fmt.Errorf("tests failed and could not reset: %w (test error: %v)", resetErr, err)

View File

@@ -957,7 +957,7 @@ func getGitState(worktreePath string) (*GitState, error) {
// origin/main might not exist - try origin/master
logCmd = exec.Command("git", "log", "origin/master..HEAD", "--oneline")
logCmd.Dir = worktreePath
output, _ = logCmd.Output() // Ignore error - might be a new repo
output, _ = logCmd.Output() // non-fatal: might be a new repo without remote tracking
}
if len(output) > 0 {
lines := splitLines(string(output))

View File

@@ -282,7 +282,7 @@ func ensureRefinerySession(rigName string, r *rig.Rig) (bool, error) {
t.SetEnvironment(sessionName, "BEADS_NO_DAEMON", "1")
t.SetEnvironment(sessionName, "BEADS_AGENT_NAME", fmt.Sprintf("%s/refinery", rigName))
// Apply Gas Town theming
// Apply Gas Town theming (non-fatal: theming failure doesn't affect operation)
theme := tmux.AssignTheme(rigName)
_ = t.ConfigureGasTownSession(sessionName, theme, rigName, "refinery", "refinery")
@@ -399,7 +399,7 @@ func runGracefulShutdown(t *tmux.Tmux, gtSessions []string, townRoot string) err
fmt.Printf("Phase 1: Sending ESC to %d agent(s)...\n", len(gtSessions))
for _, sess := range gtSessions {
fmt.Printf(" %s Interrupting %s\n", style.Bold.Render("→"), sess)
_ = t.SendKeysRaw(sess, "Escape")
_ = t.SendKeysRaw(sess, "Escape") // best-effort interrupt
}
// Phase 2: Send shutdown message asking agents to handoff
@@ -408,7 +408,7 @@ func runGracefulShutdown(t *tmux.Tmux, gtSessions []string, townRoot string) err
for _, sess := range gtSessions {
// Small delay then send the message
time.Sleep(500 * time.Millisecond)
_ = t.SendKeys(sess, shutdownMsg)
_ = t.SendKeys(sess, shutdownMsg) // best-effort notification
}
// Phase 3: Wait for agents to complete handoff
@@ -712,20 +712,20 @@ func runStartCrew(cmd *cobra.Command, args []string) error {
return fmt.Errorf("creating session: %w", err)
}
// Set environment
// Set environment (non-fatal: session works without these)
_ = t.SetEnvironment(sessionID, "GT_RIG", rigName)
_ = t.SetEnvironment(sessionID, "GT_CREW", name)
// Set CLAUDE_CONFIG_DIR for account selection
// Set CLAUDE_CONFIG_DIR for account selection (non-fatal)
if claudeConfigDir != "" {
_ = t.SetEnvironment(sessionID, "CLAUDE_CONFIG_DIR", claudeConfigDir)
}
// Apply rig-based theming
// Apply rig-based theming (non-fatal: theming failure doesn't affect operation)
theme := getThemeForRig(rigName)
_ = t.ConfigureGasTownSession(sessionID, theme, rigName, name, "crew")
// Set up C-b n/p keybindings for crew session cycling
// Set up C-b n/p keybindings for crew session cycling (non-fatal)
_ = t.SetCrewCycleBindings(sessionID)
// Wait for shell to be ready after session creation

View File

@@ -35,6 +35,7 @@ func runStatusLine(cmd *cobra.Command, args []string) error {
var rigName, polecat, crew, issue, role string
if statusLineSession != "" {
// Non-fatal: missing env vars are handled gracefully below
rigName, _ = t.GetEnvironment(statusLineSession, "GT_RIG")
polecat, _ = t.GetEnvironment(statusLineSession, "GT_POLECAT")
crew, _ = t.GetEnvironment(statusLineSession, "GT_CREW")

View File

@@ -155,7 +155,7 @@ func init() {
swarmCreateCmd.Flags().StringSliceVar(&swarmWorkers, "worker", nil, "Polecat names to assign (repeatable)")
swarmCreateCmd.Flags().BoolVar(&swarmStart, "start", false, "Start swarm immediately after creation")
swarmCreateCmd.Flags().StringVar(&swarmTarget, "target", "main", "Target branch for landing")
_ = swarmCreateCmd.MarkFlagRequired("epic")
_ = swarmCreateCmd.MarkFlagRequired("epic") // cobra flags: error only at runtime if missing
// Status flags
swarmStatusCmd.Flags().BoolVar(&swarmStatusJSON, "json", false, "Output as JSON")
@@ -300,7 +300,7 @@ func runSwarmCreate(cmd *cobra.Command, args []string) error {
}
}
// Get the updated swarm
// Get the updated swarm (just created, error would be surprising)
sw, _ = mgr.GetSwarm(swarmEpic)
// Save to store
@@ -640,7 +640,7 @@ func runSwarmLand(cmd *cobra.Command, args []string) error {
// Create manager and land
mgr := swarm.NewManager(foundRig)
// Reload swarm into manager
// Reload swarm into manager (recreates from store, errors non-fatal)
_, _ = mgr.Create(sw.EpicID, sw.Workers, sw.TargetBranch)
_ = mgr.UpdateState(sw.ID, sw.State)

View File

@@ -200,11 +200,11 @@ func ensureSession(t *tmux.Tmux, sessionName, workDir, role string) error {
return err
}
// Set environment
// Set environment (non-fatal: session works without these)
_ = t.SetEnvironment(sessionName, "GT_ROLE", role)
_ = t.SetEnvironment(sessionName, "BD_ACTOR", role)
// Apply theme based on role
// Apply theme based on role (non-fatal: theming failure doesn't affect operation)
switch role {
case "mayor":
theme := tmux.MayorTheme()
@@ -246,13 +246,13 @@ func ensureWitness(t *tmux.Tmux, sessionName, rigPath, rigName string) error {
return err
}
// Set environment
// Set environment (non-fatal: session works without these)
bdActor := fmt.Sprintf("%s/witness", rigName)
_ = t.SetEnvironment(sessionName, "GT_ROLE", "witness")
_ = t.SetEnvironment(sessionName, "GT_RIG", rigName)
_ = t.SetEnvironment(sessionName, "BD_ACTOR", bdActor)
// Apply theme (use rig-based theme)
// Apply theme (non-fatal: theming failure doesn't affect operation)
theme := tmux.AssignTheme(rigName)
_ = t.ConfigureGasTownSession(sessionName, theme, "", "Witness", rigName)

View File

@@ -157,8 +157,8 @@ func runWitnessStart(cmd *cobra.Command, args []string) error {
return nil
}
// Update manager state to reflect running session
_ = mgr.Start() // Mark as running in state file
// Update manager state to reflect running session (non-fatal: state file update)
_ = mgr.Start()
fmt.Printf("%s Witness started for %s\n", style.Bold.Render("✓"), rigName)
fmt.Printf(" %s\n", style.Dim.Render("Use 'gt witness attach' to connect"))
@@ -326,7 +326,7 @@ func ensureWitnessSession(rigName string, r *rig.Rig) (bool, error) {
t.SetEnvironment(sessionName, "GT_RIG", rigName)
t.SetEnvironment(sessionName, "BD_ACTOR", bdActor)
// Apply Gas Town theming
// Apply Gas Town theming (non-fatal: theming failure doesn't affect operation)
theme := tmux.AssignTheme(rigName)
_ = t.ConfigureGasTownSession(sessionName, theme, rigName, "witness", "witness")
@@ -395,7 +395,7 @@ func runWitnessRestart(cmd *cobra.Command, args []string) error {
}
}
// Update state file to stopped
// Update state file to stopped (non-fatal: state file update)
_ = mgr.Stop()
// Start fresh
@@ -405,7 +405,7 @@ func runWitnessRestart(cmd *cobra.Command, args []string) error {
}
if created {
_ = mgr.Start() // Mark as running in state file
_ = mgr.Start() // non-fatal: state file update
}
fmt.Printf("%s Witness restarted for %s\n", style.Bold.Render("✓"), rigName)