* perf(ready): recurse the descendant walk off indexed base tables (be-qfm)
`bd ready --parent` and `bd blocked --parent` compute the parent's
transitive descendants with a recursive CTE whose edge relation was a
non-recursive `parent_edges` CTE over `dependencies UNION ALL
wisp_dependencies` with the typed target columns COALESCE'd into one.
Dolt cannot index through that wrapper: it materializes the relation and
re-scans it once per recursion row, so the walk costs (parent-child rows)
x (descendants) — 7.46 s for 483 descendants on a 4.6k-edge database,
about 14 ms per descendant, and past the shared pool's read deadline on
a busy server.
Build the walk in sqlbuild.DescendantWalkQuery instead: one anchor and
one recursive member per (dependency table x typed target column), each
joining the base table on a bare indexed column, with per-column IS NULL
guards reproducing the COALESCE precedence and the LOCATE cycle guard,
depth guard and parent-child filter carried onto every member. The
recursive members carry JOIN_ORDER(d,e) LOOKUP_JOIN(d,e): the cycle guard
references both join sides, and without the hints Dolt's planner keeps
the recursive working table on the inner side and scans the edge table
per iteration, which measured no faster than the wrapper shape and
flipped plans between runs. With them the frontier is the outer side and
every member is an index probe.
issueops.GetDescendantIDsInTx and domain/db.getDescendantIDs call the
builder; they had carried the same query text separately.
Measured on a local Dolt 2.2.4 sql-server with a generated forest of
4,541 issues, 4,500 parent-child rows and 500 descendants under the
probed parent (BenchmarkDescendantWalk, new): 1.26–2.28 s/op on main,
32–36 ms/op with this change. Same rows on every target kind, cycle
and depth limit (TestDescendantWalkReachesEveryTargetKindAndStopsOnCycles,
new; the conformance ReadyParentScopesToItsTransitiveDescendants cases on
all three backends).
Refs #6128
Co-authored-by: qcore/syl <q@withq.ai>
Agent-Signature: claude-code-claude-fable-5-max on behalf of a3ackerman
* test(embeddeddolt): gate the descendant-walk reference test on cgo (be-qfm)
The embedded-Dolt test tier is cgo-only and every sibling file carries
the build tag; this one did not, so the CGO_ENABLED=0 boundary job
compiled it against a package whose helpers were excluded and failed on
an undefined newTestEnv.
Refs #6128
Agent-Signature: claude-code-claude-fable-5-max on behalf of a3ackerman
* fix(review): sync BUILD.bazel srcs and resolve every dep target column in the descendants CTE
Maintainer fixup from the PR #6130 adoption review, iterations 1 and 2.
Bazel srcs gap (major, claude+codex). The four new .go files were absent from
the gazelle-managed go_library/go_test srcs lists, so
//internal/storage/sqlbuild did not contain DescendantWalkQuery and both
consumers failed to compile under Bazel:
internal/storage/issueops/blocked.go:170:13: undefined: sqlbuild.DescendantWalkQuery
internal/storage/issueops/blocked.go:171:13: undefined: sqlbuild.DescendantWalkArgs
`make bazel-sync` adds exactly the four srcs rows the review measured; the
fifth BUILD.bazel row is a deps entry this commit's own new test requires.
A second sync leaves the tree clean. Note that `make bazel-sync-check` and
tools/bazel/go_srcs.py --check pass falsely on a srcs gap -- they manage only
the go_srcs glob filegroups -- and bazel-autofix cannot absorb this one
because bazel.yml:313 guards the sync step on steps.bazel.outcome ==
'success', which a compile break never reaches.
buildDescendantsCTE target columns (major, codex). GetDescendants' walk
resolved a row's parent through COALESCE(depends_on_issue_id,
depends_on_wisp_id), omitting depends_on_external, while the classic ParentID
filter it mirrors resolves all three and the reference test this PR adds makes
a cross-prefix parent a pinned contract for the sibling walk. ck_dep_one_target
(migration 0041) leaves exactly one target column set, so an external-target
row coalesced to NULL and could never match an edge: adding the column is
strictly additive, and it closes a gap where the proxied-server
bd list --parent tree (and --watch) could not see a cross-prefix child or
its subtree, while the direct route's per-level ParentID filter listed them.
TestBuildDescendantsCTEResolvesEveryDepTargetColumn derives the expected
column set from sqlbuild.DepTargetExpr, so the two cannot drift again.
That finding's other half -- migrating these members to the per-(table,
column) shape -- is deliberately deferred to bd-tztam and recorded at the
site. buildDescendantsCTE is a different query ((id, src, via) projection, a
dotted-ID fallback recursion, hoisted per-level filter predicates, no depth
cap, no path cycle guard), sqlbuild exports no member-fragment API, and
per-column members would triple its branch count, which the predBundle
comment above it records as tripping the dolt 2.1.6 analyzer.
nullGuards precedence and column binding (minor, claude+codex; minor, codex).
TestDescendantWalkQueryReproducesDepTargetPrecedence pins the per-column
IS NULL guards, which no existing test could see: the shape test never asserts
on a guard and the reference test seeds exactly one target column per edge, so
emptying nullGuards left both new test files green. The expected counts are
derived from DepTargetExpr's column list rather than restated, so the same
test binds descendantWalkTargetCols to it. The review's prescribed
`DepTargetExpr = "COALESCE(" + strings.Join(descendantWalkTargetCols, ", ")
+ ")"` does not compile -- issueops/dependencies.go:58 and
domain/db/dependency.go:35,:37 consume it in const declarations -- so this
takes the unit-assertion arm the same finding offers.
LOOKUP_JOIN warning multiplicity (nit, codex). The doc comment now records
that the ignored-hint warning is raised once per hint comment, six per
includeWisps=true query.
Iteration 2 (two minors, gate impact none, on a 981/850 approve).
TestGetDescendantsCrossPrefixParent pins the widened COALESCE against real
rows, where the test above pins only query text. Its edges go through the
repository's own classifier, which routes any cross-prefix target to
depends_on_external even when both ends are local, and each of its four
edges is matched by a different edge member (issues and wisps, anchor and
recursive): reverting the column at any one member reds the case with a
different set of children missing. CHANGELOG.md gains a Fixed bullet for
the user-visible half of this change, the proxied-server bd list --parent
tree.
Validation: sqlbuild 31 PASS / 0 FAIL / 0 SKIP; full domain/db package green
against the real Dolt container (915 PASS / 0 FAIL / 0 SKIP, 49s),
including TestGetDescendantsCrossPrefixParent,
TestGetDescendantsDottedOrphans, TestGetDescendantsFilteredByStatus and
TestParityReadyBlockedDescendants; golangci-lint 2.10.1 reports 0 issues on
the three changed packages; go test -run Bazel ./scripts/ is 13 PASS / 0 FAIL,
including TestBazelTestTagsFollowTaxonomy; bazel test
//internal/storage/sqlbuild:sqlbuild_test PASSED and bazel build
//internal/storage/domain/db:db_test succeeds; a final make bazel-sync
leaves the tree unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: qcore/syl <q@withq.ai>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>