teamstate

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package teamstate persists Coding Team application resource bindings.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalid means an API value or durable snapshot is malformed.
	ErrInvalid = errors.New("coding team state: invalid value")
	// ErrNotFound means no resource journal exists for the requested Team.
	ErrNotFound = errors.New("coding team state: not found")
	// ErrConflict means expected revision does not match the durable revision.
	ErrConflict = errors.New("coding team state: revision conflict")
	// ErrIdempotency means a Command ID was reused for different semantics.
	ErrIdempotency = errors.New("coding team state: idempotency conflict")
	// ErrCorrupt means a journal cannot be replayed safely.
	ErrCorrupt = errors.New("coding team state: corrupt journal")
	// ErrUnsafeFile means a filesystem object violates the private-file contract.
	ErrUnsafeFile = errors.New("coding team state: unsafe filesystem object")
	// ErrLimit means an input or durable journal exceeds configured bounds.
	ErrLimit = errors.New("coding team state: limit exceeded")
	// ErrLocked means another writer owns the Team journal.
	ErrLocked = errors.New("coding team state: journal is locked")
	// ErrUnsupported means this platform cannot enforce the journal contract.
	ErrUnsupported = errors.New("coding team state: unsupported platform")
)

Functions

func IsTerminal

func IsTerminal(state State) bool

IsTerminal reports whether retained resources no longer represent an active or reviewable Team lifecycle.

Types

type Admission

type Admission string

Admission identifies the workspace baseline admitted by the user.

const (
	AdmissionClean    Admission = "clean"
	AdmissionHEADOnly Admission = "head_only"
)

Supported Team admission modes.

type AttemptBaseResource

type AttemptBaseResource struct {
	OID               string `json:"oid"`
	TreeOID           string `json:"tree_oid,omitempty"`
	OwnedRef          string `json:"owned_ref,omitempty"`
	CompositionDigest string `json:"composition_digest,omitempty"`
	DependencyDigest  string `json:"dependency_digest,omitempty"`
	DependencyCount   int    `json:"dependency_count,omitempty"`
}

AttemptBaseResource binds a Worker to the exact dependency generation used to create its Worktree. OwnedRef is set only for a generated multi-result base; prerequisite result refs remain owned by their source Attempts.

type AttemptResource

type AttemptResource struct {
	TaskID         team.TaskID           `json:"task_id"`
	AttemptID      team.AttemptID        `json:"attempt_id"`
	MemberID       team.MemberID         `json:"member_id"`
	ContinuationID continuation.ID       `json:"continuation_id"`
	Base           AttemptBaseResource   `json:"base,omitzero"`
	Session        WorkerSessionResource `json:"session,omitzero"`
	Worktree       WorktreeResource      `json:"worktree,omitzero"`
	State          AttemptState          `json:"state"`
	Cleanup        CleanupClass          `json:"cleanup"`
}

AttemptResource binds one Team task attempt to all external resources.

type AttemptState

type AttemptState string

AttemptState classifies the application resources of one Team Attempt.

const (
	AttemptPlanned       AttemptState = "planned"
	AttemptBasePrepared  AttemptState = "base_prepared"
	AttemptWorktreeReady AttemptState = "worktree_ready"
	AttemptSessionReady  AttemptState = "session_ready"
	AttemptRunning       AttemptState = "running"
	AttemptCapturing     AttemptState = "capturing"
	AttemptCaptured      AttemptState = "captured"
	AttemptTerminal      AttemptState = "terminal"
	AttemptInterrupted   AttemptState = "interrupted"
	AttemptRecoverable   AttemptState = "recoverable"
	AttemptFailed        AttemptState = "failed"
	AttemptCancelled     AttemptState = "cancelled"
	AttemptConflicted    AttemptState = "conflicted"
	AttemptCaptureFailed AttemptState = "capture_failed"
	AttemptOrphaned      AttemptState = "orphaned"
)

Attempt application resource states.

type CleanupClass

type CleanupClass string

CleanupClass states what may happen to retained resources. It is a classification only; this package never performs cleanup.

