controlstore

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncompatible    = errors.New("control store is incompatible")
	ErrMigration       = errors.New("control store migration failed")
	ErrRequestsBlocked = errors.New("control store is not ready; requests are blocked")
)
View Source
var ErrRecordNotFound = errors.New("control store record not found")
View Source
var ErrRevisionConflict = errors.New("control store revision conflict")
View Source
var ErrStateConflict = errors.New("control store state conflict")

Functions

func SourceDigest

func SourceDigest(path string) (string, error)

Types

type Config

type Config struct {
	Path    string
	Sources []Source
	Faults  Faults
}

type Confirmation

type Confirmation struct {
	ID                   string
	PluginInstanceID     string
	OwnerSessionHash     string
	OwnerUserHash        string
	OwnerEnvHash         string
	SessionChannelIDHash string
	Status               string
	ExpiresAt            int64
	RawJSON              json.RawMessage
}

type ConfirmationRevocation

type ConfirmationRevocation struct {
	SessionKey
	TeardownOperationID string
	RevokedCount        int
	RawJSON             json.RawMessage
}

type ConfirmationView

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

func (ConfirmationView) ConsumeConfirmationIntentRecord

func (v ConfirmationView) ConsumeConfirmationIntentRecord(ctx context.Context, id string, scope sessionctx.SessionScope, now time.Time) (security.ConfirmationIntentRecord, error)

func (ConfirmationView) FinalizeSessionConfirmationIntentRevocation

func (v ConfirmationView) FinalizeSessionConfirmationIntentRevocation(ctx context.Context, scope sessionctx.SessionScope, operationID string) error

func (ConfirmationView) Generation

func (v ConfirmationView) Generation() uint64

func (ConfirmationView) Get

func (ConfirmationView) ListConfirmationIntentRecords

func (v ConfirmationView) ListConfirmationIntentRecords(ctx context.Context, pluginInstanceID string) ([]security.ConfirmationIntentRecord, error)

func (ConfirmationView) Put

func (ConfirmationView) PutConfirmationIntentRecord

PutConfirmationIntentRecord implements security's durable control-store boundary without opening or initializing a second SQLite owner.

func (ConfirmationView) Resolve

func (v ConfirmationView) Resolve(ctx context.Context, id, status string, now time.Time) (Confirmation, error)

func (ConfirmationView) RevokePluginConfirmationIntentRecords

func (v ConfirmationView) RevokePluginConfirmationIntentRecords(ctx context.Context, ownerEnvHash, pluginInstanceID string) (int, error)

func (ConfirmationView) RevokeSession

func (v ConfirmationView) RevokeSession(ctx context.Context, value ConfirmationRevocation) (int, error)

func (ConfirmationView) RevokeSessionConfirmationIntentRecords

func (v ConfirmationView) RevokeSessionConfirmationIntentRecords(ctx context.Context, scope sessionctx.SessionScope, operationID string, maxRevocations int) (int, error)

type Event

type Event = executionmodel.Event

type Execution

type Execution = executionmodel.Execution

type ExecutionOwner

type ExecutionOwner struct {
	OwnerSessionHash     string
	OwnerUserHash        string
	OwnerEnvHash         string
	SessionChannelIDHash string
}

func (ExecutionOwner) Valid

func (owner ExecutionOwner) Valid() bool

type ExecutionPruneRequest

type ExecutionPruneRequest struct {
	Before                      time.Time
	Limit                       int
	MaxTerminalRecordsPerPlugin int
}

type ExecutionPruneResult

type ExecutionPruneResult struct{ Deleted int }

type ExecutionReconcileResult

type ExecutionReconcileResult struct {
	Orphaned int
	Canceled int
	Records  []execution.Execution
}

type ExecutionView

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

func (ExecutionView) Append

func (v ExecutionView) Append(ctx context.Context, event execution.Event) error

func (ExecutionView) Create

func (v ExecutionView) Create(ctx context.Context, value execution.Execution) error

func (ExecutionView) CreateOwned

func (v ExecutionView) CreateOwned(ctx context.Context, value execution.Execution, owner ExecutionOwner) error

func (ExecutionView) EventsAfter

