chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package lane
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Status string
|
||||
|
||||
const (
|
||||
StatusDraft Status = "draft"
|
||||
StatusReady Status = "ready"
|
||||
StatusRunning Status = "running"
|
||||
StatusBlocked Status = "blocked"
|
||||
StatusSucceeded Status = "succeeded"
|
||||
StatusFailed Status = "failed"
|
||||
StatusCancelled Status = "cancelled"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
WorkspaceID string `json:"workspace_id"`
|
||||
TopicID string `json:"topic_id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Purpose string `json:"purpose,omitempty"`
|
||||
Status Status `json:"status"`
|
||||
BaseBranch string `json:"base_branch"`
|
||||
BranchName string `json:"branch_name"`
|
||||
HeadCommit string `json:"head_commit,omitempty"`
|
||||
WorktreePath string `json:"worktree_path"`
|
||||
ContainerName string `json:"container_name"`
|
||||
RuntimeEndpoint string `json:"runtime_endpoint"`
|
||||
CreatedByRoleName string `json:"created_by_role_name"`
|
||||
ResultSummaryMarkdown string `json:"result_summary_markdown,omitempty"`
|
||||
ErrorMessage string `json:"error_message,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
StartedAt string `json:"started_at,omitempty"`
|
||||
CompletedAt string `json:"completed_at,omitempty"`
|
||||
}
|
||||
|
||||
func ValidateStatus(value Status) error {
|
||||
switch value {
|
||||
case StatusDraft, StatusReady, StatusRunning, StatusBlocked, StatusSucceeded, StatusFailed, StatusCancelled:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("invalid lane status %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
func (r Record) Validate() error {
|
||||
if r.WorkspaceID == "" {
|
||||
return fmt.Errorf("workspace id is required")
|
||||
}
|
||||
if r.TopicID == "" {
|
||||
return fmt.Errorf("topic id is required")
|
||||
}
|
||||
if r.Name == "" {
|
||||
return fmt.Errorf("lane name is required")
|
||||
}
|
||||
if r.Slug == "" {
|
||||
return fmt.Errorf("lane slug is required")
|
||||
}
|
||||
if r.CreatedByRoleName == "" {
|
||||
return fmt.Errorf("created by role is required")
|
||||
}
|
||||
return ValidateStatus(r.Status)
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package lane
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"inbox/internal/base/slug"
|
||||
)
|
||||
|
||||
func DefaultBranchName(workspaceSlug, topicID, laneSlug string) string {
|
||||
return "lane/" + runtimeWorkspaceSlug(workspaceSlug) + "/" + runtimeLaneSlug(laneSlug) + "-" + runtimeTopicSuffix(topicID)
|
||||
}
|
||||
|
||||
func DefaultWorktreePath(workspaceRoot, workspaceSlug, topicID, laneSlug string) string {
|
||||
return filepath.Join(filepath.Dir(workspaceRoot), runtimeWorkspaceSlug(workspaceSlug)+"--"+runtimeLaneSlug(laneSlug)+"--"+runtimeTopicSuffix(topicID))
|
||||
}
|
||||
|
||||
func DefaultContainerName(workspaceSlug, topicID, laneSlug string) string {
|
||||
return "lane-" + runtimeWorkspaceSlug(workspaceSlug) + "-" + runtimeLaneSlug(laneSlug) + "-" + runtimeTopicSuffix(topicID)
|
||||
}
|
||||
|
||||
func runtimeWorkspaceSlug(value string) string {
|
||||
if normalized := slug.Normalize(value); normalized != "" {
|
||||
return normalized
|
||||
}
|
||||
return "workspace"
|
||||
}
|
||||
|
||||
func runtimeLaneSlug(value string) string {
|
||||
if normalized := slug.Normalize(value); normalized != "" {
|
||||
return normalized
|
||||
}
|
||||
return "lane"
|
||||
}
|
||||
|
||||
func runtimeTopicSuffix(value string) string {
|
||||
normalized := slug.Normalize(strings.TrimPrefix(strings.TrimSpace(value), "topic-"))
|
||||
if normalized == "" {
|
||||
return "topic"
|
||||
}
|
||||
if len(normalized) > 12 {
|
||||
return normalized[len(normalized)-12:]
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package lane
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRuntimeNamesIncludeTopicSuffix(t *testing.T) {
|
||||
topicID := "topic-20260317T030141Z-05c4bd6c9a45"
|
||||
|
||||
branch := DefaultBranchName("todo", topicID, "frontend-app")
|
||||
if branch != "lane/todo/frontend-app-05c4bd6c9a45" {
|
||||
t.Fatalf("unexpected branch name: %s", branch)
|
||||
}
|
||||
|
||||
worktree := DefaultWorktreePath("/tmp/inbox-worktrees/todo", "todo", topicID, "frontend-app")
|
||||
if worktree != "/tmp/inbox-worktrees/todo--frontend-app--05c4bd6c9a45" {
|
||||
t.Fatalf("unexpected worktree path: %s", worktree)
|
||||
}
|
||||
|
||||
container := DefaultContainerName("todo", topicID, "frontend-app")
|
||||
if container != "lane-todo-frontend-app-05c4bd6c9a45" {
|
||||
t.Fatalf("unexpected container name: %s", container)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user