Skip to content

fix(pr): Read the head branch labels.yml when --repo is set #6469

Description

@dan-petty

Problem

Checked at main (0d90de5).

devops pr create --repo OWNER/NAME --head BRANCH checks the title scope against .github/labels.yml at the base branch only. src/devops_cli/commands/pr.py:1248 passes checkout=_checkout() if repo is None else None, so with --repo the pull request's own labels.yml is never read. The refusal text (form_title_scope in src/devops_cli/lang/en/messages.py:1660) still says "declare the label in the same pull request", which cannot work in that mode.

Seen on 2026-11-19 in dan-petty/vibes: a builder added scope/tools to .github/labels.yml on its branch and devops pr create -R dan-petty/vibes -H fix/177-slo-burn-rate still refused the scope. It worked only when run without -R from the worktree.

Proposed remedy

  • With --head, read labels.yml at the head ref as well as the base (the same store call with ref=head), and accept a label declared in either.
  • If that is not wanted, make the message say that with --repo the label must already be on the base branch.

Acceptance criteria

  • A test: --repo plus --head, with the scope label declared only on the head ref, opens the pull request.
  • A test: the refusal message matches the mode it runs in.

Alternatives check of 2026-11-20: none.
Tool: none found.
Reason: Searches returned only PR-creation actions and general docs, no tool that reads a repository's labels.yml at a git ref to validate a pull-request title scope. The need is devops-cli's own form rule, which it must fix in place.

Lacks:

  • No tool reads labels.yml at a chosen git ref
  • No tool validates title scopes inside a CLI's own create path
  • No tool emits a mode-specific refusal message

Proposed design

Problem statement

The devops pr create --repo OWNER/NAME --head BRANCH command checks the title scope against .github/labels.yml at the base branch only. It never reads the labels.yml of the head branch. A builder that declares the scope label on its branch is refused. The refusal also tells the user to declare the label in the same pull request, and the --repo mode cannot read that declaration.

Acceptance criteria

Requirement: The scope check reads the head ref

The title scope check MUST accept a scope label that .github/labels.yml declares at the head ref when the caller sets --repo and --head.

Scenario: A label declared only on the head ref

  • WHEN A test calls the title scope check with --repo and --head, the base ref declares no scope/tools label, and the head ref declares it
  • THEN The check returns no error.

Requirement: The scope check keeps the base ref

The title scope check MUST accept a scope label that .github/labels.yml declares at the base ref when the caller sets --repo and --head.

Scenario: A label declared only on the base ref

  • WHEN A test calls the title scope check with --repo and --head, the base ref declares scope/tools, and the head ref declares no scope/tools label
  • THEN The check returns no error.

Requirement: The refusal message names the refs read

The refusal message MUST name the refs whose .github/labels.yml the check read.

Scenario: Neither ref declares the label

  • WHEN A test calls the title scope check with --repo and --head, and neither the base ref nor the head ref declares scope/tools
  • THEN The message names the base ref and the head ref, and it tells the user to declare the label in the same pull request.

Requirement: The check-out mode keeps its message

The title scope check MUST read the check-out only and keep its message when the caller sets no --repo.

Scenario: The check-out mode refuses a scope

  • WHEN A test calls the title scope check with no --repo, and the .github/labels.yml of the check-out declares no scope/tools label
  • THEN The check returns the refusal, and the message tells the user to declare the label in the same pull request.

Requirement: The check reads the base ref with no head ref

The title scope check MUST read the base ref only when the caller sets --repo and no --head.

Scenario: No head ref is set

  • WHEN A test calls the title scope check with --repo and no --head, and the base ref declares no scope/tools label
  • THEN The check returns the refusal, and the message names the base ref only.

Existing Tool Considered

The alternatives check of 2026-11-20 in the issue body records verdict none and no tool. It lists that no tool reads labels.yml at a chosen git ref, validates title scopes inside a CLI's own create path, or emits a mode-specific refusal message. The change does what the block says no tool covers: it reuses the existing declared_label_set call with ref=head and passes the union of the base and head labels to title_problems. It adds no dependency. The written cost is about 10 lines of code and one test, about 4,000 tokens to build, about 500 tokens a month to keep, about 2,000 tokens for one fix, and under one hour of elapsed time.

