Complete reference for the Source interface, WorkItem struct, and the GitHub Projects adapter.
Defined in internal/source/source.go. The boundary between hive's core pipeline and wherever work items come from.
type Source interface {
Ready(ctx context.Context) ([]WorkItem, error)
Take(ctx context.Context, ref string) error
Complete(ctx context.Context, ref string) error
Release(ctx context.Context, ref string) error
}| Method | Called By | Description |
|---|---|---|
Ready |
poll |
Returns all work items currently available for dispatch. Items are filtered by source-specific criteria (e.g. board column, author authorization). |
Take |
poll |
Marks a work item as claimed/in-progress on the source. Called after local claim and systemd unit start. |
Complete |
— | Marks a work item as done on the source (e.g. moves to In Review). Currently unused: publish calls gh.MoveToInReview() directly instead. |
Release |
reap |
Returns a work item to the ready state on the source. Used when a session fails or is detected as stale. |
The ref parameter is an opaque string that uniquely identifies a work item within a source. The format is source-specific:
- GitHub Projects:
github:{owner}/{repo}#{number}(e.g.github:ivy/hive#42)
Refs are constructed by the adapter's Ready method and passed through to Take, Complete, and Release.
Defined in internal/source/source.go. Represents a unit of work returned by Ready.
type WorkItem struct {
Ref string // opaque identifier (source-specific)
Repo string // repository location (e.g., "ivy/hive")
Title string // human-readable summary
Prompt string // agent instructions (e.g., issue body)
Metadata map[string]string // source-specific data
}| Field | Type | Description |
|---|---|---|
Ref |
string | Source-specific unique identifier. Used as the key for claims and all subsequent Source operations. |
Repo |
string | Repository in owner/name format. Used to resolve the local repo path. |
Title |
string | Issue or item title. Written to session JSON. |
Prompt |
string | Agent instructions. For GitHub issues, this is the issue body. Written to .hive/prompt.md. |
Metadata |
map[string]string | Source-specific key-value data. Carried through to session.SourceMetadata. |
| Key | Description |
|---|---|
board_item_id |
GraphQL item ID on the project board. Required for column transitions. |
project_node_id |
GraphQL node ID of the project. Passed through from adapter config. |
Defined in internal/source/ghprojects/ghprojects.go. Implements Source backed by a GitHub Projects (v2) board.
type Config struct {
Client *github.Client
ProjectNumber string
ProjectNodeID string
AllowedUsers []string
}| Field | Description |
|---|---|
Client |
GitHub client (wraps gh CLI). Configured with status field IDs and option IDs. |
ProjectNumber |
Board number (e.g. "29"). Passed to GraphQL query. |
ProjectNodeID |
GraphQL node ID (e.g. "PVT_kwHOADgWUM4BOsG3"). Used for item-edit mutations. |
AllowedUsers |
Authorized GitHub usernames. Issues by other authors are silently skipped. |
- Queries the GraphQL API for items matching the configured
ReadyStatus(server-side filtering) - Skips draft issues (
DraftIssuetypename) - Fetches full issue data for each item via
gh issue view - Checks issue author against
AllowedUsers(case-insensitive) - Builds
WorkItemwith ref formatgithub:{owner}/{repo}#{number} - Caches
ref → board_item_idmapping for subsequent operations
Moves the board item to In Progress using gh project item-edit with the configured InProgressOptionID.
Moves the board item to In Review using the configured InReviewOptionID.
Moves the board item back to Ready using the configured ReadyOptionID.
func (a *Adapter) RegisterItem(ref, boardItemID string)Populates the internal ref → board_item_id cache for Complete and Release calls outside the Ready → Take flow. Used by reap to release items that were fetched in a previous poll cycle.
The adapter maintains an in-memory map[string]itemInfo (mutex-protected) that maps refs to board item IDs. This cache is populated by:
Ready— for each item returned from the boardRegisterItem— for items loaded from session metadata
The cache is required because Take, Complete, and Release need the board item ID but only receive the ref string.