config

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultAttributionRetentionDays = 90
	MaxAttributionRetentionDays     = 3650
)

Documented default and bound of attribution.retention_days.

View Source
const (
	DefaultExecutorTimeout = 60
	DefaultLogLevel        = "info"
	DefaultVersion         = "unknown"
)

Documented defaults for keys the configuration file may omit.

View Source
const (
	MinExecutorTimeout = 1
	MaxExecutorTimeout = 300
)

Documented bounds for the negotiated control lease, in seconds.

View Source
const (
	MaxExecutorEntries   = 4096
	MaxDisplayTextLength = 64
)

Bounds on operator display metadata, in characters.

View Source
const DefaultAllowanceGrant int64 = 30_000_000

DefaultAllowanceGrant is the documented default of allowance.default_grant: ten runs of the default 100,000 bit/s for 30 seconds at a price of 1.

View Source
const DefaultReceiptKeyFile = "attribution-receipt-key.pem"

DefaultReceiptKeyFile is the receipt key file used when attribution.receipt_key_path is empty, beside the database.

View Source
const MaxAttributionTrustedProxies = 64

MaxAttributionTrustedProxies bounds attribution.trusted_proxies.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountLimits added in v0.3.0

type AccountLimits struct {
	RequestsPerMinute int   `toml:"requests_per_minute"`
	QueuedJobs        int64 `toml:"queued_jobs"`
	ActiveJobs        int64 `toml:"active_jobs"`
	QueuedBytes       int64 `toml:"queued_bytes"`
}

AccountLimits bounds work belonging to one authenticated account across all executors. ActiveJobs bounds overlapping reserved execution windows; QueuedJobs also includes active and unreconciled work until confirmed retirement.

type AdmissionConfig added in v0.3.0

type AdmissionConfig struct {
	Account AccountLimits `toml:"account"`
	// Operator applies to authenticated operator accounts and the explicitly
	// enabled local-development bucket. Neither bypasses admission accounting.
	Operator AccountLimits `toml:"operator"`
}

func DefaultAdmissionConfig added in v0.3.0

func DefaultAdmissionConfig() AdmissionConfig

func (AdmissionConfig) Validate added in v0.3.0

func (cfg AdmissionConfig) Validate() error

type AllowanceConfig added in v0.3.0

type AllowanceConfig struct {
	Enabled bool `toml:"enabled"`
	// DefaultGrant is the amount, in TEST units, of a grant whose request names
	// none. Omitted or 0 means DefaultAllowanceGrant.
	DefaultGrant int64 `toml:"default_grant"`
}

AllowanceConfig governs usage allowances: fixed grants of TEST units an operator issues to an account, which cap what the account may reserve with TEST payment intents. Allowances are usage credits, not money; they cannot be transferred and nothing grants them automatically. Disabled, the default, TEST intents are not capped.

func DefaultAllowanceConfig added in v0.3.0

func DefaultAllowanceConfig() AllowanceConfig

func (AllowanceConfig) Grant added in v0.3.0

func (cfg AllowanceConfig) Grant() int64

Grant is the configured default grant, with 0 resolved to the default, so a configuration built in code without it keeps the documented default.

func (AllowanceConfig) Validate added in v0.3.0

func (cfg AllowanceConfig) Validate() error

type AttributionConfig added in v0.3.0

type AttributionConfig struct {
	// RetentionDays is how long the history is kept. Older records are pruned
	// periodically, and GET /attribution/candidates reports the resulting
	// retained_from. Omitted or 0 means DefaultAttributionRetentionDays, so
	// a configuration built in code without it keeps the documented default.
	RetentionDays int `toml:"retention_days"`
	// TrustedProxies lists the addresses or CIDR prefixes of reverse proxies
	// in front of the HTTP API that set X-Forwarded-For. The attribution
	// routes are rate-limited per client address; for a request whose TCP
	// peer is one of these, the client address is the right-most
	// X-Forwarded-For entry that is not itself a trusted proxy. Empty, the
	// default, trusts no forwarding header, so every client behind a proxy
	// shares the proxy's allowance.
	TrustedProxies []string `toml:"trusted_proxies"`
	// ReceiptKeyPath is the PEM file holding the Ed25519 private key that
	// signs the receipts of POST /attribution/verify. It is created, owner
	// readable only, when absent. Empty means DefaultReceiptKeyFile in the
	// directory of the database.
	ReceiptKeyPath string `toml:"receipt_key_path"`
}

AttributionConfig bounds the attribution history the dispatcher keeps for probe verification: the TESLA chains executors announced, their disclosed keys and the source addresses and intervals of runs.

func DefaultAttributionConfig added in v0.3.0

func DefaultAttributionConfig() AttributionConfig

func (AttributionConfig) Retention added in v0.3.0

func (cfg AttributionConfig) Retention() time.Duration

Retention is the configured retention as a duration.

func (AttributionConfig) TrustedProxyPrefixes added in v0.3.0

func (cfg AttributionConfig) TrustedProxyPrefixes() ([]netip.Prefix, error)

TrustedProxyPrefixes parses TrustedProxies: each entry is an IP address, which stands for itself, or a CIDR prefix. An IPv4-mapped IPv6 entry is refused, since peers are compared in their unmapped form.

func (AttributionConfig) Validate added in v0.3.0

func (cfg AttributionConfig) Validate() error

type AuthenticationConfig added in v0.3.0

type AuthenticationConfig struct {
	PublicURL             string `toml:"public_url"`
	DeviceVerificationURL string `toml:"device_verification_url"`
}

type CILogonConfig added in v0.3.0

type CILogonConfig struct {
	Enabled     bool   `toml:"enabled"`
	Issuer      string `toml:"issuer"`
	CallbackURL string `toml:"callback_url"`
	SuccessURL  string `toml:"success_url"`
}

type CORSConfig

type CORSConfig struct {
	// AllowedOrigins is the list of origins allowed to make credentialed
	// (cookie-based) requests to the API. Cookie auth (session_token) only
	// works cross-origin for origins listed here — an empty list leaves CORS
	// wide open ("*") but without credentials, so browser clients can't send
	// the session cookie at all.
	AllowedOrigins []string `toml:"allowed_origins"`
}

type ConfiguredFile

type ConfiguredFile struct {
	Field, Path string
}

ConfiguredFile is a configured path together with the key that named it.

type DatabaseConfig

type DatabaseConfig struct {
	Path string `toml:"path"`
}

type DispatcherConfig

type DispatcherConfig struct {
	Server             ServerConfig             `toml:"server"`
	Logging            LoggingConfig            `toml:"logging"`
	Scheduler          SchedulerConfig          `toml:"scheduler"`
	TLS                TLSConfig                `toml:"tls"`
	Database           DatabaseConfig           `toml:"database"`
	Sui                SuiConfig                `toml:"sui"`
	CORS               CORSConfig               `toml:"cors"`
	GitHubOAuth        GitHubOAuthConfig        `toml:"github_oauth"`
	CILogonOIDC        CILogonConfig            `toml:"cilogon_oidc"`
	Authentication     AuthenticationConfig     `toml:"authentication"`
	Output             OutputConfig             `toml:"output"`
	Egress             EgressConfig             `toml:"egress"`
	Admission          AdmissionConfig          `toml:"admission"`
	Retention          RetentionConfig          `toml:"retention"`
	ExecutorOnboarding ExecutorOnboardingConfig `toml:"executor_onboarding"`
	Attribution        AttributionConfig        `toml:"attribution"`
	Allowance          AllowanceConfig          `toml:"allowance"`
	// Executors holds optional operator display metadata by executor ID.
	Executors map[string]ExecutorDisplay `toml:"executors"`
	Metadata  MetadataConfig             `toml:"metadata"`
}

func DecodeConfig added in v0.3.0

func DecodeConfig(data []byte) (*DispatcherConfig, configcheck.Document, error)

DecodeConfig applies the startup defaults and validation without reading files or discovering host resources. The document identifies supplied keys.

func LoadConfig

func LoadConfig(path string) (*DispatcherConfig, error)

LoadConfig reads a TOML config file, applies the documented defaults for omitted keys and validates every supported key. It fails before the command opens the database or binds a listener, so a misspelled or unusable field never reaches a partially started daemon.

func (*DispatcherConfig) TLSFiles

func (cfg *DispatcherConfig) TLSFiles() []ConfiguredFile

TLSFiles lists the certificate files the HTTP API reads, and nothing when TLS is disabled. An optional file is included only when it is configured.

func (*DispatcherConfig) Validate

func (cfg *DispatcherConfig) Validate() error

Validate reports the first unusable configuration field. Defaults for omitted keys are applied by LoadConfig before this runs, so every value seen here is the one the daemon would actually use.

type EgressConfig added in v0.3.0

type EgressConfig struct {
	Enabled       bool          `toml:"enabled"`
	WindowSeconds int64         `toml:"window_seconds"`
	Run           EgressLimits  `toml:"run"`
	Account       EgressLimits  `toml:"account"`
	Node          EgressLimits  `toml:"node"`
	Groups        []EgressGroup `toml:"groups"`
}

func (EgressConfig) Validate added in v0.3.0

func (c EgressConfig) Validate() error

type EgressGroup added in v0.3.0

type EgressGroup struct {
	Name     string       `toml:"name"`
	Prefixes []string     `toml:"prefixes"`
	Names    []string     `toml:"names"`
	Limits   EgressLimits `toml:"limits"`
}

type EgressLimits added in v0.3.0

type EgressLimits struct {
	BitsPerSecond     int64 `toml:"bits_per_second"`
	BurstBytes        int64 `toml:"burst_bytes"`
	Bytes             int64 `toml:"bytes"`
	AttemptsPerSecond int64 `toml:"attempts_per_second"`
	AttemptBurst      int64 `toml:"attempt_burst"`
	Attempts          int64 `toml:"attempts"`
	Targets           int64 `toml:"targets"`
}

EgressLimits are reserved for a complete fixed window. Payload bytes exclude IP/TCP/TLS headers and retransmissions. Attempts include failed connects; targets count each run's distinct pinned addresses conservatively.

func (EgressLimits) Values added in v0.3.0

func (l EgressLimits) Values() [7]int64

type ExecutorDisplay added in v0.3.0

type ExecutorDisplay struct {
	DisplayName string `toml:"display_name" json:"display_name"`
	City        string `toml:"city" json:"city"`
	Country     string `toml:"country" json:"country"` // ISO 3166-1 alpha-2, upper case.
	Network     string `toml:"network" json:"network"`
	// Only this locally approved literal host and pool may receive connect-back
	// challenges for this executor. Neither hello nor a measurement selects it.
	ConnectivityHost  string `toml:"connectivity_host" json:"-"`
	ConnectivityPorts string `toml:"connectivity_ports" json:"-"`
}

ExecutorDisplay is the operator's presentation metadata for one executor, configured as [executors."<executor-id>"]. Every key is optional. It is published in the executor listing and in result provenance with source operator; nothing here is verified against the executor.

func (ExecutorDisplay) ConnectivityTarget added in v0.3.0

func (c ExecutorDisplay) ConnectivityTarget(port uint32) (netip.AddrPort, bool)

ConnectivityTarget returns an endpoint only when its port belongs to the operator's bounded pool. The advertised host never supplies a dial target.

func (ExecutorDisplay) Validate added in v0.3.0

func (display ExecutorDisplay) Validate() error

Validate checks presentation labels independently of connectivity configuration.

type ExecutorOnboardingConfig added in v0.3.0

type ExecutorOnboardingConfig struct {
	Enabled       bool   `toml:"enabled"`
	CACert        string `toml:"ca_cert"`
	CAKey         string `toml:"ca_key"`
	DispatcherURL string `toml:"dispatcher_url"`
	GRPCAddress   string `toml:"grpc_address"`
	YamuxAddress  string `toml:"yamux_address"`
}

ExecutorOnboardingConfig enables account owners to enroll their machines. The signing key stays on the dispatcher; executors generate their own keys.

func (ExecutorOnboardingConfig) Validate added in v0.3.0

func (cfg ExecutorOnboardingConfig) Validate(tls TLSConfig) error

type GitHubOAuthConfig

type GitHubOAuthConfig struct {
	Enabled     bool   `toml:"enabled"`
	CallbackURL string `toml:"callback_url"`
	SuccessURL  string `toml:"success_url"`
}

type LoggingConfig

type LoggingConfig struct {
	LogLevel string `toml:"log_level"`
	JSONLogs bool   `toml:"json_logs"`
}

type MetadataConfig added in v0.3.0

type MetadataConfig struct {
	ASNDatabase  string `toml:"asn_database"`
	CityDatabase string `toml:"city_database"`
}

MetadataConfig names optional operator-supplied offline MMDB files.

type OutputConfig added in v0.3.0

type OutputConfig struct {
	ControlReserveBytes int64 `toml:"control_reserve_bytes"`
	RunBytes            int64 `toml:"run_bytes"`
	RunFrames           int64 `toml:"run_frames"`
	AccountBytes        int64 `toml:"account_bytes"`
	NodeBytes           int64 `toml:"node_bytes"`
}

OutputConfig bounds retained output. Account and node limits include a fixed per-frame charge, so tiny writes consume capacity as well as large writes. Payload deletion releases the exact charge once; reference metadata remains. Zero explicitly disables an aggregate cap only in the local TEST profile.

func DefaultOutputConfig added in v0.3.0

func DefaultOutputConfig() OutputConfig

func (OutputConfig) Validate added in v0.3.0

func (cfg OutputConfig) Validate() error

type RetentionConfig added in v0.3.0

type RetentionConfig struct {
	PayloadMaxAgeSeconds int64 `toml:"payload_max_age_seconds"`
}

RetentionConfig governs completed measurement payloads. Zero preserves them until their owner deletes them. This does not expire identities, accounting, verification references, active runs or uncertain remote ownership.

