Skip to content

fix(pr): devops pr create labels the pull request from its title #2748

Description

@dan-petty

Problem Description

A pull request gets its type/* and scope/* labels by hand. No code sets them. #2715 made the title of an issue the only source of its type and scope labels, but a pull request has no such rule, so it takes whatever the person or the agent copies from the issue.

Reproduction Steps

  1. Run devops gh api 'repos/{owner}/{repo}/pulls?state=all&per_page=30' and read the labels.
  2. Pull request 2746 fix(security): refuse the keys that make a child write a file has type/security and scope/security. Pull request 2738 fix(ai): the mcp benchmark tool takes no file path has type/security and scope/security, but its scope is ai.
  3. The events of pull request 2746 show both labels added in the same second by the account dan-petty, 16 seconds after the pull request opened. src/ has no code that adds a label to a pull request.

Expected vs Actual Behavior

Expected: devops pr create gives the pull request the labels that its Conventional Commit title gives, with the rule of intake: fix(ai): ... gets type/bug and scope/ai, and a scope that .github/labels.yml does not declare gets no label and a warning. The audit in github/labels.py and the hardening audit then read labels that agree with the title.

Actual: the labels are whatever the author adds. They often copy the old model-chosen type of the issue, so a fix has type/security and a scope that is not the scope of the title.

Proposed design

Problem statement

devops pr create does not set type/* or scope/* labels on the pull request it creates. Labels are added by hand, so they often disagree with the Conventional Commit title. The fix adds label-setting to the PR creation path, deriving labels from the title and the project's label file.

Acceptance criteria

Requirement: Set labels from title

devops pr create SHALL set the type/* and scope/* labels on the new pull request derived from its Conventional Commit title.

Scenario: fix(ai) title gets correct labels

  • WHEN A pull request is created with the title fix(ai): the mcp benchmark tool takes no file path
  • THEN The pull request has labels type/bug and scope/ai

Requirement: Unknown scope warning

When the scope in the title is not declared in .github/labels.yml, the command SHALL NOT set a scope label and SHALL emit a warning to stderr.

Scenario: Unknown scope produces no label

  • WHEN A pull request is created with the title fix(unknown): some change
  • THEN The pull request has label type/bug, has no scope/unknown label, and a warning is printed to stderr

Requirement: Type mapping

The command SHALL map each Conventional Commit type to the type/* label declared in .github/labels.yml.

Scenario: feat maps to type/feature

  • WHEN A pull request is created with the title feat(cli): add new command
  • THEN The pull request has label type/feature

Requirement: Audit agreement

After devops pr create sets the labels, the audit in github/labels.py SHALL read labels that agree with the pull request title.

Scenario: Audit passes after creation

  • WHEN A pull request is created with the title fix(ai): some change and the audit runs against it
  • THEN The audit reports no mismatch between the title and the labels

Existing Tool Considered

No check has run. No open, maintained tool maps a Conventional Commit title to a project-specific GitHub label set. The project builds its own code: parse the title, look up labels in .github/labels.yml, and call the GitHub API to add them. The written cost is about 80 lines of Python to build, keep, and fix, at an elapsed time of one session.

Key questions

  • What is the Conventional Commit type-to-label mapping used by the project?: feat maps to type/feature, fix maps to type/bug, refactor maps to type/refactor, docs maps to type/docs, test maps to type/test, chore maps to type/chore, ci and build map to type/infra. The exact mapping is defined by the project's label set in .github/labels.yml and the intake rule from fix(roadmap): intake derives type and scope labels from the issue title #2715. [sources: .github/labels.yml]
  • Should labels be set during PR creation or as a separate post-creation step?: During PR creation, as part of the devops pr create command, before the command returns. This avoids a race window and keeps the command atomic. (proposed)
    • Chosen: Set during creation. Atomic, no race window, no extra webhook or job needed.
    • Rejected: Set via post-creation webhook. Adds a webhook handler, introduces delay, and requires a separate code path.
  • What happens when the scope in the title is not in .github/labels.yml?: No scope label is set, and a warning is emitted to stderr. The command does not abort. (proposed)
    • Chosen: No label plus warning. Matches the issue expected behavior. Non-blocking. The PR is still valid.
    • Rejected: Error and abort. Too strict. A valid PR should not fail because of an unknown scope.
    • Rejected: Create the label on the fly. Requires write access to label definitions and pollutes the label set.
  • What happens when the Conventional Commit type has no matching type/ label?*: No type label is set, and a warning is emitted to stderr. The command does not abort. (proposed)
    • Chosen: No label plus warning. Consistent with the unknown-scope handling. Non-blocking.
    • Rejected: Error and abort. Too strict. The PR title is still valid Conventional Commit.

Open questions

  • Where does devops pr create live in the codebase? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    on Oct 30, 2026
  2. dan-petty commented on Oct 30, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: none. The title has the scope pr, and .github/labels.yml declares no scope/pr label. Add the label to the file to give the scope to this item.
    • Priority: P2-Medium. PR labels are wrong and break audit consistency, but no user-facing feature is blocked.
    • Value: Medium. Correct labels on PRs let the audit and hardening checks read consistent data.
    • Effort: Low. The rule already exists in intake; the work is to apply the same parse to the PR title in pr create.
    • Related: fix(roadmap): intake derives type and scope labels from the issue title #2715, which asks for a different change. Both derive type and scope labels from a Conventional Commit title, but #2715 targets issue intake while this candidate targets devops pr create.
  3. added
    priority/p2-medium
    on Oct 30, 2026
  4. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 7c931b9 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Where does devops pr create live in the codebase? (missing verified source)
  5. added
    status/in-review
    and removed
    status/new
    on Oct 30, 2026
  6. removed
    status/in-review
    on Oct 30, 2026
  7. added 2 commits that reference this issue on Nov 2, 2026
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-mediumsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions