authorizedexecute

package
v1.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package authorizedexecute is the only package-level capability boundary for operations against business datasources. The concrete drivers and their raw SQL handles live below the nested internal/businessdb package.

Index

Constants

View Source
const (
	DBErrorCodeObjectNotFound       = businessdb.DBErrorCodeObjectNotFound
	DBErrorCodeColumnNotFound       = businessdb.DBErrorCodeColumnNotFound
	DBErrorCodeAlreadyExists        = businessdb.DBErrorCodeAlreadyExists
	DBErrorCodeSyntax               = businessdb.DBErrorCodeSyntax
	DBErrorCodeSemantic             = businessdb.DBErrorCodeSemantic
	DBErrorCodeData                 = businessdb.DBErrorCodeData
	DBErrorCodeConstraint           = businessdb.DBErrorCodeConstraint
	DBErrorCodeRetryable            = businessdb.DBErrorCodeRetryable
	DBErrorCodeTransaction          = businessdb.DBErrorCodeTransaction
	DBErrorCodeResource             = businessdb.DBErrorCodeResource
	DBErrorCodeTimeout              = businessdb.DBErrorCodeTimeout
	DBErrorCodeInterrupted          = businessdb.DBErrorCodeInterrupted
	DBErrorCodePermission           = businessdb.DBErrorCodePermission
	DBErrorCodeReadOnly             = businessdb.DBErrorCodeReadOnly
	DBErrorCodeAuthentication       = businessdb.DBErrorCodeAuthentication
	DBErrorCodeDatabaseNotFound     = businessdb.DBErrorCodeDatabaseNotFound
	DBErrorCodeConnection           = businessdb.DBErrorCodeConnection
	DBErrorCodeExecution            = businessdb.DBErrorCodeExecution
	DBErrorCodeGatewayInternal      = businessdb.DBErrorCodeGatewayInternal
	DBErrorCodeAuditUnavailable     = businessdb.DBErrorCodeAuditUnavailable
	DBErrorCodeAuditOverloaded      = businessdb.DBErrorCodeAuditOverloaded
	DBErrorCodeCommitOutcomeUnknown = businessdb.DBErrorCodeCommitOutcomeUnknown

	DBErrorKindObjectNotFound   = businessdb.DBErrorKindObjectNotFound
	DBErrorKindColumnNotFound   = businessdb.DBErrorKindColumnNotFound
	DBErrorKindAlreadyExists    = businessdb.DBErrorKindAlreadyExists
	DBErrorKindSyntax           = businessdb.DBErrorKindSyntax
	DBErrorKindSemantic         = businessdb.DBErrorKindSemantic
	DBErrorKindData             = businessdb.DBErrorKindData
	DBErrorKindConstraint       = businessdb.DBErrorKindConstraint
	DBErrorKindRetryable        = businessdb.DBErrorKindRetryable
	DBErrorKindTransaction      = businessdb.DBErrorKindTransaction
	DBErrorKindResource         = businessdb.DBErrorKindResource
	DBErrorKindTimeout          = businessdb.DBErrorKindTimeout
	DBErrorKindInterrupted      = businessdb.DBErrorKindInterrupted
	DBErrorKindPermission       = businessdb.DBErrorKindPermission
	DBErrorKindReadOnly         = businessdb.DBErrorKindReadOnly
	DBErrorKindAuthentication   = businessdb.DBErrorKindAuthentication
	DBErrorKindDatabaseNotFound = businessdb.DBErrorKindDatabaseNotFound
	DBErrorKindConnection       = businessdb.DBErrorKindConnection
	DBErrorKindExecution        = businessdb.DBErrorKindExecution

	DBStageParse    = businessdb.DBStageParse
	DBStageConnect  = businessdb.DBStageConnect
	DBStagePing     = businessdb.DBStagePing
	DBStageAcquire  = businessdb.DBStageAcquire
	DBStageBeginTx  = businessdb.DBStageBeginTx
	DBStageExplain  = businessdb.DBStageExplain
	DBStageMetadata = businessdb.DBStageMetadata
	DBStageQuery    = businessdb.DBStageQuery
	DBStageReadRows = businessdb.DBStageReadRows
	DBStageExecute  = businessdb.DBStageExecute
	DBStageCommit   = businessdb.DBStageCommit
	DBStageRollback = businessdb.DBStageRollback
)
View Source
const (
	DefaultRequestWall   = 10 * time.Second
	DefaultStatementWall = 5 * time.Second
	DefaultLockWall      = 2 * time.Second
)
View Source
const (
	ColumnAuditVersion = 2
)

Variables

View Source
var (
	ErrQueryTimeout             = businessdb.ErrQueryTimeout
	ErrReadOnlyViolated         = businessdb.ErrReadOnlyViolated
	ErrDatasourceUnreachable    = businessdb.ErrDatasourceUnreachable
	ErrPermissionDenied         = businessdb.ErrPermissionDenied
	ErrSessionExists            = businessdb.ErrSessionExists
	ErrSessionClosed            = businessdb.ErrSessionClosed
	ErrTransactionDone          = businessdb.ErrTransactionDone
	ErrSessionTransactionActive = businessdb.ErrSessionTransactionActive
)
View Source
var DefaultLimits = Limits{
	RawSQLBytes: 256 << 10, ParameterCount: 256, ParameterBytes: 64 << 10, ParametersBytes: 1 << 20,
	Tokens: 100_000, LexicalDepth: 128, ASTNodes: 50_000, QueryBlocks: 256,
	Projections: 4_096, OutputColumns: 256, Relations: 256, ViewDepth: 16, CatalogRoundTrips: 32,
	DefinitionBytes: 1 << 20, BinderBytes: 8 << 20, CatalogBytes: 8 << 20,
	CatalogRows: 50_000, ColumnMetadata: 16_384, DependencyEdges: 32_768,
	ExpandedPaths: 65_536, WorkUnits: 250_000, FrameBytes: 1 << 20,
	RawCellBytes: 64 << 10, RawRowBytes: 1 << 20, RawResultBytes: 16 << 20,
	MaskedCellBytes: 128 << 10, MaskedResultBytes: 16 << 20, EnvelopeBytes: 20 << 20,
}
View Source
var DefaultReservationLimits = ReservationLimits{PerAgent: 4, PerTenant: 32, PerDatasource: 16, GlobalMemoryBytes: 1 << 30}

DefaultReservationLimits permits a datasource's full concurrency envelope (16 requests at 52 MiB each) with 192 MiB of global headroom. The memory counter tracks only explicit request buffer reservations; it must never be initialized from process/runtime memory, which is outside the request quota.

View Source
var ErrCommitOutcomeUnknown = errors.New("authorized execution commit outcome unknown")
View Source
var ErrNativeUnsupported = errors.New("native capability unsupported")
View Source
var ErrUnsealed = errors.New("authorized response is not sealed")

Functions

func ClassifyNativeCommand added in v0.5.0

func ClassifyNativeCommand(dbType string, request NativeQueryRequest) (string, error)

func EncodeEnvelope

func EncodeEnvelope(value any, limits Limits) ([]byte, error)

EncodeEnvelope fully encodes and caps a final response before any transport can observe it.

func PostgresColumnTypeDigest

func PostgresColumnTypeDigest(typeOID uint32, typmod int32, collationOID uint32) string

func PostgresStableObjectID

func PostgresStableObjectID(databaseOID, relationOID uint32) string

func ProbeDatasource

func ProbeDatasource(ctx context.Context, datasource model.Datasource, password string) error

ProbeDatasource performs only connect, ping and close for CLI enrollment. It never returns the opened pool or any SQL-capable object.

func ReadBoundedFrame

func ReadBoundedFrame(reader io.Reader, limit int) ([]byte, error)

ReadBoundedFrame validates the attacker-controlled length before allocation.

func SealedHTTP

func SealedHTTP(next http.Handler, limit int) http.Handler

SealedHTTP buffers one handler invocation and commits only after it returns successfully and the complete bounded body has been sealed.

func Suggestion

func Suggestion(code DBErrorCode) string

func ValidatePreParse

func ValidatePreParse(rawSQL string, parameters [][]byte, limits Limits) error

ValidatePreParse applies byte, parameter, token and lexical-depth bounds without allocating proportionally to attacker-controlled token counts.

func ValidateResult

func ValidateResult(result model.QueryResult, masked bool, limits Limits) error

ValidateResult applies independent cell, row and aggregate limits. It does not truncate: any overflow invalidates the entire buffered result.

func WithColumnAuthorization

func WithColumnAuthorization(ctx context.Context, request ColumnAuthorizationRequest) context.Context

WithColumnAuthorization binds non-executable control-snapshot facts to the sole AuthorizedExecute façade. The request deliberately cannot carry SQL, credentials, a datasource, or a database capability.

func WithLockDeadline

func WithLockDeadline(parent context.Context, configuredRequest time.Duration) (context.Context, context.CancelFunc)

WithLockDeadline creates one shared wall budget for lock, execute, read, mask, encode, post-check, audit and transaction cleanup.

func WithRequestDeadline

func WithRequestDeadline(parent context.Context, configured time.Duration) (context.Context, context.CancelFunc)

WithRequestDeadline creates the sole request parent deadline.

func WithReservationScope

func WithReservationScope(ctx context.Context, agent, tenant string) context.Context

WithReservationScope attaches stable quota identities without exposing a mutable reservation or any database capability to the caller.

func WithStatementDeadline

func WithStatementDeadline(parent context.Context, datasource time.Duration) (context.Context, context.CancelFunc)

WithStatementDeadline derives execution from the request/lock parent.

func WriteSealedFrame

func WriteSealedFrame(writer io.Writer, frame []byte, limit int) error

WriteSealedFrame caps a complete frame before writing its header or payload.

Types

type AuthError

type AuthError struct{ Reason Reason }

AuthError intentionally carries no underlying error or dynamic text.

func StableError

func StableError(err error) *AuthError

StableError maps every internal/database failure to a fixed public error.

func (*AuthError) Error

func (err *AuthError) Error() string

type AuthorizedSelectResult

type AuthorizedSelectResult struct {
	Allowed bool
	Reason  Reason
	Result  model.QueryResult
	Redact  mask.RedactReport
	Audit   ColumnAuthorizationAudit
	Encoded []byte
	Seal    DeliverySeal
}

type B5DMLAuthorizationConfig

type B5DMLAuthorizationConfig struct {
	PrincipalID          string
	DatasourceID         string
	Policies             []b5dml.Policy
	Decision             b5coordinator.Decision
	PreliminaryAllowed   bool
	DatasourceSupported  bool
	ReservedTarget       bool
	PolicySnapshotDigest string
}

type B5DMLPolicyProvider

B5DMLPolicyProvider derives the exact action/write/reference grants from an enrolled, non-executable statement fact set. It is the production-safe bridge for policy resolvers that cannot know PostgreSQL OIDs before binder enrollment; it never receives a connection, transaction, prepared object, or executor.

type B5PostgresRuntime

type B5PostgresRuntime struct {
	Analyzer b5coordinator.Analyzer
	Engine   b5coordinator.Engine
}

B5PostgresRuntime is the narrow B5 capability bridge used by production. Neither side exposes a pool, connection, transaction, prepared statement or raw SQL executor. Production protocol handlers intentionally do not reference it.

type Budget

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

Budget is a single checked counter shared by AST, lineage and catalog work.

func NewBudget

func NewBudget(limits Limits) *Budget

func (*Budget) ChargeAST

func (budget *Budget) ChargeAST(ast *model.AST) error

func (*Budget) ChargeBinderBytes

func (budget *Budget) ChargeBinderBytes(count int) error

func (*Budget) ChargeCatalogBytes

func (budget *Budget) ChargeCatalogBytes(count int) error

func (*Budget) ChargeCatalogRoundTrips

func (budget *Budget) ChargeCatalogRoundTrips(count int) error

func (*Budget) ChargeCatalogRows

func (budget *Budget) ChargeCatalogRows(count int) error

func (*Budget) ChargeColumnMetadata

func (budget *Budget) ChargeColumnMetadata(count int) error

func (*Budget) ChargeDefinitionBytes

func (budget *Budget) ChargeDefinitionBytes(count int) error

func (*Budget) ChargeEdges

func (budget *Budget) ChargeEdges(count int) error

func (*Budget) ChargeNodes

func (budget *Budget) ChargeNodes(count int) error

func (*Budget) ChargePaths

func (budget *Budget) ChargePaths(count int) error

func (*Budget) ChargeRelations

func (budget *Budget) ChargeRelations(count int) error

ChargeRelations counts every distinct relation admitted to a candidate or locked closure. Callers must charge before appending to an attacker-sized slice so the limit also bounds allocation.

func (*Budget) ChargeWork

func (budget *Budget) ChargeWork(count int) error

func (*Budget) CheckViewDepth

func (budget *Budget) CheckViewDepth(depth int) error

type ColumnAuditDetail

type ColumnAuditDetail struct {
	Identity string `json:"identity"`
	Usage    string `json:"usage"`
	Site     string `json:"site"`
	Reason   string `json:"reason"`
}

type ColumnAuthorizationAudit

type ColumnAuthorizationAudit struct {
	Version        int                 `json:"version"`
	Decision       string              `json:"decision"`
	Reason         string              `json:"reason"`
	PlanDigest     string              `json:"plan_digest"`
	BinderDigest   string              `json:"binder_digest"`
	FpreDigest     string              `json:"fpre_digest"`
	FpostDigest    string              `json:"fpost_digest,omitempty"`
	Details        []ColumnAuditDetail `json:"details,omitempty"`
	Truncated      bool                `json:"truncated,omitempty"`
	CompleteDigest string              `json:"complete_digest,omitempty"`
}

type ColumnAuthorizationProvider

type ColumnAuthorizationProvider interface {
	BeginColumnAuthorization(context.Context, string, model.Datasource) (ColumnAuthorizationRequest, func() error, error)
}

ColumnAuthorizationProvider is used by fixed internal SELECT producers (currently controlledread sampling) that cannot attach an agent pipeline snapshot themselves. It returns request facts plus the control-snapshot close barrier that must run after seal and before any result is returned.

