Documentation
¶
Overview ¶
Package hive owns the on-disk orchestration state (Phase 2): one directory per registered project workspace holding agents, tasks, approvals, mailboxes and an append-only ledger. Files are the source of truth; SQLite mirrors them for the UI and is rebuildable by rescan. The hive is the single git committer — agents never run git on it. See .ai/05-orchestration.md.
Index ¶
- Constants
- func CanTransition(from, to string) bool
- type Hive
- func (h *Hive) CreateTask(t Task) error
- func (h *Hive) Deliver() (int, error)
- func (h *Hive) GetTask(id string) (Task, error)
- func (h *Hive) Inbox(agentID string) ([]Message, error)
- func (h *Hive) InboxCount(agentID string) int
- func (h *Hive) Ledger() ([]LedgerEntry, error)
- func (h *Hive) ListTasks() ([]Task, error)
- func (h *Hive) RegisterAgent(id, identity string) error
- func (h *Hive) Send(m Message) (string, error)
- func (h *Hive) UpdateTask(id string, mut func(*Task) error) (Task, error)
- type LedgerEntry
- type Message
- type Task
Constants ¶
const ( KindAssign = "assign" KindResult = "result" KindQuestion = "question" KindEscalation = "escalation" )
Message kinds.
const ( StatusInbox = "inbox" StatusAssigned = "assigned" StatusInProgress = "in_progress" StatusVerifying = "verifying" StatusNeedsYou = "needs_you" StatusDone = "done" StatusFailed = "failed" )
Task statuses (kanban columns).
Variables ¶
This section is empty.
Functions ¶
func CanTransition ¶
CanTransition reports whether from→to is an allowed board move.
Types ¶
type Hive ¶
type Hive struct {
Root string
// contains filtered or unexported fields
}
Layout:
<hive>/
agents/<agent-id>/{identity.md, memory.md, inbox/, outbox/}
tasks/<task-id>.md
approvals/<id>.json
ledger.jsonl
func (*Hive) CreateTask ¶
CreateTask writes a new task file in the inbox column and ledgers it.
func (*Hive) Deliver ¶
Deliver moves every message from every outbox into the recipient's inbox and ledgers each delivery. This is the router's single-writer step. Returns the number delivered.
func (*Hive) InboxCount ¶
InboxCount returns how many messages an agent has waiting (the Stop-loop check).
func (*Hive) Ledger ¶
func (h *Hive) Ledger() ([]LedgerEntry, error)
Ledger reads the full ledger (newest last).
func (*Hive) RegisterAgent ¶
RegisterAgent creates an agent's directory tree with identity/memory files.
type LedgerEntry ¶
type LedgerEntry struct {
Ts int64 `json:"ts"` // unix ms
Kind string `json:"kind"`
AgentID string `json:"agent_id,omitempty"`
TaskID string `json:"task_id,omitempty"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Note string `json:"note,omitempty"`
}
LedgerEntry is one append-only record of a hive state transition.
type Message ¶
type Message struct {
From string `json:"from"`
To string `json:"to"`
Ts int64 `json:"ts"`
TaskID string `json:"task_id,omitempty"`
Kind string `json:"kind"` // assign | result | question | escalation
Body string `json:"body"`
// Name is the on-disk filename (set on read).
Name string `json:"name,omitempty"`
}
Message is a mailbox file: markdown with YAML frontmatter {from,to,ts,task_id?,kind} and a free-form body. See .ai/05-orchestration.md § Mailbox message.
type Task ¶
type Task struct {
ID string `yaml:"id" json:"id"`
Title string `yaml:"title" json:"title"`
Status string `yaml:"status" json:"status"`
Assignee string `yaml:"assignee" json:"assignee"`
BudgetUSD float64 `yaml:"budget_usd" json:"budget_usd"`
DoneCriteria []string `yaml:"done_criteria" json:"done_criteria"`
VerifyRoundsUsed int `yaml:"verify_rounds_used" json:"verify_rounds_used"`
Body string `yaml:"-" json:"body"`
}
Task mirrors tasks/<id>.md (YAML frontmatter + free-form body). See .ai/05-orchestration.md § Task file. Statuses are the kanban columns.