Key questions

  • Should the title scope check read .github/labels.yml at the head ref when --repo and --head are set?: Yes. The check reads the base ref and the head ref, and it accepts a label that either ref declares. (best practice) [sources: src/devops_cli/commands/pr.py, src/devops_cli/roadmap/pull_form.py:222, openspec/specs/pull-request-form/spec.md]
    • Chosen: Read the base ref and the head ref. It accepts the label that the builder declared on its branch and keeps the label that the base ref declares.
    • Rejected: Read the base ref only and reword the message. It refuses a correct pull request and leaves the reported defect.
    • Rejected: Read the head ref only. It refuses a label that the base ref declares and that a pull request into that base ref needs.
  • How does the check read labels.yml at the head ref?: The check passes head to the same declared_label_set call that reads labels.yml. It then passes the union of the base and head label sets to title_problems. (best practice) [sources: src/devops_cli/roadmap/pull_describe.py:108, src/devops_cli/commands/pr.py]
    • Chosen: Reuse declared_label_set with ref=head. It already reads the file at a ref and returns the declared labels.
    • Rejected: Add a YAML reader in the check. It adds code and a dependency for no gain.
  • Which text does the refusal message show in each mode?: One message takes the refs that the check read. In --repo and --head mode it names the base ref and the head ref. In the check-out mode it keeps the instruction to declare the label in the same pull request. (best practice) [sources: src/devops_cli/lang/en/messages.py:1659, src/devops_cli/roadmap/pull_form.py:222]
    • Chosen: One message with the refs read as a parameter. One text holds each mode, and a test asserts the text of each mode.
    • Rejected: Two separate message fields. It duplicates the text, and the two copies can drift.
  • What does the check do when --repo is set and --head is not?: The check reads the base ref only. The refusal message names the base ref only. (best practice) [sources: src/devops_cli/commands/pr.py]
    • Chosen: Read the base ref only. No head ref exists to read.
    • Rejected: Require --head with --repo. It changes the command contract beyond this defect.
  • Does the change add a dependency or a new tool?: No. The change reuses declared_label_set and adds no dependency. [sources: src/devops_cli/roadmap/pull_describe.py:108, src/devops_cli/commands/pr.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    status/new
    value/medium
    effort/low
    scope/pr
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (3)

    Searches run:

    • GitHub action validate pull request title scope against labels.yml labels, results: 5
    • open source tool check PR title prefix label exists in labels file head branch, results: 5
    • action-semantic-pull-request scopes from labels.yml file, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Nov 20, 2026
  7. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    Seen again on 2026-11-21 with dan-petty/danielpetty.com#16. The pull request adds scope/harvester to .github/labels.yml on its head branch. devops pr create --repo dan-petty/danielpetty.com --head fix/4-harvest-push-and-pr refused the title with "The scope harvester has no label". The cause is src/devops_cli/commands/pr.py:1248: with --repo set, declared_label_set gets checkout=None and reads only the base ref. The same command without --repo, run in the checkout of the head branch, opened the pull request.

  9. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    More evidence, 2026-11-21, in the service repository dan-petty/danielpetty.com, where .github/labels.yml declared no scope/ labels.

    • With --repo dan-petty/danielpetty.com, devops pr create refused the scoped titles fix(security), fix(harvester), fix(event-stream), fix(pixelfed) and chore(ci). The error told the builder to declare the label in the same pull request. The branch declared the label, but src/devops_cli/commands/pr.py:1248-1249 passes checkout=None when --repo is set, so declared_label_set reads only the base branch.
    • Workaround of 4 builders: run the command from the worktree of the branch, with no --repo. 5 other pull requests dropped the scope from the title.
    • Result: 3 open pull requests in that repository (feat(release): v0.1.13 — embedding benchmarks, tls automation & otel integrations #16, feat(release): v0.2.1 #19 and feat(release): v0.2.3 #22) each add a scope section at the end of labels.yml. They conflict with each other when they merge.
  10. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    One more case, 2026-11-21: a new repository whose default branch has no .github/labels.yml at all. The first pull request of dan-petty/infra adds that file (it onboards the repository to the roadmap jobs). devops pr create refuses it with "dan-petty/infra has no .github/labels.yml at main", with --repo and also when it runs from the worktree of the branch with no --repo. So the tool cannot open the pull request that devops roadmap onboard asks for (row 3). I opened that draft through devops gh api repos/dan-petty/infra/pulls -X POST ... -F draft=true. A fix for this item could read the labels of the head branch, and treat a missing file on the base branch as an empty list.

  11. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  12. removed
    status/in-review
    on Nov 25, 2026
  13. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 17:09 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/prsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions