Integrate BACKBEAT SDK and resolve KACHING license validation
Major integrations and fixes: - Added BACKBEAT SDK integration for P2P operation timing - Implemented beat-aware status tracking for distributed operations - Added Docker secrets support for secure license management - Resolved KACHING license validation via HTTPS/TLS - Updated docker-compose configuration for clean stack deployment - Disabled rollback policies to prevent deployment failures - Added license credential storage (CHORUS-DEV-MULTI-001) Technical improvements: - BACKBEAT P2P operation tracking with phase management - Enhanced configuration system with file-based secrets - Improved error handling for license validation - Clean separation of KACHING and CHORUS deployment stacks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
199
pkg/repository/types.go
Normal file
199
pkg/repository/types.go
Normal file
@@ -0,0 +1,199 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Task represents a task from a repository (GitHub issue, GitLab MR, etc.)
|
||||
type Task struct {
|
||||
Number int `json:"number"`
|
||||
Title string `json:"title"`
|
||||
Body string `json:"body"`
|
||||
Repository string `json:"repository"`
|
||||
Labels []string `json:"labels"`
|
||||
Priority int `json:"priority"`
|
||||
Complexity int `json:"complexity"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
RequiredRole string `json:"required_role"`
|
||||
RequiredExpertise []string `json:"required_expertise"`
|
||||
}
|
||||
|
||||
// TaskProvider interface for different repository providers (GitHub, GitLab, etc.)
|
||||
type TaskProvider interface {
|
||||
GetTasks(projectID int) ([]*Task, error)
|
||||
ClaimTask(taskNumber int, agentID string) (bool, error)
|
||||
UpdateTaskStatus(task *Task, status string, comment string) error
|
||||
CompleteTask(task *Task, result *TaskResult) error
|
||||
GetTaskDetails(projectID int, taskNumber int) (*Task, error)
|
||||
ListAvailableTasks(projectID int) ([]*Task, error)
|
||||
}
|
||||
|
||||
// TaskMatcher determines if an agent should work on a task
|
||||
type TaskMatcher interface {
|
||||
ShouldProcessTask(task *Task, agentInfo *AgentInfo) bool
|
||||
CalculateTaskPriority(task *Task, agentInfo *AgentInfo) int
|
||||
ScoreTaskForAgent(task *Task, agentInfo *AgentInfo) float64
|
||||
}
|
||||
|
||||
// ProviderFactory creates task providers for different repository types
|
||||
type ProviderFactory interface {
|
||||
CreateProvider(ctx interface{}, config *Config) (TaskProvider, error)
|
||||
GetSupportedTypes() []string
|
||||
SupportedProviders() []string
|
||||
}
|
||||
|
||||
// AgentInfo represents information about the current agent
|
||||
type AgentInfo struct {
|
||||
ID string `json:"id"`
|
||||
Role string `json:"role"`
|
||||
Expertise []string `json:"expertise"`
|
||||
Capabilities []string `json:"capabilities"`
|
||||
MaxTasks int `json:"max_tasks"`
|
||||
CurrentTasks int `json:"current_tasks"`
|
||||
Status string `json:"status"`
|
||||
LastSeen time.Time `json:"last_seen"`
|
||||
Performance map[string]interface{} `json:"performance"`
|
||||
Availability string `json:"availability"`
|
||||
}
|
||||
|
||||
// TaskResult represents the result of completing a task
|
||||
type TaskResult struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message"`
|
||||
Artifacts []string `json:"artifacts"`
|
||||
Duration time.Duration `json:"duration"`
|
||||
Metadata map[string]interface{} `json:"metadata"`
|
||||
}
|
||||
|
||||
// Config represents repository configuration
|
||||
type Config struct {
|
||||
Type string `json:"type"`
|
||||
Settings map[string]interface{} `json:"settings"`
|
||||
Provider string `json:"provider"`
|
||||
BaseURL string `json:"base_url"`
|
||||
AccessToken string `json:"access_token"`
|
||||
Owner string `json:"owner"`
|
||||
Repository string `json:"repository"`
|
||||
TaskLabel string `json:"task_label"`
|
||||
InProgressLabel string `json:"in_progress_label"`
|
||||
CompletedLabel string `json:"completed_label"`
|
||||
BaseBranch string `json:"base_branch"`
|
||||
BranchPrefix string `json:"branch_prefix"`
|
||||
}
|
||||
|
||||
// DefaultTaskMatcher provides a default implementation of TaskMatcher
|
||||
type DefaultTaskMatcher struct{}
|
||||
|
||||
// ShouldProcessTask determines if an agent should process a task
|
||||
func (m *DefaultTaskMatcher) ShouldProcessTask(task *Task, agentInfo *AgentInfo) bool {
|
||||
// Simple logic: check if agent has capacity and matching expertise
|
||||
if agentInfo.CurrentTasks >= agentInfo.MaxTasks {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if any of agent's expertise matches task labels
|
||||
for _, expertise := range agentInfo.Expertise {
|
||||
for _, label := range task.Labels {
|
||||
if expertise == label {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Default to true for general tasks
|
||||
return len(task.Labels) == 0 || task.Priority > 5
|
||||
}
|
||||
|
||||
// CalculateTaskPriority calculates priority score for a task
|
||||
func (m *DefaultTaskMatcher) CalculateTaskPriority(task *Task, agentInfo *AgentInfo) int {
|
||||
priority := task.Priority
|
||||
|
||||
// Boost priority for tasks matching expertise
|
||||
for _, expertise := range agentInfo.Expertise {
|
||||
for _, label := range task.Labels {
|
||||
if expertise == label {
|
||||
priority += 2
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return priority
|
||||
}
|
||||
|
||||
// ScoreTaskForAgent calculates a score for how well an agent matches a task
|
||||
func (m *DefaultTaskMatcher) ScoreTaskForAgent(task *Task, agentInfo *AgentInfo) float64 {
|
||||
score := float64(task.Priority) / 10.0
|
||||
|
||||
// Boost score for matching expertise
|
||||
matchCount := 0
|
||||
for _, expertise := range agentInfo.Expertise {
|
||||
for _, label := range task.Labels {
|
||||
if expertise == label {
|
||||
matchCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(agentInfo.Expertise) > 0 {
|
||||
score += (float64(matchCount) / float64(len(agentInfo.Expertise))) * 0.5
|
||||
}
|
||||
|
||||
return score
|
||||
}
|
||||
|
||||
// DefaultProviderFactory provides a default implementation of ProviderFactory
|
||||
type DefaultProviderFactory struct{}
|
||||
|
||||
// CreateProvider creates a task provider (stub implementation)
|
||||
func (f *DefaultProviderFactory) CreateProvider(ctx interface{}, config *Config) (TaskProvider, error) {
|
||||
// In a real implementation, this would create GitHub, GitLab, etc. providers
|
||||
return &MockTaskProvider{}, nil
|
||||
}
|
||||
|
||||
// GetSupportedTypes returns supported repository types
|
||||
func (f *DefaultProviderFactory) GetSupportedTypes() []string {
|
||||
return []string{"github", "gitlab", "mock"}
|
||||
}
|
||||
|
||||
// SupportedProviders returns list of supported providers
|
||||
func (f *DefaultProviderFactory) SupportedProviders() []string {
|
||||
return f.GetSupportedTypes()
|
||||
}
|
||||
|
||||
// MockTaskProvider provides a mock implementation for testing
|
||||
type MockTaskProvider struct{}
|
||||
|
||||
// GetTasks returns mock tasks
|
||||
func (p *MockTaskProvider) GetTasks(projectID int) ([]*Task, error) {
|
||||
return []*Task{}, nil
|
||||
}
|
||||
|
||||
// ClaimTask claims a task
|
||||
func (p *MockTaskProvider) ClaimTask(taskNumber int, agentID string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// UpdateTaskStatus updates task status
|
||||
func (p *MockTaskProvider) UpdateTaskStatus(task *Task, status string, comment string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CompleteTask completes a task
|
||||
func (p *MockTaskProvider) CompleteTask(task *Task, result *TaskResult) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTaskDetails gets task details
|
||||
func (p *MockTaskProvider) GetTaskDetails(projectID int, taskNumber int) (*Task, error) {
|
||||
return &Task{}, nil
|
||||
}
|
||||
|
||||
// ListAvailableTasks lists available tasks
|
||||
func (p *MockTaskProvider) ListAvailableTasks(projectID int) ([]*Task, error) {
|
||||
return []*Task{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user