type ColumnAuthorizationRequest

type ColumnAuthorizationRequest struct {
	Agent              model.Agent
	Policies           []model.Policy
	Redactor           mask.Redactor
	RowLimit           int
	PreliminaryAllowed bool
	// BindBeforePreliminaryDeny permits the prepare-only binder to resolve
	// object existence before honoring a preliminary static denial. The
	// preliminary denial remains part of the sealed authorization input, so a
	// successfully bound statement is still denied before execution.
	BindBeforePreliminaryDeny bool
	ControlRevisionDigest     string
	Limits                    Limits
	DurableAudit              func(context.Context, ColumnAuthorizationAudit, *model.QueryResult, mask.RedactReport) error
	FinalFence                func(context.Context) error
	Observe                   func(SelectPhase)
	// These credentials are supplied by the local, per-datasource configuration
	// and are used only by the fixed PROCESS-only TABLE_ID inspector.
	MySQLMetadataUsername string
	MySQLMetadataPassword string
}

ColumnAuthorizationRequest contains control-snapshot facts and callbacks, but no SQL, credentials, datasource, or SQL-capable handle. It is attached to the AuthorizedExecute call and cannot create a second raw SQL ingress.

type ColumnAuthorizedStatement

type ColumnAuthorizedStatement interface {
	Statement
	ColumnAuthorizationResult() (AuthorizedSelectResult, bool)
}

ColumnAuthorizedStatement exposes only the sealed outcome of the exact statement routed by AuthorizedExecute; it cannot accept or execute SQL.

type ColumnRef

type ColumnRef struct{ Schema, Table, Column string }

type DBError

type DBError = businessdb.DBError

Stable error aliases preserve the A4 public envelope without exposing a driver, pool, session, transaction, or arbitrary-SQL capability.

func NewDBError

func NewDBError(kind DBErrorKind, code DBErrorCode, stage DBStage) *DBError

type DBErrorCode

type DBErrorCode = businessdb.DBErrorCode

Stable error aliases preserve the A4 public envelope without exposing a driver, pool, session, transaction, or arbitrary-SQL capability.

type DBErrorKind

type DBErrorKind = businessdb.DBErrorKind

Stable error aliases preserve the A4 public envelope without exposing a driver, pool, session, transaction, or arbitrary-SQL capability.

type DBStage

type DBStage = businessdb.DBStage

Stable error aliases preserve the A4 public envelope without exposing a driver, pool, session, transaction, or arbitrary-SQL capability.

type DeliverySeal

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

DeliverySeal has no exported constructor or fields. It binds the exact encoded candidate to this invocation after audit and final fence complete.

func (DeliverySeal) Verify

func (seal DeliverySeal) Verify(encoded []byte) bool

type Gateway

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

Gateway owns business credentials and pools without exporting a raw SQL, connection, session, transaction, driver or database/sql handle.

func NewGateway

func NewGateway(readOnly bool, options ...GatewayOption) *Gateway

func (*Gateway) AuthorizedExecute

func (gateway *Gateway) AuthorizedExecute(
	ctx context.Context,
	datasource model.Datasource,
	secret []byte,
	sqlText string,
	sessionID string,
) (Statement, error)

AuthorizedExecute is the sole raw-statement ingress to the business database capability domain. The returned capability can only operate on this exact statement and cannot be repurposed as an arbitrary SQL sink.

func (*Gateway) BindMySQLColumnCatalog added in v1.3.0

func (gateway *Gateway) BindMySQLColumnCatalog(ctx context.Context, datasource model.Datasource,
	secret []byte, metadataUsername, metadataPassword, schema, table string,
) (_ *MySQLCatalogLease, returnedErr error)

func (*Gateway) Close

func (gateway *Gateway) Close(id string) error

func (*Gateway) CloseAll

func (gateway *Gateway) CloseAll() error

func (*Gateway) EnrollPostgresPolicyDML

func (gateway *Gateway) EnrollPostgresPolicyDML(ctx context.Context, datasource model.Datasource, secret []byte, rawSQL string, limits Limits) (PostgresPolicyEnrollment, error)

EnrollPostgresPolicyDML performs the same mode selection for one planned DML statement. It never executes the statement and exposes only exact grant elements consumed by the B5 policy store.

func (*Gateway) EnrollPostgresPolicySelect

func (gateway *Gateway) EnrollPostgresPolicySelect(ctx context.Context, datasource model.Datasource, secret []byte, rawSQL string, limits Limits) (PostgresPolicyEnrollment, error)

EnrollPostgresPolicySelect chooses the same native-or-closed mode used by production, binds the statement without executing it, and returns only the exact identities required to seed a formal column policy.

func (*Gateway) EnrollPostgresSelect

