Help us shape the future of Go! Take the 2026 Go Developer Survey

workspace

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package workspace defines Mango's only tenant boundary.

A Workspace is resolved from an authenticated API key at the HTTP edge and carried in context. It is deliberately not part of CMA request or response bodies: the upstream contract scopes resources through credentials too.

Index

Constants

View Source
const (
	// DefaultID owns rows created before Workspace tenancy was introduced and
	// is used by the local bootstrap path.
	DefaultID = "wrkspc_default"
	Prefix    = "wrkspc_"
	KeyPrefix = "sk-mango-"
)

Variables

View Source
var (
	ErrMissingScope          = errors.New("workspace scope is required")
	ErrInvalidAPIKey         = errors.New("invalid API key")
	ErrInvalidSessionToken   = errors.New("invalid session token")
	ErrInvalidEnvironmentKey = errors.New("invalid environment key")
)

Functions

func BlobKey

func BlobKey(ctx context.Context, suffix string) string

BlobKey places object-store data beneath the authenticated Workspace. The suffix is an internal stable path such as files/file_... or skills/skill_....

func WithEnvironmentScope

func WithEnvironmentScope(ctx context.Context, id string, environment EnvironmentScope) context.Context

func WithScope

func WithScope(ctx context.Context, id string) context.Context

func WithSessionScope

func WithSessionScope(ctx context.Context, id string, session SessionScope) context.Context

Types

type EnvironmentScope

type EnvironmentScope struct {
	EnvironmentID    string
	KeyID            string
	CredentialDigest []byte
}

EnvironmentScope permits a supervisor to Poll/Ack one Environment and read its queue statistics. The digest fences revocation inside claim transactions.

type Scope

type Scope struct {
	ID string
	// Session is non-nil only for a per-Work Session credential. Environment
	// is non-nil only for a supervisor key. Workspace keys leave both nil.
	Session     *SessionScope
	Environment *EnvironmentScope
}

func FromContext

func FromContext(ctx context.Context) (Scope, bool)

func Require

func Require(ctx context.Context) (Scope, error)

type SessionScope

type SessionScope struct {
	// ResultOnly is the brief terminal healthcheck replay grant. It never
	// authorizes lease renewal or Session execution.
	ResultOnly    bool
	EnvironmentID string
	WorkID        string
	SessionID     string
	// CredentialDigest is the server-side SHA-256 identity of the bearer.
	// Repositories use it to fence mutations in the same transaction as the
	// protected write, closing the middleware-to-database reclaim race.
	CredentialDigest []byte
	Skills           map[SkillVersion]struct{}
	// Memories records the access snapshotted on each Memory Store attached to
	// the Session. The per-Work credential may read only these stores and may
	// mutate a store only when its value is "read_write".
	Memories map[string]string
}

SessionScope is the least-privilege identity issued with one claimed Work item. HTTP authorization further limits it to that Work's lease operations, Session execution APIs, and immutable inputs attached to the Session.

type SkillVersion

type SkillVersion struct {
	ID      string
	Version string
}

Jump to

Keyboard shortcuts

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