const (
	CleanupRetain      CleanupClass = "retain"
	CleanupRecoverable CleanupClass = "recoverable"
	CleanupEligible    CleanupClass = "eligible"
	CleanupPending     CleanupClass = "pending"
	CleanupComplete    CleanupClass = "complete"
	CleanupOrphaned    CleanupClass = "orphaned"
)

Cleanup classifications.

type FileIdentity

type FileIdentity struct {
	Path   string `json:"path"`
	Device uint64 `json:"device"`
	Inode  uint64 `json:"inode"`
}

FileIdentity binds a canonical absolute path to one filesystem object.

type IndexEntry

type IndexEntry struct {
	TeamID          team.ID       `json:"team_id"`
	ParentSessionID string        `json:"parent_session_id"`
	WorkspaceID     string        `json:"workspace_id"`
	Revision        team.Revision `json:"revision"`
	State           State         `json:"state"`
	Cleanup         CleanupClass  `json:"cleanup"`
	UpdatedAt       time.Time     `json:"updated_at"`
}

IndexEntry is the bounded path-free identity and lifecycle projection used for read-only workspace and parent discovery.

type IntegrationResource

type IntegrationResource struct {
	ID                 string           `json:"id"`
	AttemptIDs         []team.AttemptID `json:"attempt_ids"`
	ResourceRevision   team.Revision    `json:"resource_revision,omitempty"`
	Worktree           WorktreeResource `json:"worktree,omitzero"`
	State              IntegrationState `json:"state"`
	DiffDigest         string           `json:"diff_digest,omitempty"`
	TreeOID            string           `json:"tree_oid,omitempty"`
	CommitOID          string           `json:"commit_oid,omitempty"`
	ManifestDigest     string           `json:"manifest_digest,omitempty"`
	VerificationDigest string           `json:"verification_digest,omitempty"`
	JournalDigest      string           `json:"journal_digest,omitempty"`
	ApprovalTokenHash  string           `json:"approval_token_hash,omitempty"`
	Cleanup            CleanupClass     `json:"cleanup"`
}

IntegrationResource binds one integration attempt to selected Team results.

type IntegrationState

type IntegrationState string

IntegrationState classifies one integration resource.

const (
	IntegrationPlanned     IntegrationState = "planned"
	IntegrationReady       IntegrationState = "ready"
	IntegrationVerified    IntegrationState = "verified"
	IntegrationApproved    IntegrationState = "approved"
	IntegrationApplied     IntegrationState = "applied"
	IntegrationConflict    IntegrationState = "conflict"
	IntegrationApplying    IntegrationState = "applying"
	IntegrationInterrupted IntegrationState = "interrupted"
	IntegrationRolledBack  IntegrationState = "rolled_back"
	IntegrationFailed      IntegrationState = "failed"
	IntegrationRetained    IntegrationState = "retained"
)

Integration resource states.

type Limits

type Limits struct {
	MaxFileBytes    int64
	MaxRecordBytes  int
	MaxRecords      int
	MaxTeams        int
	MaxMembers      int
	MaxAttempts     int
	MaxIntegrations int
	MaxListResults  int
}

Limits bound resource journals and reconciliation projections.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns production resource journal limits.

type MemberResource

type MemberResource struct {
	MemberID                     team.MemberID `json:"member_id"`
	CapabilityProfileFingerprint string        `json:"capability_profile_fingerprint"`
}

MemberResource binds one logical Team member to a capability profile.

type Mutation

type Mutation struct {
	CommandID        team.CommandID `json:"command_id"`
	ExpectedRevision team.Revision  `json:"expected_revision"`
	Snapshot         Snapshot       `json:"snapshot"`
}

Mutation is one idempotent optimistic update. Snapshot.Revision must equal ExpectedRevision + 1.

type ParentResource

type ParentResource struct {
	SessionID   string       `json:"session_id"`
	WorkspaceID string       `json:"workspace_id"`
	Workspace   FileIdentity `json:"workspace"`
}

ParentResource identifies the Lead conversation and its Workspace.

type RepositoryResource

