Skip to content

Fix #3: gov why shows historical failures incorrectly#13

Merged
cmtonkinson merged 1 commit intomainfrom
fix-issue-3
Feb 14, 2026
Merged

Fix #3: gov why shows historical failures incorrectly#13
cmtonkinson merged 1 commit intomainfrom
fix-issue-3

Conversation

@cmtonkinson
Copy link
Owner

Fixes #3

Problem

The gov why command was showing tasks with historical failures even after they had successfully completed.

Reproduction Steps

  1. Start a project with tasks executing
  2. Run gov stop -w to kill workers (increments Attempts.Failed)
  3. Run gov start to restart
  4. Tasks complete successfully (state changes to merged, etc.)
  5. Run gov why - incorrectly shows the completed tasks

Root Cause

The whyTaskKind() function in main.go was checking if task.Attempts.Failed > 0 to determine if a task should appear in output. This matches any task that has ever failed, not just tasks that are currently failing.

When workers are killed:

  • task.Attempts.Failed is incremented
  • Task transitions to blocked state
  • When task resumes and succeeds, it transitions to success states
  • But Attempts.Failed is never reset - it remains as historical record

The old logic showed any task with historical failures, even if it had since recovered.

Solution

Removed the Attempts.Failed > 0 check from whyTaskKind(). Now the function only shows:

  1. Tasks currently in TaskStateBlocked (actively blocked/failing)
  2. Planning tasks that caused supervisor failure

This preserves the Attempts.Failed counter for observability while fixing the incorrect gov why output.

Changes

main.go:

  • Removed if task.Attempts.Failed > 0 { return "failed" } check
  • Tasks with historical failures but current success states no longer appear

main_test.go:

  • Updated test fixtures to use state: "blocked" instead of state: "triaged" with failed: 1
  • Tests now correctly verify that only currently-blocked tasks appear in output

Testing

All tests pass:

go test ./...

Manual verification shows completed tasks with historical failures no longer appear in gov why output.

The `gov why` command was incorrectly showing tasks with historical failures
even after they had successfully completed. This was caused by the
`whyTaskKind()` function checking `task.Attempts.Failed > 0`, which matches
any task that has ever failed, regardless of its current state.

Root cause:
- When `gov stop -w` kills a worker, `Attempts.Failed` is incremented
- The task transitions to `blocked` state
- When the task is resumed and completes successfully, it transitions to
  success states (merged, etc.) but `Attempts.Failed` remains > 0
- The `gov why` command would still show the task because of the historical
  failure count

Fix:
- Removed the `Attempts.Failed > 0` check from `whyTaskKind()`
- Tasks in `TaskStateBlocked` are still shown (currently blocked/failing)
- Planning tasks that caused supervisor failure are still shown
- Historical failures no longer cause completed tasks to appear in output

This preserves the `Attempts.Failed` counter for observability while fixing
the display issue.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@cmtonkinson cmtonkinson merged commit 0535c62 into main Feb 14, 2026
2 checks passed
@cmtonkinson cmtonkinson deleted the fix-issue-3 branch February 15, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State/Flag error ("why" output)

1 participant