sessionscope

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxScopes = 4_096
	HardMaxScopes    = 65_536
	MinProofBytes    = 32
	MaxProofBytes    = MinProofBytes
)

Variables

View Source
var (
	ErrInvalidState              = errors.New("session scope state is invalid")
	ErrInvalidCounts             = errors.New("session scope counts are invalid")
	ErrSessionRevoked            = errors.New("session scope is revoked")
	ErrFenceCapacity             = errors.New("session fence capacity is exhausted")
	ErrScopeNotFound             = errors.New("session scope is not found")
	ErrClosedSessionProofInvalid = errors.New("closed session proof is invalid")
	ErrTeardownIdentityInvalid   = errors.New("session teardown identity is invalid")
	ErrTeardownIdentityMismatch  = errors.New("session teardown identity does not match")
	ErrStoreRequired             = errors.New("session scope store is required")
	ErrSchemaVersion             = errors.New("session scope schema version is unsupported")
)

Functions

This section is empty.

Types

type ClosedSessionProof

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

func GenerateClosedSessionProof

func GenerateClosedSessionProof() (ClosedSessionProof, error)

GenerateClosedSessionProof creates a proof with 256 bits of operating-system CSPRNG entropy. Session lifecycle adapters use this function when creating a new closed-session tombstone.

func NewClosedSessionProof

func NewClosedSessionProof(value []byte) (ClosedSessionProof, error)

NewClosedSessionProof reconstructs a proof previously generated by GenerateClosedSessionProof from trusted durable host storage. Entropy cannot be inferred from bytes after generation, so untrusted payloads must never call this constructor.

func (ClosedSessionProof) BytesForDurableStorage

func (proof ClosedSessionProof) BytesForDurableStorage() ([]byte, error)

BytesForDurableStorage returns an owned copy for the trusted host session adapter's private durable tombstone. It must never enter HTTP or plugin IPC.

func (ClosedSessionProof) Valid

func (proof ClosedSessionProof) Valid() bool

type Coordinator

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

func NewCoordinator

func NewCoordinator(store Store) (*Coordinator, error)

func (*Coordinator) BeginTeardown

func (c *Coordinator) BeginTeardown(ctx context.Context, scope sessionctx.SessionScope, identity TeardownIdentity, now time.Time) (*Teardown, Snapshot, error)

func (*Coordinator) Durable

func (c *Coordinator) Durable() bool

func (*Coordinator) Finalize

func (c *Coordinator) Finalize(ctx context.Context, scope sessionctx.SessionScope, identity TeardownIdentity) error

func (*Coordinator) ListRetained

func (c *Coordinator) ListRetained(ctx context.Context) ([]RetainedScope, error)

func (*Coordinator) Reserve

func (c *Coordinator) Reserve(ctx context.Context, scope sessionctx.SessionScope) (*Reservation, error)

func (*Coordinator) Snapshot

func (c *Coordinator) Snapshot(ctx context.Context, scope sessionctx.SessionScope) (Snapshot, error)

type Counts

type Counts struct {
	Surfaces              uint64 `json:"surfaces"`
	AssetTickets          uint64 `json:"asset_tickets"`
	AssetSessions         uint64 `json:"asset_sessions"`
	PluginGatewayTokens   uint64 `json:"plugin_gateway_tokens"`
	ConfirmationTokens    uint64 `json:"confirmation_tokens"`
	StreamTickets         uint64 `json:"stream_tickets"`
	HandleGrants          uint64 `json:"handle_grants"`
	Confirmations         uint64 `json:"confirmations"`
	Operations            uint64 `json:"operations"`
	Streams               uint64 `json:"streams"`
	RuntimeExecutions     uint64 `json:"runtime_executions"`
	ActiveNetworkRequests uint64 `json:"active_network_requests"`
	Sockets               uint64 `json:"sockets"`
	NetworkStreams        uint64 `json:"network_streams"`
	StorageHostcalls      uint64 `json:"storage_hostcalls"`
}

func (Counts) Add

func (counts Counts) Add(delta Counts) (Counts, error)

func (Counts) Valid

func (counts Counts) Valid() bool

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore(options StoreOptions) (*MemoryStore, error)

func (*MemoryStore) Accumulate

func (s *MemoryStore) Accumulate(ctx context.Context, scope sessionctx.SessionScope, delta Counts, now time.Time) (record, error)

func (*MemoryStore) AccumulatePhase

func (s *MemoryStore) AccumulatePhase(ctx context.Context, scope sessionctx.SessionScope, phase Phase, delta Counts, now time.Time) (record, error)

func (*MemoryStore) BeginTeardown

func (s *MemoryStore) BeginTeardown(
	ctx context.Context,
	scope sessionctx.SessionScope,
	operationID string,
	proof [sha256.Size]byte,
	now time.Time,
) (record, error)

func (*MemoryStore) Durable

func (s *MemoryStore) Durable() bool

func (*MemoryStore) Finalize

func (s *MemoryStore) Finalize(ctx context.Context, scope sessionctx.SessionScope, operationID string, proof [sha256.Size]byte) error

func (*MemoryStore) Get

func (s *MemoryStore) Get(ctx context.Context, scope sessionctx.SessionScope) (record, error)

func (*MemoryStore) ListRetained

func (s *MemoryStore) ListRetained(ctx context.Context) ([]record, error)

func (*MemoryStore) MarkComplete

func (s *MemoryStore) MarkComplete(ctx context.Context, scope sessionctx.SessionScope, now time.Time) (record, error)

