Dispatch handler matches child issues that need coding (no PR yet, assigned to a known agent) and SCPs ticket JSON to the agent's queue directory via SSH. Includes dedup across queue/active/done and posts dispatch comments on issues. - Extend PipelineSignal with NeedsCoding, Assignee, IssueTitle, IssueBody - Extend ForgejoSource to emit signals for unstarted children - Add DispatchHandler with Match/Execute (SCP ticket delivery) - Add agent-runner.sh cron-based queue runner for agent machines - Wire dispatch handler into headless mode Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package handlers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/host-uk/core/pkg/jobrunner"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDispatch_Match_Good_NeedsCoding(t *testing.T) {
|
|
h := NewDispatchHandler(nil, "", "", map[string]AgentTarget{
|
|
"darbs-claude": {Host: "claude@192.168.0.201", QueueDir: "~/ai-work/queue"},
|
|
})
|
|
sig := &jobrunner.PipelineSignal{
|
|
NeedsCoding: true,
|
|
Assignee: "darbs-claude",
|
|
}
|
|
assert.True(t, h.Match(sig))
|
|
}
|
|
|
|
func TestDispatch_Match_Bad_HasPR(t *testing.T) {
|
|
h := NewDispatchHandler(nil, "", "", map[string]AgentTarget{
|
|
"darbs-claude": {Host: "claude@192.168.0.201", QueueDir: "~/ai-work/queue"},
|
|
})
|
|
sig := &jobrunner.PipelineSignal{
|
|
NeedsCoding: false,
|
|
PRNumber: 7,
|
|
Assignee: "darbs-claude",
|
|
}
|
|
assert.False(t, h.Match(sig))
|
|
}
|
|
|
|
func TestDispatch_Match_Bad_UnknownAgent(t *testing.T) {
|
|
h := NewDispatchHandler(nil, "", "", map[string]AgentTarget{
|
|
"darbs-claude": {Host: "claude@192.168.0.201", QueueDir: "~/ai-work/queue"},
|
|
})
|
|
sig := &jobrunner.PipelineSignal{
|
|
NeedsCoding: true,
|
|
Assignee: "unknown-user",
|
|
}
|
|
assert.False(t, h.Match(sig))
|
|
}
|
|
|
|
func TestDispatch_Match_Bad_NotAssigned(t *testing.T) {
|
|
h := NewDispatchHandler(nil, "", "", map[string]AgentTarget{
|
|
"darbs-claude": {Host: "claude@192.168.0.201", QueueDir: "~/ai-work/queue"},
|
|
})
|
|
sig := &jobrunner.PipelineSignal{
|
|
NeedsCoding: true,
|
|
Assignee: "",
|
|
}
|
|
assert.False(t, h.Match(sig))
|
|
}
|