registry

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package registry manages tenant/project registration with UUID tracking.

The registry provides:

  • Human-readable names to UUID mapping for future database migration
  • Path sanitization for filesystem safety
  • Registration validation and persistence

Directory structure:

~/.config/contextd/vectorstore/
├── {tenant}/                      ← org level
│   ├── {project}/                 ← direct project
│   │   └── {collections}
│   ├── {team}/                    ← team level
│   │   └── {project}/             ← team-scoped project
│   │       └── {collections}
│   ├── memories/                  ← org-shared
│   └── remediations/              ← org-shared

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTenantNotFound    = errors.New("tenant not found")
	ErrProjectNotFound   = errors.New("project not found")
	ErrTeamNotFound      = errors.New("team not found")
	ErrInvalidName       = errors.New("invalid name: must be alphanumeric with hyphens/underscores")
	ErrPathTraversal     = errors.New("path traversal detected")
	ErrRegistryCorrupted = errors.New("registry file corrupted")
)

Errors for registry operations.

Functions

func ValidateName

func ValidateName(name string) error

ValidateName checks if a name is safe for filesystem paths.

Types

type Entry

type Entry struct {
	UUID      string    `json:"uuid"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
}

Entry represents a registered entity (tenant, team, or project).

type Registry

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

Registry manages tenant/project registration and path resolution.

func NewRegistry

func NewRegistry(basePath string) (*Registry, error)

NewRegistry creates a new registry at the specified base path.

func (*Registry) BasePath

func (r *Registry) BasePath() string

BasePath returns the base vectorstore path.

func (*Registry) EnsureProjectExists

func (r *Registry) EnsureProjectExists(tenant, team, project string) error

EnsureProjectExists registers tenant and project if they don't exist. This is a convenience method for auto-registration on first use.

func (*Registry) GetOrgPath

func (r *Registry) GetOrgPath(tenant string) (string, error)

GetOrgPath returns the filesystem path for an org (for org-shared collections).

func (*Registry) GetProject

func (r *Registry) GetProject(tenant, team, project string) (*Entry, error)

GetProject returns the project entry.

func (*Registry) GetProjectPath

func (r *Registry) GetProjectPath(tenant, team, project string) (string, error)

GetProjectPath returns the filesystem path for a project.

func (*Registry) GetTeam

func (r *Registry) GetTeam(tenant, team string) (*Entry, error)

GetTeam returns the team entry.

func (*Registry) GetTeamPath

func (r *Registry) GetTeamPath(tenant, team string) (string, error)

GetTeamPath returns the filesystem path for a team (for shared collections).

func (*Registry) GetTenant

func (r *Registry) GetTenant(name string) (*Entry, error)

GetTenant returns the tenant entry by name.

func (*Registry) ListProjects

func (r *Registry) ListProjects(tenant string) []string

ListProjects returns all registered projects for a tenant.

func (*Registry) ListTenants

func (r *Registry) ListTenants() []string

ListTenants returns all registered tenant names.

func (*Registry) RegisterProject

func (r *Registry) RegisterProject(tenant, team, project string) (*Entry, error)

RegisterProject registers a new project. If team is empty, registers under tenant directly. If team is set, registers under tenant/team.

func (*Registry) RegisterTeam

func (r *Registry) RegisterTeam(tenant, team string) (*Entry, error)

RegisterTeam registers a new team under a tenant.

func (*Registry) RegisterTenant

func (r *Registry) RegisterTenant(name string) (*Entry, error)

RegisterTenant registers a new tenant or returns existing entry.

type RegistryData

type RegistryData struct {
	Version  int               `json:"version"`
	Tenants  map[string]*Entry `json:"tenants"`  // key: tenant name
	Teams    map[string]*Entry `json:"teams"`    // key: tenant/team
	Projects map[string]*Entry `json:"projects"` // key: tenant/project or tenant/team/project
}

RegistryData is the persisted registry structure.

Jump to

Keyboard shortcuts

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