Documentation
¶
Overview ¶
Package handoff is the crafting-brain executor's stock-handoff channel: a flock-guarded JSON queue file. The executor enqueues "holder gifts stock to recipient" instructions as it walks a craft plan; workers claim and complete the handoffs via send_gift. Mirrors pkg/rescue/queue.go's withLock mechanics (flock LOCK_EX sidecar, read-mutate-atomic-rename).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a handle on the shared queue file. Safe for concurrent use across processes: every operation takes an exclusive flock on a sidecar lock file (never renamed, so the lock identity is stable), then atomically rewrites the queue via temp+rename.
func (*Queue) Enqueue ¶
Enqueue appends rec (status pending, timestamps stamped) unless a record with the same ID already exists — one record per plan node, so re-planning while a handoff is in flight is a no-op.
func (*Queue) List ¶
List returns all records. A missing file is an empty queue; a corrupt file is an error (callers log and skip the tick rather than clobbering it).
type Record ¶
type Record struct {
ID string `json:"id"` // "<plan-id>/<node-id>" — unique per node
Holder string `json:"holder"` // agent_id that owns the stock
Station string `json:"station"` // base_id where the stock sits
ItemID string `json:"item_id"`
Qty int `json:"qty"`
Recipient string `json:"recipient"` // agent_id to send_gift to
Status Status `json:"status"`
MovedQty int `json:"moved_qty"` // actually transferred (may be < Qty)
Error string `json:"error,omitempty"`
RequestedAt string `json:"requested_at"`
UpdatedAt string `json:"updated_at"`
}
Record is one "holder gifts stock to recipient" instruction.