func (RetentionConfig) PayloadMaxAge added in v0.3.0

func (cfg RetentionConfig) PayloadMaxAge() time.Duration

func (RetentionConfig) Validate added in v0.3.0

func (cfg RetentionConfig) Validate() error

type SchedulerConfig

type SchedulerConfig struct {
	// ExecutorTimeout is the negotiated control lease in seconds, from 1 to 300.
	// Heartbeat telemetry is separate from lease renewal.
	ExecutorTimeout int `toml:"executor_timeout"`
	// SchedulerGranularityMs is the scheduler granularity in milliseconds for time-range capacity tracking.
	SchedulerGranularityMs int64 `toml:"scheduler_granularity_ms"`
}

type ServerConfig

type ServerConfig struct {
	BindHost string `toml:"bind_host"`
	Version  string `toml:"version"`
	GRPCPort int    `toml:"grpc_port"`
	HTTPPort int    `toml:"http_port"`
	// LocalDevelopment asks the HTTP API for its local development profile, in
	// which a request that presents no credential at all is served as the
	// dispatcher's own local operator. It is an explicit opt-in and is never
	// inferred: the daemon additionally requires the environment it describes
	// (blockchain payments off, TLS listener off, both listeners on loopback)
	// and refuses to start when the key is set without it. Omitted or false
	// keeps authentication and authorization enforced.
	LocalDevelopment bool `toml:"local_development"`
	// BehindTLSTerminator states that a TLS terminator stands in front of this
	// dispatcher, so the session cookie is marked Secure although the daemon
	// itself serves cleartext. It is configuration because a request cannot be
	// trusted to describe its own scheme: X-Forwarded-Proto and its relatives
	// are set by whoever sent the request.
	BehindTLSTerminator bool `toml:"behind_tls_terminator"`
}

type ServerTLS

type ServerTLS struct {
	Combined *tls.Config
	Direct   *tls.Config
	// RequireClientIdentity reports whether an executor must present a
	// certificate issued by tls.ca_file on both control channels.
	RequireClientIdentity bool
}

ServerTLS is the loaded transport security for the dispatcher's listeners.

Combined carries the HTTP API and the reverse control stream, which share one port behind a protocol multiplexer. The multiplexer reads cleartext framing, so that connection is terminated before it and offers HTTP/1.1 only: an HTTP/2 connection negotiated through ALPN would reach the multiplexer as a preface it cannot route back into a protocol-aware server. Direct is the separate gRPC listener, which offers h2 because gRPC requires it.

Both listeners present the same server identity and trust the same authority, so an executor verifies one name and one root for both of its channels.

func LoadServerTLS

func LoadServerTLS(cfg TLSConfig) (*ServerTLS, error)

LoadServerTLS reads the configured server identity and trust roots. It returns nil without an error for a plaintext listener, and otherwise fails naming the configuration key an operator has to correct — before the command opens storage or binds a listener, so an unusable certificate never leaves a half-started daemon serving a downgraded connection.

type SuiConfig

type SuiConfig struct {
	Network           string `toml:"network"`       //testnet or mainnet
	GRPCEndpoint      string `toml:"grpc_endpoint"` // host:port, e.g. fullnode.testnet.sui.io:443
	GraphQLURL        string `toml:"graphql_url"`   // Sui GraphQL RPC, used to catch up on PaymentReceipt events by type
	Address           string `toml:"address"`
	PaymentRegistryId string `toml:"payment_registry_id"`
	PaymentKitPackage string `toml:"payment_kit_package"`
	KeystorePath      string `toml:"keystore_path"`
	// Disabled switches blockchain payments off explicitly. When true, the
	// dispatcher constructs neither the Sui client/listener nor the payout
	// ticker and rejects USDC/SUI payment actions; TEST payments keep working.
	// The other Sui fields are ignored in that mode. Omitted or false keeps
	// the enabled semantics unchanged; nothing is inferred from empty fields.
	Disabled bool `toml:"disabled"`
}

type TLSConfig

type TLSConfig struct {
	Disable  bool   `toml:"disable"`
	CertFile string `toml:"cert_file"`
	KeyFile  string `toml:"key_file"`
	CAFile   string `toml:"ca_file,omitempty"` // optional for client cert validation
	// RequireClientCert makes an executor present a certificate issued by
	// CAFile on both control channels: the direct gRPC listener refuses a
	// missing identity during the handshake, and the reverse control stream
	// on the combined listener is refused after it. The HTTP API shares that
	// listener and keeps working without a client certificate.
	RequireClientCert bool `toml:"require_client_cert"`
}

Jump to

Keyboard shortcuts

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