Workspace preflight rejects an unborn main branch
Observed
A task using immediate workspace setup failed during preflight while its selected repository had a newly initialized, unborn main branch.
Task setup reported this verbatim:
Stage: preflight
Message: Unable to resolve source ref: main
Command: git rev-parse --verify main^{commit}
Exit code: 128
Stderr:
fatal: Needed a single revisionAfter the failure, repository inspection showed that main had acquired an initial empty commit and that a task worktree had been created from the same commit:
$ git worktree list --porcelain
worktree <source-repository>
HEAD 921f2b6f653fdcbcbb5cf4d8485e813b9144b6fd
branch refs/heads/main
worktree <task-worktree>
HEAD 921f2b6f653fdcbcbb5cf4d8485e813b9144b6fd
branch refs/heads/humanlayer-ai-tool-lunch-and-learn-slideshow-jknnguThe reflog records the initial commit before creation of the task branch:
921f2b6 main@{2026-09-22 11:01:17 -0700} commit (initial): Initial commit, intentionally empty
921f2b6 humanlayer-ai-tool-lunch-and-learn-slideshow-jknngu@{2026-09-22 11:01:33 -0700} branch: Created from 921f2b6f653fdcbcbb5cf4d8485e813b9144b6fdThe originally failing command now succeeds:
$ git rev-parse --verify 'main^{commit}'
921f2b6f653fdcbcbb5cf4d8485e813b9144b6fdObserved once on macOS. The repository had no remote and no .humanlayer/workspace.json, so the effective source ref was the local main branch.
Minimal reproduction based on the observed setup:
- Initialize a local repository whose default branch is
main, without creating a commit or configuring a remote. - Create a task with immediate workspace setup for that repository.
- Observe preflight validation of
main.
Impact
A first task in a newly initialized repository is reported as a workspace setup failure even though an initial commit and task worktree subsequently exist. The user must diagnose the contradictory state and retry manually before starting the task.
Desired outcome
- Immediate workspace setup can start the first task in a repository whose selected default branch does not yet contain a commit.
- A task is not left in a failed preflight state when its source commit and worktree were successfully created during the same setup attempt.
- When workspace creation genuinely cannot resolve a source ref, the reported failure identifies the repository state and leaves no partially created task worktree.
- Existing repositories with a valid configured source ref continue to use that ref unchanged.
Hypotheses
Filer's guesses — DECIDE weighs alternatives and may discard these:
- The failure may be an ordering issue: source-ref validation appears to run before the initial empty commit is available, while later setup steps still create the commit and worktree.
Source: humanlayer/humanlayer