fix: prevent closing issues with open blockers (GH#962)

Added IsBlocked method to Storage interface that checks if an issue is
in the blocked_issues_cache and returns the blocking issue IDs.

The close command now checks for blockers before allowing an issue to
be closed:
- If an issue has open blockers, closing is blocked with an error message
- The --force flag overrides this check
- Works in both daemon mode (RPC) and direct storage mode
- Also handles cross-rig routed IDs

This addresses the bug where agents could close a bead even when it
depends on an open bug/issue.

Closes #962

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
fang
2026-01-09 22:56:56 -08:00
committed by Steve Yegge
parent 0933bf5eda
commit a851104203
8 changed files with 175 additions and 0 deletions

View File

@@ -122,6 +122,7 @@ create, update, show, or close operation).`,
Reason: reason,
Session: session,
SuggestNext: suggestNext,
Force: force,
}
resp, err := daemonClient.CloseIssue(closeArgs)
if err != nil {
@@ -191,6 +192,21 @@ create, update, show, or close operation).`,
continue
}
// Check if issue has open blockers (GH#962)
if !force {
blocked, blockers, err := result.Store.IsBlocked(ctx, result.ResolvedID)
if err != nil {
result.Close()
fmt.Fprintf(os.Stderr, "Error checking blockers for %s: %v\n", id, err)
continue
}
if blocked && len(blockers) > 0 {
result.Close()
fmt.Fprintf(os.Stderr, "cannot close %s: blocked by open issues %v (use --force to override)\n", id, blockers)
continue
}
}
if err := result.Store.CloseIssue(ctx, result.ResolvedID, reason, actor, session); err != nil {
result.Close()
fmt.Fprintf(os.Stderr, "Error closing %s: %v\n", id, err)
@@ -240,6 +256,19 @@ create, update, show, or close operation).`,
continue
}
// Check if issue has open blockers (GH#962)
if !force {
blocked, blockers, err := store.IsBlocked(ctx, id)
if err != nil {
fmt.Fprintf(os.Stderr, "Error checking blockers for %s: %v\n", id, err)
continue
}
if blocked && len(blockers) > 0 {
fmt.Fprintf(os.Stderr, "cannot close %s: blocked by open issues %v (use --force to override)\n", id, blockers)
continue
}
}
if err := store.CloseIssue(ctx, id, reason, actor, session); err != nil {
fmt.Fprintf(os.Stderr, "Error closing %s: %v\n", id, err)
continue
@@ -283,6 +312,21 @@ create, update, show, or close operation).`,
continue
}
// Check if issue has open blockers (GH#962)
if !force {
blocked, blockers, err := result.Store.IsBlocked(ctx, result.ResolvedID)
if err != nil {
result.Close()
fmt.Fprintf(os.Stderr, "Error checking blockers for %s: %v\n", id, err)
continue
}
if blocked && len(blockers) > 0 {
result.Close()
fmt.Fprintf(os.Stderr, "cannot close %s: blocked by open issues %v (use --force to override)\n", id, blockers)
continue
}
}
if err := result.Store.CloseIssue(ctx, result.ResolvedID, reason, actor, session); err != nil {
result.Close()
fmt.Fprintf(os.Stderr, "Error closing %s: %v\n", id, err)