Files
Test 002fe98e17
ci / test (push) Failing after 5s
feat(workflows): wire TaskUnit/Orchestrator activities, add k8s deploy manifests
Implements real activity-calling logic in OrchestratorWorkflow and
TaskUnitWorkflow (previously stubs), adds GitDiffActivity, and expands
PlanningActivity's I/O to carry repo path and prior task results.

Adds k8s/ deployment manifests (worker Deployment, orchestrator Job,
Kustomize base) for the poimen-workflows Temporal worker, using a
dedicated Kubernetes namespace `poimen` and Temporal namespace
`poimen-harness` rather than sharing the Temporal server's own
`temporal`/`production` namespaces.
2026-08-21 21:57:01 -07:00

92 lines
2.8 KiB
Go

package action
import (
"context"
"fmt"
"github.com/rockliang/poimen/workflows/action/llm"
"github.com/rockliang/poimen/workflows/prompts"
"github.com/rockliang/poimen/workflows/statemachine"
)
// PlanningInput is input to PlanningActivity.
type PlanningInput struct {
Config statemachine.OrchestratorConfig
BoardState string // JSON or markdown of task board
RepoPath string // Path to target repository
Milestone string // e.g., "T0"
TaskResults []statemachine.TaskUnitOutput // Results from completed tasks
}
// TaskDispatch represents a dispatched task.
type TaskDispatch struct {
TaskID string
PromptSpec statemachine.PromptSpec
BaseTimeout *int64 // optional override in milliseconds
}
// PlanningOutput is the output of PlanningActivity.
type PlanningOutput struct {
TasksToDispatch []string // Task IDs to dispatch in this cycle
CompletedBranches []string // Branches to squash merge (when milestone complete)
SubmilestoneComplete bool // Whether the milestone is complete
}
// PlanningActivity calls the Planner LLM to decide which tasks to dispatch.
func PlanningActivity(ctx context.Context, in PlanningInput) (PlanningOutput, error) {
// Get LLM client
client, err := llm.NewClient()
if err != nil {
return PlanningOutput{}, fmt.Errorf("failed to create LLM client: %w", err)
}
// Get planner spec
plannerSpec, exists := in.Config.RolePrompts["planner"]
if !exists {
return PlanningOutput{}, fmt.Errorf("planner role prompt not configured")
}
// Render template
var templateContent string
if plannerSpec.RawTemplate != "" {
templateContent = plannerSpec.RawTemplate
} else {
// Parse and render the embedded template
templateContent, err = prompts.Render(plannerSpec.TemplateRef, map[string]any{
"SystemPrompt": in.Config.SystemPrompt,
"BoardState": in.BoardState,
"Milestone": in.Milestone,
"Config": in.Config,
})
if err != nil {
return PlanningOutput{}, fmt.Errorf("failed to render planner template: %w", err)
}
}
// Call LLM
messages := []llm.MessageParam{
{
Role: "user",
Content: templateContent,
},
}
response, err := client.CreateMessage(ctx, llm.MessageInput{
Model: plannerSpec.Model,
SystemPrompt: in.Config.SystemPrompt,
Messages: messages,
})
if err != nil {
return PlanningOutput{}, fmt.Errorf("planner LLM call failed: %w", err)
}
// For now, return empty dispatch (will be parsed from LLM response in full implementation)
// This is a stub that allows the test to verify the activity is called
_ = response
return PlanningOutput{
TasksToDispatch: []string{},
CompletedBranches: []string{},
SubmilestoneComplete: false,
}, nil
}