wy-j2upyy: compute gated_by AFTER the dependencies read in BuildIssueDetails
The be-lpi merge (#6352) moved src.Dependencies() below the cardinality
counts so the unresolvable-edge delta reads count-first. That hunk merged
cleanly, which left details.GatedBy computed on the still-nil slice, and
both CI shards' show_json…carries_gated_by subtests went red (PR Risk
Embedded Dolt Cmd 20/20, Proxied Dolt Cmd 4/15 at d21237f3dc).
Move the GatedBy line to directly after details.Dependencies = deps, still
before the BriefDeps trim that rewrites the slice, and pin the ordering with
a workapi unit test over both DetailSource seams and BriefDeps on/off (red
on the pre-fix code, green after).
Ran: go test ./internal/workapi; go vet ./internal/workapi;
BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd -run TestEmbeddedGatedRendering;
BEADS_TEST_PROXIED_SERVER=1 go test ./cmd/bd -run TestProxiedServerGatedRendering.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
d21237f3dc
commit
c43eb567d2
2 changed files with 65 additions and 8 deletions
|
|
@ -118,14 +118,6 @@ func BuildIssueDetails(ctx context.Context, src DetailSource, issue *types.Issue
|
|||
|
||||
details.Labels, _ = src.Labels(ctx, id, isWisp)
|
||||
|
||||
// The gates blocking this issue are the gate-typed subset of the
|
||||
// dependencies just read (types.GatesHolding, the one predicate the
|
||||
// readiness query's is_blocked column encodes — subject clause included,
|
||||
// so a closed or pinned issue publishes no gated_by), which costs no extra
|
||||
// query. Computed BEFORE the BriefDeps trim below, which rewrites the
|
||||
// slice.
|
||||
details.GatedBy = types.GateRefs(types.GatesHolding(issue, details.Dependencies))
|
||||
|
||||
// Aggregate counts - O(1) queries, no row materialization.
|
||||
//
|
||||
// THE COUNTS ARE READ BEFORE THE ROW LISTS, and the order is load-bearing
|
||||
|
|
@ -153,6 +145,16 @@ func BuildIssueDetails(ctx context.Context, src DetailSource, issue *types.Issue
|
|||
deps, depsErr := src.Dependencies(ctx, id, isWisp)
|
||||
details.Dependencies = deps
|
||||
|
||||
// The gates blocking this issue are the gate-typed subset of the
|
||||
// dependencies JUST read (types.GatesHolding, the one predicate the
|
||||
// readiness query's is_blocked column encodes — subject clause included,
|
||||
// so a closed or pinned issue publishes no gated_by), which costs no extra
|
||||
// query. The order is load-bearing twice over: computed AFTER the
|
||||
// Dependencies read above (an earlier slot sees the nil slice and
|
||||
// publishes no gate at all) and BEFORE the BriefDeps trim below, which
|
||||
// rewrites the slice.
|
||||
details.GatedBy = types.GateRefs(types.GatesHolding(issue, details.Dependencies))
|
||||
|
||||
// The count counts edge ROWS; the slice carries the issues on the far
|
||||
// end, and drops any whose id has no row in this database. The two
|
||||
// therefore disagree by exactly the cross-repo and `external:` edges,
|
||||
|
|
|
|||
|
|
@ -793,3 +793,58 @@ func deref(t *testing.T, v *int64) int64 {
|
|||
}
|
||||
return *v
|
||||
}
|
||||
|
||||
// TestBuildIssueDetailsGatedByReadsTheDependencies pins the ORDER of the
|
||||
// build: gated_by is derived from the Dependencies slice, so it must be
|
||||
// computed after that slice is read and before BriefDeps rewrites it. The
|
||||
// be-lpi merge moved the read below the counts and silently left gated_by
|
||||
// computed on a nil slice (wy-j2upyy, PR #6606 CI).
|
||||
func TestBuildIssueDetailsGatedByReadsTheDependencies(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
heavy := strings.Repeat("x", 1024)
|
||||
|
||||
newFixture := func() *detailFixture {
|
||||
fx := newDetailFixture()
|
||||
fx.deps["bd-1"] = []*types.IssueWithDependencyMetadata{
|
||||
{
|
||||
Issue: types.Issue{
|
||||
ID: "bd-gate", Title: "Gate: human", Status: types.StatusOpen,
|
||||
IssueType: types.TypeGate, Priority: 2, Description: heavy,
|
||||
},
|
||||
DependencyType: types.DepBlocks,
|
||||
},
|
||||
{
|
||||
Issue: types.Issue{ID: "bd-blocker", Title: "Blocker", Status: types.StatusOpen, IssueType: types.TypeTask},
|
||||
DependencyType: types.DepBlocks,
|
||||
},
|
||||
}
|
||||
return fx
|
||||
}
|
||||
|
||||
wantGate := func(t *testing.T, details *types.IssueDetails) {
|
||||
t.Helper()
|
||||
if len(details.GatedBy) != 1 {
|
||||
t.Fatalf("gated_by = %#v, want exactly the one open gate", details.GatedBy)
|
||||
}
|
||||
if got := details.GatedBy[0].ID; got != "bd-gate" {
|
||||
t.Fatalf("gated_by[0].ID = %q, want bd-gate", got)
|
||||
}
|
||||
}
|
||||
|
||||
for _, opts := range []DetailOptions{{}, {BriefDeps: true}} {
|
||||
t.Run(fmt.Sprintf("BriefDeps=%v", opts.BriefDeps), func(t *testing.T) {
|
||||
fx := newFixture()
|
||||
store, useCase := fixtureSources(fx)
|
||||
for name, src := range map[string]DetailSource{"store": store, "usecase": useCase} {
|
||||
details, err := BuildIssueDetails(ctx, src, fx.issues["bd-1"], false, opts)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: BuildIssueDetails: %v", name, err)
|
||||
}
|
||||
wantGate(t, details)
|
||||
if len(details.Dependencies) != 2 {
|
||||
t.Fatalf("%s: dependencies = %d rows, want 2", name, len(details.Dependencies))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue