* fix(ready): --explain sorts a ready issue's blocking edges by status instead of calling a pinned dependency resolved (wy-0h6t03) The ready query skips a pinned target exactly as it skips a closed one, so a blocks edge onto a pinned bead never fences its dependent. The explanation never read the target's status: every blocking edge of a ready issue was appended to ResolvedBlockers, so a bead wired behind a long-lived pinned bring-up reported "1 blocker(s) resolved" while its precondition was unmet. Two trials sat on a takeable front for days that way. BuildReadyExplanation now sorts each blocks / conditional-blocks / waits-for edge by the target's status in blockerMap: closed stays under ResolvedBlockers, pinned goes to PinnedDependencies (never block), any other status to OpenDependencies (not blocking; the #6066 shape, now visible). A target without a status in the map keeps the old treatment. Reason keeps its "N blocker(s) resolved" lead and appends the other two counts as clauses. Both explain routes previously fetched only the blockers of blocked issues, so no ready target ever had a status; explainBlockerIDs now adds the ready issues' blocking-dependency targets to that one batch fetch, once each, and printReadyItemDependencies prints the three lines for both routes. Pinned-never-blocks itself is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * build(bazel): list ready_explain_ids_test.go in the cmd/bd go_test srcs (wy-0h6t03) The equivalence gate named TestExplainBlockerIDs and TestExplainBlockerIDs_Empty as tests go test runs that Bazel did not: the new test file was never added to BUILD.bazel. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// explainBlockerIDs must hand the explanation every id whose status it
|
|
// reads: the blockers of blocked issues AND the blocking-dependency targets of
|
|
// ready issues (the ones whose closed-or-pinned status the ready query
|
|
// collapsed), once each, and no parent-child or related target.
|
|
func TestExplainBlockerIDs(t *testing.T) {
|
|
blocked := []*types.BlockedIssue{
|
|
{Issue: types.Issue{ID: "bd-b1"}, BlockedBy: []string{"bd-x", "bd-y"}},
|
|
{Issue: types.Issue{ID: "bd-b2"}, BlockedBy: []string{"bd-y", ""}},
|
|
}
|
|
ready := []*types.Issue{{ID: "bd-r1"}, {ID: "bd-r2"}}
|
|
allDeps := map[string][]*types.Dependency{
|
|
"bd-r1": {
|
|
{IssueID: "bd-r1", DependsOnID: "bd-pinned", Type: types.DepBlocks},
|
|
{IssueID: "bd-r1", DependsOnID: "bd-x", Type: types.DepConditionalBlocks},
|
|
{IssueID: "bd-r1", DependsOnID: "bd-epic", Type: types.DepParentChild},
|
|
},
|
|
"bd-r2": {
|
|
{IssueID: "bd-r2", DependsOnID: "bd-spawner", Type: types.DepWaitsFor},
|
|
{IssueID: "bd-r2", DependsOnID: "bd-rel", Type: types.DepRelated},
|
|
},
|
|
"bd-not-ready": {
|
|
{IssueID: "bd-not-ready", DependsOnID: "bd-elsewhere", Type: types.DepBlocks},
|
|
},
|
|
}
|
|
|
|
got := explainBlockerIDs(blocked, ready, allDeps)
|
|
want := []string{"bd-x", "bd-y", "bd-pinned", "bd-spawner"}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("explainBlockerIDs = %v, want %v", got, want)
|
|
}
|
|
for i := range want {
|
|
if got[i] != want[i] {
|
|
t.Fatalf("explainBlockerIDs = %v, want %v", got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestExplainBlockerIDs_Empty(t *testing.T) {
|
|
if got := explainBlockerIDs(nil, nil, nil); len(got) != 0 {
|
|
t.Fatalf("expected no ids, got %v", got)
|
|
}
|
|
}
|