apps

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyApp added in v0.3.1

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

func NewAPIKeyApp added in v0.3.1

func NewAPIKeyApp(store apiKeyStore) *APIKeyApp

func (*APIKeyApp) Create added in v0.3.1

func (a *APIKeyApp) Create(ctx context.Context, workspaceID models.WorkspaceID, label string) (string, *models.APIKey, error)

Create mints a new API key in the given workspace. The plaintext token is returned exactly once — the store holds only the SHA-256 hash. Losing the plaintext means revoking and creating a new key.

func (*APIKeyApp) List added in v0.3.1

func (a *APIKeyApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.APIKeySummary, error)

List returns every API key scoped to the given workspace — metadata only, never the hash or plaintext.

func (*APIKeyApp) Resolve added in v0.3.1

func (a *APIKeyApp) Resolve(ctx context.Context, plaintext string) (*models.APIKey, error)

Resolve maps a presented plaintext token to its record. Returns Unauthorized when the token is malformed, unknown, or revoked. This is the entry point for the Auth middleware — called once per HTTP request, so a revocation takes effect on the *next* request; any request already past the middleware continues to completion.

func (*APIKeyApp) Revoke added in v0.3.1

func (a *APIKeyApp) Revoke(ctx context.Context, workspaceID models.WorkspaceID, keyID models.APIKeyID) error

Revoke soft-deletes a key by setting revoked_at. Revoked keys fail Resolve and can no longer authenticate requests.

type AdminApp

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

func NewAdminApp

func NewAdminApp(souls adminSoulApp, personas adminPersonaApp, rules adminRuleApp, brains adminBrainApp, state adminStateApp) *AdminApp

func (*AdminApp) Export

Export returns a ContentBundle for the given workspace. Entities are read through the app layer so business invariants apply. Returns an error only on store-layer failures or context cancellation.

func (*AdminApp) Import

Import applies a bundle to the workspace additively. Per-entity failures (dangling refs, validation errors) become warnings and do not abort. Returns an error only on unknown schema version, context cancellation, or store I/O that the caller cannot recover from.

type BrainApp

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

func NewBrainApp

func NewBrainApp(store brainStore, refs *RefChecker) *BrainApp

func (*BrainApp) Delete

func (a *BrainApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*BrainApp) Get

func (a *BrainApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Brain, error)

func (*BrainApp) List

func (a *BrainApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Brain, error)

func (*BrainApp) Upsert

func (a *BrainApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, soulSlug, personaSlug models.Slug, ruleSlugs []models.Slug, modelPrefs *models.ModelPrefs) (*models.Brain, error)

type ComposeApp

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

func NewComposeApp

func NewComposeApp(content composeContentStore, state composeStateResolver) *ComposeApp

func (*ComposeApp) Compose

type PersonaApp

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

func NewPersonaApp

func NewPersonaApp(store personaStore, refs *RefChecker) *PersonaApp

func (*PersonaApp) Delete

func (a *PersonaApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*PersonaApp) Get

func (a *PersonaApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Persona, error)

func (*PersonaApp) List

func (a *PersonaApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Persona, error)

func (*PersonaApp) Upsert

func (a *PersonaApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, content string, bundledRules []models.Slug) (*models.Persona, error)

type RefChecker

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

RefChecker validates referential integrity across content entities.

func NewRefChecker

func NewRefChecker(souls refSoulStore, personas refPersonaStore, rules refRuleStore) *RefChecker

NewRefChecker creates a RefChecker with access to content stores.

func (*RefChecker) ValidateBrainRefs

func (r *RefChecker) ValidateBrainRefs(ctx context.Context, workspaceID models.WorkspaceID, soulSlug, personaSlug models.Slug, ruleSlugs []models.Slug) error

ValidateBrainRefs checks that all references in a brain exist. Returns a RefError with a map of invalid fields if any are missing.

func (*RefChecker) ValidateRuleSlugs

func (r *RefChecker) ValidateRuleSlugs(ctx context.Context, workspaceID models.WorkspaceID, slugs []models.Slug) error

ValidateRuleSlugs checks that all rule slugs exist. Used by PersonaApp to validate bundled rules on upsert.

type RuleApp

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

func NewRuleApp

func NewRuleApp(store ruleStore) *RuleApp

func (*RuleApp) Delete

func (a *RuleApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*RuleApp) Get

func (a *RuleApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Rule, error)

func (*RuleApp) List

func (a *RuleApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Rule, error)

