ADR 0034 — One YAML configuration file; secrets by reference ​
- Status: accepted (2026-10-02), on the owner's request of 2026-10-02; the details are the planner's (plan 10, section 3.6) and the owner may revisit them. Amends the environment-only practice of the composition root (ADR 0009, status note there). Built (2026-10-02, PR S9): the loader and every key marked now in
docs/api/config.md; the keys marked reserved come with S11 (ADR 0032,artifacts.maxPerJobBytesandfetchHosts), S14/S15 (ADR 0033, authentication and roles), each written with its PR. Built (2026-10-02, PR S18, ADR 0035):models.endpointswith several endpoints,tasks.titleandtasks.descriptionwith theirsystem,maxTokens,language,maxCharsandrecompute, theuisection andGET /api/config;tasks.turnSummaryandtasks.stepLabelstay reserved. Status note (2026-10-02, PR S10): theartifactssection is built (ADR 0032):store,fs.root,s3.*andmaxFileBytes, and its two S3 credentials are secrets by reference, so the contract has ten (the eight below and these two).artifacts.storeis the key that selects an implementation among the compiled-in ones: a store whose Cargo feature (artifacts-fs,artifacts-s3) is not in the build is exit 78 naming the feature. Status note (2026-10-02, slice 8, ADR 0024): thetoolServerssection is built (the servers a person may attach to a conversation). Itsbearerand itsheaders(a header name to a reference) are two more secrets by reference, so the contract has twelve (the ten above and these two); the section has no variable, so it belongs to the file alone. Its rules (a unique id, a URL with no credential in it, an icon that is a smalldata:image, header names the client may set, anagentslist that names agents of the agents file) are inorch-configand the binary, and every error names the key and never a value. Status note (2026-10-14, slice 3 of ADR 0046): thesecretssection is built (store: pg,pg.keysof{ id, key },pg.current: where a person's own credentials are sealed). Eachkeyis a secret by reference that must read as 64 hexadecimal characters, so the contract has fifteen (the fourteen the notes above count, and this one); the section has no variable,secrets.storeselects among the compiled-in implementations (the Cargo featuresecrets-pg, else exit 78 naming it), and the commandorchestrator secrets rewrapreadsdatabase.urland this section only. Status note (2026-10-02, PR S18): the legacy variables are now the endpointdefaultbeside the file's other endpoints (S9 refused a file that named another one, because the build took one), andORCH_TITLE_MODELthe title task on it. A prompt file (tasks.<task>.system: { file }) is read in the rules pass through the resolver, like a secret's file, and its errors name the key and the path, never the text.Validatedcarries the prompts beside the secrets.GET /api/configis behind the identity layer as decided in section 6, served as{"ui": {...}}from a typedPublicConfigthe composition root fills. Status note (2026-10-02, PR S9): the three passes each list all of their errors, and a pass runs only when the one before it found none (a rule cannot be checked on a value that is not there), so one run lists the shape errors, or, when there are none, the rule errors;docs/api/config.mdsays so. A role that serves no routes (worker) is not asked for the secrets of the routes it would not mount (webhooks.*), so one file serves a control plane and its workers. A relative path is relative to the directory of the file even when a legacy variable gave it. A secret flag given on the command line is read through the{ env: NAME }reference of the file, ahead of the variable. Amended (2026-10-04): a model endpoint'sbaseUrlis the first key that is not a secret and takes{ env }or{ file }(ADR 0035); the fourteen secrets are unchanged, the loader reads such a URL by the rules of a secret reference, checks it as a written one, and never puts it in an error.
Context ​
The owner, 2026-10-02: "We need a custom model for title, description,... Maybe with its custom system prompt too. I think we should do the config of the web using a yaml then. A .env won't be enough."
How the owner's words are read. "The config of the web" is read as the system's configuration, served by the orchestrator from one YAML file, with a public ui subset the web reads from GET /api/config. The web itself stays configuration-free and secret-free, as designed (architecture: "no Next.js API routes, no server-side fetches and no secrets in the web"; its only variables, API_ORIGIN and MOCK_API_ORIGIN in web/next.config.ts, are development tooling). One file, one reader. If the owner meant a file the web reads itself, this ADR is the place to say so.
What exists (verified 2026-10-02 in the code at 9dddfc1):
- The binary is configured by 53 environment variables: 52 declared in
orchestrator/bin/orchestrator/src/config.rsas clap flags with an environment fallback (--listen-addr/LISTEN_ADDR, …;HOSTNAMEhidden), andRUST_LOG, read byEnvFilterinlogging.rs. No other crate underorchestrator/reads the environment outside tests. The full list, each with its key, isdocs/api/config.md. - Two YAML files already exist beside them:
AGENTS_FILE(the agents, withdeny_unknown_fieldsongate) andMCP_TOKENS_FILE. Both hold secrets by reference (tokenEnv: CODER_A2A_TOKEN), never by value. Config::loadis pure: clap only collects raw strings, the validation reads the files and thetokenEnvvariables through closures, every error is aConfigErrornaming the variable, and any error exits 78.- The YAML parser of the workspace is
serde_norway0.9.42;schemars1 andjsonschema0.58 are workspace dependencies already (orchestrator/Cargo.toml).
What is wrong with variables. Plan 10 adds settings that are structured, not scalar: several model endpoints, a task per utility call with its own prompt (a paragraph, or a file), roles mapped to permissions (§3.4), an artifact store with S3 settings (§3.3). Flat names cannot hold lists of objects without a private syntax per variable (today ORCH_SURFACES and ORCH_GATE are comma lists, and WEBHOOK_*_SECRETS "one or two comma-separated secrets"). And a variable mixes what is secret with what is not: DATABASE_URL, THREAD_TOOLS_SECRET and LISTEN_ADDR look the same in a Deployment.
Decision ​
1. One file, read at startup ​
- The orchestrator reads one YAML file, named by
ORCH_CONFIG_FILE(or--config <path>), once, at startup. There is no hot reload: processes are stateless and restart cheaply (ADR 0001), and agents are already live through the registry (ADR 0022). A Kubernetes chart restarts on a change of the ConfigMap's checksum. Hot reload is open question 43. version: 1is required. A later incompatible shape isversion: 2, read beside1for one release.- The file configures the orchestrator only. The agents file and the MCP tokens file stay separate files, named from it (
agents.file,mcp.tokensFile), with their formats unchanged. - The sections and keys, and which PR builds each, are
docs/api/config.md. S9 buildsserver,log,database,dispatcher,inbox,agents,gate,steps,models(one endpoint),tasks.title(endpoint,model),threadTools,mcp,webhooksandauth.devUser: exactly the 51 variables of today that have a key. A reserved key is refused with exit 78 naming the ADR that brings it, so a file never holds a setting that silently does nothing.
2. Secrets only by reference ​
- A secret field is a
SecretRef:{ env: NAME }or{ file: PATH }, nothing else. A plain string there is refused at startup (exit 78), with the key and the two allowed forms, never the value. - References are resolved at startup through closures the binary passes in (the environment, the file system), as
tokenEnvis today. A reference that does not resolve (a variable unset or empty, a file that cannot be read) is exit 78 naming the key and the variable or path.{ file }loses one trailing newline and is at most 64 KiB. An optional secret is absent by leaving its key out, never by an empty variable. - No error carries a value. Every message the loader prints names a key path, what is wrong and what is allowed, never a value from the file, the environment or a secret file. Library messages that quote the input are not passed through:
jsonschema's errors are reported by their instance path and kind (itsDisplayincludes the instance, which may be a pasted secret), a string at aSecretRefis reported as "a secret is a reference:{ env: NAME }or{ file: PATH }", and a YAML syntax error by line and column only. - The secrets are the eight values of today that are secrets (
database.url, the two registry tokens,threadTools.secretandpreviousSecret, a model endpoint'sapiKey, the two webhook secret lists) and, later,artifacts.s3.accessKeyId/secretAccessKey. Resolved values areSecretStrings; everyDebugprints the reference, never the value.
3. Validation: typed, closed, and every error at once ​
- A new pure crate,
orch-config(orchestrator/crates/config): the file's types (serde,#[serde(deny_unknown_fields)]on every struct,rename_all = "camelCase", no#[serde(flatten)], because serde does not support it together withdeny_unknown_fields) andvalidate(raw, resolve) -> Result<Config, Vec<ConfigError>>. It does no I/O: reading the file, the environment and secret files stays in the binary. - Loading has three passes, so that one run lists every error it can find:
- Syntax.
serde_norwayparses the text into a value tree; merge keys are applied (Value::apply_merge); a tag is refused, and so is a key repeated in one mapping (never "the last one wins"). A syntax error is reported alone, with its line and column. - Shape. The tree is checked against the JSON Schema generated from the types, with
jsonschema'siter_errors, which yields every violation (unknown keys, sincedeny_unknown_fieldsbecomesadditionalProperties: false; wrong types; missing required keys; a string where aSecretRefgoes), each with its path. An unknown key that is a reserved key (a short table inorch-config: the path, the PR and the ADR that bring it) is reported as reserved, not as unknown. Then the tree is deserialized into the types; after a clean schema pass that cannot fail, short of a drift the schema test catches. - Rules.
validate()checks ranges, URLs, the cross-key rules of today (both or neither ofthreadTools.urlandsecret; a gate that requirescinames a check; a verifier that is another configured agent; a surface or implementation this build compiled in) and resolves the secrets, collecting every error.
- Syntax.
- Any error: the list on stderr, exit 78, as today.
- The schema is committed at
docs/api/config.schema.json, generated byschemarsfrom the types. A test oforch-configcompares the generated schema with the committed file and fails on any difference;UPDATE_SCHEMA=1rewrites it, asUPDATE_GOLDEN=1does for the goldens. CI runs it with the other Rust tests. S9 writes the file; this PR does not.
4. Migration: the environment over the file for one release ​
sequenceDiagram
participant Op as Operator (Deployment, compose)
participant B as orchestrator binary (main.rs)
participant L as loader (binary: file, env, secret files)
participant C as orch-config (pure)
participant H as boot.rs (composition)
Op->>B: start, with ORCH_CONFIG_FILE and maybe old variables
B->>L: args and the process environment
L->>L: read the file (unset in the transition release: environment only, as today)
L->>C: parse, apply merge keys, refuse tags
C-->>L: value tree, or the syntax error (exit 78)
L->>L: overlay each old variable that is set onto its key, and note it
L->>C: check the tree against the generated schema (every shape error)
L->>C: deserialize, then validate() with the resolver of env and file references
C-->>L: Config, or every error at once
alt any error
L-->>B: the list of errors
B-->>Op: stderr, exit 78
else valid
B->>B: start logging (log.format, RUST_LOG)
B-->>Op: warn once per old variable that overrode the file, naming the variable and the key
B->>H: compose the compiled-in implementations from Config
endstateDiagram-v2
[*] --> EnvOnly: today
EnvOnly --> Transition: S9 ships (a release)
Transition --> FileOnly: the next release
state Transition {
[*] --> NoFile: ORCH_CONFIG_FILE unset
[*] --> WithFile: ORCH_CONFIG_FILE set
NoFile: the environment alone, one warning that variables are deprecated
WithFile: the file, each old variable that is set wins and warns
}
FileOnly: ORCH_CONFIG_FILE required, old variables ignored and reported- Transition release (S9). Every variable of today still works. Precedence: a flag or its variable (a flag wins over its variable, as today) > the file > the default. Each old variable that is set and has a key overrides the file, and startup logs one
warnper override naming the variable and the key (ORCH_TITLE_MODEL overrides tasks.title.model; set it in the file), never the value. The overlay converts a variable with today's parser for it (ORCH_STEPS_RECORD_IO=yesistrue,ORCH_SURFACESa comma list) before the shape pass, and a value that does not parse is an error naming the variable, as today. The process overrides (ORCH_ROLE,ORCH_INSTANCE_ID) log atinfo, notwarn: they are not deprecated. A secret variable of today counts as a reference to itself (ORCH_MODEL_API_KEYset meansmodels.endpoints.default.apiKey: { env: ORCH_MODEL_API_KEY }); the webhook variables keep their comma rule.ORCH_TITLE_MODELmaps totasks.title.modelwithtasks.title.endpoint: default, andORCH_MODEL_*to the endpoint nameddefault(S9 takes one endpoint: a file that names another one whileORCH_MODEL_*is set is an error naming both). WithoutORCH_CONFIG_FILEthe process runs from the environment alone, exactly as today, with one warning. --print-configprints the merged configuration as YAML (file, overrides and defaults), secrets as their references, and exits 0, or lists the errors and exits 78. It opens no connection. CI and operators use it to check a file before a rollout.- Next release.
ORCH_CONFIG_FILEis required, and the old variables and their per-setting flags are removed: a removed variable that is still set is listed in onewarn, and ignored. What stays for good:ORCH_CONFIG_FILEand--config,--print-config;- the process overrides
ORCH_ROLE/--roleandORCH_INSTANCE_ID/--instance-id, which win overserver.roleandserver.instanceIdand log atinfo: they describe one process, and a control plane and its workers share one file; RUST_LOG(the log filter, read before anything else) andHOSTNAME(set by the runtime; the default instance id's prefix);- the secrets' own variables, now named only by
{ env }references.
5. Configuration is not a port ​
- ADR 0009: ports are the infrastructure boundaries the running application calls (store, agents, model, clock); binaries are compositions. Configuration is the composition root's input: it is read once, before any port exists, and decides which compiled-in implementation each port gets. It is not a port and gets no trait or testkit.
orch-configis a library of types and rules; the binary reads the file. A developer with their own composition root (ADR 0009) may useorch-configor not. - A key that selects an implementation (
server.surfaces, and laterartifacts.store,auth.mode) chooses only among what the build compiled in, a closed enum per key. A value this build did not compile in is exit 78 naming the Cargo feature, asORCH_SURFACESandAGENT_REGISTRY_URLbehave today. There are no runtime plugins: no library path, no command, no URL that loads code. - No implementation type appears in
orch-config's public types: an S3 bucket is strings and aSecretRef, not anobject_storebuilder.
6. The public subset: GET /api/config ​
- The
uisection is the only part of the file the web can see, served asGET /api/config→200 {"ui": {…}}, everyuikey with its effective value (docs/api/config.md). Theuitype has no secret field, and a test asserts that its generated schema has noSecretRef. - It is behind the same identity layer as every
/api/*route (401 without an identity), not public. Reasons: the web asks for it only after the edge has let the browser in (oauth2-proxy guards the web and the API alike), so nothing in it is needed before sign-in; one rule for all of/api/*means no carve-out in the edge's routes or in the authenticator of ADR 0033 (a carve-out is where fail-closed rules leak); and a later setting may depend on who asks (a role's features) without a contract change. The cost, that a signed-out page cannot read it, is none: a signed-out browser never gets the page. - It is built with the first
uikey,ui.showDescriptions, in S18 (served) and S19 (read by the web, built). S9 does not serve it: an empty section would be a contract without a use.
7. The local stack ​
dev/orchestrator.yamlconfigures the offline stack (compose.yaml): the mocks, the surfaces, the title task onmock-model. Every secret in it is{ env: … }; compose keeps setting those variables to their dummy values, next to the file, so a reader sees which values are secrets.x-orchestrator-envshrinks to the secrets, thetokenEnvvariables andORCH_CONFIG_FILE, and the services mount the file read-only at/etc/orchestrator/config.yamlbesideagents.yamlandmcp-tokens.yaml.dev/orchestrator.live.yamlis the filecompose.live.yamlmounts instead (the same path,!overrideon the volumes, as it already does foragents.live.yaml): a whole file, not a patch, because there is no layering. Its secrets are{ env: … }references to the variables.envsets today (CODER_A2A_TOKEN,MODEL_API_KEY, …).- The
splitprofile mounts the samedev/orchestrator.yamland sets the process overridesORCH_ROLEandORCH_INSTANCE_ID. Its short lease (OUTBOX_LEASE_SECS: "5") stays an old variable in the transition release, with its warning; how a profile that differs in one deployment key keeps it after the deprecation is open question 44. - The
local-agentprofile stays on environment variables in the transition release: it keeps the old path covered by a stack that runs. dev/README.mddocuments the files; CI runsorchestrator --print-configon both dev files.
Consequences ​
- An operator sees, in one file and one schema, every setting and which ones are secrets; an editor can validate it. A typo is an error, never an ignored key.
- Lists and maps (endpoints, tasks, roles, stores) have a natural shape; the comma syntaxes go with the deprecation.
- Secrets never enter the file, so it can live in a ConfigMap or the repository. The variables or mounted files that hold the secrets are named in it.
- S9 is large: a crate, a three-pass loader, an overlay of 51 variables with warnings,
--print-config, the schema and its test, the dev files, compose anddev/README.md. The existing tests ofconfig.rsstay and run against the environment path; new ones cover the file and the overlay. - One release carries two ways to configure the same thing. The warnings,
--print-configand the dev stack's own move to the file are what keep it visible. orch-configaddsschemarsandjsonschemato the binary's dependency tree (both in the workspace already).
Alternatives rejected ​
- Keep variables and add structured ones as JSON strings (
ORCH_TASKS='{"title": …}'): a second language inside the first, with no schema and no line numbers. - TOML. A fine format, but the system's other files (the agents file, the MCP tokens file, compose, the platform's CRDs) are YAML; one format for operators.
- Layered files (
ORCH_CONFIG_FILE=base.yaml:worker.yaml, deep merge) or a generic--set key=value: they solve the split profile's one-key difference, but every error must then say which layer it came from, and lists merge ambiguously. Not inversion: 1; open question 44. - Hot reload (a file watch or
SIGHUP): half the settings (the listen address, the pool, the surfaces) cannot change in a running process, and a restart is cheap. Open question 43. - Plain-string secrets allowed with a warning: a warning is read after the secret is in git.
GET /api/configwithout authentication: see decision 6.- Configuration as a port (a
ConfigSourcetrait for files, Consul, …): it is input to the composition root, not a boundary the application calls; a deployment that keeps settings elsewhere renders the file (a ConfigMap, a template) before start.
Facts this rests on ​
- Verified 2026-10-02, crates.io API:
serde_yamlis0.9.34+deprecated(2024-03-25, archived upstream);serde_yml0.0.13 (2026-05-27) describes itself as "DEPRECATED … unmaintained … a thin compatibility shim";serde_norway0.9.42 is the newest, of 2024-12-21. - Verified 2026-10-02, RUSTSEC-2025-0068 (2025-09-12): "serde_yml crate is unsound and unmaintained"; it recommends
serde_norway("Maintained fork ofserde_yaml, usingunsafe-libyaml-norway") andserde_yaml_ng(whoseunsafe-libyamlis unmaintained). Choice:serde_norway, the workspace's parser already. Its last release is from 2024-12: if it stops being maintained, the parser is one crate behindorch-configand can be replaced there. - Verified 2026-10-02 by reading
serde_norway0.9.42'ssrc/de.rs: booleans are onlytrue/false(any case of those two), and digits with a leading zero are a string "according to the YAML 1.2 spec"; sonoandonare strings, not booleans (the "Norway problem" does not apply). The parser underneath is a translation of libyaml, which reads YAML 1.1 syntax (unverified beyond its name and the crate's README); the scalars are resolved the YAML 1.2 way above.Value::apply_mergeexists (src/value/mod.rs). - Verified 2026-10-02, schemars attributes (version 1 docs) and
schemars_derive1.2.2's source:#[serde(deny_unknown_fields)]setsadditionalProperties: false. - Verified 2026-10-02 in
jsonschema0.58.3's source:Validator::iter_errorsreturns every error, not the first. - Unverified: that serde rejects
flattentogether withdeny_unknown_fieldsin every case (serde's documentation says they are not supported together); the decision avoidsflatteneither way.