feat(gate): bd gate create --repo names the repository a gh:run/gh:pr gate is checked in (#7176)

* feat(gate): bd gate create --repo names the repository a gh:run/gh:pr gate is checked in

A gh:pr gate for a PR in another repository could only be pointed there
through the blocked issue's metadata.repo; with none, `bd gate check`
resolved the bare number against the current repository and escalated
"pull request not found" on every check, with nothing in the text saying
which repository it had looked in. Five gates armed that way on 2026-10-03
never released after their PRs merged.

- `--repo OWNER/REPO` (or HOST/OWNER/REPO) on `bd gate create`: an
  explicit value wins over the inherited one; it goes through the same
  validator as metadata.repo (now `validateGitHubRepo`, split out of
  `githubRepoFromIssue`); it is refused on human/timer/bead gates, where
  nothing would read it. Both create routes call one helper,
  `gateMetadataForCreate`, so the flag cannot drift between them.
- The gh:pr not-found escalation reason names the repository the number
  was resolved against ("pull request not found: #42 in owner/repo" or
  "... in the current repository").
- Help text, docs/workflows/gates.md and the plugin's ASYNC_GATES.md say
  when the flag is needed. docs/cli-reference is pinned to the release
  and regenerates on its own.

Tests: TestGateMetadataForCreateExplicitRepo, TestCheckGHPRNotFoundNamesTheRepository
(unit); TestEmbeddedGateCreate/create_gate_with_repo + /repo_flag_on_human_gate_is_refused
(embedded); TestProxiedServerGateCreateInheritsRepoMetadata/explicit_repo_flag_wins_over_inherited
(proxied).

Refs ghosttrack/wyvern wy-2jh4v5.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(gate): keep the create --repo workspace bypass off bd gate create

The root pre-run bypass for `bd create --repo` (GH#3686) matched the leaf
name "create", so `bd gate create --repo` outside a workspace took it: an
OWNER/REPO slug opened a stray ./OWNER/REPO/.beads workspace under the cwd
and failed with "issue not found", and an https:// URL skipped store wiring
and panicked on the nil store. Key the bypass on the command path, as
proxy_capability.go already does; gate create now fails with "no beads
database found" outside a workspace like every other command, and top-level
create --repo (local path and remote URL) still takes the bypass.

Also name the repository in the gh:run not-found escalation, as the gh:pr
one already does. Only stderr with a lowercase "not found" reaches that
arm: real gh reports a missing run as "HTTP 404: Not Found (<api url>)",
which takes the existing error path, and that URL already names the
repository. The match stays case-sensitive because a token without access
to the repository gets the same 404.

Tests: TestEmbeddedCreateRepoFromNonBeadsCwd/gate_create_repo_flag_is_not_a_workspace
(slug and URL forms, built binary run from an empty cwd) and the
cross_repo/current_repo subtests of TestCheckGHRunNotFoundNamesTheRepository
fail with the fixes reverted. Its real_gh_404_names_the_repository subtest
feeds gh's real 404 stderr and fails if the match is widened.

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 Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
This commit is contained in:
Bee 2026-10-08 08:02:46 +00:00 • committed by GitHub
commit b485a0975e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 375 additions and 13 deletions

View file

@ -4,6 +4,7 @@ package main
import (
"os"
"os/exec"
"strings"
"testing"
)
@ -65,4 +66,38 @@ func TestEmbeddedCreateRepoFromNonBeadsCwd(t *testing.T) {
t.Errorf("expected 'no beads database found' error, got:\n%s", out)
}
})
t.Run("gate_create_repo_flag_is_not_a_workspace", func(t *testing.T) {
// The --repo bypass is for top-level create only. `bd gate create
// --repo` names the GitHub repository a gh:run/gh:pr gate is checked
// in, so outside a workspace it must fail like any other command.
// While the bypass matched the leaf name "create", the slug form
// opened a stray ./owner/repo/.beads workspace under the cwd and the
// URL form panicked on the nil store.
for _, tc := range []struct{ name, repo string }{
{"slug", "owner/repo"},
{"url", "https://github.com/owner/repo"},
} {
t.Run(tc.name, func(t *testing.T) {
noBeadsCwd := t.TempDir()
cmd := exec.Command(bd, "gate", "create", "--type=gh:pr", "--blocks", "bd-abc", "--await-id=42", "--repo", tc.repo)
cmd.Dir = noBeadsCwd
cmd.Env = bdEnv(t.TempDir())
out, err := cmd.CombinedOutput()
if err == nil {
t.Fatalf("bd gate create --repo %s succeeded outside a workspace:\n%s", tc.repo, out)
}
if !strings.Contains(string(out), "no beads database found") || strings.Contains(string(out), "panic") {
t.Errorf("expected 'no beads database found' error, got:\n%s", out)
}
entries, readErr := os.ReadDir(noBeadsCwd)
if readErr != nil {
t.Fatal(readErr)
}
if len(entries) != 0 {
t.Errorf("bd gate create wrote into the cwd: %d entries, first %q", len(entries), entries[0].Name())
}
})
}
})
}

