Skip to content

Use repository default branch for session brief and PR base #9

@romgenie

Description

@romgenie

Local source: coven-github/issues/06-use-repository-default-branch-for-pr-base.md

Summary

coven-github should use the repository's actual default branch or task-specific base branch rather than hardcoding main in the session brief and draft PR creation.

Current Evidence

  • crates/worker/src/brief.rs sets RepoBrief.default_branch to "main".
  • crates/worker/src/lib.rs opens draft PRs with base branch "main".
  • README.md marks PR creation as partial and notes the base branch is still hardcoded to main.
  • docs/hosted-mvp-plan.md lists using repository default branch instead of hardcoded main for PR base and session brief.

Problem

Not every repository uses main. Some use master, develop, release branches, protected maintenance branches, or PR-specific base branches. A coding agent that opens a draft PR against the wrong base can create invalid diffs or fail entirely.

Impact

  • Draft PR creation fails for repositories without main.
  • Agent changes may target the wrong integration branch.
  • Backport, release, or maintenance workflows cannot be supported.
  • The session brief can mislead the agent about repository branch structure.

Proposed Design

Resolve the base branch during task hydration:

  • For issue tasks, fetch repository metadata and use default_branch unless policy overrides it.
  • For PR review-comment tasks, use the PR's actual base branch.
  • For future push/commit tasks, use the pushed branch or configured target branch.
  • Allow repo policy to override allowed base branches by label, path, familiar, or command.

Store base_ref, base_sha, head_ref, and head_sha on the task where applicable. Pass the resolved base to the session brief and PR creation call.

Acceptance Criteria

  • No production path hardcodes "main" as the PR base.
  • Session brief includes resolved default/base branch from GitHub context.
  • Draft PR creation uses the task's resolved base branch.
  • Tests cover repositories whose default branch is master, develop, and main.
  • PR review-comment tasks preserve the original PR base branch.
  • README status is updated when the hardcoded base issue is fixed.

Test Notes

Use mocked GitHub repository and PR metadata responses. Assert brief::build receives branch metadata rather than choosing it internally. Assert PR request payloads use the resolved branch.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions