registry

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("registry: entry not found")

ErrNotFound is returned by Read when no entry exists for the given cwd.

View Source
var HealthTimeout = 500 * time.Millisecond

Functions

func EntryPath

func EntryPath(cwd string) string

EntryPath returns the absolute path of the JSON file for the given workspace cwd.

func IsAlive

func IsAlive(e Entry) bool

IsAlive returns true if BOTH (a) the recorded HubPID is alive on this host AND (b) GET <HubURL> succeeds at the TCP/HTTP level within HealthTimeout. Both checks are required because a recycled PID can pass (a) but fail (b).

The HTTP probe doesn't require any specific endpoint — any HTTP response (including 4xx) means the port is bound and serving, which is what we actually want to know. The Fossil HTTP server bones uses doesn't expose a /health endpoint and we deliberately don't add a sidecar HTTP server just for the probe.

func IsOrphan added in v0.7.0

func IsOrphan(e Entry) bool

IsOrphan reports whether e represents a process that is alive on this host but whose workspace is no longer reachable. Three signals qualify a workspace as gone:

  1. e.Cwd does not exist on disk (ENOENT)
  2. e.Cwd exists but its workspace marker (.bones/agent.id) does not
  3. e.Cwd resolves into the user's Trash (~/.Trash on macOS, the XDG-Trash equivalent on Linux)

The PID-alive check is the same one IsAlive uses; an entry whose PID is dead is not an orphan (it's a stale entry awaiting prune) and will be reported by IsAlive returning false.

func Reap added in v0.7.0

func Reap(e Entry) error

Reap terminates the process for e and removes its registry entry. SIGTERM first; if the PID is still alive after reapGrace, SIGKILL. Returns nil on success (process gone, entry removed) or an error describing which step failed. The entry is removed even after SIGKILL — leaving it would create a permanent registry record for a process that, by definition, isn't going to come back.

func RegistryDir

func RegistryDir() string

RegistryDir returns the directory that holds workspace entry files.

func Remove

func Remove(cwd string) error

Remove deletes the registry entry for the given workspace cwd. Idempotent.

func WorkspaceID

func WorkspaceID(cwd string) string

WorkspaceID returns a deterministic 16-hex-char identifier for an absolute cwd. Used as the registry filename: ~/.bones/workspaces/<id>.json

func Write

func Write(e Entry) error

Write persists e to its file atomically (tmp+rename). Creates the registry directory if missing.

Types

type Entry

type Entry struct {
	Cwd       string    `json:"cwd"`
	Name      string    `json:"name"`
	HubURL    string    `json:"hub_url"`
	NATSURL   string    `json:"nats_url"`
	HubPID    int       `json:"hub_pid"`
	StartedAt time.Time `json:"started_at"`
}

Entry is one workspace's registry record. One JSON file per Entry at ~/.bones/workspaces/<WorkspaceID>.json.

func List

func List() ([]Entry, error)

List returns all registry entries, skipping corrupt files.

func Orphans added in v0.7.0

func Orphans() ([]Entry, error)

Orphans returns all registry entries whose process is alive but whose workspace is gone. Read-only; the caller decides what to do.

func Read

func Read(cwd string) (Entry, error)

Read loads the registry entry for the given workspace cwd.

Jump to

Keyboard shortcuts

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