func (gateway *Gateway) EnrollPostgresSelect(ctx context.Context, datasource model.Datasource, secret []byte, rawSQL string, limits Limits) (PostgresRelationEnrollment, error)

EnrollPostgresSelect performs S3 discovery only. It intentionally does not activate protocol 3 or expose the prepared execution capability.

func (*Gateway) ListSchema

func (gateway *Gateway) ListSchema(ctx context.Context, datasource model.Datasource, secret []byte, tables []TableRef) ([]SchemaColumn, error)

func (*Gateway) NativeDiscover added in v0.5.0

func (gateway *Gateway) NativeDiscover(ctx context.Context, datasource model.Datasource, secret []byte) (NativeCatalog, error)

func (*Gateway) NativeQueryRead added in v0.5.0

func (gateway *Gateway) NativeQueryRead(ctx context.Context, datasource model.Datasource, secret []byte, request NativeQueryRequest) (NativeQueryResult, error)

func (*Gateway) NativeServerVersion added in v0.5.0

func (gateway *Gateway) NativeServerVersion(ctx context.Context, datasource model.Datasource, secret []byte) (string, error)

func (*Gateway) NewB5ClosedPostgresRuntimeWithPolicyProvider

func (gateway *Gateway) NewB5ClosedPostgresRuntimeWithPolicyProvider(ctx context.Context, datasource model.Datasource, secret []byte, provider B5DMLPolicyProvider) (B5PostgresRuntime, error)

NewB5ClosedPostgresRuntimeWithPolicyProvider builds the default extension-free CATALOG_CLOSED_V1 runtime. It retains the same narrow Analyzer/Engine boundary as the optional native accelerator.

func (*Gateway) NewB5PostgresRuntime

func (gateway *Gateway) NewB5PostgresRuntime(ctx context.Context, datasource model.Datasource, secret []byte, authorization B5DMLAuthorizationConfig) (B5PostgresRuntime, error)

NewB5PostgresRuntime reuses the enrolled PostgreSQL pool but does not itself make B5 reachable from MCP/HTTP. Bootstrap and the protocol entrypoints own that activation decision.

func (*Gateway) NewB5PostgresRuntimeWithPolicyProvider

func (gateway *Gateway) NewB5PostgresRuntimeWithPolicyProvider(ctx context.Context, datasource model.Datasource, secret []byte, provider B5DMLPolicyProvider) (B5PostgresRuntime, error)

NewB5PostgresRuntimeWithPolicyProvider is equivalent to NewB5PostgresRuntime but resolves exact grants after binder enrollment.

func (*Gateway) Ping

func (gateway *Gateway) Ping(ctx context.Context, datasource model.Datasource, secret []byte) error

func (*Gateway) ProbeMySQLSingleTableB2 added in v1.3.0

func (gateway *Gateway) ProbeMySQLSingleTableB2(ctx context.Context, datasource model.Datasource,
	secret []byte, metadataUsername, metadataPassword string,
) (string, error)

ProbeMySQLSingleTableB2 checks both dedicated accounts and proves they address the same supported MySQL server. It does not enroll any policy.

func (*Gateway) ProbePostgresB2Capability

func (gateway *Gateway) ProbePostgresB2Capability(ctx context.Context, datasource model.Datasource, secret []byte) (PostgresB2Capability, error)

ProbePostgresB2Capability validates the same extension ABI and PG14-18 capability manifest that the locked SELECT path consumes.

func (*Gateway) ProbePostgresB2Modes

func (gateway *Gateway) ProbePostgresB2Modes(ctx context.Context, datasource model.Datasource, secret []byte) (PostgresB2Capability, error)

ProbePostgresB2Modes proves that the pure catalog binder is available and opportunistically validates the native extension against the build-embedded signature. A missing or mismatched extension does not invalidate closed mode.

func (*Gateway) ProbeReservation

func (gateway *Gateway) ProbeReservation(datasourceID string) error

ProbeReservation proves that the request-level concurrency and memory reservation primitive is live before protocol 3 can be activated.

func (*Gateway) Sample

func (gateway *Gateway) Sample(ctx context.Context, datasource model.Datasource, secret []byte, table TableRef, columns []ColumnRef, limit int) (model.QueryResult, error)

func (*Gateway) SnapshotPools

func (gateway *Gateway) SnapshotPools() []PoolStat

type GatewayOption

type GatewayOption func(*Gateway)

func WithColumnAuthorizationProvider

func WithColumnAuthorizationProvider(provider ColumnAuthorizationProvider) GatewayOption

type Limits

