registry

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package registry remembers what flow created, so that open, delete, list and status can find it again. It is a cache of facts about the world, not the source of truth: every reader must tolerate drift — a worktree deleted by hand, a workspace closed, a branch renamed — and never crash because of it.

Index

Constants

View Source
const Version = 1

Version is the on-disk schema version. An unknown version is a hard error rather than a silent partial read, so a newer flow's file is never truncated by an older one.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the registry location, honoring FLOW_REGISTRY for tests.

Types

type Entry

type Entry struct {
	TicketID     string    `json:"ticket_id"`
	Slug         string    `json:"slug"`
	RepoKey      string    `json:"repo_key"`
	RepoRoot     string    `json:"repo_root"`
	WorktreePath string    `json:"worktree_path"`
	Branch       string    `json:"branch"`
	BaseBranch   string    `json:"base_branch"`
	AssetsPath   string    `json:"assets_path"`
	Workspace    Workspace `json:"workspace"`
	CreatedAt    time.Time `json:"created_at"`
	LastOpenedAt time.Time `json:"last_opened_at"`

	// Extra preserves fields written by a future version of flow so that an
	// older binary rewriting the file does not discard them.
	Extra map[string]json.RawMessage `json:"-"`
}

Entry is everything flow knows about one ticket in one repository.

func (Entry) Key

func (e Entry) Key() Key

Key returns the entry's identity.

func (Entry) MarshalJSON

func (e Entry) MarshalJSON() ([]byte, error)

MarshalJSON writes the known fields plus anything preserved from a newer schema.

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes an entry while retaining any fields this version of flow does not know about.

type ErrUnknownVersion

type ErrUnknownVersion struct {
	Path string
	Got  int
}

ErrUnknownVersion reports a registry written by a newer flow.

func (*ErrUnknownVersion) Error

func (e *ErrUnknownVersion) Error() string

type File

type File struct {
	Version int     `json:"version"`
	Entries []Entry `json:"entries"`
}

File is the whole registry document.

func (*File) All

func (f *File) All() []Entry

All returns every entry, newest first.

func (*File) Find

func (f *File) Find(repoKey, ticketID string) (Entry, bool)

Find returns the entry for a repo and ticket.

func (*File) FindAnyRepo

func (f *File) FindAnyRepo(ticketID string) (Entry, bool, bool)

FindAnyRepo returns the entry for a ticket in any repo, and reports whether the match was ambiguous across repositories.

func (*File) ForRepo

func (f *File) ForRepo(repoKey string) []Entry

ForRepo returns every entry for one repository, newest first.

func (*File) MatchByPath

func (f *File) MatchByPath(dir string) (Entry, bool, bool)

MatchByPath finds the entry whose worktree path is dir or an ancestor of it. Matching is on path-segment boundaries, so /a/b never matches /a/bc.

func (*File) Remove

func (f *File) Remove(repoKey, ticketID string) bool

Remove deletes an entry and reports whether it was present.

func (*File) Upsert

func (f *File) Upsert(e Entry)

Upsert inserts or replaces an entry, preserving the original CreatedAt when one already existed.

type Key

type Key struct {
	RepoKey  string
	TicketID string
}

Key identifies an entry. The same ticket ID may exist in two repositories, so the repo key is part of the identity.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store reads and writes the registry file, serializing concurrent flow invocations with a lock on a sibling .lock file.

func Open

func Open(path string) *Store

Open returns a Store for path, or the default location when path is empty.

func (*Store) Load

func (s *Store) Load() (*File, error)

Load reads the registry. A missing file yields an empty registry, because a first run is not an error.

func (*Store) Path

func (s *Store) Path() string

Path reports the registry file location.

func (*Store) Update

func (s *Store) Update(fn func(*File) error) error

Update performs a locked read-modify-write. The lock is held for the whole cycle, so two concurrent flow processes cannot interleave and lose an entry.

type Workspace

type Workspace struct {
	Provider   string `json:"provider,omitempty"`
	ID         string `json:"id,omitempty"`
	Label      string `json:"label,omitempty"`
	TabID      string `json:"tab_id,omitempty"`
	RootPaneID string `json:"root_pane_id,omitempty"`
}

Workspace records the terminal workspace flow created for a ticket.

func (Workspace) Empty

func (w Workspace) Empty() bool

Empty reports whether no workspace is recorded.

Jump to

Keyboard shortcuts

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