Skip to content

Sessions start on an empty branch when the project's default branch isn't in its repository #273

Closed

Description

@fctl-sh

What is wrong

A project's default branch is only checked for being a valid branch name, wherever it is set: the web app's Settings → Project, fctl projects set --default-branch and PATCH /api/v1/projects/{id}. When the repository has no such branch (a typo, or a branch renamed or deleted on GitHub), new sessions don't fail. Each agent starts its branch empty, without any of the repository's files, and works from there. fctl run --base with a branch the repository lacks does the same.

How it works now

  • update in crates/fctl-control/src/api/projects.rs checks the branch with fctl_domain::validate::branch (the rules of git check-ref-format) and never asks GitHub. create takes the branch from GitHub when it links or creates the repository, unless the request names one.
  • crates/fctl-agent/src/workspace.rs clones the repository and, when origin/<base branch> is missing, starts the session branch with git checkout --orphan. The only sign is a warning in the session's log ("acme/web has no develop branch; starting fctl/12 empty"). That path is meant for empty repositories, which have no branches at all, but any missing base branch takes it.

Found while adding --default-branch to the CLI in #272.

What should happen

Compatibility

Checking the branch where it is set takes a control plane release only. Failing the session changes fctl-agent, which reaches sessions as their hosts update: hosts one version behind keep starting empty branches.

Decisions for a person

  • Refuse a default branch the repository doesn't have, or accept it with a warning (for a branch someone is about to push)?

Session: https://app.fctl.sh/s/ses_01M5S8H5B8K7MWJP1XM8P5VTR9

Activity

  1. added
    bug
    control-plane
    agents
    on Oct 25, 2026
  2. fctl-sh commented on Oct 28, 2026

    @fctl-sh
    ContributorAuthor

    Done in #298, merged as 865e9e9.

    • Where the default branch is set (Settings → Project, fctl projects set --default-branch, PATCH /api/v1/projects/{id}), the control plane asks GitHub through the App and refuses a branch the repository doesn't have. The error names the branch and one the repository has, such as "acme/web has no branch named mian: push it first, or choose one it has, like main". An empty repository takes any branch. For the open decision, fix: catch a default or base branch the repository doesn't have #298 refuses rather than warns; that choice was listed for review there, and the pull request was approved and merged. This part is deployed to app.fctl.sh (CI run).
    • When a session starts, fctl-agent fails a session whose base branch is missing from a repository with commits, with a reason that names the branch and says how to fix it. Empty repositories still start an orphan branch. No release has it yet: it ships with the next one after v0.24.3 and reaches sessions as their hosts update to it. Until then, such sessions still start on an empty branch.
    • The docs are live: docs/api.md, docs/cli.md and docs/architecture.md on fctl.sh, and llms.txt on fctl.sh and app.fctl.sh.

    fctl run --base and schedules' base branches aren't checked when a session is created: such sessions fail as they start, once their hosts run the next release.

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

    agentsbugcontrol-plane

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions