Documentation
¶
Overview ¶
Package sessionpg stores Sessions in PostgreSQL and decides nothing. WithSession runs a Session transaction: it locks the Session, runs the operation and prunes the journal. Inside a Session transaction, on its queries, the participants load the facts the sessions and items decisions read and apply what they decide: they lock the Session, allocate event sequence positions, event IDs, Item positions and output indexes, and write the public change journal, a Turn's execution journal and its counters, Items, Turn usage, Subagent bindings, child Turns and child Items, Artifact settlement, Environment state, input reservations and devices. SessionTx binds a Session to its caller's transaction for the sessions procedures. Store is the pooled adapter: it stores the sessions.Service use cases and serves the Session reads. Execution is the lease-bound adapter: it runs the sessions.ExecutionOperations transactions on the execution lease.
Index ¶
- func AppendChanges(ctx context.Context, q *sqlc.Queries, session pgtype.UUID, ...) error
- func ApplyTurnEnd(ctx context.Context, q *sqlc.Queries, session, turn pgtype.UUID, ...) error
- func CreateSessionEnvironment(ctx context.Context, q *sqlc.Queries, session pgtype.UUID) error
- func DeviceLookup(tenantID, id string) (sqlc.GetDeviceParams, error)
- func EnvironmentFromRow(row sqlc.Environment, tenant pgtype.UUID, configuration []byte, err error) (sessions.Environment, error)
- func LoadEnding(ctx context.Context, q *sqlc.Queries, session, turn pgtype.UUID) (sessions.Ending, error)
- func LoadEnvironment(ctx context.Context, q *sqlc.Queries, tenant, environment string) (sessions.Environment, error)
- func LoadEnvironmentInput(ctx context.Context, q *sqlc.Queries, session pgtype.UUID) (*sessions.EnvironmentInputState, error)
- func LoadRequiredActions(ctx context.Context, q *sqlc.Queries, session pgtype.UUID, turn sessions.Turn) ([]v1.FunctionCallAction, error)
- func LoadUsage(ctx context.Context, q *sqlc.Queries, session pgtype.UUID) (json.RawMessage, error)
- func LockSession(ctx context.Context, q *sqlc.Queries, tenant, session pgtype.UUID) (sessions.LockedSession, error)
- func PruneChanges(ctx context.Context, q *sqlc.Queries, session pgtype.UUID) error
- func SessionFromRow(row sqlc.Session) (sessions.Session, error)
- func TurnFromRow(row sqlc.Turn) sessions.Turn
- func TurnLookup(tenantID, sessionID, turnID string) (sqlc.GetTurnParams, error)
- func WithSession(ctx context.Context, runner pgunit.Transactor, tenant, session pgtype.UUID, ...) error
- type Execution
- func (e *Execution) ListEnvironmentConnections(ctx context.Context, after string) ([]sessions.EnvironmentKey, error)
- func (e *Execution) WithConnection(ctx context.Context, tenant, environment string, ...) error
- func (e *Execution) WithDeviceBinding(ctx context.Context, tenant, session string, ...) error
- func (e *Execution) WithFileWriteReservation(ctx context.Context, tenant, environment string, ...) error
- func (e *Execution) WithFileWriteSettlement(ctx context.Context, tenant, environment, write string, ...) error
- func (e *Execution) WithFunctionTurn(ctx context.Context, tenant, session, turn string, ...) error
- func (e *Execution) WithInitialization(ctx context.Context, tenant, session string, ...) error
- func (e *Execution) WithTurnJournal(ctx context.Context, tenantID, sessionID string, ...) error
- type SessionTx
- func (t *SessionTx) AppendChanges(ctx context.Context, changes ...sessions.SessionChange) error
- func (t *SessionTx) ApplyFunctionResult(ctx context.Context, turn, call string) error
- func (t *SessionTx) ApplyFunctionTurnStatus(ctx context.Context, turn, expected, status string) (sessions.Turn, error)
- func (t *SessionTx) ApplySubagentLifecycle(ctx context.Context, subagent string, lifecycle sessions.SubagentLifecycle) error
- func (t *SessionTx) ApplyTurnEnd(ctx context.Context, turn string, end sessions.TurnEnd) error
- func (t *SessionTx) BindDevice(ctx context.Context, device string) error
- func (t *SessionTx) CancelPendingInput(ctx context.Context) error
- func (t *SessionTx) CountEvents(ctx context.Context, turn string, count int32, size int64) error
- func (t *SessionTx) CreateFunctionCall(ctx context.Context, turn string, call sessions.FunctionCall) error
- func (t *SessionTx) ExpireEnvironment(ctx context.Context, environment string) error
- func (t *SessionTx) FailPendingInput(ctx context.Context) error
- func (t *SessionTx) FindResultTurn(ctx context.Context, turn string) (sessions.Turn, bool, error)
- func (t *SessionTx) HasFunctionCall(ctx context.Context, call string) (bool, error)
- func (t *SessionTx) InsertEnvironmentDevice(ctx context.Context, device sessions.ExecutionDevice, credentialHash string) error
- func (t *SessionTx) InsertEvent(ctx context.Context, turn string, ordinal int32, event sessions.ExecutionEvent) error
- func (t *SessionTx) InsertEvents(ctx context.Context, turn string, first int32, ...) error
- func (t *SessionTx) LoadActiveTurn(ctx context.Context) (sessions.Turn, bool, error)
- func (t *SessionTx) LoadBoundDevice(ctx context.Context) (bool, error)
- func (t *SessionTx) LoadChildItem(ctx context.Context, subagent, item string, candidate json.RawMessage) (sessions.StoredChildItem, bool, error)
- func (t *SessionTx) LoadChildTurn(ctx context.Context, subagent, id string) (sessions.ChildTurn, bool, error)
- func (t *SessionTx) LoadComputeSuspension(ctx context.Context) (bool, error)
- func (t *SessionTx) LoadDevice(ctx context.Context, device string) (bool, error)
- func (t *SessionTx) LoadEnding(ctx context.Context, turn string) (sessions.Ending, error)
- func (t *SessionTx) LoadEnvironment(ctx context.Context) (sessions.Environment, error)
- func (t *SessionTx) LoadEnvironmentInput(ctx context.Context) (*sessions.EnvironmentInputState, error)
- func (t *SessionTx) LoadEventSources(ctx context.Context, turn string, first int32) ([]sessions.Source, error)
- func (t *SessionTx) LoadFunctionCall(ctx context.Context, turn, call string) (sessions.FunctionCall, bool, error)
- func (t *SessionTx) LoadInputSource(ctx context.Context, sequence int64) (sessions.Source, error)
- func (t *SessionTx) LoadItem(ctx context.Context, turnID string, update items.Update) (items.Stored, error)
- func (t *SessionTx) LoadJournalTurn(ctx context.Context, turn string) (sessions.JournalTurn, bool, error)
- func (t *SessionTx) LoadNativeSubagent(ctx context.Context, native string) (sessions.NativeSubagent, bool, error)
- func (t *SessionTx) LoadPendingFileWrite(ctx context.Context) (bool, error)
- func (t *SessionTx) LoadPendingFunctionCalls(ctx context.Context, turn string) ([]sessions.FunctionCall, error)
- func (t *SessionTx) LoadPublicSubagent(ctx context.Context, id string) (v1.Subagent, error)
- func (t *SessionTx) LoadRootAgent(ctx context.Context) (string, error)
- func (t *SessionTx) LoadTurn(ctx context.Context, turn string) (sessions.Turn, error)
- func (t *SessionTx) LoadUsage(ctx context.Context) (json.RawMessage, error)
- func (t *SessionTx) MatchEvents(ctx context.Context, turn string, first int32, ...) (bool, error)
- func (t *SessionTx) MatchFunctionCall(ctx context.Context, turn string, call sessions.FunctionCall) (sessions.FunctionCallMatch, error)
- func (t *SessionTx) MatchFunctionResult(ctx context.Context, turn, call string, result json.RawMessage) (sessions.FunctionResultMatch, error)
- func (t *SessionTx) PublishSubagent(ctx context.Context, subagent string, name, instructions *string) error
- func (t *SessionTx) PutChildItem(ctx context.Context, item sessions.ChildItem) error
- func (t *SessionTx) PutChildTurn(ctx context.Context, turn sessions.ChildTurn) error
- func (t *SessionTx) PutItem(ctx context.Context, turnID string, created time.Time, change items.Change) (*int32, error)
- func (t *SessionTx) PutSubagentEffect(ctx context.Context, effect string, payload json.RawMessage) (bool, error)
- func (t *SessionTx) PutSubagentIdentity(ctx context.Context, identity sessions.SubagentIdentity) (string, error)
- func (t *SessionTx) PutTurnUsage(ctx context.Context, turnID string, usage v1.TokenUsage) error
- func (t *SessionTx) RecordEnvironmentFailure(ctx context.Context, environment, reason string, ...) (time.Time, error)
- func (t *SessionTx) RecordTerminalActivity(ctx context.Context) error
- func (t *SessionTx) RequestTurnCancel(ctx context.Context, turn string) error
- func (t *SessionTx) SubmitFunctionResult(ctx context.Context, turn, call string, result json.RawMessage) error
- type Store
- func (s *Store) AuthenticateEnvironmentExecutor(ctx context.Context, environment, digest string) (string, error)
- func (s *Store) CreateDevice(ctx context.Context, tenant string, registration sessions.DeviceRegistration) (sessions.ExecutionDevice, error)
- func (s *Store) DeleteSessionArtifact(ctx context.Context, tenantID, sessionID, artifactID string) error
- func (s *Store) ExecutorProjectExists(ctx context.Context, scope identity.ProjectScope) (bool, error)
- func (s *Store) GetDeviceCredential(ctx context.Context, device string) (runtimedevice.Credential, bool, error)
- func (s *Store) GetEnvironment(ctx context.Context, tenant, environment string) (sessions.Environment, error)
- func (s *Store) GetSessionArtifact(ctx context.Context, tenantID, sessionID, artifactID string) (sessions.Artifact, error)
- func (s *Store) GetSessionDevice(ctx context.Context, tenant, session string) (sessions.ExecutionDevice, error)
- func (s *Store) GetSessionEnvironment(ctx context.Context, tenant, session string) (sessions.Environment, error)
- func (s *Store) GetSessionRuntimeDevice(ctx context.Context, tenant, session string) (sessions.ExecutionDevice, error)
- func (s *Store) GetSubagent(ctx context.Context, tenantID, sessionID, subagentID string) (v1.Subagent, error)
- func (s *Store) GetSubagentTurn(ctx context.Context, tenantID, sessionID, subagentID, turnID string) (v1.Turn, error)
- func (s *Store) ListEnrolledRuntimeBindings(ctx context.Context) ([]sessions.EnrolledRuntimeBinding, error)
- func (s *Store) ListEnvironmentInitializations(ctx context.Context, after string) ([]sessions.EnvironmentInitialization, error)
- func (s *Store) ListItems(ctx context.Context, tenantID, sessionID, cursor string, limit int, ...) (sessions.ItemPage, error)
- func (s *Store) ListSessionArtifacts(ctx context.Context, tenantID, sessionID, environmentID, cursor string, ...) (sessions.ArtifactPage, error)
- func (s *Store) ListSubagentItems(ctx context.Context, tenantID, sessionID, subagentID, cursor string, limit int, ...) (v1.ItemList, error)
- func (s *Store) ListSubagentTurnItems(ctx context.Context, tenantID, sessionID, subagentID, turnID, cursor string, ...) (v1.ItemList, error)
- func (s *Store) ListSubagentTurns(ctx context.Context, tenantID, sessionID, subagentID, cursor string, limit int, ...) (v1.TurnList, error)
- func (s *Store) ListSubagents(ctx context.Context, tenantID, sessionID, cursor string, limit int, ...) (v1.SubagentList, error)
- func (s *Store) LoadExecutorCredentialRestriction(ctx context.Context, principal identity.Principal, key string) (string, error)
- func (s *Store) LoadProjectArchived(ctx context.Context, tenant string) (bool, error)
- func (s *Store) ProjectExecutorCredentialState(ctx context.Context, project identity.Principal, environment string) (sessions.ExecutorCredentialState, error)
- func (s *Store) ReadEnvironmentSetup(ctx context.Context, tenant, session string) (environmentconfig.Setup, error)
- func (s *Store) ReadInitialEnvironmentFile(ctx context.Context, tenant, session string, position int) (environmentconfig.InitialFileMetadata, []byte, error)
- func (s *Store) ReadSessionArtifact(ctx context.Context, tenantID, sessionID, artifactID string, ...) error
- func (s *Store) RevokeDevice(ctx context.Context, tenant, device string) error
- func (s *Store) SignInstallation(_ context.Context, payload string) (string, error)
- func (s *Store) TouchAuthenticatedDevice(ctx context.Context, device, credentialHash string) (bool, error)
- func (s *Store) TouchDevice(ctx context.Context, device string) (bool, error)
- func (s *Store) VerifyInstallation(_ context.Context, payload, signature string) error
- func (s *Store) WithArtifactStaging(ctx context.Context, key sessions.ArtifactStagingKey, ...) error
- func (s *Store) WithEnrollment(ctx context.Context, environment, credentialHash string, ...) error
- func (s *Store) WithEnvironmentExecutorCredentials(ctx context.Context, tenant, environment string, ...) error
- func (s *Store) WithExecutorCredentials(ctx context.Context, tenant string, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendChanges ¶
func AppendChanges(ctx context.Context, q *sqlc.Queries, session pgtype.UUID, changes ...sessions.SessionChange) error
AppendChanges journals public changes in order. Each gets a new event ID and the Session's next sequence position, and commits with the caller's state. Text PostgreSQL cannot store is textvalue.ErrUnstorable.
func ApplyTurnEnd ¶
func ApplyTurnEnd(ctx context.Context, q *sqlc.Queries, session, turn pgtype.UUID, end sessions.TurnEnd) error
ApplyTurnEnd writes what a Turn that ended settles, in the order sessions.TurnEnd lists: terminal activity, Artifacts, finished Items and then the public changes.
func CreateSessionEnvironment ¶
CreateSessionEnvironment creates, on q, the Environment of a new Session whose configuration has one, as sessions.CreatesEnvironment decides. Its preparation is pending when the Session froze a setup or initial files, and complete otherwise, so it runs after those are saved.
func DeviceLookup ¶
func DeviceLookup(tenantID, id string) (sqlc.GetDeviceParams, error)
DeviceLookup parses a tenant and the internal identifier of one of its resources, such as a device, Session or Environment; a malformed one is sessions.ErrInvalidInput.
func EnvironmentFromRow ¶
func EnvironmentFromRow(row sqlc.Environment, tenant pgtype.UUID, configuration []byte, err error) (sessions.Environment, error)
EnvironmentFromRow maps a stored Environment of the tenant with its normalized configuration snapshot, from the result of the query that read it: no rows is sessions.ErrNotFound.
func LoadEnding ¶
func LoadEnding(ctx context.Context, q *sqlc.Queries, session, turn pgtype.UUID) (sessions.Ending, error)
LoadEnding reads the facts sessions.EndTurn settles a Turn that ended with: its Items still in progress and the Session's public usage.
func LoadEnvironment ¶
func LoadEnvironment(ctx context.Context, q *sqlc.Queries, tenant, environment string) (sessions.Environment, error)
LoadEnvironment reads, on q, the tenant's Environment of a Session that was not publicly deleted. A malformed tenant is sessions.ErrInvalidInput, and a malformed Environment ID a missing Environment, sessions.ErrNotFound. Other adapters read the Environment of their operation with it.
func LoadEnvironmentInput ¶
func LoadEnvironmentInput(ctx context.Context, q *sqlc.Queries, session pgtype.UUID) (*sessions.EnvironmentInputState, error)
LoadEnvironmentInput reads the Session's latest Environment input reservation that no Turn has admitted or superseded, with the facts of its Environment, and nil when there is none. sessions.InputActivity projects it.
func LoadRequiredActions ¶
func LoadRequiredActions(ctx context.Context, q *sqlc.Queries, session pgtype.UUID, turn sessions.Turn) ([]v1.FunctionCallAction, error)
LoadRequiredActions reads the required actions of the Session's Turn within the caller's snapshot, as sessions.LoadRequiredActions selects them.
func LoadUsage ¶
LoadUsage reads the Session's public usage: the sum of its root Turns once every one has ended with recorded usage, and null otherwise.
func LockSession ¶
func LockSession(ctx context.Context, q *sqlc.Queries, tenant, session pgtype.UUID) (sessions.LockedSession, error)
LockSession locks the tenant's Session row, including a publicly deleted one, and returns what the lock shows. Every Session write takes this lock first, which orders input admission against completion and cancellation across service processes. A missing Session is sessions.ErrNotFound.
func PruneChanges ¶
PruneChanges drops the Session's journaled changes beyond the sessions retention bounds. Callers run it after the transaction's last change.
func SessionFromRow ¶
SessionFromRow maps a stored Session with its creator, normalized configuration and metadata.
func TurnLookup ¶
func TurnLookup(tenantID, sessionID, turnID string) (sqlc.GetTurnParams, error)
TurnLookup parses the internal identifiers of a tenant's Turn; a malformed one is sessions.ErrInvalidInput.
func WithSession ¶
func WithSession(ctx context.Context, runner pgunit.Transactor, tenant, session pgtype.UUID, apply func(context.Context, *sqlc.Queries, sessions.LockedSession) error) error
WithSession runs one Session transaction on runner: it locks the tenant's Session, runs apply on the transaction's queries with what the lock shows, then prunes the Session's journal, and commits only when all of them succeed. apply applies the public view itself, with sessions.LockedSession.Public. It is the transaction runner of Session operations; other adapters lock the Session inside their own transaction with LockSession.
Types ¶
type Execution ¶
type Execution struct {
// contains filtered or unexported fields
}
Execution is the Session storage of the execution owner. Every transaction runs on the connection that holds the execution lease, which the owner acquired and closes; losing or closing the lease fails the operation and never falls back to the pool.
func NewExecution ¶
NewExecution builds the Session execution storage on a lease it borrows.
func (*Execution) ListEnvironmentConnections ¶
func (*Execution) WithConnection ¶
func (e *Execution) WithConnection(ctx context.Context, tenant, environment string, apply func(context.Context, sessions.ConnectionTx, sessions.LockedSession) error) error
WithConnection reads the Environment in the transaction before it locks the Environment's Session.
func (*Execution) WithDeviceBinding ¶
func (*Execution) WithFileWriteReservation ¶
func (e *Execution) WithFileWriteReservation(ctx context.Context, tenant, environment string, apply func(context.Context, sessions.FileWriteReservationTx, sessions.Environment, sessions.LockedSession) error) error
WithFileWriteReservation reads the Environment in the transaction before it locks the Environment's Session.
func (*Execution) WithFileWriteSettlement ¶
func (e *Execution) WithFileWriteSettlement(ctx context.Context, tenant, environment, write string, apply func(context.Context, sessions.FileWriteSettlementTx) error) error
WithFileWriteSettlement reads the write in the transaction before it locks the Session of the write's Environment, whether or not that Session was publicly deleted. A malformed ID is sessions.ErrInvalidInput and an unknown write sessions.ErrNotFound.
func (*Execution) WithFunctionTurn ¶
func (*Execution) WithInitialization ¶
type SessionTx ¶
type SessionTx struct {
// contains filtered or unexported fields
}
SessionTx is one Session inside its caller's transaction. It implements the transaction interfaces of the sessions procedures by loading the facts they read and applying what they decide, and decides nothing itself.
The caller guarantees what the procedures assume: the queries are bound to the caller's open transaction, the tenant owns the Session, the transaction already holds the Session lock (LockSession), and the operation that owns the transaction supplies its authority, such as the execution lease. A SessionTx never begins or commits a transaction, never chooses a pool or the lease, and is not used after the transaction callback it was bound in returns.
func BindSession ¶
BindSession binds the tenant's Session to the caller's transaction-bound queries.
func (*SessionTx) AppendChanges ¶
func (*SessionTx) ApplyFunctionResult ¶
func (*SessionTx) ApplyFunctionTurnStatus ¶
func (*SessionTx) ApplySubagentLifecycle ¶
func (*SessionTx) ApplyTurnEnd ¶
func (*SessionTx) BindDevice ¶
BindDevice binds the device to the Session; a Session bound to another device is sessions.ErrDeviceBindingConflict.
func (*SessionTx) CancelPendingInput ¶
func (*SessionTx) CountEvents ¶
CountEvents adds entries to the Turn's journal counters.
func (*SessionTx) CreateFunctionCall ¶
func (*SessionTx) ExpireEnvironment ¶
ExpireEnvironment expires the Environment only while it is the Session's; another Environment is sessions.ErrNotFound and changes nothing.
func (*SessionTx) FailPendingInput ¶
func (*SessionTx) FindResultTurn ¶
func (*SessionTx) HasFunctionCall ¶
func (*SessionTx) InsertEnvironmentDevice ¶
func (t *SessionTx) InsertEnvironmentDevice(ctx context.Context, device sessions.ExecutionDevice, credentialHash string) error
InsertEnvironmentDevice inserts the device only for the Session's own hosted Environment. The insert takes no row when the Environment already has a device, including one a concurrent transaction inserted first, or cannot take one: that is sessions.ErrDeviceBindingConflict.
func (*SessionTx) InsertEvent ¶
func (t *SessionTx) InsertEvent(ctx context.Context, turn string, ordinal int32, event sessions.ExecutionEvent) error
InsertEvent records event at the Turn's journal position ordinal.
func (*SessionTx) InsertEvents ¶
func (t *SessionTx) InsertEvents(ctx context.Context, turn string, first int32, events []sessions.ExecutionEvent) error
InsertEvents records events at the Turn's journal positions from first. The database stamps each entry.
func (*SessionTx) LoadActiveTurn ¶
func (*SessionTx) LoadBoundDevice ¶
func (*SessionTx) LoadChildItem ¶
func (t *SessionTx) LoadChildItem(ctx context.Context, subagent, item string, candidate json.RawMessage) (sessions.StoredChildItem, bool, error)
func (*SessionTx) LoadChildTurn ¶
func (*SessionTx) LoadComputeSuspension ¶
func (*SessionTx) LoadDevice ¶
func (*SessionTx) LoadEnding ¶
func (*SessionTx) LoadEnvironment ¶
func (*SessionTx) LoadEnvironmentInput ¶
func (*SessionTx) LoadEventSources ¶
func (t *SessionTx) LoadEventSources(ctx context.Context, turn string, first int32) ([]sessions.Source, error)
LoadEventSources reads the Turn's journal entries from first, in order.
func (*SessionTx) LoadFunctionCall ¶
func (*SessionTx) LoadInputSource ¶
LoadInputSource reads the Session's admitted input at sequence.
func (*SessionTx) LoadItem ¶
func (t *SessionTx) LoadItem(ctx context.Context, turnID string, update items.Update) (items.Stored, error)
LoadItem reads what the Session holds for update's Item: the stored Item and, when update asks for them, whether the Turn has another assistant message and the result the application saved for the call.
func (*SessionTx) LoadJournalTurn ¶
func (t *SessionTx) LoadJournalTurn(ctx context.Context, turn string) (sessions.JournalTurn, bool, error)
LoadJournalTurn reads the tenant's Turn in the Session.
func (*SessionTx) LoadNativeSubagent ¶
func (*SessionTx) LoadPendingFileWrite ¶
func (*SessionTx) LoadPendingFunctionCalls ¶
func (*SessionTx) LoadPublicSubagent ¶
func (*SessionTx) LoadRootAgent ¶
func (*SessionTx) MatchEvents ¶
func (t *SessionTx) MatchEvents(ctx context.Context, turn string, first int32, events []sessions.ExecutionEvent) (bool, error)
MatchEvents compares the Turn's journal entries from first with events.
func (*SessionTx) MatchFunctionCall ¶
func (t *SessionTx) MatchFunctionCall(ctx context.Context, turn string, call sessions.FunctionCall) (sessions.FunctionCallMatch, error)
func (*SessionTx) MatchFunctionResult ¶
func (t *SessionTx) MatchFunctionResult(ctx context.Context, turn, call string, result json.RawMessage) (sessions.FunctionResultMatch, error)
func (*SessionTx) PublishSubagent ¶
func (*SessionTx) PutChildItem ¶
PutChildItem stores a Subagent Item; a new output Item takes its Turn's next output index.
func (*SessionTx) PutChildTurn ¶
func (*SessionTx) PutItem ¶
func (t *SessionTx) PutItem(ctx context.Context, turnID string, created time.Time, change items.Change) (*int32, error)
PutItem stores a decided Item change. A new Item takes the Session's next position and, when it is output, the Turn's next output index; an update keeps both, and its first terminal status records when it settled. PutItem returns the Item's output index, nil when it has none, and textvalue.ErrUnstorable for text PostgreSQL cannot store.
func (*SessionTx) PutSubagentEffect ¶
func (*SessionTx) PutSubagentIdentity ¶
func (t *SessionTx) PutSubagentIdentity(ctx context.Context, identity sessions.SubagentIdentity) (string, error)
PutSubagentIdentity allocates the Subagent ID of a new binding.
func (*SessionTx) PutTurnUsage ¶
PutTurnUsage replaces a root Turn's recorded usage with a measurement.
func (*SessionTx) RecordEnvironmentFailure ¶
func (t *SessionTx) RecordEnvironmentFailure(ctx context.Context, environment, reason string, detail *sessions.ProvisioningFailureDetail) (time.Time, error)
RecordEnvironmentFailure fails the Environment only while it is the Session's and still live; otherwise it changes nothing and returns pgx.ErrNoRows.
func (*SessionTx) RecordTerminalActivity ¶
RecordTerminalActivity marks the Session's running managed compute active at the database's commit clock.
func (*SessionTx) RequestTurnCancel ¶
func (*SessionTx) SubmitFunctionResult ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the pooled Session adapter: the storage of the Session use cases and the Session reads. cipher opens the Session data frozen at creation and signs installation authorizations; it is nil on a service without a credential key.
func New ¶
func New(units *pgunit.Pool, cipher *credentialcrypto.Cipher) *Store
New builds the pooled Session adapter on units, opening frozen Session data and signing installation authorizations with cipher.
func (*Store) AuthenticateEnvironmentExecutor ¶
func (*Store) CreateDevice ¶
func (s *Store) CreateDevice(ctx context.Context, tenant string, registration sessions.DeviceRegistration) (sessions.ExecutionDevice, error)
func (*Store) DeleteSessionArtifact ¶
func (*Store) ExecutorProjectExists ¶
func (*Store) GetDeviceCredential ¶
func (s *Store) GetDeviceCredential(ctx context.Context, device string) (runtimedevice.Credential, bool, error)
GetDeviceCredential reads a device's credential for the Runtime gateway. A malformed or unknown device has no credential. The standalone service assigns no product WorkspaceID.
func (*Store) GetEnvironment ¶
func (*Store) GetSessionArtifact ¶
func (*Store) GetSessionDevice ¶
func (*Store) GetSessionEnvironment ¶
func (*Store) GetSessionRuntimeDevice ¶
func (*Store) GetSubagent ¶
func (*Store) GetSubagentTurn ¶
func (*Store) ListEnrolledRuntimeBindings ¶
func (*Store) ListEnvironmentInitializations ¶
func (*Store) ListSessionArtifacts ¶
func (*Store) ListSubagentItems ¶
func (*Store) ListSubagentTurnItems ¶
func (*Store) ListSubagentTurns ¶
func (*Store) ListSubagents ¶
func (*Store) LoadExecutorCredentialRestriction ¶
func (*Store) LoadProjectArchived ¶
func (*Store) ProjectExecutorCredentialState ¶
func (*Store) ReadEnvironmentSetup ¶
func (s *Store) ReadEnvironmentSetup(ctx context.Context, tenant, session string) (environmentconfig.Setup, error)
ReadEnvironmentSetup opens the setup the Session froze at creation. Frozen data that does not open, decode or validate is corrupt stored data, never the caller's input, so it is an internal error.
func (*Store) ReadInitialEnvironmentFile ¶
func (s *Store) ReadInitialEnvironmentFile(ctx context.Context, tenant, session string, position int) (environmentconfig.InitialFileMetadata, []byte, error)
ReadInitialEnvironmentFile opens the initial file the Session froze at position. A file that does not open or match its recorded size is corrupt stored data, so it is an internal error.
func (*Store) ReadSessionArtifact ¶
func (s *Store) ReadSessionArtifact(ctx context.Context, tenantID, sessionID, artifactID string, consume func(sessions.Artifact, io.Reader) error) error
ReadSessionArtifact keeps an admitted snapshot available across concurrent deletion.
func (*Store) RevokeDevice ¶
func (*Store) SignInstallation ¶
func (*Store) TouchAuthenticatedDevice ¶
func (*Store) TouchDevice ¶
func (*Store) VerifyInstallation ¶
func (*Store) WithArtifactStaging ¶
func (s *Store) WithArtifactStaging(ctx context.Context, key sessions.ArtifactStagingKey, stage func(context.Context, sessions.ArtifactStagingTx) error) error
WithArtifactStaging runs the staging in one pooled transaction, not on the execution lease: the transfer can outlast a lease transaction, and staged Artifacts stay private until the lease-bound completion publishes or discards them. Large objects the staging created are removed with the rolled-back transaction.
func (*Store) WithEnrollment ¶
func (s *Store) WithEnrollment(ctx context.Context, environment, credentialHash string, apply func(context.Context, sessions.EnrollmentTx, sessions.Environment, sessions.LockedSession) error) error
WithEnrollment authenticates the credential and reads the Environment on the pool before it knows which Session to lock; the enrollment transaction rechecks that authority under the Session lock.
func (*Store) WithEnvironmentExecutorCredentials ¶
func (s *Store) WithEnvironmentExecutorCredentials(ctx context.Context, tenant, environment string, apply func(context.Context, sessions.EnvironmentExecutorCredentialTx, sessions.LockedSession) error) error
WithEnvironmentExecutorCredentials reads the Environment on the pool before it knows which Session to lock.
Source Files
¶
- artifacts.go
- binding.go
- changes.go
- devices.go
- doc.go
- environment.go
- execution.go
- execution_environment.go
- execution_file_writes.go
- execution_functions.go
- execution_journal.go
- executor_credentials.go
- frozen.go
- functions.go
- item_reads.go
- items.go
- journal.go
- public_session.go
- rows.go
- session.go
- store.go
- subagent_reads.go
- subagents.go
- turn_end.go
- usage.go