config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogLevelNames = []string{"debug", "info", "warn", "error"}

LogLevelNames is the accepted set of config.yaml log.level values, in the same order schema.go's "log.level" KindEnum leaf exposes as its EnumValues (so `boid config set log.level <bogus>`'s error message and this package's own ParseLogLevel error message list the exact same options — see TestLogLevelNames_MatchesParseLogLevel).

View Source
var Schema = []FieldSpec{
	{Path: "gc.enabled", Kind: KindBool, Reload: ReloadRestartRequired},
	{Path: "gc.interval", Kind: KindDuration, Reload: ReloadRestartRequired},
	{Path: "gc.older_than", Kind: KindDuration, Reload: ReloadRestartRequired},

	{Path: "log.level", Kind: KindEnum, Reload: ReloadRestartRequired, EnumValues: LogLevelNames},

	{Path: "web.public_url", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "web.http_addr", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "notify.command", Kind: KindStringArray, Reload: ReloadRestartRequired},

	{Path: "sandbox.allowed_domains", Kind: KindStringArray, Reload: ReloadRestartRequired},

	{Path: "sandbox.egress_proxy_port_low", Kind: KindInt, Reload: ReloadRestartRequired},
	{Path: "sandbox.egress_proxy_port_high", Kind: KindInt, Reload: ReloadRestartRequired},

	{Path: "sandbox.backend", Kind: KindOpaque, Reload: ReloadRestartRequired,
		Note: "removed in the volume-only cutover (docs/plans/volume-only-daemon.md §論点e) — container is the only sandbox backend now"},

	{Path: "task_ask.disconnect_grace", Kind: KindDuration, Reload: ReloadRestartRequired},

	{Path: "gateway.forges.*.host", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "gateway.forges.*.forge", Kind: KindEnum, Reload: ReloadRestartRequired, EnumValues: []string{"github", "bitbucket"}},
	{Path: "gateway.forges.*.secret_key", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "gateway.hosts", Kind: KindOpaque, Reload: ReloadRestartRequired,
		Note: "migrate to gateway.forges.<id>.* instead (see docs/ja/reference/config-yaml.md)"},

	{Path: "services.*.base_url", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.base_url_secret_key", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "services.*.allow_insecure", Kind: KindBool, Reload: ReloadRestartRequired},

	{Path: "services.*.allow_readonly_write", Kind: KindBool, Reload: ReloadRestartRequired},
	{Path: "services.*.redirects.allowed_hosts", Kind: KindStringArray, Reload: ReloadRestartRequired},
	{Path: "services.*.require_account", Kind: KindBool, Reload: ReloadRestartRequired},
	{Path: "services.*.auth.kind", Kind: KindEnum, Reload: ReloadRestartRequired,
		EnumValues: []string{"bearer", "basic", "header", "query", "oauth2"}},
	{Path: "services.*.auth.secret_key", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.auth.username", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.auth.username_secret_key", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.auth.header", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.auth.query", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.auth.provider", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "services.*.uses", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.endpoint", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.endpoint_secret_key", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.credentials.*", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.username", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "services.*.username_secret_key", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "services_floor", Kind: KindStringArray, Reload: ReloadRestartRequired},

	{Path: "oauth_providers.*.token_endpoint", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "oauth_providers.*.client_id", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "oauth_providers.*.client_secret_key", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "oauth_providers.*.scopes", Kind: KindStringArray, Reload: ReloadRestartRequired},

	{Path: "oauth_providers.*.grant", Kind: KindEnum, Reload: ReloadRestartRequired,
		EnumValues: []string{"authorization_code", "client_credentials"}},

	{Path: "oauth_providers.*.flow", Kind: KindEnum, Reload: ReloadRestartRequired,
		EnumValues: []string{"device", "loopback", "manual"}},
	{Path: "oauth_providers.*.authorization_endpoint", Kind: KindString, Reload: ReloadRestartRequired},
	{Path: "oauth_providers.*.device_authorization_endpoint", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "oauth_providers.*.authorize_params.*", Kind: KindString, Reload: ReloadRestartRequired},

	{Path: "integrations.dir", Kind: KindString, Reload: ReloadRestartRequired},
}

Schema is every leaf path `boid config set/get/unset` (and `apply`'s structural validation) recognizes. Order matches config.yaml's own section order (config.go's Config struct field order) for readability in error messages / help output that enumerates it.

Functions

func DefaultAllowedDomains added in v0.1.0

func DefaultAllowedDomains() []string

DefaultAllowedDomains returns boid's built-in sandbox.allowed_domains floor — the domains every daemon allows regardless of what config.yaml says (common AI-agent/package-registry endpoints). Exported so internal/server's config-hot-reload path (config_edit.go's applyDynamicConfigLocked) can recompute "floor ∪ user list" on every sandbox.allowed_domains change without internal/server needing to import cmd (which would cycle) or duplicate this literal.

A fresh copy is returned on every call — callers may freely mutate/append to the result.

func DefaultPath added in v0.1.0

func DefaultPath() (string, error)

DefaultPath resolves the default XDG config.yaml path (~/.config/boid/config.yaml) without reading it. Exported so callers that need the *path* itself — not just its parsed content — have one place to ask (internal/server's daemon-side config-editing wiring: `boid config get/set/unset/apply/edit` reads-modifies-writes this exact file) instead of re-deriving os.UserConfigDir()+"boid/config.yaml" independently and risking drift from what Load() itself actually reads.

func Get added in v0.1.0

func Get(tree Tree, path string) (any, error)

Get resolves a dotted path against tree for `boid config get <key>`. Returns the raw value (a scalar, []any, or Tree) and an error naming the closest known key when path is not a recognized schema leaf/container.

func GetPath added in v0.1.0

func GetPath(tree Tree, path string) (value any, ok bool)

GetPath reads the value at a dotted path in tree. ok is false when any segment along the way is absent, or an intermediate segment resolves to a non-map value (a scalar/array sitting where a nested key was expected).

func IsForgeEntryPath added in v0.1.0

func IsForgeEntryPath(path string) (id string, ok bool)

IsForgeEntryPath reports whether path names a whole gateway.forges.<id> entry (exactly "gateway.forges.<id>", no further segment) — the one dotted path `boid config unset` treats specially: removing a map entry removes the whole entry. id is returned when ok is true.

func IsOAuthProviderEntryPath added in v0.1.0

func IsOAuthProviderEntryPath(path string) (name string, ok bool)

IsOAuthProviderEntryPath reports whether path names a whole oauth_providers.<name> entry (exactly "oauth_providers.<name>", no further segment) — IsServiceEntryPath's counterpart for the OAuth2 provider registry, given the same "removing a map entry removes the whole entry" treatment `boid config unset` gives gateway.forges.<id> and services.<name>. name is returned when ok is true.

func IsServiceEntryPath added in v0.1.0

func IsServiceEntryPath(path string) (name string, ok bool)

IsServiceEntryPath reports whether path names a whole services.<name> entry (exactly "services.<name>", no further segment) — the API gateway's counterpart to IsForgeEntryPath above, given the identical "removing a map entry removes the whole entry" treatment `boid config unset` gives gateway.forges.<id>. name is returned when ok is true.

func ParseLogLevel added in v0.1.0

func ParseLogLevel(s string) (slog.Level, error)

ParseLogLevel maps a config.yaml log.level string to its slog.Level constant. It is the single source of truth both Config.UnmarshalYAML (load-time validation — an unrecognized string is a hard config error, same treatment as an unrecognized gateway.forges.*.forge value) and the daemon's own startup wiring (internal/daemon.ApplyLogLevel, which calls slog.SetLogLoggerLevel with the result) consult, so the two can never silently disagree about which strings are valid.

func ParseUsesReference added in v0.4.0

func ParseUsesReference(uses string) (pack, profile, version string, err error)

ParseUsesReference parses a services.<name>.uses value of the form "<pack名>/<profile名>@<pack version>" into its three components. Exported so internal/integrationpack — which resolves the reference against the loaded Pack registry — parses it with the exact same rule this package's own load-time syntax check (validateServiceConfig) uses.

func ValidateDomainEntry added in v0.1.0

func ValidateDomainEntry(entry string) error

ValidateDomainEntry validates a single sandbox.allowed_domains entry's syntax. Exported so `boid config set sandbox.allowed_domains ...`/`apply`/ `edit` all share this one check (dotted.go's Set does not itself know about per-Kind semantic constraints beyond parsing, so validate.go's ValidateYAML pass is what actually enforces this — see its own doc comment).

func ValidateKnownKeys added in v0.1.0

func ValidateKnownKeys(tree Tree) error

ValidateKnownKeys walks tree against the schema trie, rejecting any key (at any depth) that has no corresponding schema entry. Every gateway.forges.<id> map entry's id is accepted as a wildcard match, but the fields inside it are still checked against {host, forge, secret_key}.

func ValidateServiceURL added in v0.4.0

func ValidateServiceURL(serviceName, fieldName, rawURL string, allowInsecure bool) error

ValidateServiceURL validates rawURL for the safety properties every service's outbound upstream address must have:

  • an absolute URL with an explicit scheme and host
  • no query string or fragment (apigateway.Server always forwards the inbound request's own RawQuery verbatim)
  • https, unless allowInsecure is true
  • only http/https schemes even with allowInsecure set (the gateway's outbound Transport only ever speaks http/https)

Shared by validateServiceConfig's base_url check and its uses:-branch endpoint check. serviceName/fieldName only name the offending services.<name> entry/key in the returned error — fieldName is "base_url" or "endpoint" depending on the caller.

A thin wrapper around apigateway.ValidateBaseURL: the same check needs to run at request time too (for a base_url_secret_key-backed service), and internal/apigateway cannot import this package back, so the implementation lives there and this function delegates.

func WriteFileAtomic added in v0.0.13

func WriteFileAtomic(path string, data []byte, perm os.FileMode) (retErr error)

WriteFileAtomic writes data to path via a sibling temp file + rename, so concurrent readers (or a crash mid-write) never observe a partially written file. The temp file is created in the same directory as path (so the final os.Rename is same-filesystem and atomic), synced to disk before close, and removed on any error path before return — an existing file at path is left untouched unless the write fully succeeds.

The temp file's name is derived from path's own basename (".<base>.*") so a crash-leftover file names the caller it came from, since this function has more than one caller.

Types

type Config

type Config struct {
	GC      GCConfig      `yaml:"gc"`
	Log     LogConfig     `yaml:"log"`
	Web     WebConfig     `yaml:"web"`
	Notify  NotifyConfig  `yaml:"notify"`
	Sandbox SandboxConfig `yaml:"sandbox"`
	TaskAsk TaskAskConfig `yaml:"task_ask"`
	Gateway GatewayConfig `yaml:"gateway"`
	// Services declares the API gateway's service registry — a top-level
	// key, deliberately NOT nested under Gateway (which is git-gateway-
	// specific: per-forge Basic-auth credential config). See
	// ServiceConfig's own doc comment.
	Services map[string]ServiceConfig `yaml:"services,omitempty"`
	// ServicesFloor is the daemon-wide set of service names enabled for
	// EVERY workspace, mirroring sandbox.allowed_domains' own floor role. A
	// workspace's own WorkspaceMeta.Services list adds to this floor — see
	// orchestrator.ResolveEnabledServices. An entry naming a service not
	// declared under Services is not a load error — it just never resolves
	// to anything at dispatch time, the same lenient-string-list posture
	// allowed_domains' floor has always had.
	ServicesFloor []string `yaml:"services_floor,omitempty"`
	// OAuthProviders declares the API gateway's OAuth2 provider registry,
	// keyed by provider name — the same name a
	// services.<name>.auth.provider entry references. A provider reference
	// naming an entry not declared here is not a config-load error — see
	// TestLoadFromPath_Services_OAuth2ProviderReferenceNotCrossValidated
	// (oauth_providers_test.go): it fails at request time instead, with a
	// clear error, the same contract every other secret-store-shaped
	// reference in this file already has.
	OAuthProviders map[string]OAuthProviderConfig `yaml:"oauth_providers,omitempty"`
	// Integrations configures where the daemon looks for installed
	// Integration Packs. A top-level key, deliberately separate from
	// Services: the Pack registry is loaded/validated by
	// internal/integrationpack (not this package), while services.*.uses
	// just references it.
	Integrations IntegrationsConfig `yaml:"integrations,omitempty"`
}

Config holds the global boid configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default boid configuration.

func Load

func Load() (*Config, error)

Load reads the configuration from the default XDG path (~/.config/boid/config.yaml). If the file does not exist, the default configuration is returned without error.

func LoadFromPath added in v0.1.0

func LoadFromPath(path string) (*Config, error)

LoadFromPath is loadFromPath's exported counterpart: a pure filesystem read + yaml.v3 decode with no daemon/HTTP dependency at all — unlike `boid config get` (cmd/config.go), which always talks to a live daemon's HTTP API and therefore has no bootstrap-before-first-boot path. Exported so any standalone tooling can resolve a config.yaml's effective values — including the strict validation UnmarshalYAML performs — against an arbitrary path, not just the CLI process's own XDG default. Same not-found semantics as Load()/loadFromPath: a missing file returns DefaultConfig(), not an error.

func ValidateYAML added in v0.1.0

func ValidateYAML(data []byte) (*Config, error)

ValidateYAML decodes and fully validates a candidate config.yaml document, returning the resolved *Config on success. data may be a full document (a `boid config apply -f`/`edit` body) or a partial one built by Set/Unset starting from an already-valid tree — either way, every key present must resolve against Schema, and the document must decode cleanly through Config.UnmarshalYAML.

func (Config) APIGatewayOAuthProviders added in v0.1.0

func (c Config) APIGatewayOAuthProviders() []apigateway.OAuthProviderConfig

APIGatewayOAuthProviders resolves c.OAuthProviders into the flat []apigateway.OAuthProviderConfig list apigateway.NewOAuth2TokenSource consumes, sorted by name for determinism. An entry that fails validateOAuthProviderConfig here (a hand-built Config that skipped validation) is skipped silently rather than surfaced as an error, since this method has no error return.

func (Config) APIGatewayServices added in v0.1.0

func (c Config) APIGatewayServices() []apigateway.ServiceConfig

APIGatewayServices resolves c.Services into the flat []apigateway.ServiceConfig list apigateway.NewCredentialProvider consumes, sorted by name for determinism. An entry that fails validateServiceConfig here (a hand-built Config that skipped validation) is skipped silently rather than surfaced as an error, since this method has no error return.

A uses: entry is deliberately excluded from the output — it has no BaseURL/Auth of its own to convert (those come from the resolved Integration Pack service profile, which this package cannot reach). internal/integrationpack.ResolveServices is what combines this method's output with its own Pack-resolved uses: entries into the full flat list.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler for Config. It starts from DefaultConfig values so that unspecified fields retain defaults. Unknown legacy fields (state_machine.rework_limit) are silently ignored.

func (Config) UsesServices added in v0.4.0

func (c Config) UsesServices() map[string]ServiceConfig

UsesServices returns the subset of c.Services with uses: set, keyed by instance name — the counterpart to APIGatewayServices() (which deliberately excludes them) that internal/integrationpack.ResolveServices consumes to know which instances to desugar against the loaded Pack registry.

type FieldKind added in v0.1.0

type FieldKind int

FieldKind describes the shape of value a schema leaf accepts.

const (
	// KindString is a single scalar string.
	KindString FieldKind = iota
	// KindBool is a single scalar bool ("true"/"false").
	KindBool
	// KindDuration is a single scalar Go duration string (e.g. "24h").
	KindDuration
	// KindInt is a single scalar integer (e.g. a TCP port).
	KindInt
	// KindStringArray is zero or more scalar strings (`boid config set` multi-arg).
	KindStringArray
	// KindEnum is a single scalar string constrained to EnumValues.
	KindEnum
	// KindOpaque is a structurally-recognized leaf whose value is NOT
	// `boid config set/unset`-able — it exists in Schema purely so
	// ValidateKnownKeys (validate.go's pass 1, the unknown-key trie walk)
	// does not reject a path the daemon still structurally accepts
	// elsewhere (Config.UnmarshalYAML's own decode pass, ValidateYAML's
	// pass 2). Its shape (list, map, whatever) is validated by that pass 2
	// decode, not duplicated here. coerceValues (dotted.go) rejects any
	// `boid config set` attempt against a KindOpaque leaf with a dedicated
	// message rather than falling through to the generic "unsupported
	// field kind" text — see FieldSpec.Note for how that message's
	// field-specific tail is authored per leaf.
	KindOpaque
)

type FieldSpec added in v0.1.0

type FieldSpec struct {
	Path       string
	Kind       FieldKind
	Reload     ReloadClass
	EnumValues []string
	// Note is an optional field-specific clause appended to a KindOpaque
	// leaf's generic "not settable"/"not unsettable" rejection message
	// (dotted.go's coerceValues/Unset) — e.g. where to migrate instead.
	// Empty leaves the generic message with no follow-up clause. Every
	// other Kind ignores this field.
	Note string
}

FieldSpec describes one CLI-editable scalar/array leaf in config.yaml. Path is dotted, with "*" standing in for a single wildcard segment (only ever gateway.forges.<any-id> today).

func ResolveField added in v0.1.0

func ResolveField(path string) (*FieldSpec, bool)

ResolveField looks up the FieldSpec matching a concrete dotted path (no wildcards in path itself — path is what a user typed, e.g. "gateway.forges.github.host"). Returns (nil, false) when no schema leaf matches — the caller (dotted.go) is responsible for turning that into a helpful "unknown key" error, since only it has the surrounding tree to offer a closest-match suggestion against.

type ForgeConfig added in v0.0.11

type ForgeConfig struct {
	// Host is the upstream host as it appears in the gateway route path
	// (e.g. "github.com"). Optional for built-in ids; required otherwise.
	Host string `yaml:"host,omitempty"`
	// Forge selects the Basic-auth username convention
	// (gitgateway.ForgeGitHub / gitgateway.ForgeBitbucket). Optional for
	// built-in ids; required otherwise.
	Forge gitgateway.Forge `yaml:"forge,omitempty"`
	// SecretKey is a reference into the secret store
	// (internal/dispatcher/secret_store.go); never a plaintext token.
	// Optional for built-in ids (defaults below); required otherwise.
	SecretKey string `yaml:"secret_key,omitempty"`
}

ForgeConfig configures the git gateway's credential injection for a single forge id (the map key in GatewayConfig.Forges). Only the forge kind and a secret-store key reference are ever written here — the plaintext PAT itself lives in the secret store (`boid secret set <key> <value>`), never in config.yaml.

Built-in ids ("github", "bitbucket") default every field left empty here (see builtinForges): host, Basic-auth forge convention, and secret-store key all resolve without the user writing anything, so `gateway.forges: {github: {}}` — or omitting the id entirely, since DefaultConfig pre-populates both built-ins — is enough for `boid secret set github-pat <PAT>` to light up the gateway for github.com. Custom ids (e.g. "github-enterprise") must set Host explicitly, and Forge must name one of gitgateway's recognized conventions since that convention is not itself derivable from an arbitrary id.

type GCConfig

type GCConfig struct {
	Enabled   bool          `yaml:"-"`
	Interval  time.Duration `yaml:"-"`
	OlderThan time.Duration `yaml:"-"`
}

GCConfig holds garbage collection settings.

type GatewayConfig added in v0.0.10

type GatewayConfig struct {
	// Forges maps a forge id (e.g. "github", "bitbucket", or a custom id
	// like "github-enterprise") to its credential config. Built-in ids
	// "github" and "bitbucket" are pre-populated by DefaultConfig with
	// host/forge/secret_key defaults already filled in — see builtinForges.
	Forges map[string]ForgeConfig `yaml:"forges,omitempty"`
}

GatewayConfig configures the git gateway's per-forge credential injection. Forges maps a forge id to its credential config; Config.UnmarshalYAML also accepts the deprecated pre-forges-map `gateway.hosts` list and folds it into this map, so GatewayConfig itself only ever needs to carry the one shape.

func (GatewayConfig) HostConfigs added in v0.0.11

func (g GatewayConfig) HostConfigs() []gitgateway.HostForgeConfig

HostConfigs resolves g.Forges into the flat gitgateway.HostForgeConfig list gitgateway.NewCredentialProvider consumes (internal/server/wire.go), applying built-in defaults per resolveForgeConfig. Entries are returned in id-sorted order for determinism.

INVARIANT: callers must only invoke this on a GatewayConfig that has already been validated by Config.UnmarshalYAML — that is the sole place gateway.forges entries are validated, so on a validated config every entry resolves successfully. A resolution failure here is defensive-only (a hand-built GatewayConfig that skipped validation) and is skipped silently rather than surfaced as an error, since HostConfigs has no error return and never should have one under the invariant.

type IntegrationsConfig added in v0.4.0

type IntegrationsConfig struct {
	// Dir is the filesystem root internal/integrationpack.LoadPacks
	// enumerates: <dir>/<pack>/<version>/integration.yaml. Defaults to
	// "/opt/boid/integrations" — the compose volume mount point a
	// container-backend deployment bind-mounts an Integration Pack repo
	// checkout onto; a bare binary deployment overrides this to wherever
	// its own Pack checkout lives. A directory that does not exist (the
	// common case for a deployment with no Packs installed yet) is not an
	// error — see LoadPacks' own doc comment.
	Dir string `yaml:"dir,omitempty"`
}

IntegrationsConfig configures the Integration Pack loader (internal/integrationpack.LoadPacks). Deliberately just a directory path — the actual pack enumeration/parsing/validation is internal/integrationpack's job, not this package's: Config.UnmarshalYAML only ever does syntactic validation — resolving this path against the filesystem happens once, eagerly, at daemon startup, not on every config.yaml parse (a CLI invocation like `boid config get` must not need filesystem/Pack-registry access just to read a scalar).

type LogConfig added in v0.1.0

type LogConfig struct {
	// Level is one of LogLevelNames ("debug"/"info"/"warn"/"error").
	// Config.UnmarshalYAML rejects any other non-empty value as a hard
	// config-load error (ParseLogLevel) — a typo'd level should fail `boid
	// start`/`boid config apply` loudly, not silently fall back to some
	// default.
	Level string `yaml:"level,omitempty"`
}

LogConfig holds daemon logging settings.

Level controls slog's built-in bridge-to-log-package minimum level (slog.SetLogLoggerLevel — applied once at daemon startup by internal/daemon.ApplyLogLevel) without installing a custom slog.Handler or changing boid.log's line format at all: nothing in the daemon calls slog.SetDefault or installs a Handler, so every slog call already goes through slog's package-private defaultHandler, which formats via the standard "log" package and checks slog.SetLogLoggerLevel's threshold before emitting anything. A real TextHandler/JSONHandler would instead change the line format, breaking every boid.log-grepping runbook — which is why this package never installs one.

Empty (the zero value) means "leave slog's own built-in default (info) alone".

type NotifyConfig

type NotifyConfig struct {
	Command []string `yaml:"command"`
}

NotifyConfig holds settings for agent-driven notifications.

type OAuthProviderConfig added in v0.1.0

type OAuthProviderConfig struct {
	// TokenEndpoint is the provider's OAuth2 token endpoint (RFC 6749
	// §3.2), e.g. https://accounts.secure.freee.co.jp/public_api/token.
	// Always https.
	TokenEndpoint string `yaml:"token_endpoint"`
	// ClientID is the OAuth2 client_id. Not a secret by RFC 6749 §2.2's own
	// classification (a public identifier), so — unlike ClientSecretKey —
	// it is written directly here rather than referenced through the
	// secret store.
	ClientID string `yaml:"client_id"`
	// ClientSecretKey is a secret-store key reference (never a plaintext
	// value) for a confidential client's client_secret. Empty for a public
	// client (PKCE, no client_secret) — apigateway.OAuth2TokenSource simply
	// omits client_secret from the token request when this is empty.
	ClientSecretKey string `yaml:"client_secret_key,omitempty"`
	// Scopes is consumed by `boid secret oauth login`'s authorization-URL
	// construction (loopback/manual) and device-authorization request
	// (device). Never sent on an authorization_code refresh_token grant —
	// see apigateway.OAuth2TokenSource.callRefreshTokenEndpoint. A
	// client_credentials grant DOES send Scopes on every token request —
	// see callClientCredentialsTokenEndpoint instead.
	Scopes []string `yaml:"scopes,omitempty"`

	// Flow selects which of the three initial-grant flows `boid secret
	// oauth login <service>` uses for this provider: "device" / "loopback"
	// / "manual". Empty ("") means this provider has no login flow
	// configured — an operator can still seed refresh_token by hand via
	// `boid secret set`, but `boid secret oauth login` for it fails with a
	// clear "no flow configured" error rather than guessing.
	Flow string `yaml:"flow,omitempty"`
	// AuthorizationEndpoint is the provider's OAuth2 authorization endpoint
	// (RFC 6749 §3.1) — required (and only meaningful) when Flow is
	// "loopback" or "manual".
	AuthorizationEndpoint string `yaml:"authorization_endpoint,omitempty"`
	// DeviceAuthorizationEndpoint is the provider's RFC 8628 §3.1 device
	// authorization endpoint — required (and only meaningful) when Flow is
	// "device".
	DeviceAuthorizationEndpoint string `yaml:"device_authorization_endpoint,omitempty"`
	// AuthorizeParams is a fixed set of extra parameters appended verbatim
	// to the authorization request (loopback/manual: query parameters;
	// device: form fields on the device authorization request) — see
	// apigateway.OAuthProviderConfig.AuthorizeParams for the motivating
	// example (Google's access_type/prompt). Keys colliding with a
	// protocol-reserved parameter are rejected below.
	AuthorizeParams map[string]string `yaml:"authorize_params,omitempty"`

	// Grant selects which RFC 6749 grant apigateway.OAuth2TokenSource.
	// refresh performs for this provider: "authorization_code" (the
	// default) or "client_credentials" (RFC 6749 §4.4, 2-legged / app-only,
	// Service Principal). Deliberately a separate field from Flow, not a
	// fourth Flow value — see apigateway.OAuthProviderConfig.Grant. Empty
	// ("") means "authorization_code".
	Grant string `yaml:"grant,omitempty"`
}

OAuthProviderConfig declares one config.yaml oauth_providers.<name> entry — the OAuth2 token-endpoint identity a services.*.auth.kind: oauth2 entry's `provider` field references.

type ReloadClass added in v0.1.0

type ReloadClass int

ReloadClass classifies whether the daemon can apply a changed leaf live.

const (
	// ReloadDynamic keys are hot-reloaded silently (an info log line, no
	// operator-facing warning) as soon as the daemon accepts the write.
	//
	// No Schema leaf uses this class today. The constant and this
	// ReloadClass distinction are kept (not deleted) so a future
	// genuinely-safe-to-hot-reload leaf has an obvious place to go without
	// re-litigating the enum.
	ReloadDynamic ReloadClass = iota
	// ReloadRestartRequired keys are persisted but only take effect on the
	// next daemon restart — the daemon prints a loud warning naming the
	// restart command.
	ReloadRestartRequired
)

func Set added in v0.1.0

func Set(tree Tree, path string, values []string) (ReloadClass, error)

Set validates and applies `boid config set <key> <value...>` against tree, returning the ReloadClass the caller should report to the operator. Fails when path is not a scalar/array schema leaf (an unresolved path, or one resolving to a struct/map slot like a bare "gateway.forges.github" — docs/plans/volume-only-daemon.md §論点 f's unilateral decision: set never targets a whole map entry, only unset does) — or when the given values don't match the leaf's Kind (wrong arity, bad enum, unparseable duration/bool).

func Unset added in v0.1.0

func Unset(tree Tree, path string) (ReloadClass, error)

Unset validates and applies `boid config unset <key>` against tree, returning the ReloadClass the caller should report. Three shapes:

  • a whole gateway.forges.<id> entry ("gateway.forges.github") removes the entire map entry — the unilateral decision documented on IsForgeEntryPath.
  • a whole services.<name> entry ("services.myapp") removes the entire map entry too — IsServiceEntryPath's identical treatment, docs/plans/ api-gateway.md §2.
  • any other recognized scalar/array leaf removes just that key.

Fails with "key not found" when the path is unrecognized OR is recognized but not currently present in tree — per §論点 f's unilateral decision, unset never silently no-ops on a missing key.

MINOR 1 (codex review round 2): a KindOpaque leaf (gateway.hosts, the only one today) is documented as non-settable AND non-unsettable (schema.go's KindOpaque doc comment, docs/ja/reference/config-yaml.md's "旧 gateway.hosts 記法" section) — Set already rejects it via coerceValues's dedicated KindOpaque branch, but this generic path had no equivalent check and happily deleted it, silently letting `boid config unset gateway.hosts` "succeed" despite the documented read-only contract. The check runs before the presence check below (deletePathRaw) so the rejection reason is always "read-only", never "key not found", regardless of whether the key happens to be present in tree.

type SandboxConfig

type SandboxConfig struct {
	AllowedDomains []string `yaml:"allowed_domains"`
	// EgressProxyPortLow/High bound the port band the egress proxy
	// allocates each workspace's stable listener port from, inclusive.
	//
	// Both zero (the default) means "use internal/sandbox's own default
	// band", which sits below the kernel's ephemeral port range on purpose
	// — see sandbox.DefaultProxyPortRangeLow's doc comment. Override only
	// when that assumption does not hold locally, e.g. an operator who has
	// lowered net.ipv4.ip_local_port_range so the default band overlaps it.
	EgressProxyPortLow  int `yaml:"egress_proxy_port_low,omitempty"`
	EgressProxyPortHigh int `yaml:"egress_proxy_port_high,omitempty"`
}

SandboxConfig holds sandbox-related settings.

container is the only sandbox backend; an old config.yaml that still sets sandbox.backend keeps loading without error — see UnmarshalYAML's handling below — the key is just parsed-and-ignored, with a warning logged.

type ServiceAuthConfig added in v0.1.0

type ServiceAuthConfig struct {
	// Kind selects the injection strategy: "bearer" / "basic" / "header" /
	// "query" / "oauth2".
	Kind string `yaml:"kind"`
	// SecretKey is a reference into the secret store
	// (internal/dispatcher/secret_store.go); never a plaintext value.
	// Required for bearer/basic/header/query; unused for oauth2.
	SecretKey string `yaml:"secret_key,omitempty"`
	// Username is the Basic-auth username. Required (and only meaningful)
	// for kind: basic — mutually exclusive with UsernameSecretKey (exactly
	// one of the two is required for kind: basic; see validateServiceConfig).
	Username string `yaml:"username,omitempty"`
	// UsernameSecretKey, when set (kind: basic only), resolves the
	// Basic-auth username from the secret store instead of using the
	// literal Username above — account-qualified the same way SecretKey
	// already is.
	//
	// NOT the same config path as ServiceConfig.UsernameSecretKey
	// (services.<name>.username_secret_key, uses:-entries only). This field
	// only applies to a free-form entry (a uses: entry's Auth block must be
	// the exact zero value, validateServiceConfig).
	UsernameSecretKey string `yaml:"username_secret_key,omitempty"`
	// Header is the header name to set. Required (and only meaningful) for
	// kind: header.
	Header string `yaml:"header,omitempty"`
	// Query is the query parameter name to set. Required (and only
	// meaningful) for kind: query.
	Query string `yaml:"query,omitempty"`
	// Provider names the OAuth2 provider (config.yaml oauth_providers:
	// block). Required (and only meaningful) for kind: oauth2.
	Provider string `yaml:"provider,omitempty"`
}

ServiceAuthConfig configures how the API gateway authenticates requests to one service. Which fields are required depends on Kind — see validateServiceConfig.

type ServiceConfig added in v0.1.0

type ServiceConfig struct {
	// Redirects is an operator-controlled policy, also supported with uses.
	Redirects apigateway.RedirectPolicy `yaml:"redirects,omitempty"`
	// BaseURL is the upstream base URL (scheme + host, optionally a path
	// prefix) — never exposed to the sandbox; only the logical service name
	// in the route path is.
	BaseURL string            `yaml:"base_url,omitempty"`
	Auth    ServiceAuthConfig `yaml:"auth"`
	// BaseURLSecretKey, when set, resolves BaseURL from the secret store
	// instead of using the literal field above — account-qualified the
	// same way auth.secret_key already is. Mutually exclusive with
	// BaseURL; exactly one is required for a free-form (non-uses:) entry.
	BaseURLSecretKey string `yaml:"base_url_secret_key,omitempty"`
	// AllowInsecure must be explicitly set to true for BaseURL to use any
	// scheme other than "https" — a fail-closed requirement so choosing a
	// plaintext upstream is always a conscious, config-visible decision.
	AllowInsecure bool `yaml:"allow_insecure,omitempty"`
	// AllowReadOnlyWrite opts this service out of the read-only→GET/HEAD-only
	// gate (apigateway.Server.ServeHTTP) so a read-only job token can still
	// POST/PUT/PATCH/DELETE to it. Deliberately config.yaml-only (never a
	// project.yaml/task_behaviors field): granting it from inside the repo
	// would let a prompt-injected agent grant itself write access to any
	// service already reachable from the job token. Defaults to false.
	AllowReadOnlyWrite bool `yaml:"allow_readonly_write,omitempty"`

	// RequireAccount, when true, rejects (400) any request to this service
	// that omits the credential-account qualifier (the request path's
	// service segment must be "<name>@<account>", not "<name>" alone).
	// Defaults to false, so an existing services.<name> entry's behavior is
	// unchanged until an operator opts in explicitly.
	//
	// Deliberately config.yaml-only (never a project.yaml/task_behaviors
	// field) for the same reason AllowReadOnlyWrite above is: this is a
	// gateway-level credential-selection constraint the daemon operator
	// controls, not something a job running inside the repo should be able
	// to toggle either way.
	RequireAccount bool `yaml:"require_account,omitempty"`

	// Uses references an installed Integration Pack's service profile
	// instead of hand-writing BaseURL/Auth. Format:
	// "<pack名>/<profile名>@<pack version>" — parsed by ParseUsesReference.
	// Mutually exclusive with BaseURL/Auth (validateServiceConfig). This
	// package only checks the reference's SYNTAX; resolving it against the
	// installed Pack registry is internal/integrationpack's job — it has
	// the loaded Packs this package deliberately does not depend on.
	Uses string `yaml:"uses,omitempty"`
	// Endpoint fills in the resolved service profile's endpoint.configurable
	// slot. Only meaningful — and only accepted by validateServiceConfig —
	// when Uses is set; the profile itself decides whether a value is
	// required, forbidden, or unused
	// (internal/integrationpack.DesugarService enforces the pairing).
	Endpoint string `yaml:"endpoint,omitempty"`
	// EndpointSecretKey, when set, resolves the profile's
	// endpoint.configurable slot from the secret store instead of using
	// the literal Endpoint above. Mutually exclusive with Endpoint. Only
	// meaningful — and only accepted by validateServiceConfig — when Uses
	// is set, mirroring Endpoint's own scoping.
	EndpointSecretKey string `yaml:"endpoint_secret_key,omitempty"`
	// Credentials binds each of the resolved service profile's declared
	// credential slot names to a SecretStore key reference — never a
	// plaintext value, the same convention ServiceAuthConfig.SecretKey
	// already has. Only meaningful — and only accepted by
	// validateServiceConfig — when Uses is set.
	Credentials map[string]string `yaml:"credentials,omitempty"`
	// Username fills in the resolved service profile's INSTANCE-SPECIFIC
	// Basic-auth username slot (internal/integrationpack.CredentialSlot.
	// UsernameFrom == UsernameFromInstance) — e.g. a login email that
	// differs per instance rather than a Pack-fixed constant. Deliberately
	// a TOP-LEVEL, PLAINTEXT field, not folded into Credentials above:
	// Credentials only ever binds SecretStore key references, and an email
	// address is config, not a secret. Only meaningful — and only accepted
	// by validateServiceConfig — when Uses is set; whether the resolved
	// profile's slot actually accepts it is
	// internal/integrationpack.DesugarService's job.
	Username string `yaml:"username,omitempty"`
	// UsernameSecretKey, when set, resolves the profile's INSTANCE-SPECIFIC
	// Basic-auth username slot from the secret store instead of using the
	// literal Username above. Mutually exclusive with Username. Only
	// meaningful — and only accepted by validateServiceConfig — when Uses
	// is set, mirroring Username's own scoping.
	//
	// NOT the same config path as ServiceAuthConfig.UsernameSecretKey
	// (services.<name>.auth.username_secret_key, free-form entries only).
	UsernameSecretKey string `yaml:"username_secret_key,omitempty"`
}

ServiceConfig declares one logical service the API gateway can proxy job requests to.

type TaskAskConfig added in v0.0.7

type TaskAskConfig struct {
	// DisconnectGrace is how long an awaiting task may sit with no live agent
	// parked (the agent's `boid task ask` was killed by a harness command-timeout
	// and disconnected) before the daemon reclaims it. The agent normally
	// re-asks within one command-timeout and re-attaches; the grace bounds the
	// case where it never returns.
	DisconnectGrace time.Duration `yaml:"-"`
}

TaskAskConfig holds settings for the blocking `boid task ask` Q&A RPC.

type Tree added in v0.1.0

type Tree = map[string]any

Tree is the generic YAML representation `boid config get/set/unset` operates on: the same shape `yaml.Unmarshal(data, &tree)` produces for a config.yaml document (nested map[string]any / []any / scalar values). Operating on this generic shape — rather than the typed Config struct — mirrors the existing `boid web set-addr`/`set-url` local-edit pattern (cmd/web.go): it round-trips only the keys actually present, so an unrelated section of a hand-authored config.yaml a user never touches through this CLI is never silently reshaped.

func ParseTree added in v0.1.0

func ParseTree(data []byte) (Tree, error)

ParseTree decodes a YAML document into the generic Tree dotted-path operations act on, guaranteeing a non-nil map even for a genuinely empty document. Shared by cmd/config.go's client-side parseConfigTree (which delegates here) and internal/server's MutateConfig (BLOCKER 1, codex review round 1's server-side read-modify-write) so both ends of the GET/mutate/POST-body round trip decode identically.

type WebConfig

type WebConfig struct {
	PublicURL string `yaml:"public_url"`
	HTTPAddr  string `yaml:"http_addr"`
}

WebConfig holds web UI settings.

Jump to

Keyboard shortcuts

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