Documentation
¶
Overview ¶
Package rescue is the cross-overmind stranded-worker rescue channel: a flock-guarded JSON queue file. Fleet overminds enqueue quarantined workers; the assist overmind's workers claim and complete rescues; fleet overminds relaunch workers whose record is done. Operators edit the same file for manual rescues. Spec: docs/superpowers/specs/2026-07-03-stranded-worker-quarantine-design.md
Index ¶
- Constants
- func AppendDebt(agentsDir, strandeeID string, d Debt) error
- func FuelForSystem(ctx context.Context, kb knowledge.Base, systemID string) (int, error)
- func RemoveHead(agentsDir, strandeeID string) error
- func ResolveSystemID(systems []knowledge.System, nameOrID string) (string, bool)
- func ResolveUsername(agentsDir, agentID string) (string, error)
- func TransferQuantity(strandeeMaxFuel, strandeeFuel, rescuerFuel, hopsHome int) int
- type Debt
- type Queue
- type Record
- type Status
Constants ¶
const ( FuelPerJump = 5 FuelBuffer = 5 FuelMin = 10 FuelFallback = 25 )
Rescue-fuel sizing (spec: 5 per jump to the nearest station + one jump's slack for the intra-system leg; floor 10; fallback when routing fails).
Variables ¶
This section is empty.
Functions ¶
func AppendDebt ¶
AppendDebt adds one debt to the strandee's list, creating the file if absent.
func FuelForSystem ¶
FuelForSystem sizes the rescue transfer for a strandee in systemID: BFS to the nearest station-bearing system, then fuelForHops. On any routing failure the caller should fall back to FuelFallback.
func RemoveHead ¶
RemoveHead drops the first debt and rewrites the file (removing it when the list empties). A missing/empty file is a no-op.
func ResolveSystemID ¶
ResolveSystemID maps a system display name (what worker heartbeats carry, e.g. "First Step") or an id to the KB system id. Exact id match wins; otherwise a case-insensitive name match.
func ResolveUsername ¶
ResolveUsername reads the agent's in-game username from <agentsDir>/<agentID>/credentials.json. In-game usernames differ from the on-disk agent aliases; refuel --target needs the in-game one.
func TransferQuantity ¶
TransferQuantity sizes a rescue fuel transfer at refuel time: fill the strandee's remaining tank capacity, but never give away more than the rescuer can spare after reserving fuel to fly home (hopsHome jumps at FuelPerJump each, plus FuelBuffer). Both terms clamp at zero, so a rescuer that cannot cover its own trip home returns 0 — the caller then declines the transfer rather than stranding itself.
Types ¶
type Debt ¶
Debt is one owed rescue-fee reimbursement: the strandee gifts Credits to the rescuer's in-game username Recipient once it is next docked.
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 the agent already has a record of any status — one record per agent, so re-detection while a rescue 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 {
AgentID string `json:"agent_id"`
TargetUsername string `json:"target_username"`
Fleet string `json:"fleet"`
System string `json:"system"`
SystemID string `json:"system_id"`
POI string `json:"poi"`
Fuel float64 `json:"fuel"`
MaxFuel float64 `json:"max_fuel"`
RescueFuel int `json:"rescue_fuel"`
Reason string `json:"reason"`
Status Status `json:"status"`
ClaimedBy string `json:"claimed_by"`
Error string `json:"error,omitempty"`
RequestedAt string `json:"requested_at"`
UpdatedAt string `json:"updated_at"`
}
Record is one stranded worker awaiting (or through) rescue.