func (*MemoryStore) MarkIncomplete

func (s *MemoryStore) MarkIncomplete(ctx context.Context, scope sessionctx.SessionScope, now time.Time) (record, error)

type Phase

type Phase string
const (
	PhaseBridge       Phase = "bridge"
	PhaseConfirmation Phase = "confirmation"
	PhaseExecution    Phase = "execution"
	PhaseOperation    Phase = "operation"
	PhaseStream       Phase = "stream"
	PhaseRuntime      Phase = "runtime"
)

func (Phase) Valid

func (phase Phase) Valid() bool

type Reservation

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

func (*Reservation) Release

func (reservation *Reservation) Release()

type RetainedScope

type RetainedScope struct {
	SessionScope sessionctx.SessionScope `json:"-"`
	Snapshot     Snapshot                `json:"snapshot"`
	// contains filtered or unexported fields
}

RetainedScope is the durable, owner-private startup reconciliation view for fenced session scopes. It never contains the teardown operation ID or proof.

func (RetainedScope) MatchesIdentity

func (retained RetainedScope) MatchesIdentity(identity TeardownIdentity) bool

MatchesIdentity verifies that a trusted host-side teardown identity is bound to this exact durable fence without exposing the operation ID or proof hash.

type SQLiteStore

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

func NewSQLiteStore

func NewSQLiteStore(ctx context.Context, path string, options StoreOptions) (*SQLiteStore, error)

func (*SQLiteStore) Accumulate

func (s *SQLiteStore) Accumulate(ctx context.Context, scope sessionctx.SessionScope, delta Counts, now time.Time) (record, error)

func (*SQLiteStore) AccumulatePhase

func (s *SQLiteStore) AccumulatePhase(ctx context.Context, scope sessionctx.SessionScope, phase Phase, delta Counts, now time.Time) (record, error)

func (*SQLiteStore) BeginTeardown

func (s *SQLiteStore) BeginTeardown(
	ctx context.Context,
	scope sessionctx.SessionScope,
	operationID string,
	proof [sha256.Size]byte,
	now time.Time,
) (record, error)

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) Durable

func (s *SQLiteStore) Durable() bool

func (*SQLiteStore) Finalize

func (s *SQLiteStore) Finalize(ctx context.Context, scope sessionctx.SessionScope, operationID string, proof [sha256.Size]byte) error

func (*SQLiteStore) Get

func (s *SQLiteStore) Get(ctx context.Context, scope sessionctx.SessionScope) (record, error)

func (*SQLiteStore) ListRetained

func (s *SQLiteStore) ListRetained(ctx context.Context) ([]record, error)

func (*SQLiteStore) MarkComplete

func (s *SQLiteStore) MarkComplete(ctx context.Context, scope sessionctx.SessionScope, now time.Time) (record, error)

func (*SQLiteStore) MarkIncomplete

func (s *SQLiteStore) MarkIncomplete(ctx context.Context, scope sessionctx.SessionScope, now time.Time) (record, error)

type Snapshot

type Snapshot struct {
	State    State  `json:"state"`
	Fenced   bool   `json:"fenced"`
	Complete bool   `json:"complete"`
	Counts   Counts `json:"counts"`
}

type State

type State string
const (
	StateActive     State = "active"
	StateDraining   State = "draining"
	StateIncomplete State = "incomplete"
	StateComplete   State = "complete"
)

func (State) Valid

func (state State) Valid() bool

type Store

type Store interface {
	Durable() bool
	Get(context.Context, sessionctx.SessionScope) (record, error)
	ListRetained(context.Context) ([]record, error)
	BeginTeardown(context.Context, sessionctx.SessionScope, string, [sha256.Size]byte, time.Time) (record, error)
	Accumulate(context.Context, sessionctx.SessionScope, Counts, time.Time) (record, error)
	AccumulatePhase(context.Context, sessionctx.SessionScope, Phase, Counts, time.Time) (record, error)
	MarkIncomplete(context.Context, sessionctx.SessionScope, time.Time) (record, error)
	MarkComplete(context.Context, sessionctx.SessionScope, time.Time) (record, error)
	Finalize(context.Context, sessionctx.SessionScope, string, [sha256.Size]byte) error
}

type StoreOptions

type StoreOptions struct {
	MaxScopes int
}

type Teardown

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

func (*Teardown) Accumulate

func (teardown *Teardown) Accumulate(ctx context.Context, delta Counts) (Snapshot, error)

func (*Teardown) AccumulatePhase

func (teardown *Teardown) AccumulatePhase(ctx context.Context, phase Phase, delta Counts) (Snapshot, error)

func (*Teardown) MarkComplete

func (teardown *Teardown) MarkComplete(ctx context.Context, now time.Time) (Snapshot, error)

func (*Teardown) MarkIncomplete

func (teardown *Teardown) MarkIncomplete(ctx context.Context, now time.Time) (Snapshot, error)

func (*Teardown) Release

func (teardown *Teardown) Release()

type TeardownIdentity

type TeardownIdentity struct {
	OperationID string `json:"-"`
	// contains filtered or unexported fields
}

func NewTeardownIdentity

func NewTeardownIdentity(operationID string, proof ClosedSessionProof) (TeardownIdentity, error)

func (TeardownIdentity) Matches

func (identity TeardownIdentity) Matches(other TeardownIdentity) bool

func (TeardownIdentity) Valid

func (identity TeardownIdentity) Valid() bool

Jump to

Keyboard shortcuts

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