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
- Variables
- func ClassifyNativeCommand(dbType string, request NativeQueryRequest) (string, error)
- func EncodeEnvelope(value any, limits Limits) ([]byte, error)
- func PostgresColumnTypeDigest(typeOID uint32, typmod int32, collationOID uint32) string
- func PostgresStableObjectID(databaseOID, relationOID uint32) string
- func ProbeDatasource(ctx context.Context, datasource model.Datasource, password string) error
- func ReadBoundedFrame(reader io.Reader, limit int) ([]byte, error)
- func SealedHTTP(next http.Handler, limit int) http.Handler
- func Suggestion(code DBErrorCode) string
- func ValidatePreParse(rawSQL string, parameters [][]byte, limits Limits) error
- func ValidateResult(result model.QueryResult, masked bool, limits Limits) error
- func WithColumnAuthorization(ctx context.Context, request ColumnAuthorizationRequest) context.Context
- func WithLockDeadline(parent context.Context, configuredRequest time.Duration) (context.Context, context.CancelFunc)
- func WithRequestDeadline(parent context.Context, configured time.Duration) (context.Context, context.CancelFunc)
- func WithReservationScope(ctx context.Context, agent, tenant string) context.Context
- func WithStatementDeadline(parent context.Context, datasource time.Duration) (context.Context, context.CancelFunc)
- func WriteSealedFrame(writer io.Writer, frame []byte, limit int) error
- type AuthError
- type AuthorizedSelectResult
- type B5DMLAuthorizationConfig
- type B5DMLPolicyProvider
- type B5PostgresRuntime
- type Budget
- func (budget *Budget) ChargeAST(ast *model.AST) error
- func (budget *Budget) ChargeBinderBytes(count int) error
- func (budget *Budget) ChargeCatalogBytes(count int) error
- func (budget *Budget) ChargeCatalogRoundTrips(count int) error
- func (budget *Budget) ChargeCatalogRows(count int) error
- func (budget *Budget) ChargeColumnMetadata(count int) error
- func (budget *Budget) ChargeDefinitionBytes(count int) error
- func (budget *Budget) ChargeEdges(count int) error
- func (budget *Budget) ChargeNodes(count int) error
- func (budget *Budget) ChargePaths(count int) error
- func (budget *Budget) ChargeRelations(count int) error
- func (budget *Budget) ChargeWork(count int) error
- func (budget *Budget) CheckViewDepth(depth int) error
- type ColumnAuditDetail
- type ColumnAuthorizationAudit
- type ColumnAuthorizationProvider
- type ColumnAuthorizationRequest
- type ColumnAuthorizedStatement
- type ColumnRef
- type DBError
- type DBErrorCode
- type DBErrorKind
- type DBStage
- type DeliverySeal
- type Gateway
- func (gateway *Gateway) AuthorizedExecute(ctx context.Context, datasource model.Datasource, secret []byte, ...) (Statement, error)
- func (gateway *Gateway) Close(id string) error
- func (gateway *Gateway) CloseAll() error
- func (gateway *Gateway) EnrollPostgresPolicyDML(ctx context.Context, datasource model.Datasource, secret []byte, rawSQL string, ...) (PostgresPolicyEnrollment, error)
- func (gateway *Gateway) EnrollPostgresPolicySelect(ctx context.Context, datasource model.Datasource, secret []byte, rawSQL string, ...) (PostgresPolicyEnrollment, error)
- func (gateway *Gateway) EnrollPostgresSelect(ctx context.Context, datasource model.Datasource, secret []byte, rawSQL string, ...) (PostgresRelationEnrollment, error)
- func (gateway *Gateway) ListSchema(ctx context.Context, datasource model.Datasource, secret []byte, ...) ([]SchemaColumn, error)
- func (gateway *Gateway) NativeDiscover(ctx context.Context, datasource model.Datasource, secret []byte) (NativeCatalog, error)
- func (gateway *Gateway) NativeQueryRead(ctx context.Context, datasource model.Datasource, secret []byte, ...) (NativeQueryResult, error)
- func (gateway *Gateway) NativeServerVersion(ctx context.Context, datasource model.Datasource, secret []byte) (string, error)
- func (gateway *Gateway) NewB5ClosedPostgresRuntimeWithPolicyProvider(ctx context.Context, datasource model.Datasource, secret []byte, ...) (B5PostgresRuntime, error)
- func (gateway *Gateway) NewB5PostgresRuntime(ctx context.Context, datasource model.Datasource, secret []byte, ...) (B5PostgresRuntime, error)
- func (gateway *Gateway) NewB5PostgresRuntimeWithPolicyProvider(ctx context.Context, datasource model.Datasource, secret []byte, ...) (B5PostgresRuntime, error)
- func (gateway *Gateway) Ping(ctx context.Context, datasource model.Datasource, secret []byte) error
- func (gateway *Gateway) ProbePostgresB2Capability(ctx context.Context, datasource model.Datasource, secret []byte) (PostgresB2Capability, error)
- func (gateway *Gateway) ProbePostgresB2Modes(ctx context.Context, datasource model.Datasource, secret []byte) (PostgresB2Capability, error)
- func (gateway *Gateway) ProbeReservation(datasourceID string) error
- func (gateway *Gateway) Sample(ctx context.Context, datasource model.Datasource, secret []byte, ...) (model.QueryResult, error)
- func (gateway *Gateway) SnapshotPools() []PoolStat
- type GatewayOption
- type Limits
- type NativeCatalog
- type NativeNamespace
- type NativeQueryRequest
- type NativeQueryResult
- type PoolStat
- type PostgresB2Capability
- type PostgresEnrolledColumn
- type PostgresEnrolledRelation
- type PostgresPolicyColumnUse
- type PostgresPolicyEnrollment
- type PostgresPolicyRelation
- type PostgresPolicyWriteTarget
- type PostgresRelationEnrollment
- type Reason
- type Reservation
- type ReservationLimits
- type ReservationPool
- type SchemaColumn
- type SealedResponseWriter
- func (writer *SealedResponseWriter) AfterCommit(callback func())
- func (writer *SealedResponseWriter) CommitTo(destination http.ResponseWriter) error
- func (writer *SealedResponseWriter) Flush()
- func (writer *SealedResponseWriter) Header() http.Header
- func (writer *SealedResponseWriter) Seal() error
- func (writer *SealedResponseWriter) Write(body []byte) (int, error)
- func (writer *SealedResponseWriter) WriteHeader(status int)
- type SelectPhase
- type Statement
- type TableRef
Constants ¶
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 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 )
const ( DefaultRequestWall = 10 * time.Second DefaultStatementWall = 5 * time.Second DefaultLockWall = 2 * time.Second )
const (
ColumnAuditVersion = 2
)
Variables ¶
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 )
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,
}
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.
var ErrCommitOutcomeUnknown = errors.New("authorized execution commit outcome unknown")
var ErrNativeUnsupported = errors.New("native capability unsupported")
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 ¶
EncodeEnvelope fully encodes and caps a final response before any transport can observe it.
func PostgresStableObjectID ¶
func ProbeDatasource ¶
ProbeDatasource performs only connect, ping and close for CLI enrollment. It never returns the opened pool or any SQL-capable object.
func ReadBoundedFrame ¶
ReadBoundedFrame validates the attacker-controlled length before allocation.
func SealedHTTP ¶
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 ¶
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 ¶
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.
Types ¶
type AuthError ¶
type AuthError struct{ Reason Reason }
AuthError intentionally carries no underlying error or dynamic text.
func StableError ¶
StableError maps every internal/database failure to a fixed public error.
type AuthorizedSelectResult ¶
type AuthorizedSelectResult struct {
Allowed bool
Reason Reason
Result model.QueryResult
Redact mask.RedactReport
Audit ColumnAuthorizationAudit
Encoded []byte
Seal DeliverySeal
}
type B5DMLPolicyProvider ¶
type B5DMLPolicyProvider func(context.Context, b5dml.StatementFacts, b5coordinator.StatementRequest, int) (B5DMLAuthorizationConfig, error)
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 (*Budget) ChargeBinderBytes ¶
func (*Budget) ChargeCatalogBytes ¶
func (*Budget) ChargeCatalogRoundTrips ¶
func (*Budget) ChargeCatalogRows ¶
func (*Budget) ChargeColumnMetadata ¶
func (*Budget) ChargeDefinitionBytes ¶
func (*Budget) ChargeEdges ¶
func (*Budget) ChargeNodes ¶
func (*Budget) ChargePaths ¶
func (*Budget) ChargeRelations ¶
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) CheckViewDepth ¶
type ColumnAuditDetail ¶
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)
}
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 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) 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) 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) 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 ¶
ProbeReservation proves that the request-level concurrency and memory reservation primitive is live before protocol 3 can be activated.
func (*Gateway) SnapshotPools ¶
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 ¶
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 PostgresPolicyColumnUse ¶
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 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" 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" ReasonFinalFenceFailed Reason = "AUTH_FINAL_FENCE_FAILED" ReasonDeliverySealFailed Reason = "AUTH_DELIVERY_SEAL_FAILED" )
type Reservation ¶
type Reservation struct {
// contains filtered or unexported fields
}
func (*Reservation) Release ¶
func (reservation *Reservation) Release()
type ReservationLimits ¶
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 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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
businessdb
Package businessdb owns all business-database driver capabilities.
|
Package businessdb owns all business-database driver capabilities. |