type Limits struct {
	RawSQLBytes       int
	ParameterCount    int
	ParameterBytes    int
	ParametersBytes   int
	Tokens            int
	LexicalDepth      int
	ASTNodes          int
	QueryBlocks       int
	Projections       int
	OutputColumns     int
	Relations         int
	ViewDepth         int
	CatalogRoundTrips int
	DefinitionBytes   int
	BinderBytes       int
	CatalogBytes      int
	CatalogRows       int
	ColumnMetadata    int
	DependencyEdges   int
	ExpandedPaths     int
	WorkUnits         int
	FrameBytes        int
	RawCellBytes      int
	RawRowBytes       int
	RawResultBytes    int
	MaskedCellBytes   int
	MaskedResultBytes int
	EnvelopeBytes     int
}

Limits is the non-expandable S2 resource envelope. A zero field selects the default. Values above the defaults are clamped, so configuration can only tighten the security boundary.

func NormalizeLimits

func NormalizeLimits(candidate Limits) Limits

type MySQLCatalogColumn added in v1.3.0

type MySQLCatalogColumn = businessdb.MySQLBoundColumn

type MySQLCatalogLease added in v1.3.0

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

MySQLCatalogLease offers only fixed catalog facts, never SQL execution.

func (*MySQLCatalogLease) Catalog added in v1.3.0

func (lease *MySQLCatalogLease) Catalog() MySQLColumnCatalog

func (*MySQLCatalogLease) Close added in v1.3.0

func (lease *MySQLCatalogLease) Close() error

type MySQLColumnCatalog added in v1.3.0

type MySQLColumnCatalog = businessdb.MySQLBoundCatalog

type NativeCatalog added in v0.5.0

type NativeCatalog = businessdb.NativeCatalog

type NativeNamespace added in v0.5.0

type NativeNamespace = businessdb.NativeNamespace

type NativeQueryRequest added in v0.5.0

type NativeQueryRequest = businessdb.NativeQueryRequest

type NativeQueryResult added in v0.5.0

type NativeQueryResult = businessdb.NativeQueryResult

type PoolStat

type PoolStat = businessdb.PoolStat

Stable error aliases preserve the A4 public envelope without exposing a driver, pool, session, transaction, or arbitrary-SQL capability.

type PostgresB2Capability

type PostgresB2Capability struct {
	ServerMajor                                                           int
	ABI, ExtensionVersion, ExtensionHash, NodeManifestHash, AllowlistHash string
	Matview                                                               bool
	Mode, ClosedDigest, NativeDigest                                      string
	NativeAvailable                                                       bool
}

PostgresB2Capability is a non-executable startup attestation. It contains no SQL handle, credential, pool, or mutable binder object.

type PostgresEnrolledColumn

type PostgresEnrolledColumn struct {
	RelationOID  uint32
	Attnum       int16
	Name         string
	TypeOID      uint32
	CollationOID uint32
	TypeDigest   string
}

type PostgresEnrolledRelation

type PostgresEnrolledRelation struct {
	DatabaseOID, RelationOID, NamespaceOID uint32
	Schema, Name                           string
	Kind                                   byte
	ViewDepth                              int
	StableObjectID                         string
	CatalogFingerprint                     string
}

type PostgresPolicyColumnUse

type PostgresPolicyColumnUse struct {
	RelationOID  uint32
	Attnum       int16
	Name         string
	TypeOID      uint32
	TypeModifier int32
	CollationOID uint32
	Usage        string
}

type PostgresPolicyEnrollment

type PostgresPolicyEnrollment struct {
	Mode           string
	StatementClass string
	Action         b5dml.Action
	Relations      []PostgresPolicyRelation
	ColumnUses     []PostgresPolicyColumnUse
	WriteTargets   []PostgresPolicyWriteTarget
}

PostgresPolicyEnrollment is the non-executable catalog identity used by the deterministic Live Demo seeder. It contains no connection, prepared handle, transaction, SQL result, credential, or authorization decision.

type PostgresPolicyRelation

type PostgresPolicyRelation struct {
	DatabaseOID        uint32
	RelationOID        uint32
	Schema             string
	Name               string
	Kind               byte
	CatalogFingerprint string
}

type PostgresPolicyWriteTarget

type PostgresPolicyWriteTarget struct {
	RelationOID  uint32
	Attnum       int16
	Name         string
	TypeOID      uint32
	TypeModifier int32
	CollationOID uint32
	Kind         b5dml.WriteTargetKind
}

type PostgresRelationEnrollment

type PostgresRelationEnrollment struct {
	Fingerprint        string
	BinderFingerprint  string
	CatalogFingerprint string
	Relations          []PostgresEnrolledRelation
	Columns            []PostgresEnrolledColumn
}

PostgresRelationEnrollment is the feature-off S3 enrollment artifact. It is immutable request output, not an authorization proof; S4 must persist and compare it under the control->business two-phase protocol before execution.

type Reason

type Reason string

Reason is a stable, non-sensitive authorization failure reason.