View file

@ -309,11 +309,15 @@ Gate types:
gh:run - Waits for GitHub Actions workflow
gh:pr - Waits for PR merge
gh:run and gh:pr gates are checked in the current Git repository unless
--repo names another, or the blocked issue carries a metadata.repo value.
Examples:
bd gate create --blocks bd-abc
bd gate create --type=human --blocks bd-abc --reason="Need design review"
bd gate create --type=timer --blocks bd-abc --timeout=2h
bd gate create --type=gh:pr --blocks bd-abc --await-id=42
bd gate create --type=gh:pr --blocks bd-abc --await-id=42 --repo=owner/other-repo
bd gate create --blocks bd-abc --title="Gate: awaiting owner sign-off"`,
SilenceUsage: true,
SilenceErrors: true,
@ -343,9 +347,9 @@ Examples:
}
gate := buildGateIssue(in, targetIssue.ID)
metadata, metaErr := repoMetadataForGate(in.gateType, targetIssue)
metadata, metaErr := gateMetadataForCreate(in, targetIssue)
if metaErr != nil {
return HandleErrorRespectJSON("invalid GitHub repository metadata on %s: %v", targetIssue.ID, metaErr)
return HandleErrorRespectJSON("%v", metaErr)
}
gate.Metadata = metadata
@ -383,6 +387,7 @@ type gateCreateInput struct {
gateType string
reason string
awaitID string
repo string
titleFlag string
timeout time.Duration
}
@ -393,6 +398,7 @@ func gatherGateCreateInput(cmd *cobra.Command) (gateCreateInput, error) {
in.gateType, _ = cmd.Flags().GetString("type")
in.reason, _ = cmd.Flags().GetString("reason")
in.awaitID, _ = cmd.Flags().GetString("await-id")
in.repo, _ = cmd.Flags().GetString("repo")
in.titleFlag, _ = cmd.Flags().GetString("title")
timeoutStr, _ := cmd.Flags().GetString("timeout")
if timeoutStr != "" {
@ -891,6 +897,14 @@ func githubRepoFromIssue(issue *types.Issue) (string, error) {
return "", nil
}
return validateGitHubRepo(repo)
}
// validateGitHubRepo accepts an OWNER/REPO or HOST/OWNER/REPO selector made of
// the characters GitHub allows in those path components, and nothing else:
// the value is passed to `gh --repo`, so a stray shell or URL character is
// rejected here rather than reaching a subprocess argument.
func validateGitHubRepo(repo string) (string, error) {
parts := strings.Split(repo, "/")
if len(parts) != 2 && len(parts) != 3 {
return "", fmt.Errorf("repo %q must use OWNER/REPO or HOST/OWNER/REPO", repo)
@ -944,6 +958,38 @@ func repoMetadataForGate(gateType string, targetIssue *types.Issue) (json.RawMes
return metadata, nil
}
// gateMetadataForCreate computes the metadata for a new ad-hoc gate from the
// parsed flags: an explicit --repo wins, otherwise the gate inherits the
// blocked issue's validated metadata.repo (repoMetadataForGate). Both create
// routes call this so the flag cannot drift between them.
//
// --repo is only meaningful on gh:* gates, whose check runs against a GitHub
// repository; on any other type it is refused rather than stored, because a
// repo selector nothing reads would look like a working cross-repo gate.
// Errors are fully worded here (they name the flag or the blocked issue) so
// the callers print them as-is.
func gateMetadataForCreate(in gateCreateInput, targetIssue *types.Issue) (json.RawMessage, error) {
if in.repo == "" {
metadata, err := repoMetadataForGate(in.gateType, targetIssue)
if err != nil {
return nil, fmt.Errorf("invalid GitHub repository metadata on %s: %w", targetIssue.ID, err)
}
return metadata, nil
}
if !isGitHubGateType(in.gateType) {
return nil, fmt.Errorf("--repo applies only to gh:run and gh:pr gates, not %q", in.gateType)
}
repo, err := validateGitHubRepo(in.repo)
if err != nil {
return nil, fmt.Errorf("--repo: %w", err)
}
metadata, err := json.Marshal(map[string]string{"repo": repo})
if err != nil {
return nil, err
}
return metadata, nil
}
// queryGitHubRunsForWorkflow queries recent runs for a specific workflow using gh CLI.
// Returns runs sorted newest-first (GitHub API default).
func queryGitHubRunsForWorkflow(workflow string, limit int) ([]GHWorkflowRun, error) {
@ -1085,7 +1131,16 @@ func checkGHRunStatusInRepoWithRunner(runID, repo string, runGH ghCommandRunner)
}
// Check if run not found
if strings.Contains(string(stderr), "not found") {
return false, true, "workflow run not found", nil
// Name the repository, as checkGHPRWithRunner does. Real gh
// reports a missing run as "HTTP 404: Not Found (<api url>)",
// which this case-sensitive match skips: that returns the error
// below, whose URL names the repository. Keep the match narrow; a
// token without access to the repository gets the same 404.
where := "the current repository"
if repo != "" {
where = repo
}
return false, true, fmt.Sprintf("workflow run not found: %s in %s", runID, where), nil
}
return false, false, "", fmt.Errorf("gh run view failed: %s", string(stderr))
}
@ -1146,7 +1201,14 @@ func checkGHPRWithRunner(gate *types.Issue, runGH ghCommandRunner) (resolved, es
}
// Check if PR not found
if strings.Contains(string(stderr), "not found") || strings.Contains(string(stderr), "Could not resolve") {
return false, true, "pull request not found", nil
// Name the repository the number was resolved against: a gate
// armed for another repository without metadata.repo escalates
// here on every check, and the bare text never said why.
where := "the current repository"
if repo != "" {
where = repo
}
return false, true, fmt.Sprintf("pull request not found: #%s in %s", gate.AwaitID, where), nil
}
return false, false, "", fmt.Errorf("gh pr view failed: %s", string(stderr))
}
@ -1299,6 +1361,7 @@ func init() {
gateCreateCmd.Flags().StringP("type", "t", "human", "Gate type (human, timer, gh:run, gh:pr)")
gateCreateCmd.Flags().StringP("reason", "r", "", "Reason for the gate")
gateCreateCmd.Flags().String("await-id", "", "Condition identifier (run ID, PR number, etc.)")
gateCreateCmd.Flags().String("repo", "", "GitHub repository the gh:run/gh:pr condition is checked in (OWNER/REPO or HOST/OWNER/REPO); default: the blocked issue's metadata.repo, else the current repository")
gateCreateCmd.Flags().String("timeout", "", "Timeout duration (e.g., 2h, 30m)")
gateCreateCmd.Flags().String("title", "", "Custom gate title (default: \"Gate: <type>\")")
_ = gateCreateCmd.MarkFlagRequired("blocks")

View file

@ -468,6 +468,49 @@ func TestEmbeddedGateCreate(t *testing.T) {
}
})
t.Run("create_gate_with_repo", func(t *testing.T) {
task := bdCreate(t, bd, dir, "Task for cross-repo PR gate", "--type", "task")
cmd := exec.Command(bd, "gate", "create", "--blocks", task.ID,
"--type", "gh:pr", "--await-id", "7173", "--repo", "gastownhall/beads", "--json")
cmd.Dir = dir
cmd.Env = bdEnv(dir)
stdout, stderr, err := runCommandBuffers(t, cmd)
if err != nil {
t.Fatalf("bd gate create --repo failed: %v\nstdout:\n%s\nstderr:\n%s", err, stdout.String(), stderr.String())
}
var gate types.Issue
s := strings.TrimSpace(stdout.String())
start := strings.Index(s, "{")
if err := json.Unmarshal([]byte(s[start:]), &gate); err != nil {
t.Fatalf("parse gate JSON: %v\n%s", err, s)
}
var m map[string]string
if err := json.Unmarshal(gate.Metadata, &m); err != nil {
t.Fatalf("gate metadata %s is not a string map: %v", gate.Metadata, err)
}
if m["repo"] != "gastownhall/beads" {
t.Errorf("gate metadata repo = %q, want gastownhall/beads", m["repo"])
}
})
t.Run("repo_flag_on_human_gate_is_refused", func(t *testing.T) {
task := bdCreate(t, bd, dir, "Task for human gate", "--type", "task")
cmd := exec.Command(bd, "gate", "create", "--blocks", task.ID,
"--type", "human", "--repo", "gastownhall/beads")
cmd.Dir = dir
cmd.Env = bdEnv(dir)
stdout, stderr, err := runCommandBuffers(t, cmd)
if err == nil {
t.Fatalf("--repo on a human gate must be refused; got:\n%s", stdout.String())
}
if combined := stdout.String() + stderr.String(); !strings.Contains(combined, "--repo applies only to gh:run and gh:pr gates") {
t.Errorf("refusal text missing from output:\n%s", combined)
}
})
t.Run("create_gate_blocks_ready", func(t *testing.T) {
// Use a fresh db so ready output isn't polluted by other subtests
freshDir, freshBeads, _ := bdInit(t, bd, "--prefix", "gr")

View file

@ -320,6 +320,26 @@ func TestProxiedServerGateCreateInheritsRepoMetadata(t *testing.T) {
}
})
t.Run("explicit_repo_flag_wins_over_inherited", func(t *testing.T) {
target := bdProxiedCreate(t, bd, p.dir, "Gated bead with its own repo",
"--metadata", `{"repo":"acme/widgets"}`)
out, stderr, err := bdProxiedRunBuffers(t, bd, p.dir,
"gate", "create", "--type=gh:pr", "--await-id", "7173", "--repo", "gastownhall/beads", "--blocks", target.ID)
if err != nil {
t.Fatalf("gate create --repo failed: %v\nstderr:\n%s", err, stderr)
}
gateID := parseCreatedGateID(t, out)
var m map[string]string
if err := json.Unmarshal(showMetadata(t, gateID), &m); err != nil {
t.Fatalf("gate %s metadata is not a string map: %v", gateID, err)
}
if m["repo"] != "gastownhall/beads" {
t.Errorf("gate %s metadata repo = %q, want the flag's gastownhall/beads over the inherited acme/widgets", gateID, m["repo"])
}
})
t.Run("human_gate_ignores_repo_shaped_metadata", func(t *testing.T) {
// SF4 parity: "repo" is legal, unrelated metadata on any issue, so a
// human gate must neither validate nor inherit it.

View file

@ -341,9 +341,9 @@ func runGateCreateProxiedServer(cmd *cobra.Command, ctx context.Context) error {
}
gate := buildGateIssue(in, target.ID)
metadata, metaErr := repoMetadataForGate(in.gateType, target)
metadata, metaErr := gateMetadataForCreate(in, target)
if metaErr != nil {
return out, "", fmt.Errorf("invalid GitHub repository metadata on %s: %v", target.ID, metaErr)
return out, "", metaErr
}
gate.Metadata = metadata

View file

@ -1267,3 +1267,191 @@ func gateIDs(gs []*types.Issue) []string {
}
return ids
}
func TestGateMetadataForCreateExplicitRepo(t *testing.T) {
inherited := &types.Issue{ID: "bd-target", Metadata: json.RawMessage(`{"repo":"acme/inherited"}`)}
decodeRepo := func(t *testing.T, metadata json.RawMessage) string {
t.Helper()
var decoded struct {
Repo string `json:"repo"`
}
if err := json.Unmarshal(metadata, &decoded); err != nil {
t.Fatalf("metadata %s is not valid JSON: %v", metadata, err)
}
return decoded.Repo
}
t.Run("explicit_repo_wins_over_inherited", func(t *testing.T) {
metadata, err := gateMetadataForCreate(gateCreateInput{gateType: "gh:pr", repo: "gastownhall/beads"}, inherited)
if err != nil {
t.Fatalf("gateMetadataForCreate returned error: %v", err)
}
if got := decodeRepo(t, metadata); got != "gastownhall/beads" {
t.Fatalf("repo = %q, want gastownhall/beads (the flag, not the blocked issue's value)", got)
}
})
t.Run("no_flag_inherits", func(t *testing.T) {
metadata, err := gateMetadataForCreate(gateCreateInput{gateType: "gh:run"}, inherited)
if err != nil {
t.Fatalf("gateMetadataForCreate returned error: %v", err)
}
if got := decodeRepo(t, metadata); got != "acme/inherited" {
t.Fatalf("repo = %q, want the inherited acme/inherited", got)
}
})
t.Run("no_flag_no_metadata_is_nil", func(t *testing.T) {
metadata, err := gateMetadataForCreate(gateCreateInput{gateType: "gh:pr"}, &types.Issue{ID: "bd-plain"})
if err != nil {
t.Fatalf("gateMetadataForCreate returned error: %v", err)
}
if metadata != nil {
t.Fatalf("metadata = %s, want nil (current repository)", metadata)
}
})
t.Run("inherited_error_names_the_blocked_issue", func(t *testing.T) {
_, err := gateMetadataForCreate(gateCreateInput{gateType: "gh:pr"}, &types.Issue{ID: "bd-bad", Metadata: json.RawMessage(`{"repo":"owner/repo;echo"}`)})
if err == nil {
t.Fatal("malformed inherited metadata.repo must fail closed")
}
if !strings.Contains(err.Error(), "invalid GitHub repository metadata on bd-bad") {
t.Fatalf("error %q does not name the blocked issue's metadata", err)
}
})
t.Run("invalid_explicit_repo_is_rejected", func(t *testing.T) {
for _, bad := range []string{"not-owner-slash-repo", "owner/repo;echo", "owner//repo", "https://github.com/owner/repo"} {
_, err := gateMetadataForCreate(gateCreateInput{gateType: "gh:pr", repo: bad}, inherited)
if err == nil {
t.Errorf("--repo %q accepted, want validation error", bad)
continue
}
if !strings.Contains(err.Error(), "--repo") {
t.Errorf("error for --repo %q does not name the flag: %v", bad, err)
}
}
})
t.Run("host_form_is_accepted", func(t *testing.T) {
metadata, err := gateMetadataForCreate(gateCreateInput{gateType: "gh:run", repo: "ghe.example.com/acme/widgets"}, nil)
if err != nil {
t.Fatalf("HOST/OWNER/REPO rejected: %v", err)
}
if got := decodeRepo(t, metadata); got != "ghe.example.com/acme/widgets" {
t.Fatalf("repo = %q", got)
}
})
t.Run("non_github_type_refuses_the_flag", func(t *testing.T) {
for _, gateType := range []string{"human", "timer", "bead"} {
_, err := gateMetadataForCreate(gateCreateInput{gateType: gateType, repo: "acme/widgets"}, inherited)
if err == nil {
t.Errorf("--repo on a %s gate accepted, want refusal (nothing would read it)", gateType)
continue
}
if !strings.Contains(err.Error(), "--repo applies only to gh:run and gh:pr gates") {
t.Errorf("refusal for %s gate has the wrong text: %v", gateType, err)
}
}
})
}
func TestCheckGHPRNotFoundNamesTheRepository(t *testing.T) {
notFound := func(t *testing.T, wantArgs ...string) ghCommandRunner {
t.Helper()
return func(args ...string) ([]byte, []byte, error) {
if strings.Join(args, " ") != strings.Join(wantArgs, " ") {
t.Fatalf("gh args = %q, want %q", args, wantArgs)
}
return nil, []byte("GraphQL: Could not resolve to a PullRequest with the number of 7173. (repository.pullRequest)"), fmt.Errorf("exit status 1")
}
}
t.Run("cross_repo", func(t *testing.T) {
resolved, escalated, reason, err := checkGHPRWithRunner(&types.Issue{
IssueType: "gate", AwaitType: "gh:pr", AwaitID: "7173",
Metadata: json.RawMessage(`{"repo":"gastownhall/beads"}`),
}, notFound(t, "pr", "view", "7173", "--json", "state,title", "--repo", "gastownhall/beads"))
if err != nil {
t.Fatalf("checkGHPR returned error: %v", err)
}
if resolved || !escalated {
t.Fatalf("resolved, escalated = %v, %v; want false, true", resolved, escalated)
}
if reason != "pull request not found: #7173 in gastownhall/beads" {
t.Fatalf("reason = %q; it must name the repository the number was resolved against", reason)
}
})
t.Run("current_repo", func(t *testing.T) {
_, escalated, reason, err := checkGHPRWithRunner(&types.Issue{
IssueType: "gate", AwaitType: "gh:pr", AwaitID: "7173",
}, notFound(t, "pr", "view", "7173", "--json", "state,title"))
if err != nil || !escalated {
t.Fatalf("escalated, err = %v, %v; want true, nil", escalated, err)
}
if reason != "pull request not found: #7173 in the current repository" {
t.Fatalf("reason = %q", reason)
}
})
}
func TestCheckGHRunNotFoundNamesTheRepository(t *testing.T) {
notFound := func(t *testing.T, wantArgs ...string) ghCommandRunner {
t.Helper()
return func(args ...string) ([]byte, []byte, error) {
if !slices.Equal(args, wantArgs) {
t.Fatalf("gh args = %q, want %q", args, wantArgs)
}
// Stub stderr that reaches the escalation arm; real gh 404
// output does not (see real_gh_404_names_the_repository).
return nil, []byte("run 12345 not found"), fmt.Errorf("exit status 1")
}
}
t.Run("cross_repo", func(t *testing.T) {
resolved, escalated, reason, err := checkGHRunWithRunner(&types.Issue{
ID: "gt-run", IssueType: "gate", AwaitType: "gh:run", AwaitID: "12345",
Metadata: json.RawMessage(`{"repo":"gastownhall/beads"}`),
}, nil, notFound(t, "run", "view", "12345", "--json", "status,conclusion,name", "--repo", "gastownhall/beads"))
if err != nil {
t.Fatalf("checkGHRun returned error: %v", err)
}
if resolved || !escalated {
t.Fatalf("resolved, escalated = %v, %v; want false, true", resolved, escalated)
}
if reason != "workflow run not found: 12345 in gastownhall/beads" {
t.Fatalf("reason = %q; it must name the repository the run ID was looked up in", reason)
}
})
t.Run("current_repo", func(t *testing.T) {
_, escalated, reason, err := checkGHRunStatusInRepoWithRunner("12345", "",
notFound(t, "run", "view", "12345", "--json", "status,conclusion,name"))
if err != nil || !escalated {
t.Fatalf("escalated, err = %v, %v; want true, nil", escalated, err)
}
if reason != "workflow run not found: 12345 in the current repository" {
t.Fatalf("reason = %q", reason)
}
})
t.Run("real_gh_404_names_the_repository", func(t *testing.T) {
// gh run view's real stderr for a run the repository does not have.
// A token without access to the repository gets the same 404, so it
// stays an error rather than an escalation; its URL names the repo.
stderr := "failed to get run: HTTP 404: Not Found (https://api.github.com/repos/gastownhall/beads/actions/runs/12345?exclude_pull_requests=true)\n"
resolved, escalated, _, err := checkGHRunStatusInRepoWithRunner("12345", "gastownhall/beads",
func(args ...string) ([]byte, []byte, error) {
return nil, []byte(stderr), fmt.Errorf("exit status 1")
})
if err == nil || resolved || escalated {
t.Fatalf("resolved, escalated, err = %v, %v, %v; want false, false, an error", resolved, escalated, err)
}
if !strings.Contains(err.Error(), "/repos/gastownhall/beads/") {
t.Fatalf("err = %q; it must name the repository the run ID was looked up in", err)
}
})
}

View file

@ -1538,8 +1538,11 @@ var rootCmd = &cobra.Command{
// touches the local `store` global on that path (a gap left by
// #4615, which only handled local paths), so skip local
// discovery entirely instead of falling through to the "no
// beads database found" exit below.
if cmd.Name() == "create" && cmd.Flags().Changed("repo") {
// beads database found" exit below. Match the command path,
// not the leaf name: `bd gate create --repo` names a GitHub
// OWNER/REPO for gh:run/gh:pr checks, not a workspace, and must
// still need the local database like any other gate command.
if commandRegistryPath(cmd) == "create" && cmd.Flags().Changed("repo") {
if repoVal, _ := cmd.Flags().GetString("repo"); repoVal != "" {
if remotecache.IsRemoteURL(repoVal) {
return nil

View file

@ -45,11 +45,20 @@ write `24h`, not `1d`).
GitHub gates use the current Git repository by default. To evaluate a PR or
workflow run in another repository, set the gate's string `metadata.repo` value
to `OWNER/REPO` or `HOST/OWNER/REPO`. An ad-hoc `gh:run`/`gh:pr` gate created
with `bd gate create` inherits a valid `metadata.repo` value from the issue it
blocks; `human`/`timer`/`bead` gates do not, since `metadata.repo` is
unrelated, ordinary metadata for those types. `bd gate check` rejects
malformed repository values instead of falling back to the current
repository.
with `bd gate create` takes that value from `--repo`, or, without the flag,
inherits a valid `metadata.repo` value from the issue it blocks;
`human`/`timer`/`bead` gates do neither (`--repo` is refused on them), since
`metadata.repo` is unrelated, ordinary metadata for those types. `bd gate check`
rejects malformed repository values instead of falling back to the current
repository, and when a PR number does not resolve, the escalation names the
repository it was looked up in. A gate for a PR in another repository whose
blocked issue carries no `metadata.repo` needs `--repo`: without it the number
is looked up in the current repository and escalates as not found on every
check.
```bash
bd gate create --type=gh:pr --blocks bd-abc --await-id=42 --repo=owner/other-repo
```
### Known limitations: multi-rig and proxied-server topologies

View file

@ -52,6 +52,7 @@ bd gate create --type bead --blocks bd-abc \
**Optional**:
- `--type <type>` — Gate type: `human`, `timer`, `gh:run`, `gh:pr`, `bead` (default `human`)
- `--await-id <id>` — Condition identifier (run ID, PR number, `rig:bead-id`, etc.)
- `--repo <OWNER/REPO>` — For `gh:run`/`gh:pr` only: the GitHub repository the condition is checked in (also `HOST/OWNER/REPO`). Default: the blocked issue's `metadata.repo`, else the current repository — a gate on another repository's PR needs this, or it escalates as "not found" on every check.
- `--reason <text>` — Stored on the gate as its description (what is being gated)
- `--timeout <duration>` — **Only timer gates enforce this** via `bd gate check`. You can set it on other types for documentation, but `check` does not auto-resolve/escalate human or GitHub gates based on timeout.