Help us shape the future of Go! Take the 2026 Go Developer Survey

bootstrap

package
v1.7.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: 43 Imported by: 0

Documentation

Overview

Package bootstrap wires AgentSQL production components without transport concerns or process-global secret mutation.

Index

Constants

View Source
const (
	B2StateActive      = "active"
	B2StateDryRun      = "dry-run"
	B2StateFeatureOff  = "feature-off"
	B2StateDegraded    = "degraded"
	B2StateUnsupported = "unsupported"

	B2ReasonFeatureOff              = "B2_FEATURE_OFF"
	B2ReasonDryRunReady             = "B2_DRY_RUN_READY"
	B2ReasonNoPostgresDatasource    = "B2_POSTGRES_DATASOURCE_REQUIRED"
	B2ReasonMetadataUnavailable     = "B2_METADATA_UNAVAILABLE"
	B2ReasonEnrollmentIncomplete    = "B2_ENROLLMENT_INCOMPLETE"
	B2ReasonCatalogBindIncomplete   = "B2_CATALOG_BIND_INCOMPLETE"
	B2ReasonBinderUnsupported       = "B2_BINDER_ABI_UNSUPPORTED"
	B2ReasonBinderProbeFailed       = "B2_BINDER_PROBE_FAILED"
	B2ReasonReservationUnavailable  = "B2_RESERVATION_UNAVAILABLE"
	B2ReasonControlFenceUnavailable = "B2_CONTROL_FENCE_UNAVAILABLE"
	B2ReasonArtifactAttestation     = "B2_ARTIFACT_ATTESTATION_FAILED"
	B2ReasonHeartbeatFailed         = "B2_RUNTIME_HEARTBEAT_FAILED"
	B2ReasonRuntimeLeaseExpired     = "B2_RUNTIME_LEASE_EXPIRED"
	B2ReasonDatasourceUnsupported   = "B2_DATASOURCE_DIALECT_UNSUPPORTED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type B2Status

type B2Status struct {
	State                  string            `json:"state"`
	Reason                 string            `json:"reason"`
	Protocol               int               `json:"protocol"`
	InstanceID             string            `json:"instance_id,omitempty"`
	ArtifactDigest         string            `json:"artifact_digest,omitempty"`
	LeaseExpiresAt         *time.Time        `json:"lease_expires_at,omitempty"`
	UnsupportedDatasources map[string]string `json:"unsupported_datasources,omitempty"`
	DatasourceModes        map[string]string `json:"datasource_modes,omitempty"`
}

B2Status is the stable, non-secret readiness/health projection.

type B5DatasourceAuthority

type B5DatasourceAuthority struct {
	Dialect, Mode                                   string
	ServerMajor                                     int
	KeyRevision, DatasourceRevision, PolicyRevision uint64
}

B5DatasourceAuthority is derived exclusively from metadata and a live read-only capability probe. MCP request dialect/version fields never become authority.

type B5Runtime

type B5Runtime struct {
	Directory   *b5session.Directory
	Coordinator *b5coordinator.Coordinator
	Analyzer    b5coordinator.PlanAnalyzerResolver
	InstanceID  string
	StickyRoute string
	Limits      b5coordinator.ResourceLimits
	// contains filtered or unexported fields
}

B5Runtime owns the complete production B5 graph. Protocol packages receive only the narrow directory/coordinator/analyzer surfaces below.

func (*B5Runtime) Admit

func (runtime *B5Runtime) Admit() error

func (*B5Runtime) CheckDatasourceDialect

func (runtime *B5Runtime) CheckDatasourceDialect(ctx context.Context, id string) error

CheckDatasourceDialect performs only metadata lookup. It is safe to run before parsing a client plan and guarantees that MySQL is rejected without opening a business pool or probing a server.

func (*B5Runtime) Enabled

func (runtime *B5Runtime) Enabled() bool

func (*B5Runtime) FinalFence

func (runtime *B5Runtime) FinalFence(ctx context.Context, result b5coordinator.Result) error

func (*B5Runtime) PostgresEnabled

func (runtime *B5Runtime) PostgresEnabled() bool

func (*B5Runtime) ResolveDatasource

func (runtime *B5Runtime) ResolveDatasource(ctx context.Context, id string) (B5DatasourceAuthority, error)

func (*B5Runtime) Status

func (runtime *B5Runtime) Status(_ context.Context) (B5Status, error)

type B5Status

type B5Status struct {
	Enabled bool   `json:"enabled"`
	State   string `json:"state"`
	Reason  string `json:"reason"`
	Ready   bool   `json:"ready"`
}

B5Status is the non-secret S9 projection linked into health/readiness by the production assembly. An explicit feature-off keeps the pre-S9 probe representation unchanged.

type ChainManifestProvider

type ChainManifestProvider = store.ChainManifestProvider

ChainManifestProvider resolves trusted, database-external chain authority.

type ChainMonitor

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

ChainMonitor periodically verifies the configured audit-chain domains. It is observational: its result never participates in the process-wide readiness endpoint.

func NewChainMonitor

func NewChainMonitor(
	metadataStore *store.Store,
	manifests ChainManifestProvider,
	hub *metrics.Metrics,
	domains []string,
	interval time.Duration,
) *ChainMonitor

NewChainMonitor constructs a monitor with production jitter. interval is injectable so tests and alternate orchestrators can use a shorter cadence.

func (*ChainMonitor) AuditWriterReady

func (monitor *ChainMonitor) AuditWriterReady(domain string) bool

AuditWriterReady is false only when the trusted expected mode is HMAC and a non-empty current chain key cannot be obtained. Chain validity is deliberately irrelevant to writer readiness.

func (*ChainMonitor) Domains

func (monitor *ChainMonitor) Domains() []string

Domains returns a defensive copy of the domains observed by this monitor.

func (*ChainMonitor) RunChainVerificationOnce

func (monitor *ChainMonitor) RunChainVerificationOnce(ctx context.Context)

RunChainVerificationOnce synchronously attempts one verification for every domain. A domain already being verified is skipped without waiting.

type MySQLColumnGrant added in v1.3.0

type MySQLColumnGrant struct {
	Column string `json:"column"`
	Usage  string `json:"usage"`
}

type Runtime

type Runtime struct {
	Pipeline        *pipeline.Pipeline
	ControlledRead  *controlledread.Service
	ManagementAudit audit.Recorder
	Store           *store.Store
	Metrics         *metrics.Metrics
	ChainMonitor    *ChainMonitor
	// Events is the in-process stream of successfully persisted audits.
	Events *eventbus.Hub
	// Notifications is the process-local best-effort notification manager.
	Notifications *notify.Manager
	// B5 owns the production logical-session and planned-transaction graph when
	// mcp.sessions.enabled is effective.
	B5 *B5Runtime
	// contains filtered or unexported fields
}

Runtime owns the production pipeline, business connection manager, and metadata store for one AgentSQL process.

func Assemble

func Assemble(ctx context.Context, cfg config.Config, secret []byte) (*Runtime, error)

Assemble validates configuration and wires the required pipeline ports and the optional store-backed runtime rule overrides.

func (*Runtime) AuditWriterReady

func (runtime *Runtime) AuditWriterReady(domain string) bool

AuditWriterReady reports only whether the expected HMAC key is currently available for writes in domain. Historical chain validity is not a gate.

func (*Runtime) B2Ready

func (runtime *Runtime) B2Ready() bool

B2Ready is false whenever enabled enforcement cannot admit protocol-3 work. Feature-off and dry-run do not gate the existing table-level service.

func (*Runtime) B2Status

func (runtime *Runtime) B2Status() B2Status

B2Status returns the protocol-3 activation/lease state without exposing credentials or probe diagnostics.

func (*Runtime) B5Status

func (runtime *Runtime) B5Status(ctx context.Context) (B5Status, bool, error)

func (*Runtime) BindMySQLColumnPolicy added in v1.3.0

func (runtime *Runtime) BindMySQLColumnPolicy(ctx context.Context, policyID string, expectedRevision int64,
	schema, table string, grants []MySQLColumnGrant,
) (model.Policy, error)

BindMySQLColumnPolicy is the administrative two-phase enrollment boundary. The first catalog read holds no control lock. The second revalidates while the metadata CAS is held, and keeps the business MDL until commit returns.

func (*Runtime) Close

func (runtime *Runtime) Close() error

Close releases all business pools before closing metadata storage.

func (*Runtime) ListDatasourceSchema

func (runtime *Runtime) ListDatasourceSchema(
	ctx context.Context,
	datasource model.Datasource,
	tables []executor.TableRef,
) ([]executor.SchemaColumn, error)

ListDatasourceSchema performs only the fixed typed information-schema read.

func (*Runtime) NativeDiscover added in v0.5.0

func (runtime *Runtime) NativeDiscover(ctx context.Context, datasource model.Datasource) (executor.NativeCatalog, error)

func (*Runtime) NativeQueryRead added in v0.5.0

func (runtime *Runtime) NativeQueryRead(ctx context.Context, datasource model.Datasource, request executor.NativeQueryRequest) (executor.NativeQueryResult, error)

These methods keep the runtime secret and read-only pool behind the runtime.

func (*Runtime) NativeServerVersion added in v0.5.0

func (runtime *Runtime) NativeServerVersion(ctx context.Context, datasource model.Datasource) (string, error)

func (*Runtime) PingDatasource

func (runtime *Runtime) PingDatasource(ctx context.Context, datasource model.Datasource) error

PingDatasource performs a fixed health operation without exporting a database handle or accepting SQL.

func (*Runtime) PublishManagementAudit

func (runtime *Runtime) PublishManagementAudit(recorded model.AuditLog)

PublishManagementAudit emits an already-persisted management audit. It is best effort and intentionally does not affect the committed operation.

func (*Runtime) RedactionReady

func (runtime *Runtime) RedactionReady() (bool, []int)

RedactionReady returns the last newly computed reconciliation gate. It never becomes true merely because time passed or another command reported success.

func (*Runtime) RedactionReconciliation

func (runtime *Runtime) RedactionReconciliation() (redactionstate.Result, bool)

RedactionReconciliation returns a concurrency-safe, non-secret snapshot for readiness and management observation.

func (*Runtime) RefreshNotificationNames

func (runtime *Runtime) RefreshNotificationNames(ctx context.Context) error

RefreshNotificationNames atomically refreshes the notification display-name cache. Delivery keeps using the previous snapshot if refresh fails.

func (*Runtime) RerunRedactionReconciliation

func (runtime *Runtime) RerunRedactionReconciliation(ctx context.Context) error

RerunRedactionReconciliation performs one strong read and atomically replaces readiness with the result from this round's observed snapshot.

func (*Runtime) RunChainVerificationOnce

func (runtime *Runtime) RunChainVerificationOnce(ctx context.Context)

RunChainVerificationOnce attempts one audit-chain verification round without changing process-wide readiness.

func (*Runtime) RunPeriodicRedactionReconciliationOnce

func (runtime *Runtime) RunPeriodicRedactionReconciliationOnce(ctx context.Context) error

RunPeriodicRedactionReconciliationOnce exposes the production periodic read-only behavior for deterministic scheduling tests and future orchestration.

func (*Runtime) SetB5StatusProvider

func (runtime *Runtime) SetB5StatusProvider(provider func(context.Context) (B5Status, error))

SetB5StatusProvider does not activate B5 execution. It links an already explicitly assembled S9 runtime to the existing health/readiness surface.

func (*Runtime) ValidateRedactionActivation

func (runtime *Runtime) ValidateRedactionActivation(rule mask.Rule) error

ValidateRedactionActivation checks whether this process can execute an enabled rule without exposing the configured hash key to API handlers.

Jump to

Keyboard shortcuts

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