* wy-raudbw: pin that a gate on a parent hides existing and later-born children from bd ready
Embedded-dolt test: epic + two children all ready; gate on the epic hides
all three; a child created after the gate is born hidden; resolving the
gate frees all four. Pins the read-time cascade (blocked-consistency
parent-child leg) that operator tooling downstream relies on.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* ci: register TestEmbeddedGateInheritsDownParentChain with Bazel and the embedded shards
Maintainer fixup for adopt-pr #6604. The PR adds a new embedded test file,
cmd/bd/gate_inherit_embedded_test.go. Its merge-base (71c4cd08b9) predates
two checks on main that every new cmd/bd embedded test has to satisfy:
- cmd/bd/BUILD.bazel: bd_test's srcs list every untagged cmd/bd test file.
Without the row, Bazel never compiles or runs the test, and bazel.yml's
"BUILD files in sync" step in the required test job fails. The row was
added by `bazel run //:gazelle`, which changed no other file.
- .github/scripts/embedded-cmd-test-shards.txt: the Bazel-only 50-shard
block must name every TestEmbedded* test exactly once, or
TestCmdEmbeddedShardManifestGeneratorNotStale fails `go test ./scripts/`.
The entry was added by `gen_embedded_cmd_shard_manifest.py 50
--weights=duration --write`, which is incremental: it placed the test on
shard 16 and moved no existing assignment.
The PR's own file is unchanged.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: match bd ready rows by exact ID in the gate-inherit pin
Maintainer fixup for adopt-pr #6604, review iteration 1.
TestEmbeddedGateInheritsDownParentChain decided whether an issue was in
`bd ready` by looking for its title anywhere in the pretty output. The
epic's two "should be ready" checks (before gate, after resolve) were
vacuous: every ready child of an epic carries a "← <epic title>"
annotation, and buildParentEpicMap fetches that parent on its own, so the
children's rows satisfied "Inherit epic" with no epic row in the list.
The review suggested matching epic.ID instead. That is vacuous too: child
IDs are hierarchical (<epic>.N, from GetNextChildIDTx), so the epic's ID is
a substring of every child row. wantReady now takes the created issue and
requires its ID as a whole whitespace-separated token of the output. The
test keeps reading the pretty route (GetReadyWork) it was written against;
--json would read through GetReadyWorkWithCountsAndTotal instead.
Evidence: `BEADS_TEST_EMBEDDED_DOLT=1 go test -tags gms_pure_go ./cmd/bd/
-run '^TestEmbeddedGateInheritsDownParentChain$'` in git-archive copies,
with BD_*/BEADS_*/GC_* unset so the bd binary is built from the copy.
- Unmutated: PASS.
- Mutant A, "epic" added to sqlbuild.ReadyWorkExcludeTypes. Ready printed
"○ gi-83o.1 P2 Inherit child one ← Inherit epic" and no gi-83o row. The
title check PASSED, the epic.ID substring check PASSED, and the ID-token
check FAILED at the before-gate and after-resolve epic lines.
- Mutant B, the issues parent-child leg of
shouldBeBlockedIDsUnionScopedSQL disabled, so a gated parent no longer
hides its children. The ID-token check fails at exactly the three child
lines. The title check also failed the epic's "hidden" check, although
the epic row was absent, because the children's annotation carried its
title.
Unchanged: the gate ID is still taken from the first "gi-" token of
`bd gate create`. renderGateCreated documents its first line, "Created
gate <id>", as parsed by downstream scripts.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
99 lines
3.6 KiB
Go
99 lines
3.6 KiB
Go
//go:build cgo
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// TestEmbeddedGateInheritsDownParentChain pins the property that a gate on a
|
|
// parent hides the parent AND every child from `bd ready` — children that
|
|
// existed when the gate was created and children created afterwards alike —
|
|
// and that resolving the gate frees all of them. The wyvern rig's operator
|
|
// tooling relies on this (its own gate labels are a snapshot; the bd ready
|
|
// fence is not), so a regression here would silently put shelved work back
|
|
// on agent fronts. Mechanism under test: a gate is a blocks-dependency onto
|
|
// the gate issue, and the parent-child leg of the blocked-consistency
|
|
// recompute cascades a parent's blockedness to its children.
|
|
func TestEmbeddedGateInheritsDownParentChain(t *testing.T) {
|
|
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
|
|
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
|
|
}
|
|
t.Parallel()
|
|
|
|
bd := buildEmbeddedBD(t)
|
|
dir, beadsDir, _ := bdInit(t, bd, "--prefix", "gi")
|
|
store := openStore(t, beadsDir, "gi")
|
|
if err := store.SetConfig(t.Context(), "types.custom", `["gate"]`); err != nil {
|
|
t.Fatalf("SetConfig types.custom: %v", err)
|
|
}
|
|
store.Close()
|
|
|
|
ready := func() string {
|
|
t.Helper()
|
|
cmd := exec.Command(bd, "ready", "--limit", "0")
|
|
cmd.Dir = dir
|
|
cmd.Env = bdEnv(dir)
|
|
stdout, stderr, err := runCommandBuffers(t, cmd)
|
|
if err != nil {
|
|
t.Fatalf("bd ready failed: %v\nstdout:\n%s\nstderr:\n%s", err, stdout.String(), stderr.String())
|
|
}
|
|
return stdout.String()
|
|
}
|
|
// An issue counts as listed only when its ID is a whole token of the
|
|
// output. Neither its title nor a substring of its ID will do: every
|
|
// ready child of an epic carries a "← <epic title>" annotation, and a
|
|
// child's hierarchical ID (<epic>.N) contains the epic's ID, so either
|
|
// looser match would let a child row stand in for the epic.
|
|
wantReady := func(out string, issue *types.Issue, want bool, when string) {
|
|
t.Helper()
|
|
if got := slices.Contains(strings.Fields(out), issue.ID); got != want {
|
|
t.Errorf("%s: %s (%q) in ready = %v, want %v\n%s", when, issue.ID, issue.Title, got, want, out)
|
|
}
|
|
}
|
|
|
|
epic := bdCreate(t, bd, dir, "Inherit epic", "--type", "epic")
|
|
one := bdCreate(t, bd, dir, "Inherit child one", "--type", "task", "--parent", epic.ID)
|
|
two := bdCreate(t, bd, dir, "Inherit child two", "--type", "task", "--parent", epic.ID)
|
|
|
|
out := ready()
|
|
wantReady(out, epic, true, "before gate")
|
|
wantReady(out, one, true, "before gate")
|
|
wantReady(out, two, true, "before gate")
|
|
|
|
gateOut := bdGate(t, bd, dir, "create", "--blocks", epic.ID, "--reason", "hold the whole tree")
|
|
var gateID string
|
|
for _, word := range strings.Fields(gateOut) {
|
|
if strings.HasPrefix(word, "gi-") {
|
|
gateID = word
|
|
break
|
|
}
|
|
}
|
|
if gateID == "" {
|
|
t.Fatalf("could not extract gate ID from output: %s", gateOut)
|
|
}
|
|
|
|
out = ready()
|
|
wantReady(out, epic, false, "gate open, existing children")
|
|
wantReady(out, one, false, "gate open, existing children")
|
|
wantReady(out, two, false, "gate open, existing children")
|
|
|
|
// A child filed AFTER the gate must be born hidden too: the fence is a
|
|
// property of the tree at read time, not a snapshot at gate time.
|
|
late := bdCreate(t, bd, dir, "Inherit child late", "--type", "task", "--parent", epic.ID)
|
|
out = ready()
|
|
wantReady(out, late, false, "gate open, later-born child")
|
|
|
|
bdGate(t, bd, dir, "resolve", gateID, "--reason", "released")
|
|
out = ready()
|
|
wantReady(out, epic, true, "after resolve")
|
|
wantReady(out, one, true, "after resolve")
|
|
wantReady(out, two, true, "after resolve")
|
|
wantReady(out, late, true, "after resolve")
|
|
}
|