12 message types covering: agent lifecycle (Started/Completed), QA+PR pipeline (QAResult/PRCreated/PRMerged/PRNeedsReview), queue orchestration (QueueDrained/PokeQueue/RateLimitDetected), monitor events (HarvestComplete/HarvestRejected/InboxMessage). These replace the CompletionNotifier and ChannelNotifier callback interfaces with typed broadcast messages via c.ACTION(). Co-Authored-By: Virgil <virgil@lethean.io>
120 lines
3.2 KiB
Go
120 lines
3.2 KiB
Go
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
// Package messages defines IPC message types for inter-service communication
|
|
// within core-agent. Services emit these via c.ACTION() and handle them via
|
|
// c.RegisterAction(). No service imports another — they share only these types.
|
|
//
|
|
// c.ACTION(messages.AgentCompleted{Agent: "codex", Repo: "go-io", Status: "completed"})
|
|
package messages
|
|
|
|
// --- Agent Lifecycle ---
|
|
|
|
// AgentStarted is broadcast when a subagent process is spawned.
|
|
//
|
|
// c.ACTION(messages.AgentStarted{Agent: "codex", Repo: "go-io", Workspace: "core/go-io/task-5"})
|
|
type AgentStarted struct {
|
|
Agent string
|
|
Repo string
|
|
Workspace string
|
|
}
|
|
|
|
// AgentCompleted is broadcast when a subagent process exits.
|
|
//
|
|
// c.ACTION(messages.AgentCompleted{Agent: "codex", Repo: "go-io", Workspace: "core/go-io/task-5", Status: "completed"})
|
|
type AgentCompleted struct {
|
|
Agent string
|
|
Repo string
|
|
Workspace string
|
|
Status string // completed, failed, blocked
|
|
}
|
|
|
|
// --- QA & PR Pipeline ---
|
|
|
|
// QAResult is broadcast after QA runs on a completed workspace.
|
|
//
|
|
// c.ACTION(messages.QAResult{Workspace: "core/go-io/task-5", Repo: "go-io", Passed: true})
|
|
type QAResult struct {
|
|
Workspace string
|
|
Repo string
|
|
Passed bool
|
|
Output string
|
|
}
|
|
|
|
// PRCreated is broadcast after a PR is auto-created on Forge.
|
|
//
|
|
// c.ACTION(messages.PRCreated{Repo: "go-io", Branch: "agent/fix-tests", PRURL: "https://...", PRNum: 12})
|
|
type PRCreated struct {
|
|
Repo string
|
|
Branch string
|
|
PRURL string
|
|
PRNum int
|
|
}
|
|
|
|
// PRMerged is broadcast after a PR is auto-verified and merged.
|
|
//
|
|
// c.ACTION(messages.PRMerged{Repo: "go-io", PRURL: "https://...", PRNum: 12})
|
|
type PRMerged struct {
|
|
Repo string
|
|
PRURL string
|
|
PRNum int
|
|
}
|
|
|
|
// PRNeedsReview is broadcast when auto-merge fails and human attention is needed.
|
|
//
|
|
// c.ACTION(messages.PRNeedsReview{Repo: "go-io", PRNum: 12, Reason: "merge conflict"})
|
|
type PRNeedsReview struct {
|
|
Repo string
|
|
PRURL string
|
|
PRNum int
|
|
Reason string
|
|
}
|
|
|
|
// --- Queue ---
|
|
|
|
// QueueDrained is broadcast when running=0 and queued=0 (genuinely empty).
|
|
//
|
|
// c.ACTION(messages.QueueDrained{Completed: 3})
|
|
type QueueDrained struct {
|
|
Completed int
|
|
}
|
|
|
|
// PokeQueue signals the runner to drain the queue immediately.
|
|
//
|
|
// c.ACTION(messages.PokeQueue{})
|
|
type PokeQueue struct{}
|
|
|
|
// RateLimitDetected is broadcast when fast failures trigger agent pool backoff.
|
|
//
|
|
// c.ACTION(messages.RateLimitDetected{Pool: "codex", Duration: "30m"})
|
|
type RateLimitDetected struct {
|
|
Pool string
|
|
Duration string
|
|
}
|
|
|
|
// --- Monitor Events ---
|
|
|
|
// HarvestComplete is broadcast when a workspace branch is ready for review.
|
|
//
|
|
// c.ACTION(messages.HarvestComplete{Repo: "go-io", Branch: "agent/fix-tests", Files: 5})
|
|
type HarvestComplete struct {
|
|
Repo string
|
|
Branch string
|
|
Files int
|
|
}
|
|
|
|
// HarvestRejected is broadcast when a workspace fails safety checks (binaries, size).
|
|
//
|
|
// c.ACTION(messages.HarvestRejected{Repo: "go-io", Branch: "agent/fix-tests", Reason: "binary detected"})
|
|
type HarvestRejected struct {
|
|
Repo string
|
|
Branch string
|
|
Reason string
|
|
}
|
|
|
|
// InboxMessage is broadcast when new inter-agent messages arrive.
|
|
//
|
|
// c.ACTION(messages.InboxMessage{New: 2, Total: 15})
|
|
type InboxMessage struct {
|
|
New int
|
|
Total int
|
|
}
|