store

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OpenLineageDatasetDirectionInput  = "input"
	OpenLineageDatasetDirectionOutput = "output"
)

The directions a persisted run can reference a dataset in.

View Source
const (
	WorkspaceAdminRole  = "workspaceAdmin"
	WorkspaceMemberRole = "workspaceMember"
)

WorkspaceAdminRole and WorkspaceMemberRole are the two predefined roles. They are defined in Go, read-only over the RoleService API, and resolvable in memory by the IAM manager.

View Source
const ExplainSQLCacheTTL = 7 * 24 * time.Hour

ExplainSQLCacheTTL bounds how long a cached explanation is served. Metadata explanations key on the metadata hash, so a schema change invalidates them by itself; the TTL mainly bounds "sql:<hash>" entries, whose SQL text can stay unchanged while the schema underneath it moves.

Variables

View Source
var ErrPolicyEtagMismatch = errors.New("iam policy etag mismatch")

ErrPolicyEtagMismatch reports a Set whose etag does not match the stored policy. Callers map it to connect.CodeAborted so the client re-fetches.

View Source
var PredefinedRoles = []*RoleMessage{
	{
		ResourceID:  WorkspaceAdminRole,
		Name:        "Workspace admin",
		Description: "Full control of the workspace, including users, roles, settings and every data source.",
		Permissions: allPermissionSet,
	},
	{
		ResourceID:  WorkspaceMemberRole,
		Name:        "Workspace member",
		Description: "Read access to metadata, lineage, OpenLineage and manual SQL, and the ability to explain SQL.",
		Permissions: memberBaselinePermissions,
	},
}

PredefinedRoles are the read-only, Go-defined roles shown on the Roles page and resolvable in-memory by the IAM manager. WorkspaceAdmin carries the whole catalog; WorkspaceMember is the authenticated-principal baseline.

Functions

func CalcMetaHash

func CalcMetaHash(meta *storepb.StoredMetadata) ([]byte, error)

CalcMetaHash returns the change-detection fingerprint of metadata: the SHA-256 of a canonical encoding owned by this package (see encodeCanonicalMessage), computed over the statistics-normalized message.

