coordination

package module
v0.0.0-...-dddc2fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package coordination provides distributed claim, release, and checkpoint primitives for multi-node CogOS clusters.

It implements lease-based ownership of resources and durable checkpointing so that work can be resumed after node restarts or handed off between nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcceptHandoff

func AcceptHandoff(workspaceRoot, handoffFile string) error

AcceptHandoff archives a handoff (marks it as accepted)

func AgentID

func AgentID() string

AgentID returns the current agent identifier. It checks COG_AGENT_ID, then USER, defaulting to "root".

func ClaimOwner

func ClaimOwner(workspaceRoot, path string) (string, error)

ClaimOwner returns the agent that owns the claim

func CreateCheckpoint

func CreateCheckpoint(workspaceRoot, name string) (agentID string, err error)

CreateCheckpoint creates a checkpoint signal for the current agent. Returns the agent ID and checkpoint name for display purposes.

func IsClaimed

func IsClaimed(workspaceRoot, path string) bool

IsClaimed checks if a path is claimed

func ReleaseClaim

func ReleaseClaim(workspaceRoot, path string) error

ReleaseClaim releases a file lock.

func WaitCheckpoint

func WaitCheckpoint(workspaceRoot, name string, agents []string, timeout time.Duration) error

WaitCheckpoint waits for all agents to reach a checkpoint

Types

type Broadcast

type Broadcast struct {
	Channel   string    `json:"channel"`
	Agent     string    `json:"agent"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
}

Broadcast represents a channel broadcast message

func CreateBroadcast

func CreateBroadcast(workspaceRoot, channel, message string) (*Broadcast, error)

CreateBroadcast broadcasts a message to a channel. Returns the created Broadcast on success.

func ListBroadcasts

func ListBroadcasts(workspaceRoot, channel string, since time.Duration) ([]Broadcast, error)

ListBroadcasts returns broadcasts on a channel since a time window

type Claim

type Claim struct {
	Path      string    `json:"path"`
	Agent     string    `json:"agent"`
	Reason    string    `json:"reason"`
	ClaimedAt time.Time `json:"claimed_at"`
}

Claim represents a file-level lock for exclusive work

func CreateClaim

func CreateClaim(workspaceRoot, path, reason string) (*Claim, error)

CreateClaim acquires a file lock for exclusive work. Returns the created Claim on success.

func ListClaims

func ListClaims(workspaceRoot string) ([]Claim, error)

ListClaims returns all active claims

func ReadClaim

func ReadClaim(workspaceRoot, path string) (*Claim, error)

ReadClaim reads the claim for a path

type Handoff

type Handoff struct {
	From      string    `json:"from"`
	To        string    `json:"to"`
	Artifact  string    `json:"artifact"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
}

Handoff represents an agent-to-agent handoff

func CreateHandoff

func CreateHandoff(workspaceRoot, toAgent, artifact, message string) (*Handoff, error)

CreateHandoff creates a handoff to another agent. Returns the created Handoff on success.

func ListHandoffs

func ListHandoffs(workspaceRoot, agent string) ([]Handoff, error)

ListHandoffs returns pending handoffs for an agent. If agent is empty, uses the current agent ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL