Fix GitHub branch detection and complete task execution workflow

- Added dynamic branch detection that falls back to repository default branch
- Fixed sandbox image reference to use local Docker registry
- Completed full task execution pipeline: discovery → claim → sandbox → execution
- Enhanced GitHub client to verify base branch existence and auto-correct
- Successfully tested end-to-end task claiming and execution

🎉 MAJOR MILESTONE: Full Bzzz task execution workflow now functional\!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-07-14 20:52:26 +10:00
parent 054fb67767
commit 2d00214e74
3 changed files with 70 additions and 9 deletions

View File

@@ -76,6 +76,11 @@ func NewClient(ctx context.Context, config *Config) (*Client, error) {
return nil, fmt.Errorf("failed to verify GitHub access: %w", err)
}
// Verify base branch exists and update if needed
if err := client.verifyBaseBranch(); err != nil {
return nil, fmt.Errorf("failed to verify base branch: %w", err)
}
return client, nil
}
@@ -89,6 +94,25 @@ func (c *Client) verifyAccess() error {
return nil
}
// verifyBaseBranch checks if the base branch exists and updates to default if not
func (c *Client) verifyBaseBranch() error {
// Try to get the configured base branch
_, _, err := c.client.Git.GetRef(c.ctx, c.config.Owner, c.config.Repository, "heads/"+c.config.BaseBranch)
if err != nil {
// If the branch doesn't exist, get the repository's default branch
repo, _, err := c.client.Repositories.Get(c.ctx, c.config.Owner, c.config.Repository)
if err != nil {
return fmt.Errorf("failed to get repository info: %w", err)
}
// Update config to use the default branch
if repo.DefaultBranch != nil {
c.config.BaseBranch = *repo.DefaultBranch
}
}
return nil
}
// Task represents a Bzzz task as a GitHub issue
type Task struct {
ID int64 `json:"id"`

View File

@@ -12,7 +12,6 @@ import (
"github.com/anthonyrawlins/bzzz/pkg/hive"
"github.com/anthonyrawlins/bzzz/pkg/types"
"github.com/anthonyrawlins/bzzz/pubsub"
"github.com/anthonyrawlins/bzzz/reasoning"
"github.com/libp2p/go-libp2p/core/peer"
)
@@ -116,6 +115,7 @@ func (hi *HiveIntegration) syncRepositories() {
AccessToken: hi.githubToken,
Owner: repo.Owner,
Repository: repo.Repository,
BaseBranch: repo.Branch,
}
client, err := NewClient(hi.ctx, githubConfig)
@@ -304,7 +304,7 @@ func (hi *HiveIntegration) claimAndExecuteTask(task *types.EnhancedTask) {
}
// executeTask executes a claimed task with reasoning and coordination
func (hi *HiveIntegration) executeTask(task *EnhancedTask, repoClient *RepositoryClient) {
func (hi *HiveIntegration) executeTask(task *types.EnhancedTask, repoClient *RepositoryClient) {
// Define the dynamic topic for this task
taskTopic := fmt.Sprintf("bzzz/meta/issue/%d", task.Number)
hi.pubsub.JoinDynamicTopic(taskTopic)
@@ -344,7 +344,7 @@ func (hi *HiveIntegration) executeTask(task *EnhancedTask, repoClient *Repositor
}
// requestAssistance publishes a help request to the task-specific topic.
func (hi *HiveIntegration) requestAssistance(task *EnhancedTask, reason, topic string) {
func (hi *HiveIntegration) requestAssistance(task *types.EnhancedTask, reason, topic string) {
fmt.Printf("🆘 Agent %s is requesting assistance for task #%d: %s\n", hi.config.AgentID, task.Number, reason)
hi.hlog.Append(logging.TaskHelpRequested, map[string]interface{}{
"task_id": task.Number,