type RepositoryResource struct {
	CommonDir FileIdentity `json:"common_dir"`
	BaseOID   string       `json:"base_oid"`
	BranchRef string       `json:"branch_ref,omitempty"`
	Admission Admission    `json:"admission"`
}

RepositoryResource records the immutable Team admission baseline.

type Snapshot

type Snapshot struct {
	TeamID       team.ID               `json:"team_id"`
	Revision     team.Revision         `json:"revision"`
	State        State                 `json:"state"`
	Parent       ParentResource        `json:"parent"`
	Repository   RepositoryResource    `json:"repository"`
	Members      []MemberResource      `json:"members"`
	Attempts     []AttemptResource     `json:"attempts"`
	Integrations []IntegrationResource `json:"integrations,omitempty"`
	Cleanup      CleanupClass          `json:"cleanup"`
	CreatedAt    time.Time             `json:"created_at"`
	UpdatedAt    time.Time             `json:"updated_at"`
}

Snapshot is the latest full application resource truth for one Team.

type State

type State string

State is the application lifecycle of one Team's resources.

const (
	StateAdmitted                 State = "admitted"
	StateProvisioning             State = "provisioning"
	StateActive                   State = "active"
	StateWorkComplete             State = "work_complete"
	StateIntegrationPending       State = "integration_pending"
	StateIntegrated               State = "integrated"
	StateClosedWithoutIntegration State = "closed_without_integration"
	StateCanceling                State = "canceling"
	StateCancelled                State = "cancelled"
	StateInterrupted              State = "interrupted"
	StateBlockedIdentity          State = "blocked_identity"
	StateBlockedConflict          State = "blocked_conflict"
	StateFailed                   State = "failed"
)

Team application resource states.

type Store

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

Store persists one strict full-snapshot journal per Team.

func New

func New(directory string, limits Limits) (*Store, error)

New creates or opens a private Team resource journal directory.

func (*Store) Commit

func (s *Store) Commit(ctx context.Context, mutation Mutation) (Snapshot, error)

Commit atomically appends one idempotent optimistic resource mutation.

func (*Store) Dir

func (s *Store) Dir() string

Dir returns the absolute resource journal directory.

func (*Store) ListByParent

func (s *Store) ListByParent(
	ctx context.Context,
	parentSessionID string,
	limit int,
) ([]Snapshot, error)

ListByParent returns bounded newest-first resource projections for one Lead Session. It never repairs journals or acquires writer ownership.

func (*Store) ListByWorkspace

func (s *Store) ListByWorkspace(
	ctx context.Context,
	workspaceID string,
	limit int,
) ([]IndexEntry, error)

ListByWorkspace returns bounded newest-first path-free resource index entries. It scans journals once without repairing them or acquiring writer ownership.

func (*Store) Load

func (s *Store) Load(ctx context.Context, id team.ID) (Snapshot, error)

Load returns the latest durable snapshot without mutating or repairing its journal.

type WorkerSessionResource

type WorkerSessionResource struct {
	SessionID   string `json:"session_id"`
	WorkspaceID string `json:"workspace_id"`
}

WorkerSessionResource binds an Attempt to its real Worker Workspace.

type WorktreeResource

type WorktreeResource struct {
	ID              string       `json:"id,omitempty"`
	Workspace       FileIdentity `json:"workspace,omitzero"`
	Directory       FileIdentity `json:"directory,omitzero"`
	GitDir          FileIdentity `json:"git_dir,omitzero"`
	CommonDir       FileIdentity `json:"common_dir,omitzero"`
	ObjectFormat    string       `json:"object_format,omitempty"`
	BranchRef       string       `json:"branch_ref,omitempty"`
	BaseOID         string       `json:"base_oid,omitempty"`
	ResultRef       string       `json:"result_ref,omitempty"`
	ResultCommitOID string       `json:"result_commit_oid,omitempty"`
	LockReason      string       `json:"lock_reason,omitempty"`
	LeaseGeneration uint64       `json:"lease_generation,omitempty"`
}

WorktreeResource records application-observed Worktree identity. Empty fields are valid before the Worktree is provisioned.

Jump to

Keyboard shortcuts

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