func (v ExecutionView) EventsAfter(ctx context.Context, id string, cursor uint64, limit int) ([]execution.Event, error)

func (ExecutionView) EventsAfterOwned

func (v ExecutionView) EventsAfterOwned(ctx context.Context, id string, owner ExecutionOwner, cursor uint64, limit int) ([]execution.Event, error)

func (ExecutionView) Finish

func (v ExecutionView) Finish(ctx context.Context, id, status, failureCode string, event execution.Event, now time.Time) error

func (ExecutionView) Generation

func (v ExecutionView) Generation() uint64

func (ExecutionView) Get

func (ExecutionView) GetOwned

func (ExecutionView) GetReleaseInstall

func (v ExecutionView) GetReleaseInstall(ctx context.Context, ownerEnvHash, executionID string) (registry.ReleaseInstallOperation, error)

func (ExecutionView) GetReleaseInstallByRequest

func (v ExecutionView) GetReleaseInstallByRequest(ctx context.Context, ownerEnvHash, requestID string) (registry.ReleaseInstallOperation, error)

func (ExecutionView) List

func (v ExecutionView) List(ctx context.Context, pluginInstanceID string) ([]execution.Execution, error)

func (ExecutionView) ListOwned

func (v ExecutionView) ListOwned(ctx context.Context, pluginInstanceID string, owner ExecutionOwner, cursor uint64, limit int) ([]execution.Execution, uint64, error)

func (ExecutionView) ListReleaseInstalls

func (v ExecutionView) ListReleaseInstalls(ctx context.Context, ownerEnvHash string) ([]registry.ReleaseInstallOperation, error)

func (ExecutionView) PruneTerminal

PruneTerminal atomically removes the oldest terminal executions selected by age or the per-owner plugin cap. execution_events follow through the schema's cascading foreign key.

func (ExecutionView) ReconcileOrphans

func (v ExecutionView) ReconcileOrphans(ctx context.Context, now time.Time) (ExecutionReconcileResult, error)

ReconcileOrphans atomically terminates executions whose process-local owner cannot survive a Host restart. A pending cancellation converges to canceled; every other non-terminal execution converges to orphaned.

func (ExecutionView) RequestCancel

func (v ExecutionView) RequestCancel(ctx context.Context, id string, now time.Time) error

func (ExecutionView) RequestCancelOwned

func (v ExecutionView) RequestCancelOwned(ctx context.Context, id string, owner ExecutionOwner, now time.Time) (execution.Execution, error)

func (ExecutionView) UpdateReleaseInstall

type Faults

type Faults struct {
	AfterImport   error
	BeforePublish error
	AfterPublish  error
	SyncDirectory func(string) error
}

type Grant

type Grant struct {
	CapabilityID string
	Revision     uint64
	RawJSON      json.RawMessage
}

type PluginInstall

type PluginInstall struct {
	Record PluginRecord
	Grants []Grant
	Policy *Policy
}

type PluginRecord

type PluginRecord struct {
	OwnerEnvHash       string
	PluginInstanceID   string
	PublisherID        string
	PluginID           string
	Version            string
	ActiveFingerprint  string
	PackageSHA256      string
	ManifestSHA256     string
	EntriesSHA256      string
	State              string
	DisabledReason     string
	PolicyRevision     uint64
	ManagementRevision uint64
	RevokeEpoch        uint64
	InstalledAt        int64
	EnabledAt          *int64
	UpdatedAt          int64
	DeletedAt          *int64
	RawJSON            json.RawMessage
}

type PluginSnapshot

type PluginSnapshot struct {
	Record PluginRecord
	Grants []Grant
	Policy *Policy
}

type Policy

type Policy struct {
	Revision  uint64
	UpdatedAt int64
	RawJSON   json.RawMessage
}

type RegistryView

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

func (RegistryView) AbortInstall

func (v RegistryView) AbortInstall(ctx context.Context, ownerEnvHash, pluginInstanceID string) error

func (RegistryView) Generation

func (v RegistryView) Generation() uint64

func (RegistryView) Get

func (v RegistryView) Get(ctx context.Context, ownerEnvHash, pluginInstanceID string) (PluginSnapshot, error)

func (RegistryView) GetAuthorization