const (
	ReasonRequestTooLarge           Reason = "AUTH_REQUEST_TOO_LARGE"
	ReasonParameterLimit            Reason = "AUTH_PARAMETER_LIMIT"
	ReasonTokenLimit                Reason = "AUTH_TOKEN_LIMIT"
	ReasonNestingLimit              Reason = "AUTH_NESTING_LIMIT"
	ReasonASTLimit                  Reason = "AUTH_AST_LIMIT"
	ReasonQueryBlockLimit           Reason = "AUTH_QUERY_BLOCK_LIMIT"
	ReasonProjectionLimit           Reason = "AUTH_PROJECTION_LIMIT"
	ReasonRelationLimit             Reason = "AUTH_RELATION_LIMIT"
	ReasonViewDepthLimit            Reason = "AUTH_VIEW_DEPTH_LIMIT"
	ReasonCatalogRTLimit            Reason = "AUTH_CATALOG_ROUND_TRIP_LIMIT"
	ReasonDefinitionLimit           Reason = "AUTH_DEFINITION_LIMIT"
	ReasonBinderLimit               Reason = "AUTH_BINDER_LIMIT"
	ReasonCatalogLimit              Reason = "AUTH_CATALOG_LIMIT"
	ReasonCatalogRowLimit           Reason = "AUTH_CATALOG_ROW_LIMIT"
	ReasonColumnLimit               Reason = "AUTH_COLUMN_METADATA_LIMIT"
	ReasonDependencyLimit           Reason = "AUTH_DEPENDENCY_LIMIT"
	ReasonPathLimit                 Reason = "AUTH_PATH_LIMIT"
	ReasonWorkLimit                 Reason = "AUTH_WORK_LIMIT"
	ReasonFrameLimit                Reason = "AUTH_FRAME_LIMIT"
	ReasonCellLimit                 Reason = "AUTH_CELL_LIMIT"
	ReasonRowLimit                  Reason = "AUTH_ROW_LIMIT"
	ReasonResultLimit               Reason = "AUTH_RESULT_LIMIT"
	ReasonEnvelopeLimit             Reason = "AUTH_ENVELOPE_LIMIT"
	ReasonDeadlineExceeded          Reason = "AUTH_DEADLINE_EXCEEDED"
	ReasonConcurrencyLimit          Reason = "AUTH_CONCURRENCY_LIMIT"
	ReasonMemoryLimit               Reason = "AUTH_MEMORY_LIMIT"
	ReasonDatabaseFailure           Reason = "AUTH_DATABASE_ERROR"
	ReasonCatalogIncomplete         Reason = "AUTH_CATALOG_INCOMPLETE"
	ReasonImplicitObject            Reason = "AUTH_IMPLICIT_OBJECT_UNSUPPORTED"
	ReasonRelationShape             Reason = "AUTH_RELATION_SHAPE_UNSUPPORTED"
	ReasonColumnShape               Reason = "AUTH_COLUMN_SHAPE_UNSUPPORTED"
	ReasonExpressionShape           Reason = "AUTH_EXPRESSION_IDENTITY_UNSUPPORTED"
	ReasonBinderIncomplete          Reason = "AUTH_BINDER_INCOMPLETE"
	ReasonBinderCapability          Reason = "AUTH_BINDER_CAPABILITY_MISMATCH"
	ReasonBinderModeRequired        Reason = "AUTH_BINDER_MODE_REQUIRED"
	ReasonBinderModeUnsupported     Reason = "AUTH_BINDER_MODE_UNSUPPORTED"
	ReasonBinderDivergence          Reason = "AUTH_BINDER_DIVERGENCE"
	ReasonBindLockFailed            Reason = "AUTH_BIND_LOCK_FAILED"
	ReasonBindIdentityDrift         Reason = "AUTH_BIND_IDENTITY_DRIFT"
	ReasonBindClosure               Reason = "AUTH_BIND_CLOSURE_MISMATCH"
	ReasonCatalogRace               Reason = "AUTH_CATALOG_RACE"
	ReasonPreparedInvalid           Reason = "AUTH_PREPARED_INVALIDATED"
	ReasonPreparedState             Reason = "AUTH_PREPARED_STATE_INVALID"
	ReasonAgentDenied               Reason = "AUTH_AGENT_DENIED"
	ReasonStatementClassDenied      Reason = "AUTH_STATEMENT_CLASS_DENIED"
	ReasonDatasourceUnsupported     Reason = "AUTH_DATASOURCE_UNSUPPORTED"
	ReasonColumnAuthUnsupported     Reason = "AUTH_COLUMN_AUTH_UNSUPPORTED"
	ReasonVastbaseColumnUnsupported Reason = "AUTH_VASTBASE_COLUMN_AUTH_UNSUPPORTED"
	ReasonFunctionQualification     Reason = "AUTH_FUNCTION_QUALIFICATION_REQUIRED"
	ReasonColumnAuthUnavailable     Reason = "AUTH_COLUMN_AUTHORIZATION_UNAVAILABLE"
	ReasonRelationDenied            Reason = "AUTH_RELATION_DENIED"
	ReasonRelationGrantMissing      Reason = "AUTH_RELATION_GRANT_MISSING"
	ReasonIdentityUnproven          Reason = "AUTH_IDENTITY_UNPROVEN"
	ReasonColumnGrantMissing        Reason = "AUTH_COLUMN_GRANT_MISSING"
	ReasonMaskMeetUndefined         Reason = "AUTH_MASK_MEET_UNDEFINED"
	ReasonMaskCapabilityMissing     Reason = "AUTH_MASK_CAPABILITY_MISSING"
	ReasonAuthorizationProofInvalid Reason = "AUTH_PROOF_INVALID"
	ReasonAuditUnavailable          Reason = "AUTH_AUDIT_UNAVAILABLE"
	ReasonFinalFenceFailed          Reason = "AUTH_FINAL_FENCE_FAILED"
	ReasonDeliverySealFailed        Reason = "AUTH_DELIVERY_SEAL_FAILED"
)

