fix(count): PR #7199 review follow-ups — exclude-status config load, ParentID doc swap

Addresses bee's REQUEST-CHANGES on gastownhall/beads#7199 (S8):

1. BLOCKER: storecounter.filter and uow.countFilter only loaded the
   workspace list config when IncludeInfra was set, so BuildCountFilter's
   ExcludeStatus validation refused a workspace's own custom status unless
   the caller also passed the unrelated IncludeInfra flag. Both legs now
   load the config when IncludeInfra OR len(ExcludeStatus) > 0, with
   comments corrected to say so. Added leg-level regression tests (the
   conformance fixture cannot drive a workspace-configured custom status)
   on embeddeddolt and uow, reproducing the reviewer's CLI repro directly,
   plus an HTTP-level probe in cmd/bd's real-Dolt proxied count test.
2. issueops.ReadyRequest.ParentID's comment had been overwritten with the
   one-level direct-children wording that belongs to ListRequest.ParentID;
   Ready actually walks all descendants via GetDescendantIDsInTx (GH#3396).
   Restored the descendants comment on ReadyRequest.ParentID and moved the
   one-level explanation to ListRequest.ParentID, which had none.

Verified: make api-check; dolt-server, embeddeddolt and uow Counter
contract legs (BEADS_TEST_DOLT_SERVER=local with a pinned dolt binary for
uow; Docker for the dolt-server leg); the new proxied HTTP exclude_status
probe (BEADS_TEST_PROXIED_SERVER=1).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Julian Knutsen 2026-10-05 00:50:11 +00:00 • committed by Eddie the Engineer
commit f23bf5ddbf
6 changed files with 229 additions and 23 deletions

View file

@ -255,6 +255,51 @@ func TestProxiedServerServeCount(t *testing.T) {
}
})
// PR #7199 REVIEW: exclude_status against a WORKSPACE CUSTOM STATUS, over
// the wire and with include_infra left unset. The fake-role tests in
// internal/httpapi cannot write this case — a fake cannot be asked whether a
// custom status is in its own vocabulary — and the bug this pins lived below
// the HTTP layer anyway (storecounter and uow's countFilter only loaded the
// workspace's list configuration when include_infra was set, so
// BuildCountFilter's validation refused a status the workspace itself
// defined unless the caller also happened to pass the unrelated flag).
t.Run("exclude_status accepts a workspace custom status without include_infra", func(t *testing.T) {
label := countSliceLabel + "-customstatus"
scopedCustom := "?label=" + label
if out, err := bdProxiedRun(t, bd, p.dir, "config", "set", "status.custom", "review,qa"); err != nil {
t.Fatalf("bd config set status.custom: %v\n%s", err, out)
}
bdProxiedCreate(t, bd, p.dir, "custom status open row", "-p", "2", "-l", label)
reviewRow := bdProxiedCreate(t, bd, p.dir, "custom status review row", "-p", "2", "-l", label)
if out, err := bdProxiedRun(t, bd, p.dir, "update", reviewRow.ID, "--status", "review"); err != nil {
t.Fatalf("bd update --status review: %v\n%s", err, out)
}
_, total, _ := sp.countIssues(t, scopedCustom)
if total != 2 {
t.Fatalf("total = %d, want 2", total)
}
// include_infra is NOT in this query string. Before the fix this 400'd
// with an "invalid exclude-status" refusal because the config load that
// feeds BuildCountFilter's vocabulary check was gated on include_infra
// alone.
status, narrowed, _ := sp.countIssues(t, scopedCustom+"&exclude_status=review")
if status != http.StatusOK {
t.Fatalf("exclude_status=review (a workspace custom status, include_infra unset): status = %d, want 200", status)
}
if narrowed != 1 {
t.Fatalf("exclude_status=review counted %d, want 1", narrowed)
}
// The parity oracle, same as the sibling cases above.
if cli := bdProxiedCountTotal(t, bd, p.dir, "--label", label, "--exclude-status", "review"); cli != narrowed {
t.Errorf("bd count --exclude-status review = %d, the server said %d", cli, narrowed)
}
})
// The refusals, over the wire: a closed vocabulary and a typed parameter
// set, both refused before any query runs.
t.Run("the document's refusals are refused", func(t *testing.T) {

View file

@ -6,6 +6,8 @@ import (
"testing"
"github.com/steveyegge/beads/backend/conformance"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// TestCounterContract runs the Counter contract against the embedded store,
@ -118,3 +120,67 @@ func newEmbeddedCounterFixture(t *testing.T, te *testEnv, prefix string) conform
List: reader.List,
}
}
// TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra
// pins the PR #7199 review's blocker fix: the store-backed Counter must load
// the workspace's list configuration when ExcludeStatus is non-empty, not
// only when IncludeInfra is set, so BuildCountFilter's validation sees the
// workspace's own custom statuses. A leg-level test, not a conformance case,
// because CounterFixture cannot drive a workspace-configured custom status
// (counter_contract.go's CounterFixture doc) — this needs a real store with
// status.custom set.
//
// Reproduces the reviewer's CLI repro directly against the store: with
// status.custom="review,qa", an issue moved to "review", and IncludeInfra
// left unset, `--exclude-status review` must narrow the count instead of
// being refused as an unrecognized status.
func TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra(t *testing.T) {
skipUnlessEmbeddedDolt(t)
te := newTestEnv(t, "cntcs")
ctx := t.Context()
if err := te.store.SetConfig(ctx, "status.custom", "review,qa"); err != nil {
t.Fatalf("SetConfig(status.custom): %v", err)
}
const openID = "cntcs-open"
const reviewID = "cntcs-review"
for _, id := range []string{openID, reviewID} {
if err := te.store.CreateIssue(ctx, &types.Issue{
ID: id, Title: id, Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask,
}, "tester"); err != nil {
t.Fatalf("CreateIssue(%s): %v", id, err)
}
}
if err := te.store.UpdateIssue(ctx, reviewID, map[string]interface{}{
"status": types.Status("review"),
}, "tester"); err != nil {
t.Fatalf("UpdateIssue(%s) to review: %v", reviewID, err)
}
counter, err := te.store.Counter()
if err != nil {
t.Fatalf("Counter(): %v", err)
}
scope := publicops.CountRequest{IDFilter: openID + "," + reviewID}
total, err := counter.Count(ctx, scope)
if err != nil {
t.Fatalf("Count(unfiltered): %v", err)
}
if total.Total != 2 {
t.Fatalf("Count(unfiltered).Total = %d, want 2", total.Total)
}
// IncludeInfra left UNSET: before the fix this refused with "invalid
// exclude-status \"review\"" because the config load was gated on
// IncludeInfra alone.
scope.ExcludeStatus = []string{"review"}
result, err := counter.Count(ctx, scope)
if err != nil {
t.Fatalf("Count(exclude-status=review, IncludeInfra unset): %v, want the custom status accepted", err)
}
if result.Total != 1 {
t.Fatalf("Count(exclude-status=review).Total = %d, want 1", result.Total)
}
}

View file

@ -85,11 +85,14 @@ func (c *counter) CountByGroup(ctx context.Context, req publicops.CountByGroupRe
}
// countFilter builds the storage filter from the unit of work the call already
// holds, loading configuration only when IncludeInfra can read it — the same two
// decisions the store-backed body makes, through the same builder.
// holds, loading configuration only when IncludeInfra or ExcludeStatus can
// read it — the same two decisions the store-backed body makes, through the
// same builder. ExcludeStatus needs the workspace's custom status names so
// BuildCountFilter's validation does not refuse a status the workspace itself
// defines (PR #7199 review).
func countFilter(ctx context.Context, uw UnitOfWork, req publicops.CountRequest) (types.IssueFilter, error) {
var cfg workapi.ListConfig
if req.IncludeInfra {
if req.IncludeInfra || len(req.ExcludeStatus) > 0 {
loaded, err := workapi.LoadUOWListConfig(ctx, uw)
if err != nil {
return types.IssueFilter{}, err

View file

@ -5,6 +5,9 @@ import (
"testing"
"github.com/steveyegge/beads/backend/conformance"
"github.com/steveyegge/beads/internal/storage/domain"
"github.com/steveyegge/beads/internal/types"
publicops "github.com/steveyegge/beads/issueops"
)
// TestCounterContract runs the Counter contract against the unit-of-work
@ -126,3 +129,80 @@ func newUOWCounterFixture(t *testing.T, ctx context.Context, prefix string) conf
List: reader.List,
}
}
// TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra
// pins the PR #7199 review's blocker fix on the unit-of-work leg: countFilter
// must load the workspace's list configuration when ExcludeStatus is
// non-empty, not only when IncludeInfra is set, so BuildCountFilter's
// validation sees the workspace's own custom statuses. A leg-level test, not
// a conformance case, because CounterFixture cannot drive a
// workspace-configured custom status (counter_contract.go's CounterFixture
// doc) — this needs a real provider with status.custom set.
//
// Its own provider (not newUOWCounterFixture's), so status.custom does not
// leak into the other subtests sharing that fixture's one database.
func TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra(t *testing.T) {
ctx := context.Background()
provider := newUOWRoleFixtureProvider(t, ctx, "cntcs")
if err := RunTx(ctx, provider, func(ctx context.Context, uw UnitOfWork) (string, error) {
return "set status.custom", uw.ConfigUseCase().SetConfig(ctx, "status.custom", "review,qa")
}); err != nil {
t.Fatalf("SetConfig(status.custom): %v", err)
}
const openID = "cntcs-open"
const reviewID = "cntcs-review"
for _, id := range []string{openID, reviewID} {
id := id
if err := RunTx(ctx, provider, func(ctx context.Context, uw UnitOfWork) (string, error) {
_, err := uw.IssueUseCase().CreateIssue(ctx, domain.CreateIssueParams{
Issue: &types.Issue{
ID: id, Title: id, Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask,
},
ExplicitID: id,
CreateOnly: true,
}, "tester")
return "seed " + id, err
}); err != nil {
t.Fatalf("CreateIssue(%s): %v", id, err)
}
}
if err := RunTx(ctx, provider, func(ctx context.Context, uw UnitOfWork) (string, error) {
return "move to review", uw.IssueUseCase().UpdateIssue(ctx, reviewID, map[string]any{
"status": types.Status("review"),
}, "tester")
}); err != nil {
t.Fatalf("UpdateIssue(%s) to review: %v", reviewID, err)
}
source, ok := provider.(CounterSource)
if !ok {
t.Fatalf("provider %T does not offer the Counter accessor", provider)
}
counter, err := source.Counter()
if err != nil {
t.Fatalf("Counter(): %v", err)
}
scope := publicops.CountRequest{IDFilter: openID + "," + reviewID}
total, err := counter.Count(ctx, scope)
if err != nil {
t.Fatalf("Count(unfiltered): %v", err)
}
if total.Total != 2 {
t.Fatalf("Count(unfiltered).Total = %d, want 2", total.Total)
}
// IncludeInfra left UNSET: before the fix this refused with "invalid
// exclude-status \"review\"" because the config load was gated on
// IncludeInfra alone.
scope.ExcludeStatus = []string{"review"}
result, err := counter.Count(ctx, scope)
if err != nil {
t.Fatalf("Count(exclude-status=review, IncludeInfra unset): %v, want the custom status accepted", err)
}
if result.Total != 1 {
t.Fatalf("Count(exclude-status=review).Total = %d, want 1", result.Total)
}
}

View file

@ -75,15 +75,18 @@ func (c *storeCounter) CountByGroup(ctx context.Context, req issueops.CountByGro
// filter builds the storage filter, loading the workspace configuration only
// when the request can read it.
//
// TWO THINGS ARE DELIBERATE. The load is SKIPPED unless IncludeInfra is set,
// because that flag is the only thing in a count request the configuration
// reaches. And when it does run it runs PER CALL rather than once at
// construction: the infra vocabulary is workspace state a caller can change
// between two counts, and a counter that cached it would answer for the older
// workspace.
// TWO THINGS ARE DELIBERATE. The load is SKIPPED unless IncludeInfra is set OR
// ExcludeStatus is non-empty — those are the two things in a count request the
// configuration reaches: IncludeInfra needs the infra vocabulary, and
// ExcludeStatus needs the workspace's custom status names so
// BuildCountFilter's validation does not refuse a status the workspace itself
// defines (PR #7199 review). And when it does run it runs PER CALL rather
// than once at construction: the infra vocabulary and custom statuses are
// workspace state a caller can change between two counts, and a counter that
// cached it would answer for the older workspace.
func (c *storeCounter) filter(ctx context.Context, req issueops.CountRequest) (types.IssueFilter, error) {
var cfg workapi.ListConfig
if req.IncludeInfra {
if req.IncludeInfra || len(req.ExcludeStatus) > 0 {
loaded, err := workapi.LoadStoreListConfig(ctx, c.store)
if err != nil {
return types.IssueFilter{}, err

View file

@ -54,19 +54,15 @@ type ReadyRequest struct {
// the other, and P0 has already been lost that way once.
Priority *int
// ParentID restricts to one issue's DIRECT children only: a parent-child
// dependency edge, OR (for an issue with no such edge) a dotted-id prefix
// match — the same one-level sqlbuild.ParentID clause CountRequest.ParentID
// compiles to (internal/storage/sqlbuild/filter.go). It is NOT a recursive
// descendants walk, despite this field's name and this comment's own prior
// wording (fixed in the S8 review, GH#4387): the recursive tree that
// `bd list --parent X` renders by DEFAULT comes from
// cmd/bd/list_show_filter_modes.go's findAllDescendants calling this ROLE
// once per level and accumulating the results client-side, not from the
// role answering a deeper question. `bd list --parent X --flat` (or
// --json) skips that client-side recursion and returns exactly this
// field's one-level answer, which is the invocation that agrees with
// `bd count --parent X`'s cardinality.
// ParentID restricts to ALL TRANSITIVE DESCENDANTS of one issue, not just
// its direct children: internal/storage/issueops/ready_work.go calls
// GetDescendantIDsInTx(ctx, tx, *filter.ParentID, 0), the recursive walk.
// GH#3396: this used to be a one-hop subquery against the dependency
// table, so grandchildren were silently dropped despite this comment and
// the help text both promising "descendants (recursive)" — do not
// mistake this for ListRequest.ParentID's one-level clause, which is a
// DIFFERENT query (PR #7199 review: an earlier pass here wrongly copied
// that one-level wording onto this field).
ParentID string
// MolType restricts to one molecule type.
MolType *MolType
@ -351,6 +347,19 @@ type ListRequest struct {
// ExcludeTypes entries may be comma-separated; splitting happens inside.
ExcludeTypes []string
// ParentID restricts to one issue's DIRECT children only: a parent-child
// dependency edge, OR (for an issue with no such edge) a dotted-id prefix
// match — the same one-level sqlbuild.ParentID clause CountRequest.ParentID
// compiles to (internal/storage/sqlbuild/filter.go). It is NOT a recursive
// descendants walk — that is ReadyRequest.ParentID above, a DIFFERENT
// field on a different request, backed by GetDescendantIDsInTx (GH#3396).
// The recursive tree that `bd list --parent X` renders by DEFAULT comes
// from cmd/bd/list_show_filter_modes.go's findAllDescendants calling this
// ROLE once per level and accumulating the results client-side, not from
// the role answering a deeper question. `bd list --parent X --flat` (or
// --json) skips that client-side recursion and returns exactly this
// field's one-level answer, which is the invocation that agrees with
// `bd count --parent X`'s cardinality.
ParentID string
NoParent bool
MolType *MolType