The fingerprint must be a pure function of the semantic content. It therefore must not be derived from a protobuf serialization API: protojson output is deliberately randomized per binary build (protobuf-go's internal/detrand seeds from the executable image), and proto.MarshalOptions{Deterministic: true} is documented as non-canonical, unstable over time and unstable across builds when unknown fields are present. Either could change every stored hash on a rebuild or dependency upgrade, and every restart would then rewrite the whole metadata registry.

func CalcStoreMetaHash

func CalcStoreMetaHash(meta *storepb.StoredMetadata) (metadata []byte, metaHash []byte, err error)

CalcStoreMetaHash returns the JSON persisted for a registry resource and the fingerprint used to detect changes to it. The two are consistent: hashing the returned JSON with CalcMetaHash reproduces the returned fingerprint.

func CheckAllUsersBinding

func CheckAllUsersBinding(policy *storepb.IamPolicy) error

CheckAllUsersBinding enforces the allUsers invariant on a complete workspace policy. The v1 write path (validateIamPolicy) calls it, and so do the store writers below, so the invariant holds for every writer instead of only for the RPC that happens to validate first.

allUsers matches every authenticated principal, including everyone who registers after the write, and self-signup is open by default. Binding it to any other role would hand that role to every future sign-up, so it may only carry the implicit baseline; and that one binding must survive a full replace instead of being quietly dropped. Custom roles stay available; they are granted to explicit users and groups.

func IsObjectCaseSensitive

func IsObjectCaseSensitive(instance *InstanceMessage) bool

IsObjectCaseSensitive returns true if the engine ignores database and table case sensitive.

func IsPredefinedRole

func IsPredefinedRole(resourceID string) bool

IsPredefinedRole reports whether the given resource ID names a predefined role. Predefined roles are read-only over the RoleService API.

Types

type ApplicationMessage

type ApplicationMessage struct {
	ID            int64
	ApplicationID string
	Name          string
	Description   string
	Disabled      bool
	CreatedBy     string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

ApplicationMessage is the store representation of an application that reports its SQL.

type ApplicationSQLAPIKeyMessage

type ApplicationSQLAPIKeyMessage struct {
	ID int64
	// Application is the public id of the owning application.
	Application string
	KeyHash     string
	MaskedKey   string

	Description string
	CreatedBy   string
	CreatedAt   time.Time
	LastUsedAt  *time.Time
	RevokedAt   *time.Time

	// LastReportID is the last report id this key was accepted for. A repeat of it is
	// answered from the previous outcome instead of counting twice.
	LastReportID string

	// Per-key counters, which stand in for one audit row per request. audit_log is kept
	// forever, so auditing machine traffic would make it grow with request volume rather
	// than with distinct statements.
	RequestCount           int64
	StatementAcceptedCount int64
	StatementRejectedCount int64
}

ApplicationSQLAPIKeyMessage is the store representation of one reporting key.

type ApplicationSQLIdentity

type ApplicationSQLIdentity struct {
	Key         *ApplicationSQLAPIKeyMessage
	Application *ApplicationMessage
	// ApplicationName is resolved with the key so a caller can log it without a second read.
	ApplicationName string
}

ApplicationSQLIdentity is what a validated key resolves to. The application comes from the key and never from the request payload, which is what stops a report from claiming to be another application.

type ApplicationSQLKind

type ApplicationSQLKind int16

ApplicationSQLKind is the read/write classification of a statement. It is written by the lineage runner once it has analyzed the statement, and read by the list page to filter. It is never the source of the classification itself.

const (
	ApplicationSQLKindUnknown ApplicationSQLKind = 0
	ApplicationSQLKindRead    ApplicationSQLKind = 1
	ApplicationSQLKindWrite   ApplicationSQLKind = 2
)

type ApplicationSQLMessage

type ApplicationSQLMessage struct {
	ID                 int64
	GUID               string
	ApplicationSQLID   string
	InstanceResourceID string
	DatabaseName       string
	SchemaName         string
	Engine             storepb.Engine
	Fingerprint        string
	FingerprintVersion int16
	SQLText            string
	Kind               ApplicationSQLKind
	ExecutionCount     int64
	FirstSeenAt        time.Time
	LastSeenAt         time.Time
	CreatedAt          time.Time
	UpdatedAt          time.Time
	// Observations is the per-application breakdown. The detail read fills it in; a list row
	// leaves it empty, because resolving every statement's reporters would be a query per row.
	Observations []*ApplicationSQLObservationMessage
}

ApplicationSQLMessage is the store representation of one distinct reported statement.

type ApplicationSQLObservationMessage

type ApplicationSQLObservationMessage struct {
	ApplicationID string
	// ApplicationName is the application's display name, read with the observation so the
	// detail page does not have to resolve each one.
	ApplicationName string
	ExecutionCount  int64
	FirstSeenAt     time.Time
	LastSeenAt      time.Time
}

ApplicationSQLObservationMessage is one application's own history with one statement.

type ColumnLineage

type ColumnLineage struct {
	ID             int64
	MetaGUID       string
	MetaType       storepb.MetaType
	SourceGUID     string
	SourceColumn   string
	SourceType     storepb.MetaType
	TargetGUID     string
	TargetColumn   string
	TargetType     storepb.MetaType
	RelationType   model.RelationType
	Transformation []model.Transformation
	UpdatedAt      time.Time
}

ColumnLineage is a single column-level lineage edge.

type ColumnLineageCount

type ColumnLineageCount struct {
	Upstream   int32
	Downstream int32
}

ColumnLineageCount is how many distinct objects one object is connected to, at table level: the objects its column-level relations mention.

type ColumnLineageVersion

type ColumnLineageVersion struct {
	MetaGUID     string
	MetaType     storepb.MetaType
	MetaHash     []byte
	AnalyzedAt   time.Time
	ErrorMessage *string
}

ColumnLineageVersion tracks the analysis state per object.

type CreateEnvironmentMessage

type CreateEnvironmentMessage struct {
	// Title is the user-facing name. The id is derived from it.
	Title string
	// Color is a preset palette key. Empty lets the server pick one.
	Color string
}

CreateEnvironmentMessage is the message for creating an environment.

type CreateMetaRegistryResourceMessage

type CreateMetaRegistryResourceMessage struct {
	MetaRegistryResource
	MetadataBytes []byte
}

type CreateMetaRegistrySchemaMessage

type CreateMetaRegistrySchemaMessage struct {
	GUID       string
	ObjectType storepb.MetaType
	Schema     string
}

CreateMetaRegistrySchemaMessage is a DDL row to write.

type DBConnectionManager

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

func NewDBConnectionManager

func NewDBConnectionManager(pgURL string) *DBConnectionManager

func (*DBConnectionManager) Close

func (m *DBConnectionManager) Close() error

func (*DBConnectionManager) GetDB

func (m *DBConnectionManager) GetDB() *sql.DB

GetDB returns the current database connection. It is nil until Initialize succeeds.

func (*DBConnectionManager) Initialize

func (m *DBConnectionManager) Initialize(ctx context.Context) error

Initialize opens the connection pool. It is safe to call more than once and from multiple goroutines: without the guard two callers could each open a pool and leak one of them.

type DatabaseMessage

type DatabaseMessage struct {
	InstanceID   string
	DatabaseName string

	EnvironmentID          string
	EffectiveEnvironmentID string

	Deleted  bool
	Metadata *storepb.DatabaseMetadata
}

DatabaseMessage is the message for database.

func (*DatabaseMessage) String

func (d *DatabaseMessage) String() string

type EnvironmentPatch

type EnvironmentPatch struct {
	Title *string
	Color *string
	Tags  map[string]string
}

EnvironmentPatch carries the fields to write for one environment. A nil pointer leaves the stored value untouched.

type ExplainSQLCacheRow

type ExplainSQLCacheRow struct {
	CacheKey        string
	CacheType       int32
	MetaGUID        string
	Scope           string
	SQLText         string
	Provider        string
	Model           string
	ExplanationJSON string
	CreatedAt       time.Time
}

ExplainSQLCacheRow is a row from explain_sql_cache.

type ExternalDatasetMessage

type ExternalDatasetMessage struct {
	ID          int64
	GUID        string
	Namespace   string
	Name        string
	DatasetType string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

ExternalDatasetMessage is the store representation of an external dataset.

type ExtraArgs

type ExtraArgs struct {
	Left  string
	Op    string
	Right any
}

ExtraArgs is one additional predicate appended to a meta registry query.

type FindApplicationMessage

type FindApplicationMessage struct {
	ApplicationID *string
	Name          *string
	// IncludeDisabled keeps stopped applications in the result. The default excludes
	// them, because every caller but the management page is looking for one to use.
	IncludeDisabled bool
	Limit           *int
	Offset          *int
}

FindApplicationMessage is the query filter for applications.

type FindApplicationSQLMessage

type FindApplicationSQLMessage struct {
	GUID               *string
	ApplicationID      *string
	InstanceResourceID *string
	DatabaseName       *string
	SchemaName         *string
	Kind               *ApplicationSQLKind
	Query              *string
	Limit              *int
	Offset             *int
}

FindApplicationSQLMessage is the query filter for reported statements.

type FindAuditLogMessage

type FindAuditLogMessage struct {
	Parent *string
	Limit  *int
	Offset *int
	Filter *ListResourceFilter
}

type FindColumnLineageMessage

type FindColumnLineageMessage struct {
	MetaGUID     *string
	MetaType     *storepb.MetaType
	SourceGUID   *string
	SourceColumn *string
	TargetGUID   *string
	TargetColumn *string
	Limit        *int
	Offset       *int
}

FindColumnLineageMessage is the query filter for column lineage.

type FindDatabaseMessage

type FindDatabaseMessage struct {
	EffectiveEnvironmentID *string
	InstanceID             *string
	DatabaseName           *string
	Engine                 *storepb.Engine
	// When this is used, we will return databases from archived instances or environments.
	// This is used for existing tasks with archived databases.
	ShowDeleted bool

	// IsCaseSensitive is used to ignore case sensitive when finding database.
	IsCaseSensitive bool

	Filter *ListResourceFilter
	Limit  *int
	Offset *int
}

FindDatabaseMessage is the message for finding databases.

type FindExternalDatasetMessage

type FindExternalDatasetMessage struct {
	GUID      *string
	Namespace *string
	Name      *string
}

FindExternalDatasetMessage is the query filter for external datasets.

type FindGroupMessage

type FindGroupMessage struct {
	Email  *string
	Filter *ListResourceFilter

	Limit  *int
	Offset *int
}

FindGroupMessage is the message for finding groups.

type FindIdentityProviderBindingMessage

type FindIdentityProviderBindingMessage struct {
	IdpResourceID *string
	PrincipalID   *int
}

FindIdentityProviderBindingMessage filters the binding list. Both fields are optional; an unset field does not narrow the query.

type FindIdentityProviderMessage

type FindIdentityProviderMessage struct {
	ResourceID *string
}

FindIdentityProviderMessage is the message for finding identity providers.

type FindInstanceMessage

type FindInstanceMessage struct {
	ResourceID  *string
	ResourceIDs *[]string
	ShowDeleted bool
	Limit       *int
	Offset      *int
	Filter      *ListResourceFilter
}

FindInstanceMessage is the message for finding instances.

type FindLLMProfileMessage

type FindLLMProfileMessage struct {
	ResourceID *string
	Limit      *int
	Offset     *int
}

FindLLMProfileMessage is the message for finding LLM provider profiles.

type FindManualSQLMessage

type FindManualSQLMessage struct {
	GUID               *string
	ManualSQLID        *string
	InstanceResourceID *string
	DatabaseName       *string
	SchemaName         *string
	Tags               *[]string
	Query              *string
	ShowDeleted        bool
	Limit              *int
	Offset             *int
}

FindManualSQLMessage is the query filter for manual SQL entries.

type FindMetaRegistryHistoryMessage

type FindMetaRegistryHistoryMessage struct {
	GUID           *string
	GUIDPrefix     *string
	ObjectType     *storepb.MetaType
	Limit          *int
	Offset         *int
	TransitionTime *time.Time
	OrderDesc      bool
}

type FindMetaRegistryResourceMessage

type FindMetaRegistryResourceMessage struct {
	GUID       *string
	GUIDPrefix *string
	// GUIDs is the batch form of GUID: it restricts the lookup to a set of
	// known GUIDs. An empty but non-nil slice matches nothing, so a caller that
	// collected no GUIDs cannot accidentally read the whole table.
	GUIDs      *[]string
	ObjectType *storepb.MetaType
	Limit      *int
	Offset     *int
	ExtraArgs  []ExtraArgs
}

type FindNamespaceMappingMessage

type FindNamespaceMappingMessage struct {
	ID        *int64
	Namespace *string
}

FindNamespaceMappingMessage is the query filter for namespace mappings.

type FindNotificationMessage

type FindNotificationMessage struct {
	RecipientID *int
	UnreadOnly  bool
	Limit       *int
	Offset      *int
}

FindNotificationMessage is the message for finding notifications. RecipientID is required: a notification belongs to one principal, and every query in this file scopes on that id rather than on the workspace.

type FindOpenLineageDatasetMessage

type FindOpenLineageDatasetMessage struct {
	Namespace         *string
	Integration       *string
	Source            *string
	ColumnLineageOnly *bool
}

FindOpenLineageDatasetMessage filters the dataset window. The filters it carries are the ones the aggregate itself can answer: the free-text search and the internal/external scope need resolution and stay with the caller.

type FindOpenLineageRunMessage

type FindOpenLineageRunMessage struct {
	GUID         *string
	TaskGUID     *string
	RunID        *string
	JobNamespace *string
	JobName      *string
	JobType      *string
	EventType    *string
	HasLineage   *bool
	// Search matches the lowercased substring anywhere in the fields the run
	// list shows, mirroring the free-text box the page used to filter with in
	// the browser.
	Search *string
	// IncludePayload asks for raw_payload as well. The list projection leaves it
	// out by default: a page of runs would otherwise read every payload it
	// holds, which is the amplification this table's list path must not have.
	IncludePayload bool
	Limit          *int
	Offset         *int
}

FindOpenLineageRunMessage is the query filter for persisted OpenLineage runs.

type FindOpenLineageTaskMessage

type FindOpenLineageTaskMessage struct {
	GUID         *string
	JobNamespace *string
	JobName      *string
	JobType      *string
	LineageOnly  *bool
	// Search matches the lowercased substring anywhere in the fields the job
	// list shows, mirroring the free-text box the page used to filter with in
	// the browser.
	Search *string
	Limit  *int
	Offset *int
}

FindOpenLineageTaskMessage is the query filter for aggregated OpenLineage tasks/jobs.

type FindPolicyMessage

type FindPolicyMessage struct {
	ResourceType *storepb.Policy_Resource
	Resource     *string
	Type         *storepb.Policy_Type
	// ShowAll will show all policies regardless of the enforce status.
	ShowAll bool
}

FindPolicyMessage is the message for finding policies.

type FindRoleMessage

type FindRoleMessage struct {
	ResourceID *string
}

FindRoleMessage is the message for finding roles.

type FindSettingMessage

type FindSettingMessage struct {
	Name *storepb.SettingName
}

FindSettingMessage is the message for finding setting.

type FindSubLevelMetaRegistryResourceMessage

type FindSubLevelMetaRegistryResourceMessage struct {
	ParentGUID          string
	ObjectType          storepb.MetaType
	LimitPreObjectType  int
	OffsetPreObjectType int
}

type FindUserMessage

type FindUserMessage struct {
	ID          *int
	Email       *string
	ShowDeleted bool
	Type        *storepb.PrincipalType
	Limit       *int
	Offset      *int
	Filter      *ListResourceFilter
}

FindUserMessage is the message for finding users.

type GroupMessage

type GroupMessage struct {
	Email       string
	Title       string
	Description string
	Payload     *storepb.GroupPayload
}

GroupMessage is the message for a group.

type IDPBinding

type IDPBinding struct {
	ResourceID string
	Subject    string
}

IDPBinding identifies the identity provider subject an account may sign in with. It is the identity an SSO login resolves against; the email is not.

type IamPolicyMessage

type IamPolicyMessage struct {
	Policy *storepb.IamPolicy
	Etag   string
}

type IdentityProviderBindingMessage

type IdentityProviderBindingMessage struct {
	PrincipalID   int
	UserEmail     string
	UserTitle     string
	IdpResourceID string
	Subject       string
	CreatedAt     time.Time
}

IdentityProviderBindingMessage is one account's way in through one identity provider.

type IdentityProviderMessage

type IdentityProviderMessage struct {
	ResourceID string
	Title      string
	Domain     string
	Type       storepb.IdentityProviderType
	Config     *storepb.IdentityProviderConfig
}

IdentityProviderMessage is the message for identity provider.

type InstanceMessage

type InstanceMessage struct {
	ResourceID    string
	EnvironmentID string
	Deleted       bool
	Metadata      *storepb.Instance
}

InstanceMessage is the message for instance.

type LLMProfileMessage

type LLMProfileMessage struct {
	ID         int64
	ResourceID string
	// Metadata is the stored profile. Its ApiKeyCiphertext field holds the
	// ciphertext exactly as persisted, so a caller that writes the metadata back
	// cannot store the key in the clear.
	Metadata *storepb.LlmProviderProfile
	// APIKey is the provider key in the clear, in memory only. It is empty when
	// the profile has no key.
	APIKey string
}

LLMProfileMessage is the message for an LLM provider profile.

type ListResourceFilter

type ListResourceFilter struct {
	Args  []any
	Where string
}

ListResourceFilter carries a translated CEL filter: the SQL fragment and the positional arguments that belong to it.

type ManualSQLMessage

type ManualSQLMessage struct {
	ID                 int64
	GUID               string
	ManualSQLID        string
	InstanceResourceID string
	DatabaseName       string
	SchemaName         string
	Name               string
	Title              string
	Comment            string
	SQLText            string
	Tags               []string
	Attributes         map[string]string
	ContentSearch      string
	CreatedBy          string
	UpdatedBy          string
	Deleted            bool
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

ManualSQLMessage is the store representation of a user-maintained SQL entry.

type MetaGUIDKey

type MetaGUIDKey struct {
	GUID       string
	ObjectType storepb.MetaType
}

type MetaRegistryHistory

type MetaRegistryHistory struct {
	ID         int64
	GUID       string
	ObjectType storepb.MetaType
	Metadata   *storepb.StoredMetadata
	MetaHash   []byte
	ValidFrom  time.Time
	ValidTo    *time.Time
}

type MetaRegistryResource

type MetaRegistryResource struct {
	ID         int64
	GUID       string
	ObjectType storepb.MetaType
	Metadata   *storepb.StoredMetadata
	MetaHash   []byte
}

func (*MetaRegistryResource) GUIDKey

func (m *MetaRegistryResource) GUIDKey() MetaGUIDKey

type NamespaceMappingMessage

type NamespaceMappingMessage struct {
	ID                 int64
	Namespace          string
	InstanceResourceID string
	DatabaseName       string
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

NamespaceMappingMessage is the store representation of a namespace mapping.

type OAuthClient

type OAuthClient struct {
	ClientID                string
	ClientName              string
	RedirectURIs            []string
	TokenEndpointAuthMethod string
	CreatedTime             time.Time
	LastUsedTime            *time.Time
}

OAuthClient is one registered OAuth client (RFC 7591).

type OAuthRefreshToken

type OAuthRefreshToken struct {
	// TokenHash is the SHA-256 hex digest of the opaque token. The plaintext is
	// never stored, so a database read does not hand out a usable credential.
	TokenHash string
	ClientID  string
	UserID    int
	// Resource is the MCP resource identifier the user consented to. A refresh
	// is refused when it no longer matches the current endpoint.
	Resource string
	// Scope is the consented scope, carried forward verbatim: a refresh
	// re-issues the grant as consented and never widens it.
	Scope     string
	ExpiresAt time.Time
	// IssuedAt is when the grant was first issued. A rotation carries the
	// original value forward rather than stamping the rotation, so the grant
	// stays ordered against the user's last password change however many times
	// it is refreshed. Required on create.
	IssuedAt time.Time
}

OAuthRefreshToken is one MCP OAuth 2.1 grant's rotation state.

type OpenLineageAPIKeyMessage

type OpenLineageAPIKeyMessage struct {
	ID          int64
	KeyHash     string
	MaskedKey   string
	Description string
	CreatedBy   string
	CreatedAt   time.Time
	LastUsedAt  *time.Time
	RevokedAt   *time.Time
	// ScopeNamespace restricts the key to one OpenLineage namespace. Empty
	// means the key may submit events for any namespace.
	ScopeNamespace string
}

OpenLineageAPIKeyMessage is the store representation of an API key.

type OpenLineageDatasetAggregateMessage

type OpenLineageDatasetAggregateMessage struct {
	Namespace             string
	Name                  string
	LastSeen              *time.Time
	SourceJobCount        int32
	TargetJobCount        int32
	Integrations          []string
	Sources               []string
	SupportsColumnLineage bool
}

OpenLineageDatasetAggregateMessage is one dataset of the window, with the aggregate the list shows.

type OpenLineageDatasetDetailMessage

type OpenLineageDatasetDetailMessage struct {
	LastSeen              *time.Time
	SourceJobCount        int32
	TargetJobCount        int32
	Integrations          []string
	Sources               []string
	SupportsColumnLineage bool
	Jobs                  []*OpenLineageDatasetJobMessage
	Runs                  []*OpenLineageDatasetRunMessage
	SchemaFields          []byte
	ColumnLineageFields   []string
}

OpenLineageDatasetDetailMessage is a dataset's detail. The summary comes from the maintained aggregate — a single spelling reads one row — while the schema, jobs and runs are read from a bounded, newest-first window of references. The dataset's own identity and resolution stay with the caller.

type OpenLineageDatasetJobMessage

type OpenLineageDatasetJobMessage struct {
	TaskGUID      string
	JobNamespace  string
	JobName       string
	JobType       string
	Integration   string
	LastSeen      *time.Time
	RunCount      int32
	ReadsDataset  bool
	WritesDataset bool
}

OpenLineageDatasetJobMessage is one job that touched a dataset.

type OpenLineageDatasetPair

type OpenLineageDatasetPair struct {
	Namespace string
	Name      string
}

OpenLineageDatasetPair is one (namespace, name) spelling of a dataset.

type OpenLineageDatasetRunMessage

type OpenLineageDatasetRunMessage struct {
	RunGUID       string
	TaskGUID      string
	RunID         string
	JobNamespace  string
	JobName       string
	JobType       string
	EventType     string
	EventTime     *time.Time
	HasLineage    bool
	ReadsDataset  bool
	WritesDataset bool
}

OpenLineageDatasetRunMessage is one run that touched a dataset.

type OpenLineageFilterValue

type OpenLineageFilterValue struct {
	Dimension string
	Value     string
	Count     int64
}

OpenLineageFilterValue is one distinct value a filter menu offers, with the number of rows carrying it.

type OpenLineageRunDatasetMessage

type OpenLineageRunDatasetMessage struct {
	TaskGUID         string
	Namespace        string
	Name             string
	Direction        string
	HasColumnLineage bool
	// SchemaFields and ColumnLineageFields hold the facet JSON itself, like
	// raw_payload on the run, and are nil when the payload carried no facet.
	SchemaFields        []byte
	ColumnLineageFields []byte
	EventTime           *time.Time
	Integration         string
	Source              string
}

OpenLineageRunDatasetMessage is one dataset a persisted run read or wrote.

type OpenLineageRunMessage

type OpenLineageRunMessage struct {
	ID                 int64
	GUID               string
	TaskGUID           string
	RunID              string
	JobNamespace       string
	JobName            string
	JobType            string
	EventType          string
	EventTime          *time.Time
	Producer           string
	Integration        string
	ProcessingType     string
	ParentJobNamespace string
	ParentJobName      string
	ParentRunID        string
	RootJobNamespace   string
	RootJobName        string
	RootRunID          string
	Source             string
	InputCount         int32
	OutputCount        int32
	HasLineage         bool
	RawPayload         []byte
	// AirflowRunLogURL is the payload's airflow facet link, whitelisted at
	// ingestion. It is a column so a list reads the link without the payload.
	AirflowRunLogURL string
	// Datasets are the references this run's payload carried. They are written
	// with the run, in the same transaction, and replaced as a set.
	Datasets  []*OpenLineageRunDatasetMessage
	CreatedAt time.Time
	UpdatedAt time.Time
}

OpenLineageRunMessage is the store representation of a persisted OpenLineage run. One row holds one run's latest known state, so it is COMPLETE for a run that finished and START or FAIL for one that is still going or never got there.

type OpenLineageTaskMessage

type OpenLineageTaskMessage struct {
	ID                 int64
	GUID               string
	JobNamespace       string
	JobName            string
	JobType            string
	Integration        string
	ProcessingType     string
	ParentJobNamespace string
	ParentJobName      string
	RootJobNamespace   string
	RootJobName        string
	LatestRunGUID      string
	LatestRunID        string
	// LatestAirflowRunLogURL is the latest run's whitelisted airflow link,
	// joined from the run. It is a column so the task list reads the link
	// without the run's raw payload.
	LatestAirflowRunLogURL string
	LatestEventTime        *time.Time
	LatestEventType        string
	LatestProducer         string
	LatestSource           string
	RunCount               int32
	LineageRunCount        int32
	CreatedAt              time.Time
	UpdatedAt              time.Time
}

OpenLineageTaskMessage is the aggregated task/job-level view derived from persisted runs.

type OpenLineageTotals

type OpenLineageTotals struct {
	Runs          int64
	Jobs          int64
	JobNamespaces int64
}

OpenLineageTotals are the registry-wide counts the index pages' summary cards show. They are counted rather than summed over the capped filter lists.

type Option

type Option func(*Store)

Option customises a Store.

func WithCacheDisabled

func WithCacheDisabled() Option

WithCacheDisabled makes cache reads bypass the cache and query the database. Use it for a store that observes rows written by another process: such a store never sees the writer's cache invalidation, so a cached row would stay visible after the writer deleted it.

type PatchIamPolicyMessage

type PatchIamPolicyMessage struct {
	Member string
	Roles  []string
}

type PolicyMessage

type PolicyMessage struct {
	Resource          string
	ResourceType      storepb.Policy_Resource
	Payload           string
	InheritFromParent bool
	Type              storepb.Policy_Type
	Enforce           bool

	UpdatedAt time.Time
}

PolicyMessage is the mssage for policy.

type ReportApplicationSQLMessage

type ReportApplicationSQLMessage struct {
	// ApplicationID is the public id of the reporting application, which the ingest path
	// takes from the validated key and never from the payload.
	ApplicationID      string
	InstanceResourceID string
	DatabaseName       string
	SchemaName         string
	Engine             storepb.Engine
	// SQLText is the parameterized statement, the only form ever stored.
	SQLText string
	// Canonical and Fingerprint are the deduplication key of SQLText.
	Canonical          string
	Fingerprint        string
	FingerprintVersion int16
	// Count is how many times the application ran the statement in this report.
	Count int64
	// FirstSeenAt and LastSeenAt are the application's own view of when it first and last
	// ran the statement. A zero value falls back to the server's receipt time, which is what
	// an application that keeps no such record will send.
	FirstSeenAt time.Time
	LastSeenAt  time.Time
}

ReportApplicationSQLMessage is one statement an application reported. The text fields are what sqlsanitize.Sanitize produced: the store persists them and does not decide them.

type RoleMessage

type RoleMessage struct {
	ResourceID  string
	Name        string
	Description string
	Permissions map[permission.Permission]bool
}

RoleMessage is a named bundle of permissions. Predefined roles are defined in Go (predefined_roles.go) and never stored in the DB; custom roles live in the role table. Both resolve identically in the IAM manager.

func GetPredefinedRole

func GetPredefinedRole(resourceID string) *RoleMessage

GetPredefinedRole returns the predefined role with the given resource ID, or nil if no such predefined role exists.

type RoleUsedByResource

type RoleUsedByResource struct {
	ResourceType storepb.Policy_Resource
	Resource     string
}

RoleUsedByResource is a resource whose IAM policy references a role.

type SearchMetaRegistryResourceMessage

type SearchMetaRegistryResourceMessage struct {
	SearchStr string
	// GUIDPrefix restricts the search to a GUID subtree. A nil or empty prefix
	// searches every instance; an empty prefix used to compile to
	// `guid = ” OR guid LIKE ';%'`, which matched nothing, so the
	// explain-SQL search tool silently returned no rows when no instance was
	// selected.
	GUIDPrefix *string
	ObjectType *storepb.MetaType
	Limit      int
	Offset     int
}

SearchMetaRegistryResourceMessage is the message to search meta registry resources by matching name/comment fields inside the metadata JSONB.

type SetSettingMessage

type SetSettingMessage struct {
	Name  storepb.SettingName
	Value string
}

SetSettingMessage is the message for updating setting.

type SettingMessage

type SettingMessage struct {
	Name  storepb.SettingName
	Value string
}

SettingMessage is the message of setting.

type Store

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

func New

func New(ctx context.Context, pgURL string, opts ...Option) (*Store, error)

func (*Store) AuthenticateApplicationSQLAPIKey

func (s *Store) AuthenticateApplicationSQLAPIKey(ctx context.Context, plainKey string) (*ApplicationSQLIdentity, error)

AuthenticateApplicationSQLAPIKey validates a plaintext key, resolves its application, and records the use. A key whose application has been stopped is refused here rather than later, so a stopped application cannot write anything at all.

func (*Store) BatchCreateMetaRegistryResource

func (s *Store) BatchCreateMetaRegistryResource(ctx context.Context, tx *sql.Tx, creates []*CreateMetaRegistryResourceMessage) ([]*MetaRegistryResource, error)

BatchCreateMetaRegistryResource creates or updates the current meta registry snapshot.

func (*Store) BatchCreateMetaRegistryResourceAt

func (s *Store) BatchCreateMetaRegistryResourceAt(ctx context.Context, tx *sql.Tx, creates []*CreateMetaRegistryResourceMessage, observedAt time.Time) ([]*MetaRegistryResource, error)

BatchCreateMetaRegistryResourceAt creates or updates the current meta registry snapshot at a specific observed time.

func (*Store) BatchDeleteMetaRegistry

func (s *Store) BatchDeleteMetaRegistry(ctx context.Context, tx *sql.Tx, list []*MetaRegistryResource) error

BatchDeleteMetaRegistry deletes current meta registry rows and closes their open history records.

func (*Store) BatchDeleteMetaRegistryAt

func (s *Store) BatchDeleteMetaRegistryAt(ctx context.Context, tx *sql.Tx, list []*MetaRegistryResource, observedAt time.Time) error

BatchDeleteMetaRegistryAt deletes current meta registry rows and closes their open history records at a specific observed time.

func (*Store) BatchDeleteMetaRegistrySchema

func (*Store) BatchDeleteMetaRegistrySchema(ctx context.Context, tx *sql.Tx, keys []MetaGUIDKey) error

BatchDeleteMetaRegistrySchema removes DDL rows by key inside the caller's transaction. Deleting a key that has no row is a no-op.

func (*Store) BatchReplaceColumnLineage

func (s *Store) BatchReplaceColumnLineage(ctx context.Context, metaGUID string, metaType storepb.MetaType, lineages []*ColumnLineage) error

BatchReplaceColumnLineage deletes any existing lineage edges for the given object and inserts the new ones, all within a single transaction.

func (*Store) BatchUpsertMetaRegistrySchema

func (*Store) BatchUpsertMetaRegistrySchema(ctx context.Context, tx *sql.Tx, creates []*CreateMetaRegistrySchemaMessage) error

BatchUpsertMetaRegistrySchema writes DDL rows inside the caller's transaction.

func (*Store) BindAccountForSSO

func (s *Store) BindAccountForSSO(ctx context.Context, account *UserMessage, binding *IDPBinding, passwordHash string) (bool, error)

BindAccountForSSO makes an existing account reachable through an identity provider subject.

An account that carries no binding at all is being adopted: the password it had is replaced with a random one, which — through the password change time — also retires the sessions minted with it. An account that already signs in through a provider only gains another way in and keeps its sessions, because nothing it held was a secret to anyone else.

It reports whether this call is the one that adopted the account. It fails when the subject belongs to a different account, or when the account stops being the active end-user account at that address while the login is resolving.

func (*Store) Close

func (s *Store) Close() error

func (*Store) ConsumeOAuthRefreshToken

func (s *Store) ConsumeOAuthRefreshToken(ctx context.Context, clientID, tokenHash string) (bool, error)

ConsumeOAuthRefreshToken atomically deletes a grant and reports whether this call is the one that claimed it. false means the token was already consumed, never existed, or belongs to another client; a non-nil error is a real failure and must abort issuance rather than being treated as a refusal.

func (*Store) ConsumeWebRefreshToken

func (s *Store) ConsumeWebRefreshToken(ctx context.Context, tokenHash string) (*WebRefreshToken, error)

ConsumeWebRefreshToken atomically deletes a session and returns it, or (nil, nil) when the token is unknown or already consumed. A non-nil error is a real failure and must abort issuance.

func (*Store) CountColumnLineageByGUID

func (s *Store) CountColumnLineageByGUID(ctx context.Context, guids []string) (map[string]*ColumnLineageCount, error)

CountColumnLineageByGUID returns the degree of every given object. Two aggregates answer the whole batch: the incoming edges grouped by their target give the upstream counts and the outgoing edges grouped by their source give the downstream ones. The counts are of distinct objects, not of edges, so a join on five columns counts once. A guid with no edges is absent from the result rather than reported as zero.

func (*Store) CountInstancesByEnvironment

func (s *Store) CountInstancesByEnvironment(ctx context.Context, id string) (int, error)

CountInstancesByEnvironment counts the live instances assigned to an environment. Deleted instances are excluded: they still carry the id but no longer need to keep the environment alive.

func (*Store) CountInstancesByEnvironments

func (s *Store) CountInstancesByEnvironments(ctx context.Context) (map[string]int, error)

CountInstancesByEnvironments returns the live instance count per environment id. It is one grouped query so listing environments does not issue a count query per row.

func (*Store) CountNotificationCounts

func (s *Store) CountNotificationCounts(ctx context.Context, recipientID int) (unread int, unseen int, err error)

CountNotificationCounts counts one recipient's unread notifications and the subset of them written after they last opened the inbox — the number the inbox page works with and the number the bell's badge shows. Both come from one statement, so the subset can never come out larger than the whole: two reads would answer with two snapshots, and a message written between them would make the badge claim more new messages than there are unread ones.

A recipient who never opened the inbox has no watermark, and every unread message is new: -infinity is what "no watermark" compares as.

func (*Store) CountOpenLineageTotals

func (s *Store) CountOpenLineageTotals(ctx context.Context) (*OpenLineageTotals, error)

CountOpenLineageTotals returns the totals the OpenLineage index pages summarise.

func (*Store) CountUsers

func (s *Store) CountUsers(ctx context.Context, userType storepb.PrincipalType) (int, error)

CountUsers counts the active (non-deleted) principal of the given type.

func (*Store) CreateApplication

func (s *Store) CreateApplication(ctx context.Context, name, description, createdBy string) (*ApplicationMessage, error)

CreateApplication registers an application. The caller supplies no identifier: the store generates one, so every path that creates an application gets the same shape.

func (*Store) CreateApplicationSQLAPIKey

func (s *Store) CreateApplicationSQLAPIKey(ctx context.Context, application string, description, createdBy string) (string, *ApplicationSQLAPIKeyMessage, error)

CreateApplicationSQLAPIKey issues a key for one application. The plaintext key is returned once and never stored.

func (*Store) CreateAuditLog

func (s *Store) CreateAuditLog(ctx context.Context, auditLog *storepb.AuditLog) (*storepb.AuditLog, error)

func (*Store) CreateDatabaseDefault

func (s *Store) CreateDatabaseDefault(ctx context.Context, create *DatabaseMessage) (*DatabaseMessage, error)

CreateDatabaseDefault creates a new database.

func (*Store) CreateEnvironment

CreateEnvironment appends an environment to the workspace setting. The id is derived from the title and is immutable afterwards; the color falls back to the preset palette when empty.

func (*Store) CreateGroup

func (s *Store) CreateGroup(ctx context.Context, group *GroupMessage) (*GroupMessage, error)

CreateGroup creates a group. The email is the primary key, so a duplicate is reported as a conflict rather than an internal error.

func (*Store) CreateIdentityProvider

func (s *Store) CreateIdentityProvider(ctx context.Context, create *IdentityProviderMessage) (*IdentityProviderMessage, error)

CreateIdentityProvider creates an identity provider. The caller supplies the client secret in the clear; it is encrypted before it reaches the database.

func (*Store) CreateInstance

func (s *Store) CreateInstance(ctx context.Context, instanceCreate *InstanceMessage) (*InstanceMessage, error)

CreateInstance creates an instance.

func (*Store) CreateLLMProfile

func (s *Store) CreateLLMProfile(ctx context.Context, resourceID string, meta *storepb.LlmProviderProfile, apiKey string) (*LLMProfileMessage, error)

CreateLLMProfile creates a new LLM provider profile. apiKey is the provider key in the clear: the store encrypts it and the row never holds it unencrypted.

func (*Store) CreateManualSQL

func (s *Store) CreateManualSQL(ctx context.Context, msg *ManualSQLMessage) (*ManualSQLMessage, error)

CreateManualSQL creates or revives a manual SQL entry and mirrors it into meta_registry_resource.

func (*Store) CreateNamespaceMapping

func (s *Store) CreateNamespaceMapping(ctx context.Context, msg *NamespaceMappingMessage) (*NamespaceMappingMessage, error)

CreateNamespaceMapping creates a new namespace mapping.

func (*Store) CreateNotification

func (s *Store) CreateNotification(ctx context.Context, notification *storepb.Notification) (*storepb.Notification, error)

CreateNotification inserts one notification and returns it with the id and create time the row was stamped with. It returns (nil, nil) when the recipient already has a notification carrying the same dedupe_key, so a background sender can report a condition on every occurrence while the message itself is written once per suppression window (and once across replicas, because the suppression is the unique index rather than process memory).

func (*Store) CreateOAuthClient

func (s *Store) CreateOAuthClient(ctx context.Context, client *OAuthClient) (*OAuthClient, error)

CreateOAuthClient stores a new registration and returns the stored row.

func (*Store) CreateOAuthRefreshToken

func (s *Store) CreateOAuthRefreshToken(ctx context.Context, create *OAuthRefreshToken) error

CreateOAuthRefreshToken stores a newly issued grant.

func (*Store) CreateOpenLineageAPIKey

func (s *Store) CreateOpenLineageAPIKey(ctx context.Context, description, createdBy, scopeNamespace string) (string, *OpenLineageAPIKeyMessage, error)

CreateOpenLineageAPIKey generates a new API key and stores its bcrypt hash. Returns the plain-text key (only available at creation time) and the stored message.

func (*Store) CreateRole

func (s *Store) CreateRole(ctx context.Context, create *RoleMessage) (*RoleMessage, error)

CreateRole creates a new custom role. The stored permission list is sorted so the JSONB payload is deterministic.

func (*Store) CreateSettingIfNotExist

func (s *Store) CreateSettingIfNotExist(ctx context.Context, create *SettingMessage) (*SettingMessage, bool, error)

CreateSettingIfNotExist creates a new setting only if the named setting doesn't exist.

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, create *UserMessage, binding *IDPBinding) (*UserMessage, error)

CreateUser creates an user.

When the new user is an end user and there is no other active end user, the user is granted the workspace admin role in the same transaction. This is what bootstraps a fresh workspace, and doing it atomically prevents a concurrent registration from also being elected admin.

A binding makes the account reachable through an identity provider subject; it is written in the same transaction, because an SSO account without one could not sign in again. Password accounts pass nil.

func (*Store) CreateWebRefreshToken

func (s *Store) CreateWebRefreshToken(ctx context.Context, create *WebRefreshToken) error

CreateWebRefreshToken stores a newly issued session.

func (*Store) DeleteApplication

func (s *Store) DeleteApplication(ctx context.Context, applicationID string) error

DeleteApplication removes an application, everything reported with its keys, and every statement that no other application has reported.

The order matters. Deleting the application cascades its keys and its observations; the statements that are left without any observation are then orphans, and their registry mirror, lineage and analysis version have to go with them or the graph would keep nodes nothing can reach.

func (*Store) DeleteApplicationSQL

func (s *Store) DeleteApplicationSQL(ctx context.Context, guid string) error

DeleteApplicationSQL removes one reported statement and everything hanging off it: its observations, its registry mirror, its lineage and its analysis version.

func (*Store) DeleteEmptyOpenLineageDatasets

func (s *Store) DeleteEmptyOpenLineageDatasets(ctx context.Context, olderThan time.Time) (int64, error)

DeleteEmptyOpenLineageDatasets removes the dataset aggregates whose references are all gone. Ingestion maintains the aggregate and the retention prune rebuilds the datasets it prunes, but a run deleted outside those paths keeps its references' aggregate rows behind: the pages would then offer datasets the API serves nothing for.

Two things keep a live dataset out of its way. A row an ingest touched recently is left alone, and the rows it is about to delete are locked first, skipping any row a writer still holds: a writer whose references are in flight but not committed is invisible to the emptiness check, so its row must not be swept out from under it. The age alone would not settle it, because updated_at records the writing transaction's start: a transaction that began before the grace leaves a version that still looks sweepable.

func (*Store) DeleteEnvironment

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

DeleteEnvironment removes an environment from the setting. Callers must check CountInstancesByEnvironment first: a deleted environment leaves instances pointing at an id that no longer resolves.

func (*Store) DeleteExpiredExplainSQLCache

func (s *Store) DeleteExpiredExplainSQLCache(ctx context.Context, olderThan time.Time) (int64, error)

DeleteExpiredExplainSQLCache removes cached explanations created before olderThan. Expired rows are already invisible (GetExplainSQLCache enforces ExplainSQLCacheTTL), so this only reclaims space.

func (*Store) DeleteExpiredLLMDebugLog

func (s *Store) DeleteExpiredLLMDebugLog(ctx context.Context, olderThan time.Time) (int64, error)

DeleteExpiredLLMDebugLog removes debug log entries created before olderThan. The table stores full request/response bodies, so it is pruned rather than kept forever.

func (*Store) DeleteExpiredOAuthRefreshTokens

func (s *Store) DeleteExpiredOAuthRefreshTokens(ctx context.Context, before time.Time) (int64, error)

DeleteExpiredOAuthRefreshTokens drops grants past their expiry: past that point the row can issue nothing. The maintenance runner calls it and reports how many rows were dropped.

func (*Store) DeleteExpiredRevokedTokens

func (s *Store) DeleteExpiredRevokedTokens(ctx context.Context, before time.Time) (int64, error)

DeleteExpiredRevokedTokens drops records whose token has expired: past that point the token is refused by its own exp claim, so the row can refuse nothing. The maintenance runner calls this; it returns how many rows were dropped.

func (*Store) DeleteExpiredWebRefreshTokens

func (s *Store) DeleteExpiredWebRefreshTokens(ctx context.Context, before time.Time) (int64, error)

DeleteExpiredWebRefreshTokens drops sessions past their expiry. The maintenance runner calls it and reports how many rows were dropped.

func (*Store) DeleteGroup

func (s *Store) DeleteGroup(ctx context.Context, email string) (bool, error)

DeleteGroup deletes a group. It reports whether a row was removed; callers map false to NotFound.

func (*Store) DeleteIdentityProvider

func (s *Store) DeleteIdentityProvider(ctx context.Context, resourceID string) error

DeleteIdentityProvider deletes an identity provider. Accounts bound to it keep their binding rows; those bindings stop resolving until a provider with the same id exists again.

func (*Store) DeleteIdentityProviderBinding

func (s *Store) DeleteIdentityProviderBinding(ctx context.Context, principalID int, idpResourceID, subject string) error

DeleteIdentityProviderBinding removes one account's binding to one provider subject. The subject pins a single row, because the primary key is (idp_resource_id, subject).

The principal id is part of the WHERE clause rather than assumed: the caller addresses the binding by account, and matching on (idp, subject) alone would delete another account's binding if the two disagreed.

func (*Store) DeleteLLMProfile

func (s *Store) DeleteLLMProfile(ctx context.Context, resourceID string) error

DeleteLLMProfile deletes an LLM provider profile.

func (*Store) DeleteManualSQL

func (s *Store) DeleteManualSQL(ctx context.Context, guid string, updatedBy *string) error

DeleteManualSQL soft-deletes a manual SQL entry and removes its registry mirror and lineage.

func (*Store) DeleteNamespaceMapping

func (s *Store) DeleteNamespaceMapping(ctx context.Context, id int64) error

DeleteNamespaceMapping deletes a namespace mapping by ID.

func (*Store) DeleteNotification

func (s *Store) DeleteNotification(ctx context.Context, recipientID int, id int64) (bool, error)

DeleteNotification deletes one notification of one recipient. The second result is false when the recipient has no such row, which includes the case where it belongs to somebody else.

func (*Store) DeleteOAuthClient

func (s *Store) DeleteOAuthClient(ctx context.Context, clientID string) error

DeleteOAuthClient removes a registration. The row is deleted rather than revoked: a client_id is an opaque registration token with no history to keep.

func (*Store) DeleteOAuthRefreshTokensByUserAndClient

func (s *Store) DeleteOAuthRefreshTokensByUserAndClient(ctx context.Context, userID int, clientID string) error

DeleteOAuthRefreshTokensByUserAndClient drops every grant a principal holds for one client. Logout calls it, so revoking an MCP token also retires the grant that would otherwise mint a replacement.

func (*Store) DeleteOpenLineageRunsBefore

func (s *Store) DeleteOpenLineageRunsBefore(ctx context.Context, cutoff time.Time) (int64, error)

DeleteOpenLineageRunsBefore removes persisted runs whose event time is older than cutoff, together with what was derived from them: the aggregated task rows (recomputed, or removed once they have no run left) and the meta registry rows mirroring runs and tasks. The dataset aggregates the pruned references belonged to are recomputed the same way. Runs without an event time are kept — they cannot be ordered against the cutoff.

func (*Store) DeleteRole

func (s *Store) DeleteRole(ctx context.Context, resourceID string) error

DeleteRole deletes an existing custom role.

func (*Store) DeleteSetting

func (s *Store) DeleteSetting(ctx context.Context, name storepb.SettingName) error

DeleteSetting deletes a setting by the name.

func (*Store) DeleteWebRefreshToken

func (s *Store) DeleteWebRefreshToken(ctx context.Context, tokenHash string) error

DeleteWebRefreshToken drops one session. Logout calls it, so the cookie it is about to clear cannot be replayed.

func (*Store) FindApplicationSQLLabels

func (s *Store) FindApplicationSQLLabels(ctx context.Context, guids []string) (map[string]string, error)

FindApplicationSQLLabels returns a display label per statement GUID, for the callers that only have a GUID and need something a person can read. The graph is that caller: its node names fall back to the last GUID segment, which for a statement is a generated identifier.

A GUID the registry does not have is simply absent from the result.

func (*Store) FindColumnLineageWithContradictedColumnClaim

func (s *Store) FindColumnLineageWithContradictedColumnClaim(ctx context.Context, excludePrefix string, limit int) ([]*ColumnLineage, error)

FindColumnLineageWithContradictedColumnClaim returns the ingested edges whose column claim the registry now proves wrong: the edge names a column on a relation that is a TABLE, and that table has no such column.

Ingestion stores such a claim when the relation is not in the registry yet - the table may have been created after the last schema sync - and it cannot check it then. Once the relation appears the claim becomes checkable, but the edge no longer has an unknown endpoint, so the sweep in FindColumnLineageWithUnknownEndpoint can never see it again. This is the query that finds it. The claim on a view or materialized view is left alone: those keep their columns in their own metadata rather than as registry rows.

func (*Store) FindColumnLineageWithUnknownEndpoint

func (s *Store) FindColumnLineageWithUnknownEndpoint(ctx context.Context, excludePrefix string, limit int) ([]*ColumnLineage, error)

FindColumnLineageWithUnknownEndpoint returns the edges whose source or target relation the metadata registry has no row for, oldest first. excludePrefix skips the GUIDs that are meant to have no row - an external dataset never gets one - and limit bounds what one revalidation pass reads.

func (*Store) FindExternalDatasetByGUIDs

func (s *Store) FindExternalDatasetByGUIDs(ctx context.Context, guids []string) ([]*ExternalDatasetMessage, error)

FindExternalDatasetByGUIDs returns external datasets matching the given GUIDs.

func (*Store) GetActivatedInstanceCount

func (s *Store) GetActivatedInstanceCount(ctx context.Context) (int, error)

GetActivatedInstanceCount gets the number of activated instances.

func (*Store) GetActiveUserByEmail

func (s *Store) GetActiveUserByEmail(ctx context.Context, email string) (*UserMessage, error)

GetActiveUserByEmail gets a user by email that is still active, ignoring soft-deleted rows. A deleted account is inert — it cannot sign in and its address no longer belongs to it, which is what the partial unique email index already assumes — so it must not keep that address out of a new account.

func (*Store) GetApplication

func (s *Store) GetApplication(ctx context.Context, find *FindApplicationMessage) (*ApplicationMessage, error)

GetApplication returns one application matching the filter, or nil.

func (*Store) GetApplicationSQL

func (s *Store) GetApplicationSQL(ctx context.Context, find *FindApplicationSQLMessage) (*ApplicationSQLMessage, error)

GetApplicationSQL returns one reported statement or nil.

func (*Store) GetColumnLineageVersion

func (s *Store) GetColumnLineageVersion(ctx context.Context, metaGUID string, metaType storepb.MetaType) (*ColumnLineageVersion, error)

GetColumnLineageVersion returns the analysis version record for an object, or nil if not found.

func (*Store) GetDB

func (s *Store) GetDB() *sql.DB

func (*Store) GetDatabase

func (s *Store) GetDatabase(ctx context.Context, find *FindDatabaseMessage) (*DatabaseMessage, error)

GetDatabase gets a database.

func (*Store) GetEnvironmentByID

func (s *Store) GetEnvironmentByID(ctx context.Context, id string) (*storepb.EnvironmentSetting_Environment, error)

GetEnvironmentByID returns the environment with the given id, or nil when no environment carries it.

func (*Store) GetEnvironmentSetting

func (s *Store) GetEnvironmentSetting(ctx context.Context) (*storepb.EnvironmentSetting, error)

func (*Store) GetExplainSQLCache

func (s *Store) GetExplainSQLCache(ctx context.Context, cacheKey string) (*ExplainSQLCacheRow, error)

GetExplainSQLCache looks up a cached explanation by key. Entries older than ExplainSQLCacheTTL are reported as a miss.

func (*Store) GetExternalDataset

func (s *Store) GetExternalDataset(ctx context.Context, find *FindExternalDatasetMessage) (*ExternalDatasetMessage, error)

GetExternalDataset returns a single external dataset matching the filter.

func (*Store) GetGroup

func (s *Store) GetGroup(ctx context.Context, email string) (*GroupMessage, error)

GetGroup gets a group.

func (*Store) GetGroupByName

func (s *Store) GetGroupByName(ctx context.Context, name string) (*GroupMessage, error)

GetGroupByName resolves a group resource name (`groups/{email}`). It backs IAM binding validation and member expansion.

func (*Store) GetIdentityProvider

func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProviderMessage) (*IdentityProviderMessage, error)

GetIdentityProvider gets an identity provider, with its client secret decrypted.

func (*Store) GetInstance

func (s *Store) GetInstance(ctx context.Context, find *FindInstanceMessage) (*InstanceMessage, error)

GetInstance gets an instance by the resource_id.

func (*Store) GetLLMProfile

func (s *Store) GetLLMProfile(ctx context.Context, find *FindLLMProfileMessage) (*LLMProfileMessage, error)

GetLLMProfile gets a single LLM profile by resource ID.

func (*Store) GetManualSQL

func (s *Store) GetManualSQL(ctx context.Context, find *FindManualSQLMessage) (*ManualSQLMessage, error)

GetManualSQL returns one manual SQL entry or nil if none exists.

func (*Store) GetMetaRegistry

func (*Store) GetMetaRegistryAsOf

func (s *Store) GetMetaRegistryAsOf(ctx context.Context, find *FindMetaRegistryResourceMessage, asOf time.Time) (*MetaRegistryResource, error)

func (*Store) GetMetaRegistrySchema

func (s *Store) GetMetaRegistrySchema(ctx context.Context, guid string, objectType storepb.MetaType) (string, bool, error)

GetMetaRegistrySchema returns the stored DDL of one object. ok is false when no row exists, which is the normal state before the first sync and for every engine whose DDL is not fetched; the caller then falls back to reconstructing the definition from metadata.

func (*Store) GetNamespaceMapping

func (s *Store) GetNamespaceMapping(ctx context.Context, find *FindNamespaceMappingMessage) (*NamespaceMappingMessage, error)

GetNamespaceMapping returns a single namespace mapping.

func (*Store) GetOAuthClient

func (s *Store) GetOAuthClient(ctx context.Context, clientID string) (*OAuthClient, error)

GetOAuthClient returns the registration for clientID, or (nil, nil) when no such client exists. The nil result matters: a client deleted after it registered must make the token endpoint answer invalid_client, not 500.

func (*Store) GetOAuthRefreshToken

func (s *Store) GetOAuthRefreshToken(ctx context.Context, clientID, tokenHash string) (*OAuthRefreshToken, error)

GetOAuthRefreshToken returns the grant for (clientID, tokenHash), or (nil, nil) when the token is unknown, already consumed or was issued to another client.

func (*Store) GetOpenLineageDatasetDetail

func (s *Store) GetOpenLineageDatasetDetail(ctx context.Context, pairs []OpenLineageDatasetPair) (*OpenLineageDatasetDetailMessage, error)

GetOpenLineageDatasetDetail reads the detail of a dataset from the aggregate the runs maintain and from the references they left. The summary counts jobs over the union of the spellings, so a job that reported the dataset twice is still one job; with a single spelling it is one row of the aggregate, not an aggregation over the dataset's whole history.

func (*Store) GetOpenLineageRun

func (s *Store) GetOpenLineageRun(ctx context.Context, find *FindOpenLineageRunMessage) (*OpenLineageRunMessage, error)

GetOpenLineageRun returns one persisted run or nil if none exists.

func (*Store) GetOpenLineageTask

func (s *Store) GetOpenLineageTask(ctx context.Context, find *FindOpenLineageTaskMessage) (*OpenLineageTaskMessage, error)

GetOpenLineageTask returns one aggregated task or nil if none exists.

func (*Store) GetOrCreateExternalDataset

func (s *Store) GetOrCreateExternalDataset(ctx context.Context, namespace, name, datasetType string) (*ExternalDatasetMessage, error)

GetOrCreateExternalDataset returns an existing external dataset or creates a new one.

func (*Store) GetPasswordRestrictionSetting

func (s *Store) GetPasswordRestrictionSetting(ctx context.Context) (*storepb.PasswordRestrictionSetting, error)

func (*Store) GetPoliciesUsingMember

func (s *Store) GetPoliciesUsingMember(ctx context.Context, member string) ([]*RoleUsedByResource, error)

GetPoliciesUsingMember returns every resource whose IAM policy binds the given member (e.g. "groups/{email}"). It backs the group reference guard so an admin can see which policies a group affects before deleting it.

func (*Store) GetPolicy

func (s *Store) GetPolicy(ctx context.Context, find *FindPolicyMessage) (*PolicyMessage, error)

GetPolicy gets a policy.

func (*Store) GetResourcesUsedByRole

func (s *Store) GetResourcesUsedByRole(ctx context.Context, role string) ([]*RoleUsedByResource, error)

GetResourcesUsedByRole returns every resource whose IAM policy has a non-empty binding for the given role (full name, e.g. "roles/editor"). It backs the DeleteRole reference guard: deleting a role that is still bound somewhere would silently turn that binding into a no-op.

func (*Store) GetRole

func (s *Store) GetRole(ctx context.Context, find *FindRoleMessage) (*RoleMessage, error)

GetRole returns a role by ID. Custom roles are read from the DB; predefined roles are served from GetPredefinedRole without touching the DB.

func (*Store) GetRoleSnapshot

func (s *Store) GetRoleSnapshot(ctx context.Context, resourceID string) (*RoleMessage, error)

GetRoleSnapshot returns a role by ID with cached reads. Predefined roles resolve in-memory first. This is the hot path of every permission check.

func (*Store) GetSetting

func (s *Store) GetSetting(ctx context.Context, name storepb.SettingName) (*SettingMessage, error)

GetSetting returns the setting by name.

func (*Store) GetSystemBotUser

func (s *Store) GetSystemBotUser(ctx context.Context) *UserMessage

GetSystemBotUser gets the system bot.

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (*UserMessage, error)

GetUserByEmail gets the user by email.

func (*Store) GetUserByID

func (s *Store) GetUserByID(ctx context.Context, id int) (*UserMessage, error)

GetUserByID gets the user by ID.

func (*Store) GetUserByIDPBinding

func (s *Store) GetUserByIDPBinding(ctx context.Context, binding *IDPBinding) (*UserMessage, error)

GetUserByIDPBinding gets the user an identity provider subject is bound to. The binding is what an SSO login resolves against: a user who changed their email at the provider keeps the same account, and nobody can claim it by taking the address first. Soft-deleted rows are returned too, so that signing in cannot resurrect a deactivated account.

func (*Store) GetWorkspaceGeneralSetting

func (s *Store) GetWorkspaceGeneralSetting(ctx context.Context) (*storepb.WorkspaceProfileSetting, error)

GetWorkspaceGeneralSetting gets the workspace general setting payload.

func (*Store) GetWorkspaceID

func (s *Store) GetWorkspaceID(ctx context.Context) (string, error)

GetWorkspaceID finds the workspace id in setting mt.workspace.id.

func (*Store) GetWorkspaceIamPolicy

func (s *Store) GetWorkspaceIamPolicy(ctx context.Context) (*IamPolicyMessage, error)

func (*Store) InsertLLMDebugLog

func (s *Store) InsertLLMDebugLog(ctx context.Context, provider, model, reqBody, respBody string) error

InsertLLMDebugLog inserts a debug log entry.

func (*Store) InvalidateMetaRegistryCache

func (s *Store) InvalidateMetaRegistryCache(list []*MetaRegistryResource)

InvalidateMetaRegistryCache drops the current-snapshot cache entries for the given rows. Call it after the transaction that wrote them has committed, so a rolled-back write can never leave a stale or uncommitted entry behind.

func (*Store) IsTokenRevoked

func (s *Store) IsTokenRevoked(ctx context.Context, tokenID string) (bool, error)

IsTokenRevoked reports whether the token was revoked. The persistent table is the authority; callers cache the answer only to save this lookup.

func (*Store) ListApplicationSQLAPIKeys

func (s *Store) ListApplicationSQLAPIKeys(ctx context.Context, application string) ([]*ApplicationSQLAPIKeyMessage, error)

ListApplicationSQLAPIKeys lists one application's live keys without exposing hashes.

func (*Store) ListApplicationSQLObservations

func (s *Store) ListApplicationSQLObservations(ctx context.Context, applicationSQLID int64) ([]*ApplicationSQLObservationMessage, error)

ListApplicationSQLObservations returns who reports one statement, and how much. It is read on the statement's detail view rather than with every list row.

func (*Store) ListApplicationSQLs

func (s *Store) ListApplicationSQLs(ctx context.Context, find *FindApplicationSQLMessage) ([]*ApplicationSQLMessage, error)

ListApplicationSQLs lists reported statements. It is ordered by most recently seen, which is the order the page shows by default.

func (*Store) ListApplications

func (s *Store) ListApplications(ctx context.Context, find *FindApplicationMessage) ([]*ApplicationMessage, error)

ListApplications lists applications matching the filter.

func (*Store) ListColumnLineage

func (s *Store) ListColumnLineage(ctx context.Context, find *FindColumnLineageMessage) ([]*ColumnLineage, error)

func (*Store) ListColumnLineageVersions

func (s *Store) ListColumnLineageVersions(ctx context.Context, metaType storepb.MetaType) (map[string]*ColumnLineageVersion, error)

ListColumnLineageVersions returns the analysis state of every object of the given meta type, keyed by meta GUID. The analyzer used to issue one lookup per object on every scan; column_lineage_version holds one row per analyzable object, so a single query is enough.

func (*Store) ListDatabases

func (s *Store) ListDatabases(ctx context.Context, find *FindDatabaseMessage) ([]*DatabaseMessage, error)

ListDatabases lists all databases.

func (*Store) ListEnvironments

func (s *Store) ListEnvironments(ctx context.Context) ([]*storepb.EnvironmentSetting_Environment, error)

ListEnvironments returns the configured environments in display order.

func (*Store) ListExternalDataset

func (s *Store) ListExternalDataset(ctx context.Context, find *FindExternalDatasetMessage) ([]*ExternalDatasetMessage, error)

ListExternalDataset returns external datasets matching the filter.

func (*Store) ListGroups

func (s *Store) ListGroups(ctx context.Context, find *FindGroupMessage) ([]*GroupMessage, error)

ListGroups list all groups.

func (*Store) ListIdentityProviderBindings

func (s *Store) ListIdentityProviderBindings(ctx context.Context, find *FindIdentityProviderBindingMessage) ([]*IdentityProviderBindingMessage, error)

ListIdentityProviderBindings lists the bindings an administrator can see: which account signs in through which provider subject. It is the read that makes a login landing on an unexpected account explainable without SQL.

Soft-deleted accounts are included on purpose: their bindings still exist, and hiding them would make the row that blocks a subject reuse invisible.

func (*Store) ListIdentityProviders

func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityProviderMessage) ([]*IdentityProviderMessage, error)

ListIdentityProviders lists identity providers, with their client secrets decrypted.

A row this build cannot read is skipped rather than reported: this list is what the login page renders for an anonymous visitor, and one hand-edited row must not remove every other provider's sign-in button. Get and the login path still fail loudly for it.

func (*Store) ListInstances

func (s *Store) ListInstances(ctx context.Context, find *FindInstanceMessage) ([]*InstanceMessage, error)

ListInstances lists all instance.

func (*Store) ListLLMProfiles

func (s *Store) ListLLMProfiles(ctx context.Context, find *FindLLMProfileMessage) ([]*LLMProfileMessage, error)

ListLLMProfiles lists LLM provider profiles.

func (*Store) ListManualSQL

func (s *Store) ListManualSQL(ctx context.Context, find *FindManualSQLMessage) ([]*ManualSQLMessage, error)

ListManualSQL lists manual SQL entries matching the filter.

func (*Store) ListMetaRegistry

func (s *Store) ListMetaRegistry(ctx context.Context, find *FindMetaRegistryResourceMessage) ([]*MetaRegistryResource, error)

func (*Store) ListMetaRegistryHistory

func (s *Store) ListMetaRegistryHistory(ctx context.Context, find *FindMetaRegistryHistoryMessage) ([]*MetaRegistryHistory, error)

func (*Store) ListMetaRegistryResource

func (s *Store) ListMetaRegistryResource(ctx context.Context, find *FindMetaRegistryResourceMessage) ([]*MetaRegistryResource, error)

func (*Store) ListMetaRegistryResourceAsOf

func (s *Store) ListMetaRegistryResourceAsOf(ctx context.Context, find *FindMetaRegistryResourceMessage, asOf time.Time) ([]*MetaRegistryResource, error)

func (*Store) ListMetaRegistryResourceDigest

func (s *Store) ListMetaRegistryResourceDigest(ctx context.Context, find *FindMetaRegistryResourceMessage) ([]*MetaRegistryResource, error)

ListMetaRegistryResourceDigest lists meta registry rows without loading or unmarshalling their metadata: only ID, GUID, ObjectType and MetaHash are populated. The lineage analyzer scans every analyzable object hourly just to compare hashes, and the full listing made it parse every view definition.

It deliberately does not touch the metadata caches — a cached entry with a nil Metadata would corrupt later reads.

func (*Store) ListMetaRegistrySchemaHashes

func (s *Store) ListMetaRegistrySchemaHashes(ctx context.Context, keys []MetaGUIDKey) (map[MetaGUIDKey][]byte, error)

ListMetaRegistrySchemaHashes returns the stored DDL hash of every key that has a row. A syncer that re-reads every object's DDL can compare against these hashes and write only the definitions that actually changed, instead of shipping every definition back to the database on every sync.

func (*Store) ListNamespaceMapping

func (s *Store) ListNamespaceMapping(ctx context.Context, find *FindNamespaceMappingMessage) ([]*NamespaceMappingMessage, error)

ListNamespaceMapping returns namespace mappings matching the filter.

func (*Store) ListNotifications

func (s *Store) ListNotifications(ctx context.Context, find *FindNotificationMessage) ([]*storepb.Notification, error)

ListNotifications lists one recipient's notifications, newest first.

func (*Store) ListOAuthClients

func (s *Store) ListOAuthClients(ctx context.Context) ([]*OAuthClient, error)

ListOAuthClients returns every registration, oldest first.

func (*Store) ListOpenLineageAPIKey

func (s *Store) ListOpenLineageAPIKey(ctx context.Context) ([]*OpenLineageAPIKeyMessage, error)

ListOpenLineageAPIKey returns all API keys without exposing the hash.

func (*Store) ListOpenLineageDatasetAggregate

func (s *Store) ListOpenLineageDatasetAggregate(ctx context.Context, find *FindOpenLineageDatasetMessage) ([]*OpenLineageDatasetAggregateMessage, error)

ListOpenLineageDatasetAggregate reads the dataset window with the aggregate the list shows. The filters it answers in SQL are applied inside the window, never to widen it: the detail resolves the requested GUID against the unfiltered window, so a filtered list must not offer a dataset the detail cannot open.

func (*Store) ListOpenLineageDatasetFilterValues

func (s *Store) ListOpenLineageDatasetFilterValues(ctx context.Context) ([]*OpenLineageFilterValue, error)

ListOpenLineageDatasetFilterValues returns the dataset dimensions the dataset page's filter menus offer, most common first, read from the same window the list reads: a menu value that no dataset of its window carries would filter the list down to nothing. Each count is the number of datasets carrying the value.

func (*Store) ListOpenLineageDatasetWindow

func (s *Store) ListOpenLineageDatasetWindow(ctx context.Context) ([]OpenLineageDatasetPair, error)

ListOpenLineageDatasetWindow returns the spellings of the dataset window. The detail resolves the requested GUID against it, so the dataset a list row shows is always one the detail can open.

func (*Store) ListOpenLineageFilterValues

func (s *Store) ListOpenLineageFilterValues(ctx context.Context) ([]*OpenLineageFilterValue, error)

ListOpenLineageFilterValues returns the distinct values of every dimension the OpenLineage index pages filter by, most common first.

Both tables are read in one statement so a menu costs one round trip. The dataset dimensions are answered separately by ListOpenLineageDatasetFilterValues: they describe the datasets of the window the dataset list itself reads.

func (*Store) ListOpenLineageRun

func (s *Store) ListOpenLineageRun(ctx context.Context, find *FindOpenLineageRunMessage) ([]*OpenLineageRunMessage, error)

ListOpenLineageRun lists persisted OpenLineage runs matching the filter.

func (*Store) ListOpenLineageTask

func (s *Store) ListOpenLineageTask(ctx context.Context, find *FindOpenLineageTaskMessage) ([]*OpenLineageTaskMessage, error)

ListOpenLineageTask lists aggregated OpenLineage tasks/jobs matching the filter.

func (*Store) ListRoles

func (s *Store) ListRoles(ctx context.Context, find *FindRoleMessage) ([]*RoleMessage, error)

ListRoles returns a list of roles. When ResourceID is set, predefined roles are consulted first; when listing all, predefined roles are appended to the DB result.

func (*Store) ListSetting

func (s *Store) ListSetting(ctx context.Context, find *FindSettingMessage) ([]*SettingMessage, error)

ListSetting returns a list of settings.

func (*Store) ListSublevelMetaRegistryResource

func (s *Store) ListSublevelMetaRegistryResource(ctx context.Context, find *FindSubLevelMetaRegistryResourceMessage) ([]*MetaRegistryResource, error)

func (*Store) ListUsers

func (s *Store) ListUsers(ctx context.Context, find *FindUserMessage) ([]*UserMessage, error)

ListUsers list users.

func (*Store) MarkAllNotificationsRead

func (s *Store) MarkAllNotificationsRead(ctx context.Context, recipientID int) (int64, error)

MarkAllNotificationsRead marks every unread notification of one recipient read and returns how many rows changed.

func (*Store) MarkNotificationsRead

func (s *Store) MarkNotificationsRead(ctx context.Context, recipientID int, ids []int64) (int64, error)

MarkNotificationsRead marks the named notifications of one recipient read and returns how many rows changed. Already-read rows are left alone, so the count is the number of messages this call actually turned unread → read.

func (*Store) MarkNotificationsSeen

func (s *Store) MarkNotificationsSeen(ctx context.Context, recipientID int) error

MarkNotificationsSeen records that one recipient has now opened the inbox, which clears the badge. The server stamps the time, as it does for read_at, so a caller cannot claim to have opened the inbox before a message it should see was written. Nothing is marked read here: an unread message stays unread until it is clicked.

The comparison the count makes is between this database clock and the application clock that stamped created_at, so the two hosts are assumed to agree.

func (*Store) PatchWorkspaceIamPolicy

func (s *Store) PatchWorkspaceIamPolicy(ctx context.Context, patch *PatchIamPolicyMessage) (*IamPolicyMessage, error)

PatchWorkspaceIamPolicy will set or remove the member for the workspace role.

func (*Store) RecordApplicationSQLReport

func (s *Store) RecordApplicationSQLReport(ctx context.Context, keyID int64, reportID string, accepted, rejected int) error

RecordApplicationSQLReport stores one report's outcome on its key: the counters, and the report id that a retry carries.

func (*Store) RecordLastLogin

func (s *Store) RecordLastLogin(ctx context.Context, user *UserMessage, at time.Time) error

RecordLastLogin stamps the last login time in the profile without rewriting the rest of the column. A login used to write the whole profile back from the row it had read, which could resurrect a stale copy of it — including the password change time that retires sessions, the value an SSO adoption sets.

func (*Store) ReportApplicationSQLs

func (s *Store) ReportApplicationSQLs(ctx context.Context, reports []*ReportApplicationSQLMessage) ([]*ApplicationSQLMessage, error)

ReportApplicationSQLs records one reported entry, whose statements share a transaction: either every statement lands with its observation and its mirror, or none does.

An entry is the unit the application retries, so a half-written entry is worse than a refused one — the retry would count the statements that did land a second time. The entry is also the natural unit for the mirror: a statement is mirrored exactly when it is stored.

Each statement is upserted by its scope and fingerprint, folded into that application's observation, rolled up, and mirrored into the meta registry. Statements are mirrored whether or not they turn out to be writes: the mirror is what makes an object addressable by GUID — GetMetadata, history and Explain SQL all read it — while the graph node set is derived from lineage edges, which only a write gets. See .agents/docs/application-sql-ingestion.md, "Data model".

func (*Store) ResolveCipher

func (s *Store) ResolveCipher(ctx context.Context, current []byte, previous [][]byte) error

ResolveCipher reads the deployment credential key from the setting table, unwraps it with the configured key-encryption keys, checks that it opens a credential the database already holds, and installs the resulting cipher on the store.

current is the operator's key-encryption key, or nil when none is configured: the deployment then keeps its data key in the database alone. previous holds retired keys, most recent first, and is only ever used to open a wrapped key — it never wraps one, so retiring a key cannot quietly promote it back. A data key found bare while a key-encryption key is configured, or opened by a retired one, is rewritten under the current key without re-encrypting a single credential.

func (*Store) RevokeApplicationSQLAPIKey

func (s *Store) RevokeApplicationSQLAPIKey(ctx context.Context, application string, id int64) error

RevokeApplicationSQLAPIKey stops one key without touching the application's history.

func (*Store) RevokeOpenLineageAPIKey

func (s *Store) RevokeOpenLineageAPIKey(ctx context.Context, id int64) error

RevokeOpenLineageAPIKey soft-deletes an API key by setting revoked_at.

func (*Store) RevokeToken

func (s *Store) RevokeToken(ctx context.Context, tokenID string, expiresAt time.Time) error

RevokeToken records that a token is no longer accepted, keeping the record until the token itself would have expired. Revoking the same token twice is a no-op, so a repeated logout is harmless.

func (*Store) SearchAuditLogs

func (s *Store) SearchAuditLogs(ctx context.Context, find *FindAuditLogMessage) ([]*storepb.AuditLog, error)

func (*Store) SearchMetaRegistryResource

func (s *Store) SearchMetaRegistryResource(ctx context.Context, find *SearchMetaRegistryResourceMessage) ([]*MetaRegistryResource, error)

SearchMetaRegistryResource searches metadata by name and comment within the JSONB column. It reads the generated search_text column, which is exactly the concatenation of the inner object's name, title, comment and userComment fields: the matched rows are the same, but the predicate is answered by the trigram index instead of a sequential LATERAL jsonb_each scan.

func (*Store) SetApplicationSQLKind

func (s *Store) SetApplicationSQLKind(ctx context.Context, guid string, kind ApplicationSQLKind) error

SetApplicationSQLKind records the read/write classification the runner derived. It is a filter cache written before the edges, not a claim about them: a failed edge write leaves the kind set until the next analysis rewrites both, and the lineage version records the failure meanwhile.

func (*Store) SetCipher

func (s *Store) SetCipher(c *crypto.Cipher)

SetCipher installs the data key every stored credential is encrypted with. The server resolves it once at startup; a store without one refuses to read or write a credential rather than storing plaintext.

func (*Store) SetWorkspaceIamPolicy

func (s *Store) SetWorkspaceIamPolicy(ctx context.Context, policy *storepb.IamPolicy, etag string) (*IamPolicyMessage, error)

SetWorkspaceIamPolicy replaces the workspace IAM policy whole. etag guards optimistic concurrency: an empty etag skips the check (a first write), any other value must equal the etag returned by GetWorkspaceIamPolicy. The allUsers invariant is enforced here as well as at the API boundary, so a caller that skips validateIamPolicy cannot store a policy that violates it.

func (*Store) StatUsers

func (s *Store) StatUsers(ctx context.Context) ([]*UserStat, error)

func (*Store) TouchOAuthClient

func (s *Store) TouchOAuthClient(ctx context.Context, clientID string) error

TouchOAuthClient stamps last_used_time with NOW(). A client that no longer exists is reported as NotFound rather than silently ignored.

func (*Store) UpdateApplication

func (s *Store) UpdateApplication(ctx context.Context, applicationID string, patch *UpdateApplicationMessage) (*ApplicationMessage, error)

UpdateApplication patches one application by its public id.

func (*Store) UpdateDatabase

func (s *Store) UpdateDatabase(ctx context.Context, patch *UpdateDatabaseMessage) (*DatabaseMessage, error)

UpdateDatabase updates a database.

func (*Store) UpdateEnvironment

func (s *Store) UpdateEnvironment(ctx context.Context, id string, patch *EnvironmentPatch) (*storepb.EnvironmentSetting_Environment, error)

UpdateEnvironment rewrites the mutable fields of one environment. The id is never changed so existing instance references stay valid.

func (*Store) UpdateGroup

func (s *Store) UpdateGroup(ctx context.Context, email string, patch *UpdateGroupMessage) (*GroupMessage, error)

UpdateGroup updates a group.

func (*Store) UpdateIdentityProvider

func (s *Store) UpdateIdentityProvider(ctx context.Context, patch *UpdateIdentityProviderMessage) (*IdentityProviderMessage, error)

UpdateIdentityProvider updates an identity provider. A nil field is left alone.

func (*Store) UpdateInstance

func (s *Store) UpdateInstance(ctx context.Context, patch *UpdateInstanceMessage) (*InstanceMessage, error)

UpdateInstance updates an instance.

func (*Store) UpdateLLMProfile

func (s *Store) UpdateLLMProfile(ctx context.Context, update *UpdateLLMProfileMessage) (*LLMProfileMessage, error)

UpdateLLMProfile updates an existing LLM provider profile.

func (*Store) UpdateManualSQL

func (s *Store) UpdateManualSQL(ctx context.Context, guid string, patch *UpdateManualSQLMessage) (*ManualSQLMessage, error)

UpdateManualSQL updates a manual SQL entry by GUID.

func (*Store) UpdateNamespaceMapping

func (s *Store) UpdateNamespaceMapping(ctx context.Context, id int64, msg *NamespaceMappingMessage, updateMask []string) (*NamespaceMappingMessage, error)

UpdateNamespaceMapping updates an existing namespace mapping.

updateMask lists the proto field paths to write. An empty mask keeps the fields a proto3 caller cannot mark as absent: namespace and instance_resource_id are skipped when empty, while database_name is always written so it can be cleared.

func (*Store) UpdateRole

func (s *Store) UpdateRole(ctx context.Context, patch *UpdateRoleMessage) (*RoleMessage, error)

UpdateRole updates an existing custom role.

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, currentUser *UserMessage, patch *UpdateUserMessage) (*UserMessage, error)

UpdateUser updates a user.

func (*Store) UpsertColumnLineageVersion

func (s *Store) UpsertColumnLineageVersion(ctx context.Context, v *ColumnLineageVersion) error

UpsertColumnLineageVersion inserts or updates the analysis version record for an object.

func (*Store) UpsertDatabase

func (s *Store) UpsertDatabase(ctx context.Context, create *DatabaseMessage) (*DatabaseMessage, error)

UpsertDatabase upserts a database.

func (*Store) UpsertExplainSQLCache

func (s *Store) UpsertExplainSQLCache(ctx context.Context, r *ExplainSQLCacheRow) error

UpsertExplainSQLCache inserts or replaces a cached explanation.

func (*Store) UpsertOpenLineageRun

func (s *Store) UpsertOpenLineageRun(ctx context.Context, run *OpenLineageRunMessage) (*OpenLineageRunMessage, error)

UpsertOpenLineageRun persists one OpenLineage run and mirrors it into meta_registry_resource.

func (*Store) UpsertOpenLineageRuns

func (s *Store) UpsertOpenLineageRuns(ctx context.Context, runs []*OpenLineageRunMessage) ([]*OpenLineageRunMessage, error)

UpsertOpenLineageRuns persists several runs in a single transaction, so ingesting a batch costs one transaction instead of one per event. A delivery that a finished run refuses is reported as that finished run.

func (*Store) UpsertSetting

func (s *Store) UpsertSetting(ctx context.Context, update *SetSettingMessage) (*SettingMessage, error)

UpsertSetting upserts the setting by name.

func (*Store) ValidateOpenLineageAPIKey

func (s *Store) ValidateOpenLineageAPIKey(ctx context.Context, plainKey string) (*OpenLineageAPIKeyMessage, error)

ValidateOpenLineageAPIKey checks the key against the stored digest and hash. Returns the matching key record or an error if no match is found.

type UpdateApplicationMessage

type UpdateApplicationMessage struct {
	Name        *string
	Description *string
	Disabled    *bool
}

UpdateApplicationMessage contains the mutable fields of an application.

type UpdateDatabaseMessage

type UpdateDatabaseMessage struct {
	InstanceID   string
	DatabaseName string

	Deleted *bool
	// Empty string will unset the environment.
	EnvironmentID   *string
	MetadataUpdates []func(*storepb.DatabaseMetadata)
}

UpdateDatabaseMessage is the mssage for updating a database.

type UpdateGroupMessage

type UpdateGroupMessage struct {
	Title       *string
	Description *string
	Payload     *storepb.GroupPayload
}

UpdateGroupMessage is the message to update a group.

type UpdateIdentityProviderMessage

type UpdateIdentityProviderMessage struct {
	ResourceID string
	Title      *string
	Domain     *string
	Config     *storepb.IdentityProviderConfig
}

UpdateIdentityProviderMessage is the message for updating an identity provider. A nil field is left alone.

type UpdateInstanceMessage

type UpdateInstanceMessage struct {
	ResourceID string

	Deleted       *bool
	EnvironmentID *string
	Metadata      *storepb.Instance
}

UpdateInstanceMessage is the message for updating an instance.

type UpdateLLMProfileMessage

type UpdateLLMProfileMessage struct {
	ResourceID string
	Title      *string
	BaseURL    *string
	APIKey     *string
	Models     []*storepb.LlmProviderModel
}

UpdateLLMProfileMessage is the message for updating an LLM provider profile.

type UpdateManualSQLMessage

type UpdateManualSQLMessage struct {
	Name       *string
	Title      *string
	Comment    *string
	SQLText    *string
	SchemaName *string
	Tags       *[]string
	Attributes *map[string]string
	UpdatedBy  *string
	Deleted    *bool
}

UpdateManualSQLMessage contains the mutable fields for a manual SQL entry.

type UpdateRoleMessage

type UpdateRoleMessage struct {
	ResourceID string

	Name        *string
	Description *string
	Permissions *map[permission.Permission]bool
}

UpdateRoleMessage is the message for updating roles.

type UpdateUserMessage

type UpdateUserMessage struct {
	Email        *string
	Name         *string
	PasswordHash *string
	Delete       *bool
	Profile      *storepb.UserProfile
	Phone        *string
	// Language replaces the profile's language key instead of the whole column,
	// so a preference change cannot write a stale copy of the rest of the
	// profile back into the row.
	Language *string
}

UpdateUserMessage is the message to update a user.

type UserMessage

type UserMessage struct {
	ID int
	// Email must be lower case.
	Email         string
	Name          string
	Type          storepb.PrincipalType
	PasswordHash  string
	MemberDeleted bool
	Profile       *storepb.UserProfile
	// Phone conforms E.164 format.
	Phone string
	// output only
	CreatedAt time.Time
	// The group email list
	Groups []string
}

UserMessage is the message for an user.

type UserStat

type UserStat struct {
	Type    storepb.PrincipalType
	Deleted bool
	Count   int
}

type WebRefreshToken

type WebRefreshToken struct {
	// TokenHash is the SHA-256 hex digest of the opaque token. The plaintext is
	// never stored.
	TokenHash string
	UserID    int
	ExpiresAt time.Time
	// IssuedAt is when the session was established. A rotated token carries the
	// original value forward rather than stamping the rotation, so the session
	// stays ordered against the user's last password change however many times
	// it is refreshed. Required on create.
	IssuedAt time.Time
}

WebRefreshToken is one SPA session's rotation state.

Jump to

Keyboard shortcuts

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