func (v RegistryView) GetAuthorization(ctx context.Context, ownerEnvHash, pluginInstanceID string) (registry.AuthorizationSnapshot, error)

func (RegistryView) GetPlugin

func (v RegistryView) GetPlugin(ctx context.Context, ownerEnvHash, pluginInstanceID string) (registry.PluginRecord, error)

func (RegistryView) Install

func (v RegistryView) Install(ctx context.Context, value PluginInstall) error

func (RegistryView) InstallExternalPackage

func (v RegistryView) InstallExternalPackage(ctx context.Context, ownerEnvHash string, req registry.InstallExternalPackageRequest) (registry.PluginRecord, error)

InstallExternalPackage commits the complete installed record and clears any previous grants and policy in the same control-DB transaction. Inspection identifiers and receipts never enter this store.

func (RegistryView) ListAuthorization

func (v RegistryView) ListAuthorization(ctx context.Context, ownerEnvHash string) ([]registry.AuthorizationSnapshot, error)

func (RegistryView) ListPlugins

func (v RegistryView) ListPlugins(ctx context.Context, ownerEnvHash string) ([]registry.PluginRecord, error)

func (RegistryView) PutPlugin

func (v RegistryView) PutPlugin(ctx context.Context, ownerEnvHash string, record registry.PluginRecord, now time.Time) (registry.PluginRecord, error)

func (RegistryView) ReplaceAuthorization

func (v RegistryView) ReplaceAuthorization(ctx context.Context, record PluginRecord, expected registry.AuthorizationRevisions, grants []Grant, policy *Policy) error

func (RegistryView) ReplaceAuthorizationSnapshot

func (v RegistryView) ReplaceAuthorizationSnapshot(ctx context.Context, snapshot registry.AuthorizationSnapshot, expected registry.AuthorizationRevisions) error

func (RegistryView) SetEnableState

func (v RegistryView) SetEnableState(ctx context.Context, ownerEnvHash, pluginInstanceID string, state registry.EnableState, reason string, now time.Time) (registry.PluginRecord, error)

type SessionFence

type SessionFence struct {
	SessionKey
	State       string
	ProofSHA256 []byte
	UpdatedAt   int64
	RawJSON     json.RawMessage
}

type SessionKey

type SessionKey struct {
	OwnerSessionHash     string
	OwnerUserHash        string
	OwnerEnvHash         string
	SessionChannelIDHash string
}

type SessionPhase

type SessionPhase struct {
	SessionKey
	Phase   string
	RawJSON json.RawMessage
}

type SessionView

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

func (SessionView) AccumulateSessionControl

func (v SessionView) AccumulateSessionControl(ctx context.Context, scope sessionctx.SessionScope, delta sessionscope.Counts, now time.Time) (sessionscope.ControlRecord, error)

func (SessionView) AccumulateSessionControlPhase

func (v SessionView) AccumulateSessionControlPhase(ctx context.Context, scope sessionctx.SessionScope, phase sessionscope.Phase, delta sessionscope.Counts, now time.Time) (sessionscope.ControlRecord, error)

func (SessionView) BeginSessionControlTeardown

func (v SessionView) BeginSessionControlTeardown(ctx context.Context, proposed sessionscope.ControlRecord, maxScopes int) (sessionscope.ControlRecord, error)

func (SessionView) DeriveSessionTeardownIdentity

func (v SessionView) DeriveSessionTeardownIdentity(ctx context.Context, key SessionKey) (string, []byte, error)

DeriveSessionTeardownIdentity returns stable opaque material for one exact four-hash session scope. The only durable secret is Host-owned metadata; per-session lifecycle state remains solely in the session fence tables.

func (SessionView) FinalizeSessionControl

func (v SessionView) FinalizeSessionControl(ctx context.Context, scope sessionctx.SessionScope, operationID string, proof []byte) error

func (SessionView) Generation

func (v SessionView) Generation() uint64

func (SessionView) Get

func (SessionView) GetSessionControlRecord

func (v SessionView) GetSessionControlRecord(ctx context.Context, scope sessionctx.SessionScope) (sessionscope.ControlRecord, error)

func (SessionView) ListSessionControlRecords