func (Reason) GoString

func (reason Reason) GoString() string

type Reservation

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

func (*Reservation) Release

func (reservation *Reservation) Release()

type ReservationLimits

type ReservationLimits struct {
	PerAgent, PerTenant, PerDatasource int
	GlobalMemoryBytes                  int64
}

type ReservationPool

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

func NewReservationPool

func NewReservationPool(limits ReservationLimits) *ReservationPool

func (*ReservationPool) Reserve

func (pool *ReservationPool) Reserve(agent, tenant, datasource string, memory int64) (*Reservation, error)

type SchemaColumn

type SchemaColumn struct {
	Schema, Table, Column, DataType string
	Ordinal                         int
}

type SealedResponseWriter

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

SealedResponseWriter buffers headers, status and body privately. Flush is a no-op, so middleware and handlers cannot emit progress or keepalive bytes.

func NewSealedResponseWriter

func NewSealedResponseWriter(limit int) *SealedResponseWriter

func (*SealedResponseWriter) AfterCommit

func (writer *SealedResponseWriter) AfterCommit(callback func())

AfterCommit registers a side effect that is safe only after the complete sealed body has reached the underlying writer.

func (*SealedResponseWriter) CommitTo

func (writer *SealedResponseWriter) CommitTo(destination http.ResponseWriter) error

func (*SealedResponseWriter) Flush

func (writer *SealedResponseWriter) Flush()

func (*SealedResponseWriter) Header

func (writer *SealedResponseWriter) Header() http.Header

func (*SealedResponseWriter) Seal

func (writer *SealedResponseWriter) Seal() error

func (*SealedResponseWriter) Write

func (writer *SealedResponseWriter) Write(body []byte) (int, error)

func (*SealedResponseWriter) WriteHeader

func (writer *SealedResponseWriter) WriteHeader(status int)

type SelectPhase

type SelectPhase string
const (
	PhaseBusinessBegin SelectPhase = "business_begin"
	PhaseExecute       SelectPhase = "execute"
	PhaseMask          SelectPhase = "mask"
	PhaseEncode        SelectPhase = "encode"
	PhaseFpost         SelectPhase = "fpost"
	PhaseBusinessEnd   SelectPhase = "business_end"
	PhaseAudit         SelectPhase = "audit"
	PhaseFinalFence    SelectPhase = "final_fence"
	PhaseSeal          SelectPhase = "seal"
)

type Statement

type Statement interface {
	Dialect() string
	Explain(context.Context) (model.ExplainInfo, error)
	Query(context.Context, int) (model.QueryResult, error)
	Execute(context.Context) (model.QueryResult, error)
	ExecuteTransactional(context.Context, func(model.QueryResult) error) (model.QueryResult, error)
	TableHasIndex(string, string) (bool, error)
	TableRowCount(string, string) (int64, error)
	TransactionState() (rules.TransactionState, error)
	MysqlTransactionState() (rules.MysqlTransactionState, error)
	// ReleaseReservation releases request-scoped concurrency and buffer quota
	// without closing a caller session. Wrappers must forward this method so
	// successful, failed, and canceled requests cannot leak global accounting.
	ReleaseReservation()
	Close() error
}

Statement is a request-scoped capability for exactly one caller statement. It deliberately has no method that accepts SQL, credentials, a connection, or a transaction. S4 will add the private authorization proof consumed by this capability; S2 makes bypass through a raw database handle impossible.

type TableRef

type TableRef struct{ Schema, Table string }

Directories

Path Synopsis
internal
businessdb
Package businessdb owns all business-database driver capabilities.
Package businessdb owns all business-database driver capabilities.

Jump to

Keyboard shortcuts

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