func (*RuleApp) Upsert

func (a *RuleApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, entries []models.RuleEntry) (*models.Rule, error)

type SoulApp

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

func NewSoulApp

func NewSoulApp(store soulStore) *SoulApp

func (*SoulApp) Delete

func (a *SoulApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*SoulApp) Get

func (a *SoulApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Soul, error)

func (*SoulApp) List

func (a *SoulApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Soul, error)

func (*SoulApp) Upsert

func (a *SoulApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, content string) (*models.Soul, error)

type StateApp

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

func NewStateApp

func NewStateApp(store stateStore) *StateApp

func (*StateApp) DeleteState

func (a *StateApp) DeleteState(ctx context.Context, wsID models.WorkspaceID, scopeType models.ScopeType, referenceID string) error

DeleteState removes the layer override at the target scope. No-op if no override exists.

func (*StateApp) FindLayers

func (a *StateApp) FindLayers(ctx context.Context, wsID models.WorkspaceID, projectSlug, sessionID string) ([]models.LayerOverride, error)

FindLayers returns all applicable layer overrides in precedence order (workspace first, then project if given, then session if given). Layers that don't exist are simply omitted.

func (*StateApp) ResolveForScope

func (a *StateApp) ResolveForScope(ctx context.Context, wsID models.WorkspaceID, projectSlug, sessionID string) (*models.EffectiveState, error)

ResolveForScope merges all applicable layers into an EffectiveState.

Merge rules:

  • Soul/Persona: last non-nil layer wins. nil = skip (no opinion), empty string = explicitly clear, value = set.
  • Rules: remove first, then add (no duplicates), applied per layer.

func (*StateApp) SetState

func (a *StateApp) SetState(ctx context.Context, wsID models.WorkspaceID, scopeType models.ScopeType, referenceID string, partial *models.LayerOverride) error

SetState upserts the layer override at the target scope, merging the partial override with any existing override. Nil fields in the partial are preserved from the existing override. If the result is empty (all fields nil/empty), the override is deleted.

type VersionApp

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

func NewVersionApp

func NewVersionApp(store versionStore) *VersionApp

func (*VersionApp) GetContentVersion

func (a *VersionApp) GetContentVersion(ctx context.Context, workspaceID models.WorkspaceID, contentType models.ContentType, slug models.Slug, version int) (*models.ContentVersion, error)

GetContentVersion returns the full archived snapshot. Returns NotFound when the slug is unknown or the version does not exist.

func (*VersionApp) ListContentVersions

func (a *VersionApp) ListContentVersions(ctx context.Context, workspaceID models.WorkspaceID, contentType models.ContentType, slug models.Slug) ([]models.VersionSummary, error)

ListContentVersions returns archived versions newest-first. Returns NotFound when the slug was never upserted; returns an empty slice when the slug exists but has no archived versions yet.

type WorkspaceApp added in v0.3.1

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

func NewWorkspaceApp added in v0.3.1

func NewWorkspaceApp(store workspaceStore) *WorkspaceApp

func (*WorkspaceApp) Create added in v0.3.1

func (a *WorkspaceApp) Create(ctx context.Context, name string) (*models.Workspace, error)

func (*WorkspaceApp) Delete added in v0.3.1

func (a *WorkspaceApp) Delete(ctx context.Context, id models.WorkspaceID) error

Delete removes an empty workspace. Returns Conflict if the workspace still holds content — callers who want to drop the content first use Purge.

func (*WorkspaceApp) Get added in v0.3.1

func (*WorkspaceApp) GetByName added in v0.3.1

func (a *WorkspaceApp) GetByName(ctx context.Context, name string) (*models.Workspace, error)

GetByName resolves a user-facing workspace name to a workspace. Returns NotFound when no workspace carries that name.

func (*WorkspaceApp) List added in v0.3.1

func (a *WorkspaceApp) List(ctx context.Context) ([]models.Workspace, error)

func (*WorkspaceApp) Purge added in v0.3.1

func (a *WorkspaceApp) Purge(ctx context.Context, id models.WorkspaceID) error

Purge drops every row attached to a workspace (souls, personas, rules, brains, state, api keys) and then the workspace itself. Irreversible; the caller is expected to have confirmed.

func (*WorkspaceApp) Rename added in v0.3.1

func (a *WorkspaceApp) Rename(ctx context.Context, id models.WorkspaceID, newName string) (*models.Workspace, error)

Jump to

Keyboard shortcuts

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