func (v SessionView) ListSessionControlRecords(ctx context.Context) ([]sessionscope.ControlRecord, error)

func (SessionView) PutFence

func (v SessionView) PutFence(ctx context.Context, value SessionFence) error

func (SessionView) PutPhase

func (v SessionView) PutPhase(ctx context.Context, value SessionPhase) error

func (SessionView) TransitionFence

func (v SessionView) TransitionFence(ctx context.Context, value SessionFence, expectedState string) error

func (SessionView) TransitionSessionControl

func (v SessionView) TransitionSessionControl(ctx context.Context, scope sessionctx.SessionScope, expected, next sessionscope.State, now time.Time) (sessionscope.ControlRecord, error)

type Source

type Source struct {
	Name    string
	Path    string
	Kind    string
	Version int
}

type Store

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

func Migrate

func Migrate(ctx context.Context, cfg Config) (*Store, error)

func Open

func Open(ctx context.Context, cfg Config) (*Store, error)

func (*Store) AppendEvent

func (s *Store) AppendEvent(ctx context.Context, event Event) error

func (*Store) BindRetained

func (s *Store) BindRetained(ctx context.Context, expected plugindata.Binding, targetPluginInstanceID string, targetExpectedManagementRevision uint64, targetShape plugindata.Shape, now time.Time) (plugindata.Binding, error)

func (*Store) CleanupExpired

func (s *Store) CleanupExpired(ctx context.Context, now time.Time, expected []plugindata.Binding) ([]plugindata.Binding, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CommitEnable

func (s *Store) CommitEnable(ctx context.Context, expectedManagementRevision uint64, expected *plugindata.Binding, next plugindata.Binding, shape plugindata.Shape, now time.Time) error

func (*Store) Confirmations

func (s *Store) Confirmations() ConfirmationView

func (*Store) CreateExecution

func (s *Store) CreateExecution(ctx context.Context, execution Execution) error

func (*Store) CreateObject

func (s *Store) CreateObject(ctx context.Context, scope sessionctx.ScopeKind, object plugindata.Object) error

func (*Store) DeleteObject

func (s *Store) DeleteObject(ctx context.Context, scope sessionctx.ScopeKind, pluginInstanceID, objectID string) error

func (*Store) DeleteRetained

func (s *Store) DeleteRetained(ctx context.Context, expected plugindata.Binding) error

func (*Store) Executions

func (s *Store) Executions() ExecutionView

func (*Store) Generation

func (s *Store) Generation() uint64

func (*Store) GetBinding

func (s *Store) GetBinding(ctx context.Context, pluginInstanceID string) (plugindata.Binding, bool, error)

func (*Store) GetExecution

func (s *Store) GetExecution(ctx context.Context, id string) (Execution, error)

func (*Store) GetObject

func (s *Store) GetObject(ctx context.Context, scope sessionctx.ScopeKind, pluginInstanceID, objectID string) (plugindata.Object, bool, error)

func (*Store) ListAllBindingsForMaintenance

func (s *Store) ListAllBindingsForMaintenance(ctx context.Context, cursor string, limit int) ([]plugindata.MaintenanceBinding, string, error)

func (*Store) ListAllObjectsForMaintenance

func (s *Store) ListAllObjectsForMaintenance(ctx context.Context, cursor string, limit int) ([]plugindata.MaintenanceObject, string, error)

func (*Store) ListBindings

func (s *Store) ListBindings(ctx context.Context, cursor string, limit int) ([]plugindata.Binding, string, error)

func (*Store) ListObjects

func (s *Store) ListObjects(ctx context.Context, scope sessionctx.ScopeKind, pluginInstanceID, cursor string, limit int) ([]plugindata.Object, string, error)

func (*Store) Ready

func (s *Store) Ready() bool

func (*Store) Registry

func (s *Store) Registry() RegistryView

func (*Store) Sessions

func (s *Store) Sessions() SessionView

func (*Store) SwapImport

func (s *Store) SwapImport(ctx context.Context, expectedManagementRevision uint64, expected *plugindata.Binding, next plugindata.Binding, shape plugindata.Shape, now time.Time) error

Jump to

Keyboard shortcuts

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