show/list: render a derived GATED decoration when an open gate holds the bead (#6606)
* wy-j2upyy: render the derived GATED decoration on bd show and bd list
A bead an open gate blocks is excluded from `bd ready` but rendered
`[P2 · OPEN]` by `bd show` and with a plain ○ by `bd list`, so the human
surfaces disagreed with the readiness query.
The decoration is DERIVED, never stored: no status write, no --status
filter change, no existing JSON field reshaped.
- internal/types/gated.go: IsActiveGate, the ONE predicate — a gate-typed
dependency reached over a blocking edge (blocks / conditional-blocks /
waits-for) whose status is neither closed nor pinned. That is the
is_blocked recompute's blocking leg restricted to gates, so a rendered
GATED and a `bd ready` exclusion cannot disagree. GateDescription /
GateReason own the reason's round trip with `bd gate create`.
- bd show: `[P2 · OPEN · GATED]` plus one `Gated by: <id> (<type>[:
<reason>][, awaiting <await-id>])` line per gate, beside Deferred:. The
dependency read the DEPENDS ON section already made is hoisted, so the
decoration costs no extra query.
- bd list: ⊘ in the glyph column (circle family, distinct from ○ and ❄),
and a legend entry when the page carries one. Batched by id set —
at most two extra queries per listing, one in the tree view where the
edge map is already loaded.
- --json: additive `gated_by: [{id,type,reason}]` on the detail view,
omitted when empty; documented in the OpenAPI IssueDetails schema.
Tests (red first): cmd/bd/gated_render_embedded_test.go drives real
bd show/list/--json over an embedded rig — gated, resolved, deferred+gated,
JSON additivity — plus pure unit tests for the predicate and formatters.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: document the additive gated_by field in the JSON schema reference
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: cover the flat list route's own batched gate read
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: make GATED the readiness rule's gate clause, both halves
The adversarial review found the "one predicate shared with bd ready" claim
false on two axes, and both were reproducible by hand:
BLOCKER 1 — waits-for is not the status rule. The is_blocked recompute applies
"target not closed and not pinned" only to its blocks / conditional-blocks
legs; the waits-for leg goes through waitsForGateBlockedSQL, a fanout over the
target's open parent-child children (or an also_blocks spawner). A plain
`bd dep add X G -t waits-for` onto an open childless gate therefore leaves X
in `bd ready` while every new surface called it GATED. Mirroring that leg in
Go would be a second implementation of a rule the database owns, so the edge
clause now names the two legs it really mirrors (types.IsGateEdge) and the
test that pinned the wrong direction is flipped.
BLOCKER 2 — the subject half was missing and spelled three different ways.
unmarkAllBlockedSQL forces is_blocked=0 for a closed or pinned subject
whatever its edges say, so `bd ready` never withholds one on a gate's account;
show and workapi filtered nothing, cmd/bd/gated.go filtered closed only, and
list_format.go filtered closed at two more sites. A force-closed bead rendered
[CLOSED · GATED] with gated_by on show while list showed a plain row — show
and list disagreeing about one bead, which is the drift this was meant to
prevent. The clause is now types.SubjectCanBeGated, asked once in
types.GatesHolding (which replaces ActiveGates and takes the subject) and once
in the listing helper that has no hydrated deps; the formatters re-ask the SAME
exported predicate rather than inventing a fourth spelling.
SHOULD 3 — agent mode computed the gate reads and threw them away, in every
CLAUDE_CODE seat, i.e. the population that filed the bug. Decorating it is the
real fix, so gatesByIssueID now returns the gate IDS and formatAgentIssue
carries "gated by: <id>" in the parenthetical it already prints. A gate is
also a blocker, so its id appears under both "blocked by" and "gated by": the
first says what to wait on, the second says which of those nobody can clear by
doing more work. --long and --format render no gate and no longer pay for the
reads.
NOTE 5 — a pinned+gated row kept ⊘ instead of 📌; with the subject clause a
pinned bead is not gated at all, so the pin survives by construction.
NOTE 6 — the cost comments claimed "two queries" / "exactly ONE"; the id-set
readers are a few round trips each. The bound that is real (per page, never
per row) is what the comments now say.
Tests, red-first: the flipped waits-for case; TestGatesHoldingSubjectStatus and
TestSubjectCanBeGated (open/in_progress/deferred yes, closed/pinned/nil no);
TestFormatIssueCompactGated and TestFormatAgentIssueGated; and four embedded
arms — a waits-for edge that bd ready lists and no surface decorates, a
force-closed subject and a pinned subject that render nothing and publish no
gated_by, and the agent line naming its gate. Each was watched to fail against
the pre-fix predicate before it passed.
Ran: go test ./internal/types/ -run 'TestGateIsHolding|TestGatesHolding|
TestSubjectCanBeGated|TestGateDescriptionRoundTrip|TestGateRefsProjection';
go test ./cmd/bd/ -run 'TestFormat*Gated|TestFormatIssueCompact*|
TestFormatDependencyInfoWithParent|TestListRoles*|TestDisplayPrettyList*';
BEADS_TEST_EMBEDDED_DOLT=1 go test ./cmd/bd/ -run TestEmbeddedGatedRendering
(11/11 subtests); gofmt -l (empty), go vet and golangci-lint on cmd/bd,
internal/types, internal/ui, internal/workapi; scripts/ci/pr-policy.sh.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: render GATED on the proxied `bd show` text route
SHOULD 4 of the review, and required for this rig: the constellation runs
proxied-server, where `bd show --json` already carried gated_by (uow
issue_reader -> workapi.BuildIssueDetails) while the TEXT renderer called the
plain formatters. The same bead read two ways from the same server disagreed.
proxiedRenderIssue now hoists the outgoing-edge read it already did for the
DEPENDS ON section above the header — the gates are the gate-typed subset of
that very set, so the decoration costs no extra query — and passes them to
formatIssueHeaderWithGates / formatIssueMetadataWithGates. The proxied LIST
routes were wired in the previous commit.
TestProxiedServerGatedRendering covers all five text surfaces plus the JSON
one beside them (header + Gated by line, pretty glyph, compact glyph + "gated
by", agent line, and a closed subject that renders nothing). Watched red first
with the proxied decoration stubbed out: four of six subtests failed, and the
--json arm passed, which is exactly the asymmetry the review reported.
Ran: BEADS_TEST_PROXIED_SERVER=1 go test ./cmd/bd/
-run TestProxiedServerGatedRendering -count=1 (6/6, 37.8s).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: put cmd/bd/state.go on the shared "Reason:" marker
NOTE 7 of the review: types' gateReasonMarker was not gate-private —
cmd/bd/state.go wrote the same "\n\nReason: " into state-change EVENT
descriptions from its own literal. No live collision (events are not
gate-typed), but the constant's doc claimed GateReason returns "" for every
gate not made by `bd gate create`, and that is false for any description
carrying the marker.
The previous commit exported the constant as types.ReasonMarker, reworded
GateReason to say what the pair really guarantees (a round trip, not a
provenance check) and pinned the honest behavior in
TestGateDescriptionRoundTrip. This commit is the second writer: state.go now
builds its event description from the same constant, so the two cannot drift
apart by accident.
Ran: go build ./...; go test ./internal/types/ -run TestGateDescriptionRoundTrip
-count=1; gofmt -l cmd/bd/state.go (empty); go vet ./cmd/bd/.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* wy-j2upyy: alias types.GateRef in package backend
gated_by on IssueDetails makes GateRef reachable from the public backend
contract; TestPublicSurfaceComplete requires every such type to carry an
alias here.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* wy-j2upyy: build(bazel): register gated.go and its tests in cmd/bd and internal/types
The rebase onto e766da5ed carried the new source files but not their
BUILD.bazel entries, so every Bazel lane failed to compile internal/types
(undefined: GateRef). This is CI's own bazel-sync patch for 9ad7eb96c3,
applied unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* 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>
* ci: register #6606's gated-rendering tests and gated_by wire shape with main's generated gates
Maintainer fixup for adopt-pr #6606. The adopted head merges the PR head
(c43eb567d2) into main (800d43eb8d). The PR's merge-base (02f05340f6)
predates three generated artifacts on main that every PR adding a cmd/bd
tier test or a wire member has to keep current, so the merged tree is red
on them even though the PR's own CI cannot see them:
- .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/`.
`gen_embedded_cmd_shard_manifest.py 50 --weights=duration --write`
(incremental) placed TestEmbeddedGatedRendering on shard 16 and moved
no existing assignment; the frozen 20-shard block is untouched.
- .github/scripts/proxied-cmd-test-shards.txt: likewise for the 30-shard
block and TestProxiedServerGatedRendering (shard 2), via
`gen_proxied_shard_manifest.py 30 --weights=duration --write`, so
TestProxiedShardManifestGeneratorNotStale passes.
- internal/httpapi/wireshape/testdata/golden.json: TestWireShapeDigest
(#7182) pins every response member. `go run
./internal/httpapi/wireshape/cmd/gendigest` recorded the PR's new
IssueDetails.gated_by array and its id/type/reason members as four pure
additions (+25/-0), so no wire_revision bump is owed.
The PR's own files are unchanged.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(gated): state gated_by one way, mark --watch as undecorated, fix stale refs
Review follow-ups for #6606. Comment and doc text only; no behavior change.
- gated_by is now documented in one direction. internal/types/types.go,
internal/types/gated.go and docs/reference/json-schema.md said the list
is nonempty EXACTLY when `bd ready` withholds the issue on a gate's
account. Only one direction holds: the is_blocked recompute also blocks
a child whose parent is blocked (its parent-child legs), so a child of a
gated parent leaves `bd ready` with an empty gated_by. All three now say
"nonempty means withheld", as the OpenAPI text already did, and name the
parent-child case.
- bd list --watch passes a nil gated map on both routes
(runListProxiedWatch, displayWatchedIssueList), so a bead the one-shot
listing marks with the gated glyph keeps its plain status glyph while
watched. Watch is out of this PR's scope; the three call sites now say
so instead of reading as a forgotten argument.
- show_format.go named types.ActiveGates, which does not exist; the
predicate is types.GatesHolding.
- gated.go's best-effort note compared the gate read with `bd list`'s
blocking annotation, which only the direct route swallows. It now scopes
that comparison to the direct route and names the proxied route's
failing read (A-blk-1).
- proxiedGatedIssueIDsOwnUOW now notes that its unit of work is a second
snapshot, so one render can name a just-resolved gate under "blocked by:"
but not "gated by:".
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(list): hydrate proxied gate candidates from both planes (bd-p8k7dm)
The proxied list resolved gate candidates through the use case's
GetIssuesByIDs, which reads the issues table only, while the edges it
resolved came from GetForIssueIDs, which reads both dependency tables.
A wisp gate (`bd mol wisp` clones a formula's gates as wisps, held to a
wisp step by a blocks edge) therefore hydrated to nothing. Its step
listed undecorated in pretty, --flat and agent output while `bd show`,
`--json` and `bd ready` called it gated.
Read the wisps beside the issues, the two-plane idiom
ready_proxied_server.go and uowMolReader already use. A failed wisps
read keeps the durable candidates. Correct the cost-bound comment that
claimed the id-set readers partition the planes on both routes.
Tests: a wisp-step + wisp-gate case in TestProxiedServerGatedRendering
and TestEmbeddedGatedRendering asserts the pretty, --flat and
CLAUDE_CODE=1 rows of `bd list --include-ephemeral`, and
TestProxiedGatedIssueIDsHydratesBothPlanes pins both planes plus the
failed-wisps-read fallback.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
This commit is contained in:
parent
0ed6d47ba3
commit
c3a97e172d
34 changed files with 1730 additions and 76 deletions
1
.github/scripts/embedded-cmd-test-shards.txt
vendored
1
.github/scripts/embedded-cmd-test-shards.txt
vendored
|
|
@ -293,6 +293,7 @@
|
|||
50 16 TestEmbeddedBlockedLabelFilters
|
||||
50 16 TestEmbeddedGCConditionalMatcherDecode
|
||||
50 16 TestEmbeddedGateInheritsDownParentChain
|
||||
50 16 TestEmbeddedGatedRendering
|
||||
50 16 TestEmbeddedKV
|
||||
50 16 TestEmbeddedMaxRowsReady
|
||||
50 16 TestEmbeddedMemoryCorpusBudget
|
||||
|
|
|
|||
1
.github/scripts/proxied-cmd-test-shards.txt
vendored
1
.github/scripts/proxied-cmd-test-shards.txt
vendored
|
|
@ -434,6 +434,7 @@
|
|||
30 26 TestProxiedServerFindDuplicates
|
||||
30 26 TestProxiedServerGateCheck
|
||||
30 26 TestProxiedServerGateFrontDoorDirectServerProxyParity
|
||||
30 26 TestProxiedServerGatedRendering
|
||||
30 26 TestProxiedServerServeAddComment
|
||||
30 26 TestProxiedServerServeSettingsWrites
|
||||
30 26 TestProxiedServerState
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ type (
|
|||
EpicStatus = types.EpicStatus
|
||||
Event = types.Event
|
||||
EventType = types.EventType
|
||||
GateRef = types.GateRef
|
||||
Issue = types.Issue
|
||||
IssueDetails = types.IssueDetails
|
||||
IssueFilter = types.IssueFilter
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ go_library(
|
|||
"gate.go",
|
||||
"gate_discover.go",
|
||||
"gate_proxied_server.go",
|
||||
"gated.go",
|
||||
"gc.go",
|
||||
"gc_proxied_server.go",
|
||||
"gc_prune.go",
|
||||
|
|
@ -778,6 +779,10 @@ go_test(
|
|||
"gate_lifecycle_proxied_integration_test.go",
|
||||
"gate_routing_test.go",
|
||||
"gate_test.go",
|
||||
"gated_format_test.go",
|
||||
"gated_render_embedded_test.go",
|
||||
"gated_render_proxied_integration_test.go",
|
||||
"gated_test.go",
|
||||
"gc_embedded_test.go",
|
||||
"gc_prune_test.go",
|
||||
"git_repo_template_test.go",
|
||||
|
|
|
|||
|
|
@ -423,10 +423,10 @@ func buildGateIssue(in gateCreateInput, targetID string) *types.Issue {
|
|||
title = in.titleFlag
|
||||
}
|
||||
|
||||
desc := fmt.Sprintf("Ad-hoc gate blocking %s", targetID)
|
||||
if in.reason != "" {
|
||||
desc = fmt.Sprintf("%s\n\nReason: %s", desc, in.reason)
|
||||
}
|
||||
// types owns the description format because it also owns the read back
|
||||
// out of it (types.GateReason), which is what puts the reason on
|
||||
// `bd show`'s "Gated by:" line and in the detail view's gated_by.
|
||||
desc := types.GateDescription(targetID, in.reason)
|
||||
|
||||
return &types.Issue{
|
||||
Title: title,
|
||||
|
|
|
|||
208
cmd/bd/gated.go
Normal file
208
cmd/bd/gated.go
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage"
|
||||
"github.com/steveyegge/beads/internal/storage/uow"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// gateDepLoader reads the dependency records of a page of ids.
|
||||
type gateDepLoader func(ctx context.Context, ids []string) (map[string][]*types.Dependency, error)
|
||||
|
||||
// gateHydrator resolves the gate CANDIDATES a page's edges name into issues,
|
||||
// from BOTH planes: a gate can be a wisp (`bd mol wisp` clones a formula's
|
||||
// gates as wisps), and a candidate the hydrator misses is no error but a nil
|
||||
// target, which GateIsHolding reads as no gate — the row goes undecorated
|
||||
// while `bd show` and `bd ready` call the bead gated.
|
||||
type gateHydrator func(ctx context.Context, ids []string) ([]*types.Issue, error)
|
||||
|
||||
// gatesByIssueID returns, per listed id, the OPEN gates holding it back — the
|
||||
// ids themselves, so a row can name the gate rather than only admit one exists.
|
||||
// An issue with no live gate is absent from the map.
|
||||
//
|
||||
// BATCHED BY ID SET, never per row: the dependency rows for the whole page come
|
||||
// back in one call (or from the map a tree view has already loaded), and the
|
||||
// gate candidates they name are hydrated in one more. The COST BOUND is per
|
||||
// page, not per row — two calls whatever the page length — though each of those
|
||||
// calls is itself a few round trips (each reads the issues and the wisps plane
|
||||
// separately and batches its INs), so "two queries" understates the wire
|
||||
// traffic and "per page" is the promise that matters.
|
||||
//
|
||||
// The verdict is types.GateIsHolding plus types.SubjectCanBeGated — the one
|
||||
// predicate `bd show`, the detail view and the readiness query's is_blocked
|
||||
// column all share — so a glyph here and a GATED header there cannot say
|
||||
// different things about the same bead.
|
||||
//
|
||||
// Best effort: a read that fails yields no decoration rather than failing the
|
||||
// listing, on both routes. That matches how the direct `bd list` route treats
|
||||
// its blocking annotation; the proxied route instead FAILS on that
|
||||
// annotation's read (A-blk-1), a split this helper leaves alone.
|
||||
func gatesByIssueID(
|
||||
ctx context.Context,
|
||||
issues []*types.Issue,
|
||||
preloadedDeps map[string][]*types.Dependency,
|
||||
loadDeps gateDepLoader,
|
||||
hydrate gateHydrator,
|
||||
) map[string][]string {
|
||||
if len(issues) == 0 || hydrate == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// The SUBJECT clause, asked once here so no formatter has to re-ask it: a
|
||||
// closed or pinned bead is out of `bd ready` for its own reasons and is
|
||||
// never decorated, so it does not even join the dependency read.
|
||||
ids := make([]string, 0, len(issues))
|
||||
for _, issue := range issues {
|
||||
if !types.SubjectCanBeGated(issue) {
|
||||
continue
|
||||
}
|
||||
ids = append(ids, issue.ID)
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
depsByIssue := preloadedDeps
|
||||
if depsByIssue == nil {
|
||||
if loadDeps == nil {
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
depsByIssue, err = loadDeps(ctx, ids)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Candidate targets: the gate-rule edges of the ids on this page. A gate
|
||||
// reached over any other edge (waits-for, parent-child, relates-to) does
|
||||
// not hold anything back by the status rule, and the predicate would
|
||||
// reject it anyway; skipping it here keeps the hydration batch small.
|
||||
var targetIDs []string
|
||||
seen := make(map[string]bool)
|
||||
for _, id := range ids {
|
||||
for _, dep := range depsByIssue[id] {
|
||||
if dep == nil || !types.IsGateEdge(dep.Type) || seen[dep.DependsOnID] {
|
||||
continue
|
||||
}
|
||||
seen[dep.DependsOnID] = true
|
||||
targetIDs = append(targetIDs, dep.DependsOnID)
|
||||
}
|
||||
}
|
||||
if len(targetIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
targets, err := hydrate(ctx, targetIDs)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
targetByID := make(map[string]*types.Issue, len(targets))
|
||||
for _, target := range targets {
|
||||
if target != nil {
|
||||
targetByID[target.ID] = target
|
||||
}
|
||||
}
|
||||
|
||||
gated := make(map[string][]string)
|
||||
for _, id := range ids {
|
||||
for _, dep := range depsByIssue[id] {
|
||||
if dep == nil {
|
||||
continue
|
||||
}
|
||||
if types.GateIsHolding(dep.Type, targetByID[dep.DependsOnID]) {
|
||||
gated[id] = append(gated[id], dep.DependsOnID)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(gated) == 0 {
|
||||
return nil
|
||||
}
|
||||
return gated
|
||||
}
|
||||
|
||||
// gatedIssueIDs is gatesByIssueID on the direct (embedded / non-proxied) route.
|
||||
func gatedIssueIDs(
|
||||
ctx context.Context,
|
||||
st storage.DoltStorage,
|
||||
issues []*types.Issue,
|
||||
preloadedDeps map[string][]*types.Dependency,
|
||||
) map[string][]string {
|
||||
if st == nil {
|
||||
return nil
|
||||
}
|
||||
return gatesByIssueID(ctx, issues, preloadedDeps,
|
||||
func(ctx context.Context, ids []string) (map[string][]*types.Dependency, error) {
|
||||
return st.GetDependencyRecordsForIssues(ctx, ids)
|
||||
},
|
||||
func(ctx context.Context, ids []string) ([]*types.Issue, error) {
|
||||
return st.GetIssuesByIDs(ctx, ids)
|
||||
})
|
||||
}
|
||||
|
||||
// proxiedGatedIssueIDs is gatesByIssueID on the proxied-server route, reading
|
||||
// through a unit of work the caller already holds. The proxied --json routes
|
||||
// get gated_by from workapi.BuildIssueDetails; this is what keeps the proxied
|
||||
// TEXT routes from rendering a plain OPEN row for the same bead.
|
||||
func proxiedGatedIssueIDs(
|
||||
ctx context.Context,
|
||||
uw uow.UnitOfWork,
|
||||
issues []*types.Issue,
|
||||
preloadedDeps map[string][]*types.Dependency,
|
||||
) map[string][]string {
|
||||
if uw == nil {
|
||||
return nil
|
||||
}
|
||||
return gatesByIssueID(ctx, issues, preloadedDeps,
|
||||
func(ctx context.Context, ids []string) (map[string][]*types.Dependency, error) {
|
||||
return uw.DependencyUseCase().GetForIssueIDs(ctx, ids)
|
||||
},
|
||||
func(ctx context.Context, ids []string) ([]*types.Issue, error) {
|
||||
return proxiedGateCandidates(ctx, uw, ids)
|
||||
})
|
||||
}
|
||||
|
||||
// proxiedGateCandidates is the proxied gateHydrator. Unlike the direct route's
|
||||
// st.GetIssuesByIDs, the use case's GetIssuesByIDs reads the issues table
|
||||
// only, while the edges came from GetForIssueIDs, which reads both dependency
|
||||
// tables — so the wisps are read beside it, the two-plane idiom
|
||||
// ready_proxied_server.go and uowMolReader already use for ids that may be
|
||||
// wisps.
|
||||
//
|
||||
// A failed wisps read keeps the durable candidates: it costs the wisp gates
|
||||
// their decoration, not the whole page.
|
||||
func proxiedGateCandidates(ctx context.Context, uw uow.UnitOfWork, ids []string) ([]*types.Issue, error) {
|
||||
issues, err := uw.IssueUseCase().GetIssuesByIDs(ctx, ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
wisps, err := uw.IssueUseCase().GetWispsByIDs(ctx, ids)
|
||||
if err != nil {
|
||||
return issues, nil
|
||||
}
|
||||
return append(issues, wisps...), nil
|
||||
}
|
||||
|
||||
// proxiedGatedIssueIDsOwnUOW serves the proxied compact and agent listings,
|
||||
// which reach their blocking annotation through a role rather than a unit of
|
||||
// work and so hold none to lend. It opens one, reads, and closes it; a failure
|
||||
// to open yields no decoration, because a listing that renders is worth more
|
||||
// than one that refuses over a glyph.
|
||||
//
|
||||
// Its unit of work is a second snapshot, read after the blocking annotation's:
|
||||
// a gate resolved between the two can leave one render naming the gate under
|
||||
// "blocked by:" but not "gated by:", or the reverse. Cosmetic, and gone on the
|
||||
// next call.
|
||||
func proxiedGatedIssueIDsOwnUOW(ctx context.Context, issues []*types.Issue) map[string][]string {
|
||||
if len(issues) == 0 {
|
||||
return nil
|
||||
}
|
||||
uw, err := openProxiedListUOW(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer uw.Close(ctx)
|
||||
return proxiedGatedIssueIDs(ctx, uw, issues, nil)
|
||||
}
|
||||
171
cmd/bd/gated_format_test.go
Normal file
171
cmd/bd/gated_format_test.go
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
|
||||
func openGate(id, awaitType, reason, awaitID string) *types.Issue {
|
||||
return &types.Issue{
|
||||
ID: id,
|
||||
IssueType: types.TypeGate,
|
||||
Status: types.StatusOpen,
|
||||
AwaitType: awaitType,
|
||||
AwaitID: awaitID,
|
||||
Description: types.GateDescription("bd-target", reason),
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatIssueHeaderGatedMarker(t *testing.T) {
|
||||
issue := &types.Issue{ID: "bd-target", Title: "Ship it", Status: types.StatusOpen, Priority: 2}
|
||||
|
||||
plain := formatIssueHeaderWithGates(issue, nil)
|
||||
if !strings.Contains(plain, "[P2 · OPEN]") {
|
||||
t.Errorf("ungated header = %q, want the untouched [P2 · OPEN]", plain)
|
||||
}
|
||||
if strings.Contains(plain, "GATED") {
|
||||
t.Errorf("ungated header claims GATED: %q", plain)
|
||||
}
|
||||
if plain != formatIssueHeader(issue) {
|
||||
t.Errorf("formatIssueHeader disagrees with the nil-gate call:\n%q\n%q", formatIssueHeader(issue), plain)
|
||||
}
|
||||
|
||||
gated := formatIssueHeaderWithGates(issue, []*types.Issue{openGate("bd-gate", "human", "", "")})
|
||||
if !strings.Contains(gated, "[P2 · OPEN · GATED]") {
|
||||
t.Errorf("gated header = %q, want [P2 · OPEN · GATED]", gated)
|
||||
}
|
||||
if !strings.Contains(gated, "Ship it") {
|
||||
t.Errorf("gated header lost the title: %q", gated)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatIssueMetadataGatedLines(t *testing.T) {
|
||||
issue := &types.Issue{ID: "bd-target", Title: "Ship it", Status: types.StatusOpen, Priority: 2, CreatedBy: "bee"}
|
||||
|
||||
if got := formatIssueMetadataWithGates(issue, nil); strings.Contains(got, "Gated by:") {
|
||||
t.Errorf("ungated meta block mentions a gate: %q", got)
|
||||
}
|
||||
|
||||
gates := []*types.Issue{
|
||||
openGate("bd-g1", "human", "Need design review", ""),
|
||||
openGate("bd-g2", "gh:pr", "", "42"),
|
||||
openGate("bd-g3", "", "", ""),
|
||||
}
|
||||
out := formatIssueMetadataWithGates(issue, gates)
|
||||
for _, want := range []string{
|
||||
"Gated by: bd-g1 (human: Need design review)",
|
||||
"Gated by: bd-g2 (gh:pr, awaiting 42)",
|
||||
"Gated by: bd-g3 (gate)",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Errorf("meta block missing %q:\n%s", want, out)
|
||||
}
|
||||
}
|
||||
if n := strings.Count(out, "Gated by:"); n != 3 {
|
||||
t.Errorf("meta block has %d Gated by lines, want one per gate", n)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatIssueMetadataGatedKeepsDeferredLine(t *testing.T) {
|
||||
deferUntil := time.Date(2099, time.January, 15, 12, 0, 0, 0, time.Local)
|
||||
issue := &types.Issue{
|
||||
ID: "bd-target", Title: "Later", Status: types.StatusDeferred, Priority: 1,
|
||||
DeferUntil: &deferUntil,
|
||||
}
|
||||
out := formatIssueMetadataWithGates(issue, []*types.Issue{openGate("bd-g1", "human", "", "")})
|
||||
if !strings.Contains(out, "Deferred: 2099-01-15") {
|
||||
t.Errorf("deferred+gated meta lost the Deferred line:\n%s", out)
|
||||
}
|
||||
if !strings.Contains(out, "Gated by: bd-g1") {
|
||||
t.Errorf("deferred+gated meta lost the Gated by line:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatPrettyIssueGatedGlyph(t *testing.T) {
|
||||
gates := []string{"bd-gate"}
|
||||
open := &types.Issue{ID: "bd-1", Title: "Open", Status: types.StatusOpen, Priority: 2}
|
||||
if got := formatPrettyIssueGated(open, nil); !strings.HasPrefix(got, ui.StatusIconOpen) {
|
||||
t.Errorf("ungated row = %q, want the open glyph", got)
|
||||
}
|
||||
if got := formatPrettyIssueGated(open, gates); !strings.HasPrefix(got, ui.StatusIconGated) {
|
||||
t.Errorf("gated row = %q, want the gated glyph %q", got, ui.StatusIconGated)
|
||||
}
|
||||
|
||||
// The gated glyph outranks the deferred snowflake: one column, and the
|
||||
// gate is the fact the row cannot otherwise show.
|
||||
deferred := &types.Issue{ID: "bd-2", Title: "Later", Status: types.StatusDeferred, Priority: 2}
|
||||
if got := formatPrettyIssueGated(deferred, gates); !strings.HasPrefix(got, ui.StatusIconGated) {
|
||||
t.Errorf("deferred+gated row = %q, want the gated glyph", got)
|
||||
}
|
||||
if got := formatPrettyIssueGated(deferred, nil); !strings.HasPrefix(got, ui.StatusIconDeferred) {
|
||||
t.Errorf("deferred row = %q, want the deferred glyph", got)
|
||||
}
|
||||
|
||||
// A closed issue is never decorated: `bd ready` withholds it on its own
|
||||
// account, so a gate marker would claim a causation that is not there.
|
||||
closed := &types.Issue{ID: "bd-3", Title: "Done", Status: types.StatusClosed, Priority: 2}
|
||||
if got := formatPrettyIssueGated(closed, gates); strings.Contains(got, ui.StatusIconGated) {
|
||||
t.Errorf("closed row carries the gated glyph: %q", got)
|
||||
}
|
||||
|
||||
// Nor is a PINNED one — and the pin survives, because the glyph never gets
|
||||
// the chance to evict it (types.SubjectCanBeGated says no first).
|
||||
pinned := &types.Issue{ID: "bd-4", Title: "Pinned", Status: types.StatusPinned, Priority: 2}
|
||||
got := formatPrettyIssueGated(pinned, gates)
|
||||
if strings.Contains(got, ui.StatusIconGated) {
|
||||
t.Errorf("pinned row carries the gated glyph: %q", got)
|
||||
}
|
||||
if !strings.HasPrefix(got, ui.StatusIconPinned) {
|
||||
t.Errorf("pinned+gated row = %q, want it to keep the pin %q", got, ui.StatusIconPinned)
|
||||
}
|
||||
}
|
||||
|
||||
// TestFormatIssueCompactGated pins the compact row: the same glyph rule, plus
|
||||
// the "gated by" clause that names the gate the glyph only hints at.
|
||||
func TestFormatIssueCompactGated(t *testing.T) {
|
||||
issue := &types.Issue{ID: "bd-1", Title: "Open", Status: types.StatusOpen, Priority: 2, IssueType: types.TypeTask}
|
||||
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, []string{"bd-gate"}, nil, "", []string{"bd-gate"})
|
||||
got := buf.String()
|
||||
if !strings.Contains(got, ui.StatusIconGated) {
|
||||
t.Errorf("gated compact row missing %q: %q", ui.StatusIconGated, got)
|
||||
}
|
||||
if !strings.Contains(got, "gated by: bd-gate") {
|
||||
t.Errorf("gated compact row does not name the gate: %q", got)
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
pinned := &types.Issue{ID: "bd-2", Title: "Pinned", Status: types.StatusPinned, Priority: 2, IssueType: types.TypeTask}
|
||||
formatIssueCompact(&buf, pinned, nil, nil, nil, "", []string{"bd-gate"})
|
||||
if got := buf.String(); strings.Contains(got, ui.StatusIconGated) {
|
||||
t.Errorf("pinned compact row carries the gated glyph: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestFormatAgentIssueGated is SHOULD-3: agent mode has no glyph column, and
|
||||
// ui.IsAgentMode() is true in every CLAUDE_CODE seat — the population that
|
||||
// cannot otherwise tell a gated row from a startable one.
|
||||
func TestFormatAgentIssueGated(t *testing.T) {
|
||||
issue := &types.Issue{ID: "bd-1", Title: "Gated work", Status: types.StatusOpen, Priority: 2}
|
||||
|
||||
var buf strings.Builder
|
||||
formatAgentIssue(&buf, issue, nil, nil, "", nil)
|
||||
if got := buf.String(); got != "bd-1: Gated work\n" {
|
||||
t.Errorf("ungated agent line = %q, want the untouched one-liner", got)
|
||||
}
|
||||
|
||||
buf.Reset()
|
||||
formatAgentIssue(&buf, issue, []string{"bd-gate"}, nil, "", []string{"bd-gate"})
|
||||
got := buf.String()
|
||||
if !strings.Contains(got, "gated by: bd-gate") {
|
||||
t.Errorf("agent line does not name the gate: %q", got)
|
||||
}
|
||||
if !strings.Contains(got, "blocked by: bd-gate") {
|
||||
t.Errorf("agent line lost its blocked-by clause: %q", got)
|
||||
}
|
||||
}
|
||||
351
cmd/bd/gated_render_embedded_test.go
Normal file
351
cmd/bd/gated_render_embedded_test.go
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
|
||||
// bdGateCreateIssue runs "bd gate create --json" and returns the gate issue.
|
||||
func bdGateCreateIssue(t *testing.T, bd, dir string, args ...string) *types.Issue {
|
||||
t.Helper()
|
||||
fullArgs := append([]string{"gate", "create", "--json"}, args...)
|
||||
out, err := bdRunWithFlockRetry(t, bd, dir, fullArgs...)
|
||||
if err != nil {
|
||||
t.Fatalf("bd gate create %s failed: %v\n%s", strings.Join(args, " "), err, out)
|
||||
}
|
||||
return parseIssueJSON(t, out)
|
||||
}
|
||||
|
||||
// bdListEnv is bdList with extra environment, for the agent-mode arm.
|
||||
func bdListEnv(t *testing.T, bd, dir string, extraEnv []string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command(bd, append([]string{"list"}, args...)...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(bdEnv(dir), extraEnv...)
|
||||
stdout, stderr, err := runCommandBuffers(t, cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("bd list %s failed: %v\nstdout:\n%s\nstderr:\n%s", strings.Join(args, " "), err, stdout.String(), stderr.String())
|
||||
}
|
||||
return stdout.String()
|
||||
}
|
||||
|
||||
// listRowFor returns the `bd list` row that names id, in any of the three row
|
||||
// shapes: pretty ("○ gd-1 P2 Title"), compact ("○ gd-1 [P2] ...") and agent
|
||||
// mode ("gd-1: Title (...)").
|
||||
func listRowFor(t *testing.T, out, id string) string {
|
||||
t.Helper()
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
if strings.Contains(line, id+" ") || strings.Contains(line, id+"[") || strings.Contains(line, id+":") {
|
||||
return line
|
||||
}
|
||||
}
|
||||
t.Fatalf("no row for %s in bd list output:\n%s", id, out)
|
||||
return ""
|
||||
}
|
||||
|
||||
// TestEmbeddedGatedRendering pins the derived GATED decoration on the human
|
||||
// surfaces: an issue an OPEN gate blocks is excluded from `bd ready`, so
|
||||
// `bd show` and `bd list` must say so rather than rendering a plain OPEN row.
|
||||
func TestEmbeddedGatedRendering(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, _, _ := bdInit(t, bd, "--prefix", "gd")
|
||||
|
||||
target := bdCreate(t, bd, dir, "Gated target", "-p", "2")
|
||||
gate := bdGateCreateIssue(t, bd, dir, "--blocks", target.ID, "--reason", "Need design review")
|
||||
|
||||
t.Run("ready_excludes_the_gated_issue", func(t *testing.T) {
|
||||
out, err := bdRunWithFlockRetry(t, bd, dir, "ready")
|
||||
if err != nil {
|
||||
t.Fatalf("bd ready failed: %v\n%s", err, out)
|
||||
}
|
||||
if strings.Contains(string(out), target.ID) {
|
||||
t.Fatalf("bd ready listed gated issue %s (the premise of this test):\n%s", target.ID, out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("show_header_and_meta_say_gated", func(t *testing.T) {
|
||||
out := bdShowRaw(t, bd, dir, target.ID)
|
||||
t.Logf("bd show %s:\n%s", target.ID, out)
|
||||
if !strings.Contains(out, "· GATED]") {
|
||||
t.Errorf("show header missing GATED marker:\n%s", out)
|
||||
}
|
||||
wantLine := "Gated by: " + gate.ID + " (human: Need design review)"
|
||||
if !strings.Contains(out, wantLine) {
|
||||
t.Errorf("show meta missing %q:\n%s", wantLine, out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("show_json_carries_gated_by", func(t *testing.T) {
|
||||
details := bdShowDetails(t, bd, dir, target.ID)
|
||||
raw, ok := details["gated_by"]
|
||||
if !ok {
|
||||
t.Fatalf("show --json has no gated_by field: %v", keysOf(details))
|
||||
}
|
||||
entries, ok := raw.([]any)
|
||||
if !ok || len(entries) != 1 {
|
||||
t.Fatalf("gated_by = %#v, want one entry", raw)
|
||||
}
|
||||
entry, ok := entries[0].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("gated_by[0] = %#v, want an object", entries[0])
|
||||
}
|
||||
if entry["id"] != gate.ID {
|
||||
t.Errorf("gated_by[0].id = %v, want %s", entry["id"], gate.ID)
|
||||
}
|
||||
if entry["type"] != "human" {
|
||||
t.Errorf("gated_by[0].type = %v, want human", entry["type"])
|
||||
}
|
||||
if entry["reason"] != "Need design review" {
|
||||
t.Errorf("gated_by[0].reason = %v, want the gate's reason", entry["reason"])
|
||||
}
|
||||
// Additive only: the fields bd show --json already published are unchanged.
|
||||
for _, key := range []string{"id", "title", "status", "priority", "issue_type"} {
|
||||
if _, ok := details[key]; !ok {
|
||||
t.Errorf("show --json lost pre-existing field %q", key)
|
||||
}
|
||||
}
|
||||
if details["status"] != "open" {
|
||||
t.Errorf("stored status = %v, want open (the decoration is derived, not stored)", details["status"])
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("list_row_carries_the_gated_glyph", func(t *testing.T) {
|
||||
out := bdList(t, bd, dir)
|
||||
t.Logf("bd list:\n%s", out)
|
||||
row := listRowFor(t, out, target.ID)
|
||||
if !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconGated) {
|
||||
t.Errorf("list row for %s does not lead with the gated glyph %q:\n%s",
|
||||
target.ID, ui.StatusIconGated, row)
|
||||
}
|
||||
})
|
||||
|
||||
// --flat leaves the tree view, and with it the whole-rig edge map the tree
|
||||
// already had: this arm is what exercises gatedIssueIDs' own batched
|
||||
// dependency read.
|
||||
t.Run("flat_list_row_carries_the_gated_glyph", func(t *testing.T) {
|
||||
out := bdList(t, bd, dir, "--flat")
|
||||
t.Logf("bd list --flat:\n%s", out)
|
||||
row := listRowFor(t, out, target.ID)
|
||||
if !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconGated) {
|
||||
t.Errorf("flat list row for %s does not lead with the gated glyph %q:\n%s",
|
||||
target.ID, ui.StatusIconGated, row)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("deferred_and_gated_show_both_markers", func(t *testing.T) {
|
||||
deferred := bdCreate(t, bd, dir, "Deferred and gated", "-p", "1")
|
||||
bdUpdate(t, bd, dir, deferred.ID, "--defer", "2099-01-15")
|
||||
dgate := bdGateCreateIssue(t, bd, dir, "--blocks", deferred.ID, "--type", "gh:pr", "--await-id", "42")
|
||||
|
||||
out := bdShowRaw(t, bd, dir, deferred.ID)
|
||||
t.Logf("bd show %s:\n%s", deferred.ID, out)
|
||||
if !strings.Contains(out, "Deferred: 2099-01-15") {
|
||||
t.Errorf("show lost the Deferred line:\n%s", out)
|
||||
}
|
||||
wantLine := "Gated by: " + dgate.ID + " (gh:pr, awaiting 42)"
|
||||
if !strings.Contains(out, wantLine) {
|
||||
t.Errorf("show meta missing %q:\n%s", wantLine, out)
|
||||
}
|
||||
if !strings.Contains(out, "· GATED]") {
|
||||
t.Errorf("show header missing GATED marker on a deferred issue:\n%s", out)
|
||||
}
|
||||
|
||||
listOut := bdList(t, bd, dir, "--status", "deferred")
|
||||
row := listRowFor(t, listOut, deferred.ID)
|
||||
if !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconGated) {
|
||||
t.Errorf("deferred+gated list row does not lead with %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
})
|
||||
|
||||
// BLOCKER 1 (opus-adv): waits-for is NOT the status rule. The is_blocked
|
||||
// recompute sends that leg through waitsForGateBlockedSQL, which blocks
|
||||
// only on an OPEN parent-child child of the target (or an also_blocks
|
||||
// spawner), so a plain waits-for onto an open childless gate leaves the
|
||||
// dependent IN `bd ready` — and a decoration here would contradict it.
|
||||
t.Run("waits_for_onto_a_gate_is_not_decorated", func(t *testing.T) {
|
||||
subject := bdCreate(t, bd, dir, "Waits-for subject", "-p", "2")
|
||||
wgate := bdCreate(t, bd, dir, "Bare gate", "-p", "2", "-t", "gate")
|
||||
if out, err := bdRunWithFlockRetry(t, bd, dir, "dep", "add", subject.ID, wgate.ID, "-t", "waits-for"); err != nil {
|
||||
t.Fatalf("bd dep add waits-for failed: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
out, err := bdRunWithFlockRetry(t, bd, dir, "ready")
|
||||
if err != nil {
|
||||
t.Fatalf("bd ready failed: %v\n%s", err, out)
|
||||
}
|
||||
if !strings.Contains(string(out), subject.ID) {
|
||||
t.Fatalf("bd ready dropped %s over a waits-for edge — the premise of this case is that it does not:\n%s", subject.ID, out)
|
||||
}
|
||||
|
||||
showOut := bdShowRaw(t, bd, dir, subject.ID)
|
||||
if strings.Contains(showOut, "GATED") || strings.Contains(showOut, "Gated by:") {
|
||||
t.Errorf("waits-for edge rendered a gate on bd show, while bd ready lists the bead:\n%s", showOut)
|
||||
}
|
||||
if details := bdShowDetails(t, bd, dir, subject.ID); details["gated_by"] != nil {
|
||||
t.Errorf("waits-for edge put gated_by on the detail view: %#v", details["gated_by"])
|
||||
}
|
||||
for _, listArgs := range [][]string{nil, {"--flat"}} {
|
||||
row := listRowFor(t, bdList(t, bd, dir, listArgs...), subject.ID)
|
||||
if strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("list %v decorated a waits-for edge:\n%s", listArgs, row)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// BLOCKER 2 (opus-adv), subject half: unmarkAllBlockedSQL forces
|
||||
// is_blocked=0 for a CLOSED subject, so `bd ready` never withholds one on
|
||||
// a gate's account and no surface may print [CLOSED · GATED].
|
||||
t.Run("closed_subject_renders_no_gate", func(t *testing.T) {
|
||||
subject := bdCreate(t, bd, dir, "Closed under a gate", "-p", "2")
|
||||
cgate := bdGateCreateIssue(t, bd, dir, "--blocks", subject.ID, "--reason", "hold")
|
||||
if out, err := bdRunWithFlockRetry(t, bd, dir, "close", subject.ID, "--force", "-r", "done anyway"); err != nil {
|
||||
t.Fatalf("bd close --force failed: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
showOut := bdShowRaw(t, bd, dir, subject.ID)
|
||||
t.Logf("bd show %s:\n%s", subject.ID, showOut)
|
||||
if strings.Contains(showOut, "GATED") {
|
||||
t.Errorf("closed subject rendered a GATED marker (gate %s still open):\n%s", cgate.ID, showOut)
|
||||
}
|
||||
if strings.Contains(showOut, "Gated by:") {
|
||||
t.Errorf("closed subject rendered a Gated by line:\n%s", showOut)
|
||||
}
|
||||
if details := bdShowDetails(t, bd, dir, subject.ID); details["gated_by"] != nil {
|
||||
t.Errorf("closed subject published gated_by: %#v", details["gated_by"])
|
||||
}
|
||||
row := listRowFor(t, bdList(t, bd, dir, "--status", "closed"), subject.ID)
|
||||
if strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("closed list row carries the gated glyph:\n%s", row)
|
||||
}
|
||||
})
|
||||
|
||||
// Same clause, pinned half — and NOTE 5: the pin survives, because a
|
||||
// pinned subject is never gated in the first place.
|
||||
t.Run("pinned_subject_renders_no_gate_and_keeps_the_pin", func(t *testing.T) {
|
||||
subject := bdCreate(t, bd, dir, "Pinned under a gate", "-p", "2")
|
||||
bdGateCreateIssue(t, bd, dir, "--blocks", subject.ID, "--reason", "hold")
|
||||
if out, err := bdRunWithFlockRetry(t, bd, dir, "update", subject.ID, "--status", "pinned"); err != nil {
|
||||
t.Fatalf("bd update --status pinned failed: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
showOut := bdShowRaw(t, bd, dir, subject.ID)
|
||||
t.Logf("bd show %s:\n%s", subject.ID, showOut)
|
||||
if strings.Contains(showOut, "GATED") || strings.Contains(showOut, "Gated by:") {
|
||||
t.Errorf("pinned subject rendered a gate:\n%s", showOut)
|
||||
}
|
||||
if details := bdShowDetails(t, bd, dir, subject.ID); details["gated_by"] != nil {
|
||||
t.Errorf("pinned subject published gated_by: %#v", details["gated_by"])
|
||||
}
|
||||
row := listRowFor(t, bdList(t, bd, dir, "--status", "pinned"), subject.ID)
|
||||
if strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("pinned row carries the gated glyph instead of the pin:\n%s", row)
|
||||
}
|
||||
if !strings.Contains(row, ui.StatusIconPinned) {
|
||||
t.Errorf("pinned row lost the pin %q:\n%s", ui.StatusIconPinned, row)
|
||||
}
|
||||
})
|
||||
|
||||
// SHOULD 3 (opus-adv): agent mode has no glyph column, and every
|
||||
// CLAUDE_CODE seat is in it. The gate rides the parenthetical instead.
|
||||
t.Run("agent_mode_line_names_the_gate", func(t *testing.T) {
|
||||
out := bdListEnv(t, bd, dir, []string{"CLAUDE_CODE=1"}, "--flat")
|
||||
t.Logf("CLAUDE_CODE=1 bd list --flat:\n%s", out)
|
||||
row := listRowFor(t, out, target.ID)
|
||||
if !strings.Contains(row, "gated by: "+gate.ID) {
|
||||
t.Errorf("agent-mode row does not name the gate %s:\n%s", gate.ID, row)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("resolved_gate_renders_nothing", func(t *testing.T) {
|
||||
if out, err := bdRunWithFlockRetry(t, bd, dir, "gate", "resolve", gate.ID); err != nil {
|
||||
t.Fatalf("bd gate resolve failed: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
out := bdShowRaw(t, bd, dir, target.ID)
|
||||
if strings.Contains(out, "GATED") || strings.Contains(out, "Gated by:") {
|
||||
t.Errorf("a resolved gate still renders on bd show:\n%s", out)
|
||||
}
|
||||
|
||||
details := bdShowDetails(t, bd, dir, target.ID)
|
||||
if raw, ok := details["gated_by"]; ok {
|
||||
t.Errorf("gated_by present after the gate closed: %#v", raw)
|
||||
}
|
||||
|
||||
for _, listArgs := range [][]string{nil, {"--flat"}} {
|
||||
listOut := bdList(t, bd, dir, listArgs...)
|
||||
row := listRowFor(t, listOut, target.ID)
|
||||
if strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("list %v row still carries the gated glyph after resolve:\n%s", listArgs, row)
|
||||
}
|
||||
}
|
||||
|
||||
listOut := bdList(t, bd, dir)
|
||||
row := listRowFor(t, listOut, target.ID)
|
||||
if strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("list row still carries the gated glyph after resolve:\n%s", row)
|
||||
}
|
||||
if !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconOpen) {
|
||||
t.Errorf("ungated row should lead with %q:\n%s", ui.StatusIconOpen, row)
|
||||
}
|
||||
})
|
||||
|
||||
// A gate can be a wisp — `bd mol wisp` clones a formula's gates as wisps,
|
||||
// held to a wisp step by a blocks edge. The direct route's readers
|
||||
// partition the planes; this pins that, beside the proxied twin of this
|
||||
// case in TestProxiedServerGatedRendering, whose hydrator once did not.
|
||||
t.Run("wisp_gate_decorates_the_wisp_row", func(t *testing.T) {
|
||||
subject := bdCreate(t, bd, dir, "Wisp step", "-p", "2", "--ephemeral")
|
||||
wgate := bdCreate(t, bd, dir, "Wisp gate", "-p", "2", "-t", "gate", "--ephemeral")
|
||||
if out, err := bdRunWithFlockRetry(t, bd, dir, "dep", "add", subject.ID, wgate.ID, "-t", "blocks"); err != nil {
|
||||
t.Fatalf("bd dep add failed: %v\n%s", err, out)
|
||||
}
|
||||
|
||||
showOut := bdShowRaw(t, bd, dir, subject.ID)
|
||||
t.Logf("bd show %s:\n%s", subject.ID, showOut)
|
||||
if !strings.Contains(showOut, "· GATED]") {
|
||||
t.Fatalf("show does not call the wisp gated, the premise of this case:\n%s", showOut)
|
||||
}
|
||||
|
||||
listOut := bdList(t, bd, dir, "--include-ephemeral")
|
||||
t.Logf("bd list --include-ephemeral:\n%s", listOut)
|
||||
if row := listRowFor(t, listOut, subject.ID); !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconGated) {
|
||||
t.Errorf("pretty wisp row does not lead with %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
|
||||
flatOut := bdList(t, bd, dir, "--flat", "--include-ephemeral")
|
||||
t.Logf("bd list --flat --include-ephemeral:\n%s", flatOut)
|
||||
row := listRowFor(t, flatOut, subject.ID)
|
||||
if !strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("compact wisp row missing %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
if !strings.Contains(row, "gated by: "+wgate.ID) {
|
||||
t.Errorf("compact wisp row does not name the wisp gate %s:\n%s", wgate.ID, row)
|
||||
}
|
||||
|
||||
agentOut := bdListEnv(t, bd, dir, []string{"CLAUDE_CODE=1"}, "--flat", "--include-ephemeral")
|
||||
t.Logf("CLAUDE_CODE=1 bd list --flat --include-ephemeral:\n%s", agentOut)
|
||||
if row := listRowFor(t, agentOut, subject.ID); !strings.Contains(row, "gated by: "+wgate.ID) {
|
||||
t.Errorf("agent-mode wisp row does not name the wisp gate %s:\n%s", wgate.ID, row)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func keysOf(m map[string]any) []string {
|
||||
out := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
out = append(out, k)
|
||||
}
|
||||
return out
|
||||
}
|
||||
166
cmd/bd/gated_render_proxied_integration_test.go
Normal file
166
cmd/bd/gated_render_proxied_integration_test.go
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
|
||||
// TestProxiedServerGatedRendering is the SHOULD-4 half of wy-j2upyy: the
|
||||
// proxied-server TEXT routes must render the same derived GATED decoration the
|
||||
// direct routes do.
|
||||
//
|
||||
// The proxied --json routes already carried it (uow issue_reader →
|
||||
// workapi.BuildIssueDetails), so without this the SAME bead read two ways from
|
||||
// the SAME server disagrees: gated_by in the JSON, a plain OPEN row in the
|
||||
// terminal. Whole constellations run proxied — it is the default for a shared
|
||||
// dolt server — so "upstream ships it" and "the seat that filed the bug sees
|
||||
// it" are not the same statement until this passes.
|
||||
func TestProxiedServerGatedRendering(t *testing.T) {
|
||||
requireSharedProxiedServer(t)
|
||||
t.Parallel()
|
||||
bd := buildEmbeddedBD(t)
|
||||
|
||||
p := newSharedProxiedProject(t, bd, "pgd")
|
||||
target := bdProxiedCreate(t, bd, p.dir, "Proxied gated target", "-p", "2")
|
||||
|
||||
out, stderr, err := bdProxiedRunBuffers(t, bd, p.dir,
|
||||
"gate", "create", "--type=human", "--blocks", target.ID, "--reason", "Need design review")
|
||||
if err != nil {
|
||||
t.Fatalf("gate create failed: %v\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
gateID := parseCreatedGateID(t, out)
|
||||
|
||||
t.Run("show_text_says_gated", func(t *testing.T) {
|
||||
showOut := bdProxiedShowRaw(t, bd, p.dir, target.ID)
|
||||
t.Logf("bd show %s:\n%s", target.ID, showOut)
|
||||
if !strings.Contains(showOut, "· GATED]") {
|
||||
t.Errorf("proxied show header missing the GATED marker:\n%s", showOut)
|
||||
}
|
||||
wantLine := "Gated by: " + gateID + " (human: Need design review)"
|
||||
if !strings.Contains(showOut, wantLine) {
|
||||
t.Errorf("proxied show meta missing %q:\n%s", wantLine, showOut)
|
||||
}
|
||||
})
|
||||
|
||||
// The route that was already right, kept beside the one that was not: the
|
||||
// text and the JSON are two readings of one bead and must agree.
|
||||
t.Run("show_json_still_carries_gated_by", func(t *testing.T) {
|
||||
details := bdProxiedShowDetailsFirst(t, bd, p.dir, target.ID)
|
||||
raw, ok := details["gated_by"]
|
||||
if !ok {
|
||||
t.Fatalf("proxied show --json has no gated_by")
|
||||
}
|
||||
entries, ok := raw.([]any)
|
||||
if !ok || len(entries) != 1 {
|
||||
t.Fatalf("gated_by = %#v, want one entry", raw)
|
||||
}
|
||||
entry, _ := entries[0].(map[string]any)
|
||||
if entry["id"] != gateID {
|
||||
t.Errorf("gated_by[0].id = %v, want %s", entry["id"], gateID)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("pretty_list_row_carries_the_glyph", func(t *testing.T) {
|
||||
listOut := bdProxiedList(t, bd, p)
|
||||
t.Logf("bd list:\n%s", listOut)
|
||||
row := listRowFor(t, listOut, target.ID)
|
||||
if !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconGated) {
|
||||
t.Errorf("proxied pretty row does not lead with %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("compact_list_row_carries_the_glyph_and_names_the_gate", func(t *testing.T) {
|
||||
listOut := bdProxiedList(t, bd, p, "--flat")
|
||||
t.Logf("bd list --flat:\n%s", listOut)
|
||||
row := listRowFor(t, listOut, target.ID)
|
||||
if !strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("proxied compact row missing %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
if !strings.Contains(row, "gated by: "+gateID) {
|
||||
t.Errorf("proxied compact row does not name the gate:\n%s", row)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("agent_mode_line_names_the_gate", func(t *testing.T) {
|
||||
stdout, stderr, err := bdProxiedRunBuffersWithEnv(t, bd, p.dir, []string{"CLAUDE_CODE=1"}, "list", "--flat")
|
||||
if err != nil {
|
||||
t.Fatalf("bd list --flat failed: %v\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
t.Logf("CLAUDE_CODE=1 bd list --flat:\n%s", stdout)
|
||||
row := listRowFor(t, stdout, target.ID)
|
||||
if !strings.Contains(row, "gated by: "+gateID) {
|
||||
t.Errorf("proxied agent row does not name the gate %s:\n%s", gateID, row)
|
||||
}
|
||||
})
|
||||
|
||||
// The subject clause reaches the proxied routes through the same helper,
|
||||
// so a closed bead is undecorated here too.
|
||||
t.Run("closed_subject_renders_no_gate", func(t *testing.T) {
|
||||
closedTarget := bdProxiedCreate(t, bd, p.dir, "Proxied closed under a gate", "-p", "2")
|
||||
if _, stderr, err := bdProxiedRunBuffers(t, bd, p.dir,
|
||||
"gate", "create", "--type=human", "--blocks", closedTarget.ID, "--reason", "hold"); err != nil {
|
||||
t.Fatalf("gate create failed: %v\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
if _, stderr, err := bdProxiedRunBuffers(t, bd, p.dir, "close", closedTarget.ID, "--force", "-r", "done anyway"); err != nil {
|
||||
t.Fatalf("bd close --force failed: %v\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
|
||||
showOut := bdProxiedShowRaw(t, bd, p.dir, closedTarget.ID)
|
||||
t.Logf("bd show %s:\n%s", closedTarget.ID, showOut)
|
||||
if strings.Contains(showOut, "GATED") || strings.Contains(showOut, "Gated by:") {
|
||||
t.Errorf("proxied show decorated a closed subject:\n%s", showOut)
|
||||
}
|
||||
row := listRowFor(t, bdProxiedList(t, bd, p, "--flat", "--status", "closed"), closedTarget.ID)
|
||||
if strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("proxied closed row carries the gated glyph:\n%s", row)
|
||||
}
|
||||
})
|
||||
|
||||
// A gate can be a wisp — `bd mol wisp` clones a formula's gates as wisps,
|
||||
// held to a wisp step by a blocks edge. The proxied list once hydrated gate
|
||||
// candidates from the issues table only, so this row rendered plain OPEN
|
||||
// while `bd show` and `bd ready` called the same wisp gated.
|
||||
t.Run("wisp_gate_decorates_the_wisp_row", func(t *testing.T) {
|
||||
subject := bdProxiedCreate(t, bd, p.dir, "Proxied wisp step", "-p", "2", "--ephemeral")
|
||||
wgate := bdProxiedCreate(t, bd, p.dir, "Proxied wisp gate", "-p", "2", "-t", "gate", "--ephemeral")
|
||||
if _, stderr, err := bdProxiedRunBuffers(t, bd, p.dir, "dep", "add", subject.ID, wgate.ID, "-t", "blocks"); err != nil {
|
||||
t.Fatalf("bd dep add failed: %v\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
|
||||
// The premise: the read that was already wisp-aware calls it gated.
|
||||
showOut := bdProxiedShowRaw(t, bd, p.dir, subject.ID)
|
||||
t.Logf("bd show %s:\n%s", subject.ID, showOut)
|
||||
if !strings.Contains(showOut, "· GATED]") {
|
||||
t.Fatalf("proxied show does not call the wisp gated, the premise of this case:\n%s", showOut)
|
||||
}
|
||||
|
||||
listOut := bdProxiedList(t, bd, p, "--include-ephemeral")
|
||||
t.Logf("bd list --include-ephemeral:\n%s", listOut)
|
||||
if row := listRowFor(t, listOut, subject.ID); !strings.HasPrefix(strings.TrimSpace(row), ui.StatusIconGated) {
|
||||
t.Errorf("proxied pretty wisp row does not lead with %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
|
||||
flatOut := bdProxiedList(t, bd, p, "--flat", "--include-ephemeral")
|
||||
t.Logf("bd list --flat --include-ephemeral:\n%s", flatOut)
|
||||
row := listRowFor(t, flatOut, subject.ID)
|
||||
if !strings.Contains(row, ui.StatusIconGated) {
|
||||
t.Errorf("proxied compact wisp row missing %q:\n%s", ui.StatusIconGated, row)
|
||||
}
|
||||
if !strings.Contains(row, "gated by: "+wgate.ID) {
|
||||
t.Errorf("proxied compact wisp row does not name the wisp gate %s:\n%s", wgate.ID, row)
|
||||
}
|
||||
|
||||
stdout, stderr, err := bdProxiedRunBuffersWithEnv(t, bd, p.dir, []string{"CLAUDE_CODE=1"}, "list", "--flat", "--include-ephemeral")
|
||||
if err != nil {
|
||||
t.Fatalf("bd list --flat --include-ephemeral failed: %v\nstderr:\n%s", err, stderr)
|
||||
}
|
||||
t.Logf("CLAUDE_CODE=1 bd list --flat --include-ephemeral:\n%s", stdout)
|
||||
if row := listRowFor(t, stdout, subject.ID); !strings.Contains(row, "gated by: "+wgate.ID) {
|
||||
t.Errorf("proxied agent wisp row does not name the wisp gate %s:\n%s", wgate.ID, row)
|
||||
}
|
||||
})
|
||||
}
|
||||
77
cmd/bd/gated_test.go
Normal file
77
cmd/bd/gated_test.go
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage/domain"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// planeIssueUC answers the two id-set reads proxiedGateCandidates makes and
|
||||
// nothing else, each with only the rows its own table holds: GetIssuesByIDs
|
||||
// the issues, GetWispsByIDs the wisps, as the domain use case does.
|
||||
type planeIssueUC struct {
|
||||
domain.IssueUseCase // any other method is a nil call: the hydrator must not reach one
|
||||
issues, wisps []*types.Issue
|
||||
wispsErr error
|
||||
}
|
||||
|
||||
func (s planeIssueUC) GetIssuesByIDs(context.Context, []string) ([]*types.Issue, error) {
|
||||
return s.issues, nil
|
||||
}
|
||||
|
||||
func (s planeIssueUC) GetWispsByIDs(context.Context, []string) ([]*types.Issue, error) {
|
||||
if s.wispsErr != nil {
|
||||
return nil, s.wispsErr
|
||||
}
|
||||
return s.wisps, nil
|
||||
}
|
||||
|
||||
// TestProxiedGatedIssueIDsHydratesBothPlanes pins the proxied hydrator to both
|
||||
// tables. The use case's GetIssuesByIDs reads the issues table only, so a wisp
|
||||
// gate — the kind `bd mol wisp` clones from a formula — once hydrated to
|
||||
// nothing, and its step listed undecorated while `bd show` called it GATED.
|
||||
//
|
||||
// The unit of work is lookupOnlyUOW: the dependency rows are preloaded, so a
|
||||
// call to its nil DependencyUseCase would be a panic, not a silent pass.
|
||||
func TestProxiedGatedIssueIDsHydratesBothPlanes(t *testing.T) {
|
||||
step := &types.Issue{ID: "bd-step", Status: types.StatusOpen}
|
||||
wispStep := &types.Issue{ID: "bd-wisp-step", Status: types.StatusOpen, Ephemeral: true}
|
||||
gate := openGate("bd-gate", "human", "Need design review", "")
|
||||
wispGate := openGate("bd-wisp-gate", "", "", "")
|
||||
wispGate.Ephemeral = true
|
||||
deps := map[string][]*types.Dependency{
|
||||
step.ID: {{IssueID: step.ID, DependsOnID: gate.ID, Type: types.DepBlocks}},
|
||||
wispStep.ID: {{IssueID: wispStep.ID, DependsOnID: wispGate.ID, Type: types.DepBlocks}},
|
||||
}
|
||||
page := []*types.Issue{step, wispStep}
|
||||
|
||||
t.Run("each_plane_decorates_its_own_rows", func(t *testing.T) {
|
||||
uw := lookupOnlyUOW{issues: planeIssueUC{
|
||||
issues: []*types.Issue{gate},
|
||||
wisps: []*types.Issue{wispGate},
|
||||
}}
|
||||
got := proxiedGatedIssueIDs(context.Background(), uw, page, deps)
|
||||
want := map[string][]string{step.ID: {gate.ID}, wispStep.ID: {wispGate.ID}}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("gated = %v, want %v", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
// A failed wisps read costs the wisp gates their decoration, never the
|
||||
// durable gates the issues read already found.
|
||||
t.Run("failed_wisps_read_keeps_the_durable_decoration", func(t *testing.T) {
|
||||
uw := lookupOnlyUOW{issues: planeIssueUC{
|
||||
issues: []*types.Issue{gate},
|
||||
wispsErr: errors.New("wisps read failed"),
|
||||
}}
|
||||
got := proxiedGatedIssueIDs(context.Background(), uw, page, deps)
|
||||
want := map[string][]string{step.ID: {gate.ID}}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("gated = %v, want %v", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -326,7 +326,8 @@ func runListCore(cmd *cobra.Command, _ []string) error {
|
|||
return HandleError("loading dependencies for --deps: %v", depErr)
|
||||
}
|
||||
// Hierarchical --parent walks use an unlimited per-level query, so the tree is never page-truncated.
|
||||
displayPrettyListWithDepsMode(treeIssues, false, allDeps, in.depsMode, false, in.ReadyFlag, in.Status, in.SortBy, in.Reverse)
|
||||
displayPrettyListWithDepsMode(treeIssues, false, allDeps, in.depsMode, false, in.ReadyFlag, in.Status, in.SortBy, in.Reverse,
|
||||
gatedIssueIDs(ctx, activeStore, treeIssues, allDeps))
|
||||
printSkipLabelsFooter(in.SkipLabels)
|
||||
return nil
|
||||
}
|
||||
|
|
@ -335,7 +336,11 @@ func runListCore(cmd *cobra.Command, _ []string) error {
|
|||
if depErr != nil && in.depsMode != "" {
|
||||
return HandleError("loading dependencies for --deps: %v", depErr)
|
||||
}
|
||||
displayPrettyListWithDepsMode(issues, false, allDeps, in.depsMode, truncated, in.ReadyFlag, in.Status, in.SortBy, in.Reverse)
|
||||
// allDeps is already the whole rig's edge map, so the gate decoration
|
||||
// adds ONE call here — the hydration of the gate candidates it names,
|
||||
// itself an id-set read of a few round trips. Per page, never per row.
|
||||
displayPrettyListWithDepsMode(issues, false, allDeps, in.depsMode, truncated, in.ReadyFlag, in.Status, in.SortBy, in.Reverse,
|
||||
gatedIssueIDs(ctx, activeStore, issues, allDeps))
|
||||
printTruncationHint(truncated, in.effectiveLimit)
|
||||
printSkipLabelsFooter(in.SkipLabels)
|
||||
return nil
|
||||
|
|
@ -367,11 +372,19 @@ func runListCore(cmd *cobra.Command, _ []string) error {
|
|||
// between the two CALLERS, recorded for the owner in AMBIGUITIES.md
|
||||
// (A-blk-1) rather than converged here.
|
||||
blocking := annotateListBlocking(ctx, activeStore, issueIDs)
|
||||
// Batched by id set, never per row — see gatesByIssueID. --long and
|
||||
// --format render no gate (GatedBy lives on types.IssueDetails, which a
|
||||
// --format template cannot reach), so neither pays for the reads; agent
|
||||
// and compact mode both spend them and both render them.
|
||||
var gated map[string][]string
|
||||
if ui.IsAgentMode() || !in.longFormat {
|
||||
gated = gatedIssueIDs(ctx, activeStore, issues, nil)
|
||||
}
|
||||
|
||||
var buf strings.Builder
|
||||
if ui.IsAgentMode() {
|
||||
for _, issue := range issues {
|
||||
formatAgentIssue(&buf, issue, blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID])
|
||||
formatAgentIssue(&buf, issue, blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID], gated[issue.ID])
|
||||
}
|
||||
fmt.Print(buf.String()) //nolint:forbidigo // Agent output is outside the --format contract.
|
||||
printTruncationHint(truncated, in.effectiveLimit)
|
||||
|
|
@ -385,7 +398,7 @@ func runListCore(cmd *cobra.Command, _ []string) error {
|
|||
} else {
|
||||
for _, issue := range issues {
|
||||
labels := labelsMap[issue.ID]
|
||||
formatIssueCompact(&buf, issue, labels, blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID])
|
||||
formatIssueCompact(&buf, issue, labels, blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID], gated[issue.ID])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ func TestDisplayPrettyListWithDepsReadyExplicitStatusFooter(t *testing.T) {
|
|||
}
|
||||
|
||||
depsOut := captureStdout(t, func() error {
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "scheduling", false, true, "in_progress", "", false)
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "scheduling", false, true, "in_progress", "", false, nil)
|
||||
return nil
|
||||
})
|
||||
if strings.Contains(depsOut, "open only") || strings.Contains(depsOut, "excludes in_progress") {
|
||||
|
|
|
|||
|
|
@ -43,8 +43,30 @@ func renderStatusIcon(status types.Status) string {
|
|||
// formatPrettyIssue formats a single issue for pretty output
|
||||
// Uses semantic colors: status icon colored, priority P0/P1 colored, rest neutral
|
||||
func formatPrettyIssue(issue *types.Issue) string {
|
||||
return formatPrettyIssueGated(issue, nil)
|
||||
}
|
||||
|
||||
// formatPrettyIssueGated is formatPrettyIssue with the derived gate marker
|
||||
// (wy-j2upyy): when an open gate blocks the issue, the glyph column carries
|
||||
// ⊘ instead of the stored status's icon. The rest of the row is untouched,
|
||||
// and the stored status is untouched — this is a decoration over the same
|
||||
// predicate `bd ready` filters on, so the listing stops disagreeing with it.
|
||||
//
|
||||
// The marker OUTRANKS the status icon, including ❄: one column can hold one
|
||||
// glyph, and of the two reasons the work cannot start, the gate is the one a
|
||||
// reader cannot discover from the row's own fields. It never outranks 📌,
|
||||
// because types.SubjectCanBeGated refuses a pinned subject outright — a pinned
|
||||
// bead is out of `bd ready` on its own account, not the gate's.
|
||||
//
|
||||
// gatedBy is the gate ids the ONE predicate selected (gatesByIssueID); the
|
||||
// SubjectCanBeGated re-check is the same clause, not a second rule, and is
|
||||
// here so a caller that hands over a stale map cannot invent a decoration.
|
||||
func formatPrettyIssueGated(issue *types.Issue, gatedBy []string) string {
|
||||
// Use shared helpers from ui package
|
||||
statusIcon := ui.RenderStatusIcon(string(issue.Status))
|
||||
if len(gatedBy) > 0 && types.SubjectCanBeGated(issue) {
|
||||
statusIcon = ui.StatusBlockedStyle.Render(ui.StatusIconGated)
|
||||
}
|
||||
priorityTag := renderPriorityTag(issue.Priority)
|
||||
|
||||
// Type badge - only show for notable types
|
||||
|
|
@ -132,9 +154,15 @@ func formatIssueLong(buf *strings.Builder, issue *types.Issue, labels []string,
|
|||
}
|
||||
|
||||
// formatAgentIssue formats a single issue in ultra-compact agent mode format
|
||||
// Output: "ID: Title" with optional dependency info "(parent: X, blocked by: Y, blocks: Z)"
|
||||
func formatAgentIssue(buf *strings.Builder, issue *types.Issue, blockedBy, blocks []string, parent string) {
|
||||
depInfo := formatDependencyInfo(blockedBy, blocks, parent)
|
||||
// Output: "ID: Title" with optional dependency info
|
||||
// "(parent: X, blocked by: Y, blocks: Z, gated by: G)"
|
||||
//
|
||||
// Agent mode has no glyph column, so the gate rides in the parenthetical the
|
||||
// line already carries (wy-j2upyy). It is the seat that most needs it:
|
||||
// ui.IsAgentMode() is true whenever CLAUDE_CODE is set, and an agent reading a
|
||||
// plain row cannot tell startable work from work a human has to release.
|
||||
func formatAgentIssue(buf *strings.Builder, issue *types.Issue, blockedBy, blocks []string, parent string, gatedBy []string) {
|
||||
depInfo := formatDependencyInfo(blockedBy, blocks, parent, gatedBy)
|
||||
if depInfo != "" {
|
||||
buf.WriteString(fmt.Sprintf("%s: %s %s\n", issue.ID, issue.Title, depInfo))
|
||||
} else {
|
||||
|
|
@ -144,9 +172,15 @@ func formatAgentIssue(buf *strings.Builder, issue *types.Issue, blockedBy, block
|
|||
|
||||
// formatDependencyInfo formats dependency info for list output.
|
||||
// Parent-child deps are shown as "parent: X" (structural), separate from "blocked by" (blocking). (bd-hcxu)
|
||||
// Returns "(parent: X, blocked by: Y, blocks: Z)" or "" if no dependencies.
|
||||
func formatDependencyInfo(blockedBy, blocks []string, parent string) string {
|
||||
if len(blockedBy) == 0 && len(blocks) == 0 && parent == "" {
|
||||
// Returns "(parent: X, blocked by: Y, blocks: Z, gated by: G)" or "" if no dependencies.
|
||||
//
|
||||
// A gate is also a blocker, so its id appears under BOTH "blocked by" and
|
||||
// "gated by". The repetition is the point: "blocked by" says what to wait on,
|
||||
// "gated by" says which of those is a gate — work nobody can start by doing
|
||||
// more work. The clause is present exactly when the ONE predicate selected a
|
||||
// gate (types.GateIsHolding + types.SubjectCanBeGated).
|
||||
func formatDependencyInfo(blockedBy, blocks []string, parent string, gatedBy []string) string {
|
||||
if len(blockedBy) == 0 && len(blocks) == 0 && parent == "" && len(gatedBy) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +194,9 @@ func formatDependencyInfo(blockedBy, blocks []string, parent string) string {
|
|||
if len(blocks) > 0 {
|
||||
parts = append(parts, fmt.Sprintf("blocks: %s", strings.Join(blocks, ", ")))
|
||||
}
|
||||
if len(gatedBy) > 0 {
|
||||
parts = append(parts, fmt.Sprintf("gated by: %s", strings.Join(gatedBy, ", ")))
|
||||
}
|
||||
return "(" + strings.Join(parts, ", ") + ")"
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +272,7 @@ func getClosedBlockerIDs(ctx context.Context, s storage.DoltStorage, allDeps map
|
|||
// formatIssueCompact formats a single issue in compact format to a buffer
|
||||
// Uses status icons for better scanability - consistent with bd graph
|
||||
// Format: [icon] [pin] ID [Priority] [Type] @assignee [labels] - Title (parent: X, blocked by: Y, blocks: Z)
|
||||
func formatIssueCompact(buf *strings.Builder, issue *types.Issue, labels []string, blockedBy, blocks []string, parent string) {
|
||||
func formatIssueCompact(buf *strings.Builder, issue *types.Issue, labels []string, blockedBy, blocks []string, parent string, gatedBy []string) {
|
||||
labelsStr := ""
|
||||
if len(labels) > 0 {
|
||||
labelsStr = fmt.Sprintf(" %v", labels)
|
||||
|
|
@ -246,7 +283,7 @@ func formatIssueCompact(buf *strings.Builder, issue *types.Issue, labels []strin
|
|||
}
|
||||
|
||||
// Format dependency info
|
||||
depInfo := formatDependencyInfo(blockedBy, blocks, parent)
|
||||
depInfo := formatDependencyInfo(blockedBy, blocks, parent, gatedBy)
|
||||
if depInfo != "" {
|
||||
depInfo = " " + depInfo
|
||||
}
|
||||
|
|
@ -256,6 +293,11 @@ func formatIssueCompact(buf *strings.Builder, issue *types.Issue, labels []strin
|
|||
if len(blockedBy) > 0 && issue.Status == types.StatusOpen {
|
||||
statusIcon = renderStatusIcon(types.StatusBlocked)
|
||||
}
|
||||
// A gate is a blocker a reader cannot see in the row, so it takes the
|
||||
// column back off ● (wy-j2upyy). Same predicate as the tree view's glyph.
|
||||
if len(gatedBy) > 0 && types.SubjectCanBeGated(issue) {
|
||||
statusIcon = ui.StatusBlockedStyle.Render(ui.StatusIconGated)
|
||||
}
|
||||
|
||||
if issue.Status == types.StatusClosed {
|
||||
// Closed issues: entire line muted (fades visually)
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ func TestListDisplayPrettyListHonorsSort(t *testing.T) {
|
|||
}
|
||||
|
||||
out := captureStdout(t, func() error {
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "", false, false, "closed", "closed", false)
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "", false, false, "closed", "closed", false, nil)
|
||||
return nil
|
||||
})
|
||||
newAt, oldAt := strings.Index(out, "bd-new"), strings.Index(out, "bd-old")
|
||||
|
|
@ -309,7 +309,7 @@ func TestListDisplayPrettyListHonorsSort(t *testing.T) {
|
|||
}
|
||||
|
||||
out := captureStdout(t, func() error {
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "", false, false, "", "", true)
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "", false, false, "", "", true, nil)
|
||||
return nil
|
||||
})
|
||||
p3At, p0At := strings.Index(out, "bd-p3"), strings.Index(out, "bd-p0")
|
||||
|
|
@ -328,7 +328,7 @@ func TestListDisplayPrettyListHonorsSort(t *testing.T) {
|
|||
}
|
||||
|
||||
out := captureStdout(t, func() error {
|
||||
displayPrettyListWithDepsMode([]*types.Issue{parent, oldChild, newChild}, false, deps, "", false, false, "closed", "closed", false)
|
||||
displayPrettyListWithDepsMode([]*types.Issue{parent, oldChild, newChild}, false, deps, "", false, false, "closed", "closed", false, nil)
|
||||
return nil
|
||||
})
|
||||
newAt, oldAt := strings.Index(out, newChild.ID), strings.Index(out, oldChild.ID)
|
||||
|
|
@ -373,7 +373,7 @@ func TestListDisplayPrettyList_TruncatedSummary(t *testing.T) {
|
|||
}
|
||||
|
||||
out := captureStdout(t, func() error {
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "", true, false, "", "", false)
|
||||
displayPrettyListWithDepsMode(issues, false, nil, "", true, false, "", "", false, nil)
|
||||
return nil
|
||||
})
|
||||
if !strings.Contains(out, "Showing 2 issues") {
|
||||
|
|
|
|||
|
|
@ -164,7 +164,12 @@ func runListProxiedWatch(_ *cobra.Command, ctx context.Context, in listInput) er
|
|||
if err != nil {
|
||||
return fmt.Errorf("initial query: %w", err)
|
||||
}
|
||||
displayPrettyListWithDepsMode(issues, true, deps, "", hasMore, in.ReadyFlag, in.Status, in.SortBy, in.Reverse)
|
||||
// --watch renders no gate (the nil gated map), here and on the direct route
|
||||
// in displayWatchedIssueList: a bead the one-shot listing marks ⊘ keeps its
|
||||
// plain status glyph while watched, and no refresh tick pays for the gate
|
||||
// reads. Deliberate, not a forgotten argument — decorating watch means
|
||||
// computing the map on every refresh.
|
||||
displayPrettyListWithDepsMode(issues, true, deps, "", hasMore, in.ReadyFlag, in.Status, in.SortBy, in.Reverse, nil)
|
||||
printTruncationHint(hasMore, in.effectiveLimit)
|
||||
lastSnapshot := issueSnapshot(issues)
|
||||
|
||||
|
|
@ -191,7 +196,8 @@ func runListProxiedWatch(_ *cobra.Command, ctx context.Context, in listInput) er
|
|||
snap := issueSnapshot(issues)
|
||||
if snap != lastSnapshot {
|
||||
lastSnapshot = snap
|
||||
displayPrettyListWithDepsMode(issues, true, deps, "", hasMore, in.ReadyFlag, in.Status, in.SortBy, in.Reverse)
|
||||
// Undecorated, as the initial render above.
|
||||
displayPrettyListWithDepsMode(issues, true, deps, "", hasMore, in.ReadyFlag, in.Status, in.SortBy, in.Reverse, nil)
|
||||
printTruncationHint(hasMore, in.effectiveLimit)
|
||||
fmt.Fprintf(os.Stderr, "\nWatching for changes... (Press Ctrl+C to exit)\n")
|
||||
}
|
||||
|
|
@ -247,7 +253,10 @@ func renderProxiedListText(ctx context.Context, out io.Writer, issues []*types.I
|
|||
printTruncationHint(truncated, in.effectiveLimit)
|
||||
return nil
|
||||
}
|
||||
displayPrettyListWithDepsMode(issues, false, depsByIssueID, in.depsMode, truncated, in.ReadyFlag, in.Status, in.SortBy, in.Reverse)
|
||||
// The gate decoration rides the edge map this route just read, so the
|
||||
// proxied pretty listing says what the direct one says (wy-j2upyy).
|
||||
displayPrettyListWithDepsMode(issues, false, depsByIssueID, in.depsMode, truncated, in.ReadyFlag, in.Status, in.SortBy, in.Reverse,
|
||||
proxiedGatedIssueIDs(ctx, uw, issues, depsByIssueID))
|
||||
printTruncationHint(truncated, in.effectiveLimit)
|
||||
printSkipLabelsFooter(in.SkipLabels)
|
||||
return nil
|
||||
|
|
@ -276,11 +285,19 @@ func renderProxiedListText(ctx context.Context, out io.Writer, issues []*types.I
|
|||
}
|
||||
blocking := newListBlocking(result)
|
||||
|
||||
// The proxied --json routes get gated_by from workapi.BuildIssueDetails;
|
||||
// without this the proxied TEXT routes would render a plain OPEN row for
|
||||
// the same bead (wy-j2upyy). --long renders no gate, so it pays nothing.
|
||||
var gated map[string][]string
|
||||
if ui.IsAgentMode() || !in.longFormat {
|
||||
gated = proxiedGatedIssueIDsOwnUOW(ctx, issues)
|
||||
}
|
||||
|
||||
var buf strings.Builder
|
||||
switch {
|
||||
case ui.IsAgentMode():
|
||||
for _, issue := range issues {
|
||||
formatAgentIssue(&buf, issue, blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID])
|
||||
formatAgentIssue(&buf, issue, blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID], gated[issue.ID])
|
||||
}
|
||||
fmt.Print(buf.String()) //nolint:forbidigo // Agent output is outside the --format contract.
|
||||
printTruncationHint(truncated, in.effectiveLimit)
|
||||
|
|
@ -292,7 +309,7 @@ func renderProxiedListText(ctx context.Context, out io.Writer, issues []*types.I
|
|||
}
|
||||
default:
|
||||
for _, issue := range issues {
|
||||
formatIssueCompact(&buf, issue, labelsMap[issue.ID], blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID])
|
||||
formatIssueCompact(&buf, issue, labelsMap[issue.ID], blocking.blockedBy[issue.ID], blocking.blocks[issue.ID], blocking.parent[issue.ID], gated[issue.ID])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,10 +79,10 @@ func TestNewListBlockingKeysTheDecorationByID(t *testing.T) {
|
|||
if got := blocking.blocks["bd-4"]; len(got) != 1 || got[0] != "bd-1" {
|
||||
t.Errorf("blocks[bd-4] = %v, want [bd-1]", got)
|
||||
}
|
||||
if got := formatDependencyInfo(blocking.blockedBy["bd-5"], blocking.blocks["bd-5"], blocking.parent["bd-5"]); got != "" {
|
||||
if got := formatDependencyInfo(blocking.blockedBy["bd-5"], blocking.blocks["bd-5"], blocking.parent["bd-5"], nil); got != "" {
|
||||
t.Errorf("a bare entry rendered %q, want no decoration at all", got)
|
||||
}
|
||||
if got := formatDependencyInfo(blocking.blockedBy["bd-absent"], blocking.blocks["bd-absent"], blocking.parent["bd-absent"]); got != "" {
|
||||
if got := formatDependencyInfo(blocking.blockedBy["bd-absent"], blocking.blocks["bd-absent"], blocking.parent["bd-absent"], nil); got != "" {
|
||||
t.Errorf("an id the role did not mention rendered %q, want no decoration at all", got)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,9 @@ func displayWatchedIssueList(ctx context.Context, store watchListDependencyStore
|
|||
allDeps = deps
|
||||
}
|
||||
}
|
||||
displayPrettyListWithDepsMode(issues, true, allDeps, "", truncated, readyFiltered, statusSelector, sortBy, reverse)
|
||||
// No gate decoration (the nil gated map): --watch deliberately renders a
|
||||
// gated bead undecorated, on both routes; see runListProxiedWatch.
|
||||
displayPrettyListWithDepsMode(issues, true, allDeps, "", truncated, readyFiltered, statusSelector, sortBy, reverse, nil)
|
||||
}
|
||||
|
||||
// watchIssues returns an error only for the initial query — a failure there
|
||||
|
|
@ -268,7 +270,8 @@ func runListProxiedHierarchicalParent(ctx context.Context, uw uow.UnitOfWork, in
|
|||
}
|
||||
|
||||
// Hierarchical --parent walks use an unlimited per-level query; never page-truncated.
|
||||
displayPrettyListWithDepsMode(treeIssues, false, depsByIssueID, in.depsMode, false, in.ReadyFlag, in.Status, in.SortBy, in.Reverse)
|
||||
displayPrettyListWithDepsMode(treeIssues, false, depsByIssueID, in.depsMode, false, in.ReadyFlag, in.Status, in.SortBy, in.Reverse,
|
||||
proxiedGatedIssueIDs(ctx, uw, treeIssues, depsByIssueID))
|
||||
printSkipLabelsFooter(in.SkipLabels)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1045,7 +1045,7 @@ func TestFormatIssueCompact(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, tt.issue, tt.labels, nil, nil, "")
|
||||
formatIssueCompact(&buf, tt.issue, tt.labels, nil, nil, "", nil)
|
||||
result := buf.String()
|
||||
if !strings.Contains(result, tt.want) {
|
||||
t.Errorf("formatIssueCompact() = %q, want to contain %q", result, tt.want)
|
||||
|
|
@ -1239,7 +1239,7 @@ func TestFormatIssueCompactWithDependencies(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, tt.issue, nil, tt.blockedBy, tt.blocks, "")
|
||||
formatIssueCompact(&buf, tt.issue, nil, tt.blockedBy, tt.blocks, "", nil)
|
||||
result := buf.String()
|
||||
if !strings.Contains(result, tt.want) {
|
||||
t.Errorf("formatIssueCompact() = %q, want to contain %q", result, tt.want)
|
||||
|
|
@ -1262,7 +1262,7 @@ func TestFormatIssueCompactBlockedIcon(t *testing.T) {
|
|||
Status: types.StatusOpen,
|
||||
}
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, []string{"blocker-1"}, nil, "")
|
||||
formatIssueCompact(&buf, issue, nil, []string{"blocker-1"}, nil, "", nil)
|
||||
result := buf.String()
|
||||
// Should show blocked icon ● not open icon ○
|
||||
if strings.Contains(result, ui.StatusIconOpen) {
|
||||
|
|
@ -1282,7 +1282,7 @@ func TestFormatIssueCompactBlockedIcon(t *testing.T) {
|
|||
Status: types.StatusOpen,
|
||||
}
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, nil, nil, "")
|
||||
formatIssueCompact(&buf, issue, nil, nil, nil, "", nil)
|
||||
result := buf.String()
|
||||
if !strings.Contains(result, ui.StatusIconOpen) {
|
||||
t.Errorf("open issue without blockers should show open icon ○, got: %q", result)
|
||||
|
|
@ -1298,7 +1298,7 @@ func TestFormatIssueCompactBlockedIcon(t *testing.T) {
|
|||
Status: types.StatusInProgress,
|
||||
}
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, []string{"blocker-1"}, nil, "")
|
||||
formatIssueCompact(&buf, issue, nil, []string{"blocker-1"}, nil, "", nil)
|
||||
result := buf.String()
|
||||
// Should keep in_progress icon, not override to blocked
|
||||
if !strings.Contains(result, ui.StatusIconInProgress) {
|
||||
|
|
@ -1640,6 +1640,7 @@ func TestFormatDependencyInfoWithParent(t *testing.T) {
|
|||
blockedBy []string
|
||||
blocks []string
|
||||
parent string
|
||||
gatedBy []string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
|
|
@ -1675,11 +1676,25 @@ func TestFormatDependencyInfoWithParent(t *testing.T) {
|
|||
blockedBy: []string{"blocker-1"},
|
||||
want: "(blocked by: blocker-1)",
|
||||
},
|
||||
{
|
||||
// A gate is also a blocker, so it shows up twice on purpose:
|
||||
// "blocked by" says what to wait on, "gated by" says which of
|
||||
// those nobody can clear by doing more work (wy-j2upyy).
|
||||
name: "gate names itself in both clauses",
|
||||
blockedBy: []string{"bd-gate"},
|
||||
gatedBy: []string{"bd-gate"},
|
||||
want: "(blocked by: bd-gate, gated by: bd-gate)",
|
||||
},
|
||||
{
|
||||
name: "gated by alone still renders",
|
||||
gatedBy: []string{"bd-gate"},
|
||||
want: "(gated by: bd-gate)",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := formatDependencyInfo(tt.blockedBy, tt.blocks, tt.parent)
|
||||
result := formatDependencyInfo(tt.blockedBy, tt.blocks, tt.parent, tt.gatedBy)
|
||||
if result != tt.want {
|
||||
t.Errorf("formatDependencyInfo() = %q, want %q", result, tt.want)
|
||||
}
|
||||
|
|
@ -1700,7 +1715,7 @@ func TestFormatIssueCompactWithParent(t *testing.T) {
|
|||
|
||||
t.Run("shows parent annotation", func(t *testing.T) {
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, nil, nil, "test-parent")
|
||||
formatIssueCompact(&buf, issue, nil, nil, nil, "test-parent", nil)
|
||||
result := buf.String()
|
||||
if !strings.Contains(result, "(parent: test-parent)") {
|
||||
t.Errorf("Expected '(parent: test-parent)' in output, got %q", result)
|
||||
|
|
@ -1709,7 +1724,7 @@ func TestFormatIssueCompactWithParent(t *testing.T) {
|
|||
|
||||
t.Run("does not show blocked by for parent", func(t *testing.T) {
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, nil, nil, "test-parent")
|
||||
formatIssueCompact(&buf, issue, nil, nil, nil, "test-parent", nil)
|
||||
result := buf.String()
|
||||
if strings.Contains(result, "blocked by") {
|
||||
t.Errorf("Should not contain 'blocked by' for parent-child dep, got %q", result)
|
||||
|
|
@ -1718,7 +1733,7 @@ func TestFormatIssueCompactWithParent(t *testing.T) {
|
|||
|
||||
t.Run("shows parent and blocked by together", func(t *testing.T) {
|
||||
var buf strings.Builder
|
||||
formatIssueCompact(&buf, issue, nil, []string{"blocker-1"}, nil, "test-parent")
|
||||
formatIssueCompact(&buf, issue, nil, []string{"blocker-1"}, nil, "test-parent", nil)
|
||||
result := buf.String()
|
||||
if !strings.Contains(result, "(parent: test-parent, blocked by: blocker-1)") {
|
||||
t.Errorf("Expected '(parent: test-parent, blocked by: blocker-1)' in output, got %q", result)
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ const treeCycleMarker = "(cycle: shown above; parent-child cycle in stored edges
|
|||
// Children use the requested list order. With --deps, dependency order takes
|
||||
// precedence and the requested order breaks ties. When dr is set, each node's
|
||||
// dependency edges are annotated just beneath it.
|
||||
func printPrettyTree(childrenMap map[string][]*types.Issue, parentID string, prefix string, dr *depRender, compare func(a, b *types.Issue) int) {
|
||||
printPrettyTreePath(childrenMap, parentID, prefix, dr, compare, map[string]bool{parentID: true})
|
||||
func printPrettyTree(childrenMap map[string][]*types.Issue, parentID string, prefix string, dr *depRender, compare func(a, b *types.Issue) int, gated map[string][]string) {
|
||||
printPrettyTreePath(childrenMap, parentID, prefix, dr, compare, gated, map[string]bool{parentID: true})
|
||||
}
|
||||
|
||||
// printPrettyTreePath is printPrettyTree carrying the set of ancestors on the
|
||||
|
|
@ -176,7 +176,7 @@ func printPrettyTree(childrenMap map[string][]*types.Issue, parentID string, pre
|
|||
// renders under both; only a true ancestor counts as a cycle. Like the
|
||||
// "(shown above)" arm of bd dep tree, the marked line carries no --deps
|
||||
// annotations: they were printed with the node's first appearance.
|
||||
func printPrettyTreePath(childrenMap map[string][]*types.Issue, parentID string, prefix string, dr *depRender, compare func(a, b *types.Issue) int, onPath map[string]bool) {
|
||||
func printPrettyTreePath(childrenMap map[string][]*types.Issue, parentID string, prefix string, dr *depRender, compare func(a, b *types.Issue) int, gated map[string][]string, onPath map[string]bool) {
|
||||
children := childrenMap[parentID]
|
||||
|
||||
if dr != nil {
|
||||
|
|
@ -192,10 +192,10 @@ func printPrettyTreePath(childrenMap map[string][]*types.Issue, parentID string,
|
|||
connector = "└── "
|
||||
}
|
||||
if onPath[child.ID] {
|
||||
fmt.Printf("%s%s%s %s\n", prefix, connector, formatPrettyIssue(child), ui.RenderMuted(treeCycleMarker)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Printf("%s%s%s %s\n", prefix, connector, formatPrettyIssueGated(child, gated[child.ID]), ui.RenderMuted(treeCycleMarker)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
continue
|
||||
}
|
||||
fmt.Printf("%s%s%s\n", prefix, connector, formatPrettyIssue(child)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Printf("%s%s%s\n", prefix, connector, formatPrettyIssueGated(child, gated[child.ID])) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
|
||||
extension := "│ "
|
||||
if isLast {
|
||||
|
|
@ -203,7 +203,7 @@ func printPrettyTreePath(childrenMap map[string][]*types.Issue, parentID string,
|
|||
}
|
||||
dr.annotationsFor(child.ID, prefix+extension)
|
||||
onPath[child.ID] = true
|
||||
printPrettyTreePath(childrenMap, child.ID, prefix+extension, dr, compare, onPath)
|
||||
printPrettyTreePath(childrenMap, child.ID, prefix+extension, dr, compare, gated, onPath)
|
||||
delete(onPath, child.ID)
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ func displayPrettyList(issues []*types.Issue, showHeader bool) {
|
|||
// summary through this wrapper, and a hardcoded false silently restores the
|
||||
// vacuous "(N open, 0 in progress)" that listFooterLine exists to suppress.
|
||||
func displayPrettyListWithDeps(issues []*types.Issue, showHeader bool, allDeps map[string][]*types.Dependency, truncated, readyFiltered bool, statusSelector string) {
|
||||
displayPrettyListWithDepsMode(issues, showHeader, allDeps, "", truncated, readyFiltered, statusSelector, "", false)
|
||||
displayPrettyListWithDepsMode(issues, showHeader, allDeps, "", truncated, readyFiltered, statusSelector, "", false, nil)
|
||||
}
|
||||
|
||||
// listFooterLine renders the one-line summary under a text listing.
|
||||
|
|
@ -284,7 +284,10 @@ func readyFooterScope(statusSelector string) string {
|
|||
// readyFiltered means --ready was in force; statusSelector is the --status value
|
||||
// so the summary names the pin that actually applied — see listFooterLine.
|
||||
// sortBy and reverse preserve the requested list order within the hierarchy.
|
||||
func displayPrettyListWithDepsMode(issues []*types.Issue, showHeader bool, allDeps map[string][]*types.Dependency, depsMode string, truncated, readyFiltered bool, statusSelector, sortBy string, reverse bool) {
|
||||
// gated maps each listed id to the OPEN gates holding it (gatesByIssueID);
|
||||
// nil means the caller computed no gate decoration, and every row renders as
|
||||
// it always did.
|
||||
func displayPrettyListWithDepsMode(issues []*types.Issue, showHeader bool, allDeps map[string][]*types.Dependency, depsMode string, truncated, readyFiltered bool, statusSelector, sortBy string, reverse bool, gated map[string][]string) {
|
||||
if showHeader {
|
||||
// Clear screen and show header
|
||||
fmt.Print("\033[2J\033[H") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
|
|
@ -313,9 +316,9 @@ func displayPrettyListWithDepsMode(issues []*types.Issue, showHeader bool, allDe
|
|||
}
|
||||
|
||||
for _, issue := range roots {
|
||||
fmt.Println(formatPrettyIssue(issue)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Println(formatPrettyIssueGated(issue, gated[issue.ID])) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
dr.annotationsFor(issue.ID, "")
|
||||
printPrettyTree(childrenMap, issue.ID, "", dr, compare)
|
||||
printPrettyTree(childrenMap, issue.ID, "", dr, compare, gated)
|
||||
}
|
||||
|
||||
// Summary — counts describe the shown page; never label a truncated page "Total".
|
||||
|
|
@ -333,8 +336,15 @@ func displayPrettyListWithDepsMode(issues []*types.Issue, showHeader bool, allDe
|
|||
}
|
||||
fmt.Println(listFooterLine(len(issues), openCount, inProgressCount, truncated, readyFiltered, statusSelector)) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Println() //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Println("Status: ○ open ◐ in_progress ● blocked ✓ closed ❄ deferred") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Println("Priority: P0–P4 (label only; not a status icon)") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
// The gated glyph joins the legend only when the page actually carries one:
|
||||
// it is a derived decoration, not a status, and a permanent entry would
|
||||
// promise a row shape most listings never show.
|
||||
statusLegend := "Status: ○ open ◐ in_progress ● blocked ✓ closed ❄ deferred"
|
||||
if len(gated) > 0 {
|
||||
statusLegend += " " + ui.StatusIconGated + " gated (open gate; not in bd ready)"
|
||||
}
|
||||
fmt.Println(statusLegend) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
fmt.Println("Priority: P0–P4 (label only; not a status icon)") //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
if dr != nil {
|
||||
fmt.Printf("Deps: %s = depends-on / relationship (points to target); siblings ordered so dependencies come first; ↗ = target outside current view\n", depGlyph) //nolint:forbidigo // Pretty-tree output is outside the --format contract.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func TestPrintPrettyTree_CycleRendersAncestorOnce(t *testing.T) {
|
|||
}
|
||||
|
||||
out, terminated := captureBoundedStdout(t, func() {
|
||||
printPrettyTree(childrenMap, "bd-a", "", nil, compareIssuesByPriority)
|
||||
printPrettyTree(childrenMap, "bd-a", "", nil, compareIssuesByPriority, nil)
|
||||
})
|
||||
if !terminated {
|
||||
t.Fatalf("printPrettyTree did not return within %v on a cyclic tree; first output:\n%s", captureDeadline, head(out, 20))
|
||||
|
|
@ -148,7 +148,7 @@ func TestPrintPrettyTree_DiamondRendersUnderBothParents(t *testing.T) {
|
|||
}
|
||||
|
||||
out, terminated := captureBoundedStdout(t, func() {
|
||||
printPrettyTree(childrenMap, "bd-a", "", nil, compareIssuesByPriority)
|
||||
printPrettyTree(childrenMap, "bd-a", "", nil, compareIssuesByPriority, nil)
|
||||
})
|
||||
if !terminated {
|
||||
t.Fatalf("printPrettyTree did not return on an acyclic diamond:\n%s", head(out, 20))
|
||||
|
|
@ -233,7 +233,7 @@ func TestDisplayPrettyListWithDepsMode_CycleMarkerCarriesNoAnnotations(t *testin
|
|||
}
|
||||
|
||||
out, terminated := captureBoundedStdout(t, func() {
|
||||
displayPrettyListWithDepsMode(issues, false, allDeps, "all", false, false, "", "", false)
|
||||
displayPrettyListWithDepsMode(issues, false, allDeps, "all", false, false, "", "", false, nil)
|
||||
})
|
||||
if !terminated {
|
||||
t.Fatalf("bd list --tree --deps did not return within %v on a parent-child cycle; first output:\n%s", captureDeadline, head(out, 20))
|
||||
|
|
|
|||
|
|
@ -191,15 +191,30 @@ var showCmd = &cobra.Command{
|
|||
result.Close()
|
||||
continue
|
||||
}
|
||||
// Dependencies are read here rather than at the DEPENDS ON
|
||||
// section below because the header needs them: the derived GATED
|
||||
// marker (wy-j2upyy) is the gate-typed subset of this very set,
|
||||
// so hoisting the read decorates the header and the meta block
|
||||
// without a second query. Best effort, as it always was: a failed
|
||||
// read renders the issue undecorated rather than not at all.
|
||||
//
|
||||
// Counts first — see readDepCounts for why the order matters. The
|
||||
// listing's error is KEPT, not discarded: rendering stays best
|
||||
// effort, but a FAILED listing and a SHORT one both leave the
|
||||
// slice empty, and only the second is an unresolvable edge.
|
||||
depCountsSnapshot := readDepCounts(ctx, issueStore, issue.ID)
|
||||
depsWithMeta, depsErr := issueStore.GetDependenciesWithMetadata(ctx, issue.ID)
|
||||
gates := types.GatesHolding(issue, depsWithMeta)
|
||||
|
||||
if idx > 0 {
|
||||
fmt.Println("\n" + ui.RenderMuted(strings.Repeat("─", 60)))
|
||||
fmt.Printf("\n%s\n", formatIssueHeader(issue))
|
||||
fmt.Printf("\n%s\n", formatIssueHeaderWithGates(issue, gates))
|
||||
} else {
|
||||
fmt.Printf("%s\n", formatIssueHeader(issue))
|
||||
fmt.Printf("%s\n", formatIssueHeaderWithGates(issue, gates))
|
||||
}
|
||||
|
||||
// Metadata: Owner · Type | Created · Updated
|
||||
fmt.Println(formatIssueMetadata(issue))
|
||||
fmt.Println(formatIssueMetadataWithGates(issue, gates))
|
||||
|
||||
// Content sections — always show DESCRIPTION header so the user
|
||||
// can distinguish "empty" from "hidden" (GH#3336).
|
||||
|
|
@ -234,12 +249,7 @@ var showCmd = &cobra.Command{
|
|||
relatedSeen := make(map[string]*types.IssueWithDependencyMetadata)
|
||||
|
||||
// Show dependencies - grouped by dependency type for clarity
|
||||
// Counts first — see readDepCounts for why the order matters.
|
||||
depCountsSnapshot := readDepCounts(ctx, issueStore, issue.ID)
|
||||
// The errors are KEPT, not discarded: rendering stays best
|
||||
// effort, but a FAILED listing and a SHORT one both leave the
|
||||
// slice empty, and only the second is an unresolvable edge.
|
||||
depsWithMeta, depsErr := issueStore.GetDependenciesWithMetadata(ctx, issue.ID) // Best effort: show issue even if deps unavailable
|
||||
// (read above, with the header's gate decoration).
|
||||
for _, sec := range groupDepSections(depsWithMeta, true, relatedSeen) {
|
||||
printDepSection(sec)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,17 @@ func formatShortIssue(issue *types.Issue) string {
|
|||
// Format: ID · Title [Priority · STATUS]
|
||||
// All elements in bd show get semantic colors since focus is on one issue
|
||||
func formatIssueHeader(issue *types.Issue) string {
|
||||
return formatIssueHeaderWithGates(issue, nil)
|
||||
}
|
||||
|
||||
// formatIssueHeaderWithGates is formatIssueHeader plus the derived GATED
|
||||
// marker: [P2 · OPEN · GATED] when an open gate blocks the issue. The stored
|
||||
// status is untouched — GATED is a third segment, not a replacement — because
|
||||
// the row really is open and `bd ready` really does skip it, and a reader who
|
||||
// sees only OPEN has no way to tell those two facts apart. Callers pass the
|
||||
// gates types.GatesHolding selected; an empty set renders exactly what
|
||||
// formatIssueHeader always did.
|
||||
func formatIssueHeaderWithGates(issue *types.Issue, gates []*types.Issue) string {
|
||||
// Get status icon and style
|
||||
statusIcon := ui.RenderStatusIcon(string(issue.Status))
|
||||
statusStyle := ui.GetStatusStyle(string(issue.Status))
|
||||
|
|
@ -72,10 +83,17 @@ func formatIssueHeader(issue *types.Issue) string {
|
|||
tierEmoji = " 📦"
|
||||
}
|
||||
|
||||
// Derived gate marker (wy-j2upyy): an open gate holds this issue out of
|
||||
// bd ready, so the header says so.
|
||||
gatedStr := ""
|
||||
if len(gates) > 0 {
|
||||
gatedStr = " · " + ui.StatusBlockedStyle.Render("GATED")
|
||||
}
|
||||
|
||||
// Build header: STATUS_ICON ID · Title [Priority · STATUS]
|
||||
idStyled := ui.RenderAccent(issue.ID)
|
||||
return fmt.Sprintf("%s %s%s · %s%s [%s · %s]",
|
||||
statusIcon, idStyled, typeBadge, issue.Title, tierEmoji, priorityTag, statusStr)
|
||||
return fmt.Sprintf("%s %s%s · %s%s [%s · %s%s]",
|
||||
statusIcon, idStyled, typeBadge, issue.Title, tierEmoji, priorityTag, statusStr, gatedStr)
|
||||
}
|
||||
|
||||
// formatIssueMetadata returns the metadata line(s) with grouped info
|
||||
|
|
@ -83,6 +101,15 @@ func formatIssueHeader(issue *types.Issue) string {
|
|||
//
|
||||
// Created: 2026-01-06 · Updated: 2026-01-08
|
||||
func formatIssueMetadata(issue *types.Issue) string {
|
||||
return formatIssueMetadataWithGates(issue, nil)
|
||||
}
|
||||
|
||||
// formatIssueMetadataWithGates is formatIssueMetadata plus one "Gated by:"
|
||||
// line per active gate, beside the Deferred: line the time row carries: a
|
||||
// deferred AND gated issue shows both, because they are two different reasons
|
||||
// the work is not startable. A gate that has been resolved (closed) is not in
|
||||
// the set and renders nothing.
|
||||
func formatIssueMetadataWithGates(issue *types.Issue, gates []*types.Issue) string {
|
||||
var lines []string
|
||||
|
||||
// Line 1: Created by/Assignee · Type
|
||||
|
|
@ -126,6 +153,11 @@ func formatIssueMetadata(issue *types.Issue) string {
|
|||
lines = append(lines, strings.Join(timeParts, " · "))
|
||||
}
|
||||
|
||||
// Line 3+: one line per gate actively blocking this issue.
|
||||
for _, gate := range gates {
|
||||
lines = append(lines, formatGatedByLine(gate))
|
||||
}
|
||||
|
||||
// Lease line: only when an active lease is held (in_progress + non-null
|
||||
// lease_expires_at). row_lock is internal and never surfaced.
|
||||
if issue.Status == types.StatusInProgress && issue.LeaseExpiresAt != nil {
|
||||
|
|
@ -578,3 +610,22 @@ func formatMetadataValue(v any) string {
|
|||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
// formatGatedByLine renders one gate on bd show's meta block:
|
||||
//
|
||||
// Gated by: bd-abc (human: Need design review)
|
||||
// Gated by: bd-def (gh:pr, awaiting 42)
|
||||
//
|
||||
// The parenthetical is the gate's own record — its await type, the reason its
|
||||
// creator gave, and what it is waiting on — so the reader can act on the gate
|
||||
// without a second lookup.
|
||||
func formatGatedByLine(gate *types.Issue) string {
|
||||
detail := types.GateKind(gate)
|
||||
if reason := types.GateReason(gate.Description); reason != "" {
|
||||
detail += ": " + reason
|
||||
}
|
||||
if gate.AwaitID != "" {
|
||||
detail += ", awaiting " + gate.AwaitID
|
||||
}
|
||||
return fmt.Sprintf("Gated by: %s (%s)", gate.ID, detail)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,13 +528,27 @@ func runShowProxiedDefault(ctx context.Context, uw uow.UnitOfWork, in *showProxi
|
|||
}
|
||||
|
||||
func proxiedRenderIssue(ctx context.Context, uw uow.UnitOfWork, issue *types.Issue, isWisp bool, in *showProxiedInput, idx int, formatTime func(time.Time) string) {
|
||||
// The outgoing edges are read here rather than at the DEPENDS ON section
|
||||
// below because the header needs them: the derived GATED marker
|
||||
// (wy-j2upyy) is the gate-typed subset of this very set. Without it the
|
||||
// proxied text route renders a plain OPEN header for a bead whose own
|
||||
// --json already publishes gated_by. Best effort, as it always was.
|
||||
//
|
||||
// Counts first — see readDepCounts for why the order matters. The
|
||||
// listing's error is KEPT, not discarded: rendering stays best effort,
|
||||
// but a FAILED listing and a SHORT one both leave the slice empty, and
|
||||
// only the second is an unresolvable edge.
|
||||
depCountsSnapshot := readDepCounts(ctx, proxiedDepCounter{src: workapi.NewUOWDetailSource(uw), isWisp: isWisp}, issue.ID)
|
||||
depsWithMeta, depsErr := proxiedListDeps(ctx, uw, issue.ID, isWisp, domain.DepListFilter{Direction: domain.DepDirectionOut})
|
||||
gates := types.GatesHolding(issue, depsWithMeta)
|
||||
|
||||
if idx > 0 {
|
||||
fmt.Println("\n" + ui.RenderMuted(strings.Repeat("─", 60)))
|
||||
fmt.Printf("\n%s\n", formatIssueHeader(issue))
|
||||
fmt.Printf("\n%s\n", formatIssueHeaderWithGates(issue, gates))
|
||||
} else {
|
||||
fmt.Printf("%s\n", formatIssueHeader(issue))
|
||||
fmt.Printf("%s\n", formatIssueHeaderWithGates(issue, gates))
|
||||
}
|
||||
fmt.Println(formatIssueMetadata(issue))
|
||||
fmt.Println(formatIssueMetadataWithGates(issue, gates))
|
||||
|
||||
if issue.Description != "" {
|
||||
fmt.Printf("\n%s\n%s\n", ui.RenderBold("DESCRIPTION"), uimd.RenderMarkdown(issue.Description))
|
||||
|
|
@ -576,13 +590,7 @@ func proxiedRenderIssue(ctx context.Context, uw uow.UnitOfWork, issue *types.Iss
|
|||
|
||||
relatedSeen := make(map[string]*types.IssueWithDependencyMetadata)
|
||||
|
||||
// Counts first — see readDepCounts for why the order matters.
|
||||
depCountsSnapshot := readDepCounts(ctx, proxiedDepCounter{src: workapi.NewUOWDetailSource(uw), isWisp: isWisp}, issue.ID)
|
||||
|
||||
// The errors are KEPT, not discarded: rendering stays best effort, but a
|
||||
// FAILED listing and a SHORT one both leave the slice empty, and only the
|
||||
// second is an unresolvable edge.
|
||||
depsWithMeta, depsErr := proxiedListDeps(ctx, uw, issue.ID, isWisp, domain.DepListFilter{Direction: domain.DepDirectionOut})
|
||||
// (read above, with the header's gate decoration).
|
||||
for _, sec := range groupDepSections(depsWithMeta, true, relatedSeen) {
|
||||
printDepSection(sec)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,7 +197,10 @@ func runSetState(ctx context.Context, issueID, dimension, newValue, reason strin
|
|||
eventDesc = fmt.Sprintf("Set %s to %s", dimension, newValue)
|
||||
}
|
||||
if reason != "" {
|
||||
eventDesc += "\n\nReason: " + reason
|
||||
// The same marker types.GateDescription writes, from the one constant
|
||||
// that owns its spelling — types.GateReason reads any description
|
||||
// carrying it, so the two writers must not drift apart by accident.
|
||||
eventDesc += types.ReasonMarker + reason
|
||||
}
|
||||
|
||||
lifecycle, err := openIssueLifecycle()
|
||||
|
|
|
|||
|
|
@ -206,6 +206,19 @@ items, plus:
|
|||
- `comments_omitted` (boolean, optional): `true` only when `comment_count` is
|
||||
nonzero and `comments` was left out of the response (no `--include-comments`).
|
||||
Absent when comments were included or when there are none to omit (ga-clgh)
|
||||
- `gated_by` (object[], optional): The gates actively blocking this issue, each
|
||||
`{id, type, reason}` — the gate bead to resolve, its await condition (`human`,
|
||||
`timer`, `gh:run`, `gh:pr`, `bead`, or `gate` when it carries none), and the
|
||||
reason recorded at creation. A gate counts when it is reached over a `blocks`
|
||||
or `conditional-blocks` edge, is itself neither closed nor pinned, and the
|
||||
issue is neither closed nor pinned; a `waits-for` edge onto a gate does not
|
||||
count, because that leg of the readiness rule is a fanout over the gate's
|
||||
children rather than a status test. Absent when nothing gates the issue.
|
||||
DERIVED, not stored: `status` is unaffected, and a nonempty list means
|
||||
`bd ready` withholds the issue on a gate's account. The converse does not
|
||||
hold: only the issue's own edges count, so a child of a gated parent, which
|
||||
`bd ready` also withholds because a blocked parent blocks its children,
|
||||
carries no `gated_by`
|
||||
|
||||
### `import --json`
|
||||
|
||||
|
|
|
|||
|
|
@ -7166,6 +7166,34 @@ components:
|
|||
comment_count:
|
||||
type: integer
|
||||
format: int64
|
||||
gated_by:
|
||||
type: array
|
||||
description: >-
|
||||
The gates actively blocking this issue: gate-typed dependencies
|
||||
reached over a `blocks` or `conditional-blocks` edge whose own
|
||||
status is neither closed nor pinned, on an issue that is itself
|
||||
neither closed nor pinned. ADDITIVE and absent when empty. It is
|
||||
DERIVED, not stored — `status` is unaffected, and an open issue an
|
||||
open gate blocks still reports `open` — and both clauses are the
|
||||
ones the readiness query's is_blocked column applies, so a nonempty
|
||||
list means `bd ready` withholds this issue on a gate's account.
|
||||
A `waits-for` edge onto a gate is deliberately NOT here: that leg
|
||||
of the readiness rule is a fanout over the gate's children rather
|
||||
than a status test, and it can leave the issue ready.
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: The gate issue's id; close it with `bd gate resolve`.
|
||||
type:
|
||||
type: string
|
||||
description: >-
|
||||
The gate's await condition (human, timer, gh:run, gh:pr,
|
||||
bead), or `gate` when it carries none.
|
||||
reason:
|
||||
type: string
|
||||
description: The reason recorded when the gate was created, if any.
|
||||
comments_omitted:
|
||||
type: boolean
|
||||
description: >-
|
||||
|
|
|
|||
25
internal/httpapi/wireshape/testdata/golden.json
vendored
25
internal/httpapi/wireshape/testdata/golden.json
vendored
|
|
@ -2473,6 +2473,13 @@
|
|||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": "IssueDetails",
|
||||
"member": "gated_by",
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"item_type": "object"
|
||||
},
|
||||
{
|
||||
"schema": "IssueDetails",
|
||||
"member": "heartbeat_at",
|
||||
|
|
@ -2698,6 +2705,24 @@
|
|||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": "IssueDetails.gated_by[]",
|
||||
"member": "id",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": "IssueDetails.gated_by[]",
|
||||
"member": "reason",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": "IssueDetails.gated_by[]",
|
||||
"member": "type",
|
||||
"type": "string",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"schema": "IssuePatchBody",
|
||||
"member": "acceptance_criteria",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ load("@rules_go//go:def.bzl", "go_library", "go_test")
|
|||
go_library(
|
||||
name = "types",
|
||||
srcs = [
|
||||
"gated.go",
|
||||
"id_generator.go",
|
||||
"non_completing_close.go",
|
||||
"orphans.go",
|
||||
|
|
@ -17,6 +18,7 @@ go_test(
|
|||
name = "types_test",
|
||||
srcs = [
|
||||
"explain_test.go",
|
||||
"gated_test.go",
|
||||
"id_generator_test.go",
|
||||
"issue_summary_test.go",
|
||||
"non_completing_close_test.go",
|
||||
|
|
|
|||
185
internal/types/gated.go
Normal file
185
internal/types/gated.go
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
package types
|
||||
|
||||
import "strings"
|
||||
|
||||
// This file holds the ONE rule by which an issue counts as GATED, and the
|
||||
// projection of a gate onto the wire.
|
||||
//
|
||||
// GATED IS DERIVED, NEVER STORED. `bd gate create --blocks X` writes a gate
|
||||
// issue plus an ordinary blocking dependency X -> gate; nothing on X changes.
|
||||
// `bd ready` then drops X through the denormalized is_blocked column, and the
|
||||
// rule here is the subset of that column's recompute
|
||||
// (internal/storage/issueops/blocked_consistency.go) a gate can account for:
|
||||
//
|
||||
// - the EDGE clause, from the recompute's first two union legs: the edge is
|
||||
// 'blocks' or 'conditional-blocks' and the target is neither closed nor
|
||||
// pinned (IsGateEdge + the status test in GateIsHolding);
|
||||
// - the SUBJECT clause, from unmarkAllBlockedSQL, which forces is_blocked=0
|
||||
// for a closed or pinned subject whatever its edges say (SubjectCanBeGated).
|
||||
//
|
||||
// Both halves live here, in one predicate every surface asks, so a glyph, a
|
||||
// header and a gated_by field cannot disagree with each other or with `bd
|
||||
// ready` about the same bead.
|
||||
//
|
||||
// WAITS-FOR IS DELIBERATELY OUT. The recompute's waits-for leg does not apply
|
||||
// the closed/pinned status test at all: it goes through waitsForGateBlockedSQL
|
||||
// (internal/storage/issueops/blocked_state.go), which blocks only when the
|
||||
// target has an OPEN parent-child child, or metadata.also_blocks names an open
|
||||
// spawner. A plain `bd dep add X G -t waits-for` onto an open childless gate
|
||||
// therefore leaves X in `bd ready`, and decorating it would be exactly the
|
||||
// drift this file exists to prevent. Mirroring that leg in Go would be a
|
||||
// second implementation of a rule the database already owns; a decoration that
|
||||
// covers the fanout case is its own bead, not this one.
|
||||
|
||||
// GateRef is a gate projected for a caller: the id to resolve, what kind of
|
||||
// wait it is, and why. It is what `gated_by` carries on the detail view.
|
||||
type GateRef struct {
|
||||
ID string `json:"id"`
|
||||
// Type is the gate's await condition (human, timer, gh:run, gh:pr, bead);
|
||||
// "gate" when the issue carries no await type, which is what a gate made
|
||||
// with a bare `bd create --type gate` looks like.
|
||||
Type string `json:"type,omitempty"`
|
||||
// Reason is the free text `bd gate create --reason` recorded, empty when
|
||||
// the gate was created without one.
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// IsGateEdge reports whether a dependency of this type is one whose target's
|
||||
// status alone decides blockedness — the two legs of the is_blocked recompute
|
||||
// that carry "target not closed and not pinned". It is NOT
|
||||
// DependencyType.IsBlockingEdge, which also admits waits-for; see the file
|
||||
// comment.
|
||||
func IsGateEdge(depType DependencyType) bool {
|
||||
return depType == DepBlocks || depType == DepConditionalBlocks
|
||||
}
|
||||
|
||||
// SubjectCanBeGated reports whether an issue's OWN status admits the gate
|
||||
// decoration. A closed or pinned issue never does: unmarkAllBlockedSQL clears
|
||||
// is_blocked for those two statuses unconditionally, so `bd ready` withholds
|
||||
// them for reasons that have nothing to do with a gate, and a "GATED" marker
|
||||
// on such a row would claim a causation that is not there.
|
||||
//
|
||||
// The listing route asks this without hydrated dependencies, which is why the
|
||||
// clause is exported rather than buried inside GatesHolding.
|
||||
func SubjectCanBeGated(subject *Issue) bool {
|
||||
if subject == nil {
|
||||
return false
|
||||
}
|
||||
return subject.Status != StatusClosed && subject.Status != StatusPinned
|
||||
}
|
||||
|
||||
// GateIsHolding reports whether target, reached over a dependency of type
|
||||
// depType, is a gate that is currently holding its dependent back. It is the
|
||||
// EDGE half of the rule; the caller still owes the subject half, which is what
|
||||
// GatesHolding exists to keep it from forgetting.
|
||||
func GateIsHolding(depType DependencyType, target *Issue) bool {
|
||||
if target == nil || target.IssueType != TypeGate {
|
||||
return false
|
||||
}
|
||||
if !IsGateEdge(depType) {
|
||||
return false
|
||||
}
|
||||
return target.Status != StatusClosed && target.Status != StatusPinned
|
||||
}
|
||||
|
||||
// GatesHolding selects, from subject's hydrated dependencies, the gates that
|
||||
// are actively holding subject back, in the order the dependencies arrived.
|
||||
//
|
||||
// THE one predicate: every gated decoration — `bd show`'s header and meta
|
||||
// lines, `bd list`'s glyph, the agent line, the detail view's gated_by — comes
|
||||
// from this function or from the pair it is built out of, so a nonempty result
|
||||
// means `bd ready` withholds subject on a gate's account. Not the converse:
|
||||
// only subject's own edges are read, so a child of a gated parent, withheld
|
||||
// through the recompute's parent-child leg, selects no gate here.
|
||||
func GatesHolding(subject *Issue, deps []*IssueWithDependencyMetadata) []*Issue {
|
||||
if !SubjectCanBeGated(subject) {
|
||||
return nil
|
||||
}
|
||||
var gates []*Issue
|
||||
for _, dep := range deps {
|
||||
if dep == nil {
|
||||
continue
|
||||
}
|
||||
issue := dep.Issue
|
||||
if GateIsHolding(dep.DependencyType, &issue) {
|
||||
gate := issue
|
||||
gates = append(gates, &gate)
|
||||
}
|
||||
}
|
||||
return gates
|
||||
}
|
||||
|
||||
// GateKind names a gate's await condition for display, falling back to the
|
||||
// issue type when the gate carries none.
|
||||
func GateKind(gate *Issue) string {
|
||||
if gate == nil {
|
||||
return ""
|
||||
}
|
||||
if gate.AwaitType != "" {
|
||||
return gate.AwaitType
|
||||
}
|
||||
return string(TypeGate)
|
||||
}
|
||||
|
||||
// NewGateRef projects one gate issue onto the wire shape.
|
||||
func NewGateRef(gate *Issue) GateRef {
|
||||
if gate == nil {
|
||||
return GateRef{}
|
||||
}
|
||||
return GateRef{
|
||||
ID: gate.ID,
|
||||
Type: GateKind(gate),
|
||||
Reason: GateReason(gate.Description),
|
||||
}
|
||||
}
|
||||
|
||||
// GateRefs projects a gate set, returning nil for an empty one so the field
|
||||
// stays absent rather than serializing an empty array.
|
||||
func GateRefs(gates []*Issue) []GateRef {
|
||||
if len(gates) == 0 {
|
||||
return nil
|
||||
}
|
||||
refs := make([]GateRef, 0, len(gates))
|
||||
for _, gate := range gates {
|
||||
refs = append(refs, NewGateRef(gate))
|
||||
}
|
||||
return refs
|
||||
}
|
||||
|
||||
// ReasonMarker separates a generated description from the free-text reason its
|
||||
// author gave. The reason has no column of its own, so the description is
|
||||
// where it lives.
|
||||
//
|
||||
// It is SHARED, not gate-private: `bd gate create` writes it through
|
||||
// GateDescription, and `bd state`'s state-change EVENT descriptions write the
|
||||
// same marker (cmd/bd/state.go). One exported constant so the spelling cannot
|
||||
// drift between them — and so the sharing is visible rather than a coincidence
|
||||
// two files have to keep on purpose.
|
||||
const ReasonMarker = "\n\nReason: "
|
||||
|
||||
// GateDescription builds an ad-hoc gate's description. `bd gate create` is its
|
||||
// only writer.
|
||||
func GateDescription(targetID, reason string) string {
|
||||
desc := "Ad-hoc gate blocking " + targetID
|
||||
if reason != "" {
|
||||
desc += ReasonMarker + reason
|
||||
}
|
||||
return desc
|
||||
}
|
||||
|
||||
// GateReason recovers the reason GateDescription recorded, or "" when the
|
||||
// description carries no marker.
|
||||
//
|
||||
// It is a TEXT read-back, not proof of provenance: ReasonMarker is shared (see
|
||||
// its doc), so any description containing it yields a reason here — a gate
|
||||
// written by hand with that spelling included. What the pair does guarantee is
|
||||
// the round trip: what GateDescription wrote, this returns. `bd gate create`
|
||||
// (cmd/bd/gate.go) is the only GateDescription caller today, so every gate
|
||||
// whose reason this reports is one it recorded.
|
||||
func GateReason(description string) string {
|
||||
idx := strings.Index(description, ReasonMarker)
|
||||
if idx < 0 {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(description[idx+len(ReasonMarker):])
|
||||
}
|
||||
163
internal/types/gated_test.go
Normal file
163
internal/types/gated_test.go
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
package types
|
||||
|
||||
import "testing"
|
||||
|
||||
func gateIssue(id string, status Status) *Issue {
|
||||
return &Issue{ID: id, IssueType: TypeGate, Status: status, AwaitType: "human"}
|
||||
}
|
||||
|
||||
func TestGateIsHolding(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
depType DependencyType
|
||||
target *Issue
|
||||
want bool
|
||||
}{
|
||||
{"open gate over a blocks edge", DepBlocks, gateIssue("g1", StatusOpen), true},
|
||||
{"open gate over conditional-blocks", DepConditionalBlocks, gateIssue("g1", StatusOpen), true},
|
||||
// waits-for is NOT the same rule: the is_blocked recompute sends that
|
||||
// leg through waitsForGateBlockedSQL (fanout over the target's OPEN
|
||||
// parent-child children, or metadata.also_blocks with an open spawner),
|
||||
// never the closed/pinned status test. A plain waits-for edge onto an
|
||||
// open childless gate leaves the dependent IN bd ready, so decorating it
|
||||
// would make the surfaces disagree with readiness.
|
||||
{"open gate over waits-for", DepWaitsFor, gateIssue("g1", StatusOpen), false},
|
||||
{"closed gate", DepBlocks, gateIssue("g1", StatusClosed), false},
|
||||
{"pinned gate", DepBlocks, gateIssue("g1", StatusPinned), false},
|
||||
// parent-child is structural: it propagates blockedness through the
|
||||
// is_blocked recompute, not as a direct blocking edge. Inheritance is
|
||||
// its own question (wy-raudbw) and must not sneak in here.
|
||||
{"gate over a parent-child edge", DepParentChild, gateIssue("g1", StatusOpen), false},
|
||||
{"gate over a relates-to edge", DepRelatesTo, gateIssue("g1", StatusOpen), false},
|
||||
{"open non-gate blocker", DepBlocks, &Issue{ID: "b1", IssueType: TypeTask, Status: StatusOpen}, false},
|
||||
{"nil target", DepBlocks, nil, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := GateIsHolding(tt.depType, tt.target); got != tt.want {
|
||||
t.Errorf("GateIsHolding(%s, %v) = %v, want %v", tt.depType, tt.target, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGatesHoldingSelectsOnlyLiveGates(t *testing.T) {
|
||||
deps := []*IssueWithDependencyMetadata{
|
||||
{Issue: *gateIssue("open-gate", StatusOpen), DependencyType: DepBlocks},
|
||||
{Issue: *gateIssue("closed-gate", StatusClosed), DependencyType: DepBlocks},
|
||||
{Issue: Issue{ID: "plain", IssueType: TypeTask, Status: StatusOpen}, DependencyType: DepBlocks},
|
||||
{Issue: *gateIssue("second-gate", StatusOpen), DependencyType: DepConditionalBlocks},
|
||||
nil,
|
||||
}
|
||||
gates := GatesHolding(&Issue{ID: "subject", Status: StatusOpen}, deps)
|
||||
if len(gates) != 2 {
|
||||
t.Fatalf("GatesHolding returned %d gates, want 2: %+v", len(gates), gates)
|
||||
}
|
||||
if gates[0].ID != "open-gate" || gates[1].ID != "second-gate" {
|
||||
t.Errorf("GatesHolding = %s,%s; want open-gate,second-gate in dependency order", gates[0].ID, gates[1].ID)
|
||||
}
|
||||
}
|
||||
|
||||
// TestGatesHoldingSubjectStatus pins the SUBJECT-side half of the rule. The
|
||||
// is_blocked recompute's unmark leg (unmarkAllBlockedSQL) forces is_blocked=0
|
||||
// for a closed or pinned subject whatever its dependencies say, so `bd ready`
|
||||
// never withholds such a bead on a gate's account and no surface may claim it
|
||||
// is gated.
|
||||
func TestGatesHoldingSubjectStatus(t *testing.T) {
|
||||
deps := []*IssueWithDependencyMetadata{
|
||||
{Issue: *gateIssue("open-gate", StatusOpen), DependencyType: DepBlocks},
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
subject *Issue
|
||||
want int
|
||||
}{
|
||||
{"open subject", &Issue{ID: "s1", Status: StatusOpen}, 1},
|
||||
{"in_progress subject", &Issue{ID: "s1", Status: StatusInProgress}, 1},
|
||||
{"deferred subject", &Issue{ID: "s1", Status: StatusDeferred}, 1},
|
||||
{"closed subject", &Issue{ID: "s1", Status: StatusClosed}, 0},
|
||||
{"pinned subject", &Issue{ID: "s1", Status: StatusPinned}, 0},
|
||||
{"nil subject", nil, 0},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := GatesHolding(tt.subject, deps); len(got) != tt.want {
|
||||
t.Errorf("GatesHolding(%v) returned %d gates, want %d", tt.subject, len(got), tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// SubjectCanBeGated is the clause on its own, because the listing route reaches
|
||||
// it without hydrated dependencies and must ask the SAME question.
|
||||
func TestSubjectCanBeGated(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
status Status
|
||||
want bool
|
||||
}{
|
||||
{StatusOpen, true},
|
||||
{StatusInProgress, true},
|
||||
{StatusBlocked, true},
|
||||
{StatusDeferred, true},
|
||||
{StatusClosed, false},
|
||||
{StatusPinned, false},
|
||||
} {
|
||||
if got := SubjectCanBeGated(&Issue{ID: "s1", Status: tt.status}); got != tt.want {
|
||||
t.Errorf("SubjectCanBeGated(%s) = %v, want %v", tt.status, got, tt.want)
|
||||
}
|
||||
}
|
||||
if SubjectCanBeGated(nil) {
|
||||
t.Error("SubjectCanBeGated(nil) = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGatesHoldingEmpty(t *testing.T) {
|
||||
if got := GatesHolding(&Issue{ID: "subject", Status: StatusOpen}, nil); got != nil {
|
||||
t.Errorf("GatesHolding(subject, nil) = %v, want nil", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGateDescriptionRoundTrip(t *testing.T) {
|
||||
desc := GateDescription("bd-abc", "Need design review")
|
||||
if got := GateReason(desc); got != "Need design review" {
|
||||
t.Errorf("GateReason(%q) = %q, want the reason back", desc, got)
|
||||
}
|
||||
bare := GateDescription("bd-abc", "")
|
||||
if got := GateReason(bare); got != "" {
|
||||
t.Errorf("GateReason(%q) = %q, want empty", bare, got)
|
||||
}
|
||||
if got := GateReason("a description written by something else"); got != "" {
|
||||
t.Errorf("GateReason on a foreign description = %q, want empty", got)
|
||||
}
|
||||
// The marker is SHARED (cmd/bd/state.go writes it on state-change events),
|
||||
// so this is a text read-back and not a provenance check. Pinned so the
|
||||
// doc comment and the behavior cannot drift: any description carrying the
|
||||
// marker yields a reason.
|
||||
if got := GateReason("Changed state from a to b" + ReasonMarker + "because"); got != "because" {
|
||||
t.Errorf("GateReason on a shared-marker description = %q, want %q", got, "because")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGateRefsProjection(t *testing.T) {
|
||||
if got := GateRefs(nil); got != nil {
|
||||
t.Errorf("GateRefs(nil) = %v, want nil so the field stays absent", got)
|
||||
}
|
||||
gate := &Issue{
|
||||
ID: "g1",
|
||||
IssueType: TypeGate,
|
||||
Status: StatusOpen,
|
||||
AwaitType: "gh:pr",
|
||||
Description: GateDescription("bd-abc", "waiting on review"),
|
||||
}
|
||||
refs := GateRefs([]*Issue{gate, {ID: "g2", IssueType: TypeGate, Status: StatusOpen}})
|
||||
if len(refs) != 2 {
|
||||
t.Fatalf("GateRefs returned %d refs, want 2", len(refs))
|
||||
}
|
||||
if refs[0] != (GateRef{ID: "g1", Type: "gh:pr", Reason: "waiting on review"}) {
|
||||
t.Errorf("refs[0] = %+v", refs[0])
|
||||
}
|
||||
// A gate with no await type still names a kind rather than an empty one.
|
||||
if refs[1] != (GateRef{ID: "g2", Type: "gate"}) {
|
||||
t.Errorf("refs[1] = %+v, want the gate fallback kind and no reason", refs[1])
|
||||
}
|
||||
}
|
||||
|
|
@ -1263,6 +1263,19 @@ type IssueDetails struct {
|
|||
// Comments slice or a zero count: a true empty stays plain omission.
|
||||
CommentsOmitted *bool `json:"comments_omitted,omitempty"`
|
||||
|
||||
// GatedBy names the gates actively blocking this issue — the derived
|
||||
// GATED decoration `bd show` renders in its header, as data. ADDITIVE and
|
||||
// omitted when empty: nothing else on this view changes shape, and the
|
||||
// stored status stays whatever it is (an open issue an open gate blocks
|
||||
// still reads "open" here). The rule is types.GatesHolding — the gate
|
||||
// clause of the readiness query's is_blocked column, subject half
|
||||
// included — so a nonempty list means `bd ready` withholds the issue on a
|
||||
// gate's account, and a closed or pinned issue carries no gated_by at all.
|
||||
// The converse does not hold: only the issue's own edges count, so a child
|
||||
// of a gated parent, which `bd ready` withholds through the parent-child
|
||||
// leg, carries no gated_by.
|
||||
GatedBy []GateRef `json:"gated_by,omitempty"`
|
||||
|
||||
// UnresolvableDependencies / UnresolvableDependents count the edges
|
||||
// DependencyCount / DependentCount include that the Dependencies /
|
||||
// Dependents slices could not represent, because the issue on the far
|
||||
|
|
|
|||
|
|
@ -303,6 +303,13 @@ const (
|
|||
StatusIconDeferred = "❄" // scheduled for later (snowflake)
|
||||
StatusIconPinned = "📌" // elevated priority
|
||||
StatusIconCustom = "◇" // custom/uncategorized status (diamond)
|
||||
// StatusIconGated marks an issue an OPEN gate blocks (bd gate create
|
||||
// --blocks). It is a DERIVED decoration, not a stored status: the row's
|
||||
// status is untouched and only the glyph column changes. Circle family,
|
||||
// like ○ ◐ ●, so it reads as a sibling of the status icons rather than as
|
||||
// a badge — barred rather than hollow, because the work exists and cannot
|
||||
// start.
|
||||
StatusIconGated = "⊘" // blocked by an open gate (barred circle)
|
||||
)
|
||||
|
||||
// RenderStatusIcon returns the appropriate icon for a status with semantic coloring.
|
||||
|
|
|
|||
|
|
@ -145,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,
|
||||
|
|
|
|||
|
|
@ -819,3 +819,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