config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindLocal = "local"
	KindTeam  = "team"
)

Backend kinds. A Project's kind follows from the origin it lives on, and is stored so the desktop and CLI can name it without re-deriving the rule.

View Source
const Version = 2

Version is the configuration version this build writes. Load migrates version 1 in memory and Save always writes this one.

Variables

This section is empty.

Functions

func BackendID

func BackendID(origin string) string

BackendID is the opaque, stable identifier for a backend origin. It is derived from the origin alone, so re-enrolling against the same server - with a new device identity - updates that backend rather than growing a second entry for the same server.

func BackendKind

func BackendKind(origin string) string

BackendKind is the kind stored on a Backend record, derived once at write time from the origin.

func DefaultRoot

func DefaultRoot() (string, error)

func IsLoopbackOrigin

func IsLoopbackOrigin(origin string) bool

IsLoopbackOrigin reports whether this origin is served by a backend running on this Mac. It is the single loopback rule: localbackend.IsLoopbackOrigin delegates here so the service, the CLI, and the desktop cannot disagree about which Projects are local.

func Save

func Save(paths Paths, c Config) error

Types

type Backend

type Backend struct {
	ID         string `json:"id"`
	APIBaseURL string `json:"apiBaseUrl"`
	DeviceID   string `json:"deviceId"`
	Kind       string `json:"kind"`
}

Backend is one server implementing the /v1 contract, together with the device identity this profile uses with it. One Mac has one device identity per backend (ADR-069), so the two travel together.

type Config

type Config struct {
	Version    int         `json:"version"`
	Backends   []Backend   `json:"backends"`
	Projects   []Project   `json:"projects"`
	Workspaces []Workspace `json:"workspaces"`
}

func Load

func Load(paths Paths) (Config, error)

func Single

func Single(apiBaseURL, deviceID string, workspaces []Workspace) Config

Single is the version 2 configuration a single backend can express: one backend, and every Project in workspaces bound to it. It is what Load's migration of a version 1 profile produces.

func (Config) BackendByID

func (c Config) BackendByID(id string) (Backend, bool)

BackendByID returns the backend with this identifier.

func (Config) BackendForOrigin

func (c Config) BackendForOrigin(origin string) (Backend, bool)

BackendForOrigin returns the backend this profile already uses for a server.

func (Config) BackendForProject

func (c Config) BackendForProject(projectID string) (Backend, bool)

BackendForProject resolves the backend one Project lives on.

func (Config) BackendForWorkspace

func (c Config) BackendForWorkspace(workspace Workspace) (Backend, bool)

BackendForWorkspace resolves the backend one registered repository publishes to, through the Project it belongs to. A workspace whose Project has no backend is an orphan: the caller reports it and carries on with the rest.

func (Config) BackendTarget

func (c Config) BackendTarget(apiBaseURL string) Backend

BackendTarget is the backend record this profile would use for a server: the one it already has, or an unenrolled record for a server it has never used. It is what an onboarding flow is pointed at, so the flow can tell "mint a device identity here" from "reuse the one this profile has".

func (Config) BindProject

func (c Config) BindProject(projectID, backendID string) Config

BindProject records which backend holds a Project. Re-binding an existing Project to the same backend is a no-op; nothing here moves a Project between backends.

func (Config) ProjectsForBackend

func (c Config) ProjectsForBackend(backendID string) []string

ProjectsForBackend lists the Projects bound to one backend.

func (Config) RemoveBackend

func (c Config) RemoveBackend(backendID string) (Config, int)

RemoveBackend forgets one backend, the Projects on it, and the repositories registered to those Projects. It returns the workspaces it cleared, which is what a reset reports.

func (Config) UpsertBackend

func (c Config) UpsertBackend(apiBaseURL, deviceID string) (Config, Backend, error)

UpsertBackend records the backend at this origin, or updates the device identity of the one already there.

A second device identity for a backend the profile already knows is refused rather than merged: the Projects on that backend belong to the identity that is already stored, and quietly replacing it would strand every one of them.

type Paths

type Paths struct{ Root, Config, DB, Lock, Socket string }

func Resolve

func Resolve(root string) (Paths, error)

type Project

type Project struct {
	ID        string `json:"id"`
	BackendID string `json:"backendId"`
}

Project binds one Project to the backend that holds it (ADR-074). Workspaces keep naming a Project, and resolve their backend through it.

type Workspace

type Workspace struct {
	ID           string `json:"id"`
	ProjectID    string `json:"projectId"`
	WorkstreamID string `json:"workstreamId"`
	Root         string `json:"root"`
	Baseline     string `json:"baseline"`
	Fingerprint  string `json:"repositoryFingerprint"`
	MemberID     string `json:"memberId"`
	SessionID    string `json:"sessionId"`
}

Jump to

Keyboard shortcuts

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