One config struct per prefix — restore deny_unknown_fields, retire the per-service jurisdiction env keys (#1773)

Status: Done (2026-09-10) — !1373
Epic: &82
Issues: #1773 (closure) · #1811 U-CFG-A (w5) · #1812 U-CFG-B1 (w3) · #1813 U-CFG-B2 (w5) · #1814 U-CFG-C (w5) · #1815 U-CFG-D (w3) — stream weight 21
Branches: chore/1773-config-one-struct-plan (frame) → one MR per unit in the order A → B1 → B2 → C → D

This is a Design + Scope plan: GitLab owns tracking, the child issues carry the implementer brief, and the plan freezes when U-CFG-A starts.

Context

Every canopy_api::bootstrap service deserializes two structs from one env prefix: bootstrap loads ServiceSettings through ServiceSettings::load_with_secrets(prefix, ..) (crates/canopy-api/src/bootstrap.rs), and sixteen main.rs files then call load_typed("CANOPY_<SVC>", None) for their <Svc>Config. The loader’s env source Environment::with_prefix(prefix).separator("") (crates/canopy-common/src/settings.rs, load_typed_internal) feeds every CANOPY_<SVC>* variable to both, so each struct sees the other’s keys as unknown and #[serde(deny_unknown_fields)] on either would fail boot. Result: no service config struct carries it (the only matches in services/*/src/config.rs are comments), and a misspelled key in YAML or env falls back to its default silently — the failure ADR-012 §1 was written to kill.

Facts verified on main, 2026-09-09:

  • Keys read outside any struct, on purpose — three categories:

    • secrets, through the audited provider or the key loaders: SIGNING_KEY in caps, medicaid, snap, tanf, wic, notices; APPLICANT_VERIFYING_KEY in applications, eligibility, enrollment, notices, persons, security, verification;

    • accountable-override flags, through the strict recognizer (crates/canopy-common/src/env.rs override_flag_is_true; the #1610 doctrine, security-operations.adoc §Startup-Guard Inventory: "never a config-file key"): applications ALLOW_INSECURE_SCANNER (guard.rs), notices ALLOW_DEFAULT_TEMPLATE_FALLBACK (main.rs), reporting ALLOW_BROAD_DB_ROLE (guard.rs), snap ALLOW_EXPIRED_PARAM_SET (config.rs), verification ALLOW_FABRICATED_VERIFICATION (guard.rs), web DEADLINE_OVERRIDE (config.rs);

    • ordinary tunables read ad hoc: canopy-web’s fifteen CANOPY_WEB__*_URL (fourteen in the get closure of InternalClients::from_env, clients.rs, and SECURITY_URL in security_base_url) and canopy-portal’s 31 literals (main.rs, captcha.rs, ratelimit.rs; the portal has no config struct and never loads config/canopy-portal/default.yaml, which exists);

    • CANOPY_DB* and CANOPY_STORE* use their own prefixes and are outside this plan.

  • Compose keys no struct declares: 48 — web 15 (*_URL), portal 18 (all of them), security 3 (APPLICANT_VERIFYING_KEY plus FTI_TANF_DATABASE_URL / FTI_MEDICAID_DATABASE_URL, which nothing in services/canopy-security/src reads), notices 2, and one secret each for snap, tanf, caps, wic, medicaid, persons, applications, eligibility, enrollment, verification. (The issue text says 78.)

  • Eleven <Svc>Config structs also declare jurisdiction (appeals, applications, eligibility, enrollment, medicaid, notices, renewals, reporting, snap, verification, web) and their request handlers read it (state.web_config.jurisdiction, 21 sites in web alone). Those fields stay (D2 mirrors the key); ServiceSettings.jurisdiction is the home.

  • Jurisdiction today: 19 CANOPY_<SVC>__JURISDICTION: "${CANOPY_JURISDICTION:-georgia}" compose entries; 8 of 19 config/<svc>/default.yaml lack jurisdiction: (caps, exchange, persons, portal, rules, security, tanf, wic). ServiceSettings is itself loaded through the layered loader, so a YAML jurisdiction already reaches it; only the portal reads the key by hand. The fixture-smoke lane (.gitlab-ci.yml fixture-smoke, matrix CANOPY_JURISDICTION: [test-min, test-max]) relies on compose interpolating that one variable into all 19 keys; cargo xtask e2e --jurisdiction parameterizes the seed only.

  • Why not serde(flatten) (the issue’s AC1 mechanism): serde 1.0.228 does enforce an outer deny_unknown_fields across a flatten field, but flattened fields are buffered through deserialize_any, so the config crate’s coercion is lost for them — port: "8001" in YAML, ACCEPT_OWN_AUDIENCE=1, SKIP_MIGRATIONS=on, OIDC_SERVICE_CLIENT_SECRET=123456 all load today and would stop loading. config 0.15.22 (verified in the registry source) exposes the seams a loader-side split needs instead: impl Source for Config → collect() returns the typed top-level Map<String, Value>, Config.cache is public, and its env collector already iterates env::vars_os().

  • The roadmap follow-up text is gone (replaced by the Open Work rewrite), so the issue’s "replace roadmap.adoc:1318-1319" criterion has nothing to act on. #1775 (stale comments) is closed and already cites #1773.

Rulings in force: accountable-override flags are never serde fields (#1610/#1766); secrets never appear in a config struct or checked-in YAML (ADR-012 L76) and stay on the CANOPY_{SERVICE}__* runtime contract (ADR-017 "runtime contract unchanged"); CANOPY_ENV is two axes on purpose (overlay file name vs the development permissiveness recognizer, #1264) — a CANOPY_ENV overlay is not an acceptable fixture knob; pre-1.0, so the old two-load API is deleted, not wrapped.

Design

D1 — one load, partitioned by the baseline’s declared fields. canopy_common::settings gains

pub struct LoadOptions<'a> {
    pub config_root: Option<&'a Path>,
    /// Exact upper-snake KEY names after `CANOPY_<PREFIX>__` filtered out of the env before anything
    /// sees them: read elsewhere on purpose (secrets via the audited provider / key loaders,
    /// accountable overrides via the strict recognizer). Names, never patterns.
    pub reserved_keys: &'a [&'a str],
    /// Baseline keys the service struct ALSO declares (today `jurisdiction`, eleven services); copied into both halves.
    pub mirrored_keys: &'a [&'a str],
}
pub const JURISDICTION_ENV: &str = "CANOPY_JURISDICTION";
impl ServiceSettings { pub const FIELDS: &'static [&'static str] = &[/* the 26 field names */]; }
pub fn load_service_config<C: DeserializeOwned>(prefix: &str, opts: &LoadOptions<'_>) -> Result<(ServiceSettings, C), ConfigError>;
pub fn load_single<T: DeserializeOwned>(prefix: &str, opts: &LoadOptions<'_>) -> Result<T, ConfigError>;   // no baseline (the portal)
#[doc(hidden)]
pub fn load_internal(prefix: &str, opts: &LoadOptions<'_>, env_name: &str, env: Option<Vec<(OsString, OsString)>>) -> Result<Map<String, Value>, ConfigError>; // the shared collector; tests inject `env`
pub(crate) fn prefixed_env(prefix: &str, reserved: &[&str], env: impl IntoIterator<Item = (OsString, OsString)>) -> Result<Map<String, String>, ConfigError>;

Collector sources, lowest precedence first: config/<svc>/default.yaml → config/<svc>/<CANOPY_ENV>.yaml → the whole-stack jurisdiction override (a one-entry Environment::default().source(Some({"jurisdiction": v})) from CANOPY_JURISDICTION when set and non-empty) → the prefixed env. prefixed_env keeps only entries whose key is valid UTF-8 and starts with <PREFIX>__, drops exact reserved names, and only then converts values: a non-UTF-8 value under the prefix is a ConfigError::Message naming the key, never a panic; unrelated non-UTF-8 entries are ignored. build()?.collect()? yields one typed top-level map. Partition: keys in ServiceSettings::FIELDS go to the base half (mirrored keys are copied to the service half as well); everything else goes to the service half. Each half becomes Config { cache: Value::Table(half), ..Default::default() } and is try_deserialized with the config crate’s own deserializer — coercion identical to today — into ServiceSettings and C, both #[serde(deny_unknown_fields)] for real. A typo in a baseline key (db_max_connectons) is not in FIELDS, lands in the service half and fails with unknown field db_max_connectons ; a service typo fails the same way; a reserved key that someone later turns into a field is caught by the per-service test in U-CFG-B1. The DEBUG "config loaded" dump of raw values is replaced by a key-names-only line (it printed database_url today, and a reserved key present in YAML would have been dumped too) — CHANGELOG Changed. load_typed(prefix, root) is deleted with its last main.rs caller (U-CFG-B2).

D2 — per-service structs: unchanged shape, real gate. Every <Svc>Config keeps its fields and gains [serde(deny_unknown_fields)], pub const RESERVED_KEYS: &[&str] and pub const MIRRORED_KEYS: &[&str] (&["jurisdiction"] for the eleven that declare it, &[] otherwise). No field is removed, so every handler, struct literal, Arc<WebConfig> and test fixture stays as is. canopy-persons and canopy-exchange get a config.rs holding an empty [serde(deny_unknown_fields)] pub struct PersonsConfig {} — persons RESERVED_KEYS = &["APPLICANT_VERIFYING_KEY"] (compose supplies it), exchange &[]. ServiceSettings keeps its fields and its redacting Debug; it gains [cfg_attr(test, derive(serde::Serialize))] and FIELDS, pinned by a test that serializes a fully-populated instance and asserts the key set equals FIELDS; it gains [serde(deny_unknown_fields)] in U-CFG-B2 (real under the partition).

D3 — bootstrap takes the loaded baseline. ServiceSettings::load, load_with_secrets and SettingsLoadError are deleted; canopy_api gains

/// `dotenvy::dotenv().ok()` (the ordering `bootstrap` had), then `load_service_config`.
pub fn load_config<C: DeserializeOwned>(prefix: &str, reserved_keys: &[&str], mirrored_keys: &[&str]) -> anyhow::Result<(ServiceSettings, C)>;
/// `resolve_secrets`, then everything `bootstrap` did after loading (telemetry, ADR-001 name guards, the
/// migration phase, pools, auth, MQ). Returns the provider-resolved settings — today's return shape.
pub async fn bootstrap_with(prefix: &str, settings: ServiceSettings, service_name: &str, migrator: sqlx::migrate::Migrator) -> anyhow::Result<(ServiceSettings, BootstrapResult)>;
/// The ADR-017 re-read of the five secret fields keyed `{prefix}__DATABASE_URL`, `__MIGRATION_DATABASE_URL`,
/// `__RABBITMQ_URL`, `__OIDC_SERVICE_CLIENT_SECRET`, `__OIDC_EXCHANGER_CLIENT_SECRET` (the optional three only when
/// `is_set(key)`), so `target = "canopy.secrets"` audit events still fire. Testable without process env.
pub(crate) fn resolve_secrets(prefix: &str, settings: &mut ServiceSettings, provider: &dyn SecretProvider, is_set: &dyn Fn(&str) -> bool) -> Result<(), SecretError>;

Each main.rs replaces its two loads with let (settings, svc_config): (ServiceSettings, TanfConfig) = canopy_api::load_config("CANOPY_TANF", config::RESERVED_KEYS, config::MIRRORED_KEYS)?; and let (settings, boot) = canopy_api::bootstrap_with("CANOPY_TANF", settings, "canopy-tanf", sqlx::migrate!("./migrations")).await?; — the variable names and every downstream read are unchanged. During A and B1, bootstrap(prefix, ..) survives as dotenvy + load_single::<ServiceSettings>(prefix, ..) over the full key set (ServiceSettings has no gate until B2, so unconverted services boot exactly as today) + bootstrap_with; it is deleted in B2 with its last caller.

D4 — the ad-hoc tunables become fields; secrets and overrides stay reserved. canopy-web’s fifteen *_URL become WebConfig fields with today’s defaults (#[serde(default = "…")]); InternalClients::from_env(panel_cache) becomes from_config(&WebConfig, panel_cache) and security_base_url() reads the field; DEADLINE_OVERRIDE is reserved. Reserved lists per service:

  • snap SIGNING_KEY, ALLOW_EXPIRED_PARAM_SET · tanf, caps, wic, medicaid SIGNING_KEY · notices SIGNING_KEY, APPLICANT_VERIFYING_KEY, ALLOW_DEFAULT_TEMPLATE_FALLBACK

  • applications APPLICANT_VERIFYING_KEY, ALLOW_INSECURE_SCANNER · eligibility, enrollment, persons, security APPLICANT_VERIFYING_KEY · verification APPLICANT_VERIFYING_KEY, ALLOW_FABRICATED_VERIFICATION

  • reporting ALLOW_BROAD_DB_ROLE · web DEADLINE_OVERRIDE · rules, exchange, appeals, renewals none.

The two dead security compose keys (FTI_*_DATABASE_URL) are deleted from docker-compose.yml (CHANGELOG Removed). services/canopy-snap/src/config.rs module doc and the ALLOW_EXPIRED_PARAM_SET_VAR doc lose the deferral text and the "a leftover YAML key is ignored" promise — with the gate on, a leftover allow_expired_param_set: YAML key fails boot naming the key, the intended outcome; no test pins the old ignore.

D5 — PortalConfig. canopy-portal is not a bootstrap service and has no baseline; it gains services/canopy-portal/src/config.rs (server feature) with #[serde(deny_unknown_fields)] pub struct PortalConfig, loaded once in main via load_single("CANOPY_PORTAL", &LoadOptions { reserved_keys: RESERVED_KEYS, .. }), typed to preserve today’s parsing:

  • exact-literal booleans stay String with today’s defaults and today’s comparisons kept in the readers — cookie_secure (!= "false", default "true"), require_deps (== "true", "false"), ratelimit_enabled (!= "false", "true"), ratelimit_trust_forwarded_for (== "true", "false") — so TRUE, 1, on keep meaning exactly what they mean today;

  • ratelimit_cgnat_subnets: String (default ""; the existing trim / split / warn-and-skip parser moves into RateLimitConfig::from_config);

  • port: u16 (8090), the six ratelimit_* counts (u32), oidc_service_token_revalidate_max_age_secs: u64 (60): the config crate accepts today’s numeric strings; an unparseable value now fails boot naming the key instead of silently defaulting — intentional, tested, CHANGELOG Changed;

  • captcha_provider: String ("", i.e. from_name("") as today), locales_dir ("locales"), rulesets_dir ("rulesets"), jurisdiction ("georgia"), oidc_service_client_id ("canopy-portal");

  • Option<String> for the dependent URLs, resolved after load by PortalConfig::resolve(&self, port_of: &dyn Fn(&str, u16) → u16) with today’s chains: oidc_internal_url → oidc_issuer → http://localhost:{CANOPY_PORT_KEYCLOAK_8080 | 8180}/realms/canopy; each of the eight url (applications, eligibility, enrollment, notices, persons, security, snap, verification) → http://localhost:{CANOPY_PORT_CANOPY<SVC>_<port> | <port>}; redis_sessions_url → redis://localhost:{CANOPY_PORT_REDIS_SESSIONS_6379 | 6380}. port_or survives for the CANOPY_PORT_ reads (not prefixed keys); env_or, u32_or, RateLimitConfig::from_env and CaptchaProvider::from_env go.

  • Reserved: APPLICANT_SIGNING_KEY, OIDC_SERVICE_CLIENT_SECRET, ALLOW_CONFIDENTIAL_ADDRESS_LETTER_STREAMING (two secrets read where they are today, one override through the strict recognizer).

  • config/canopy-portal/default.yaml is rewritten to the code defaults (locales_dir: locales, rulesets_dir: rulesets, jurisdiction: georgia — today’s services/canopy-portal/locales value is repo-root-relative and would break the WORKDIR /app image); the Dockerfile copies config/canopy-portal/ to the same-named directory under the image’s config root (an explicit destination — copying into the root itself would flatten the directory and the optional YAML would be silently skipped); the compose portal service sets CANOPY_CONFIG_ROOT to the image’s config root (the directory the Dockerfile copies into); xtask/src/devstack_guard.rs gains a CONFIG_DIRS marker input holding config/canopy-portal, consumed by both check_staleness and write_markers (hashed into dockerfile.sha256), so a YAML edit invalidates the baked image like any other input. CANOPY_ENV stays unset for the portal.

D6 — jurisdiction home + one whole-stack override. jurisdiction: georgia is added to the 8 default.yaml that lack it; the 19 CANOPY_<SVC>JURISDICTION compose entries are deleted; a compose anchor x-canopy-shared-env: &canopy-shared-env { CANOPY_JURISDICTION: "${CANOPY_JURISDICTION:-}" } is merged (<<: *canopy-shared-env) into every service’s environment map, so the existing CANOPY_JURISDICTION export (CI matrix, roadmap.adoc compose recipe, onboarding docs) keeps switching the whole stack — through the loader (D1), no longer through 19 interpolated keys. Precedence, documented once in configuration-reference.adoc: YAML → CANOPY_JURISDICTION → CANOPY_<SVC>JURISDICTION. Nothing in .gitlab-ci.yml or cargo xtask e2e changes. This keeps the knob name the issue’s AC4 calls "the compose-level CANOPY_JURISDICTION": the docs stop presenting compose interpolation as the mechanism and present the YAML as the home with the one override — that reading of AC4/AC5 is the plan’s deliberate choice.

Out of scope: #518 (CANOPY_WEBOIDC_* retirement — sequenced after, edits WebConfig once more); #1300’s AC wording (a GitLab note: "selected by the resolved jurisdiction"); Vault-backed secrets; any change to the accountable-override recognizer, the migration arms, CANOPY_TEST*, or CANOPY_ENV semantics.

Units (weights by complexity) — sequenced FRAME → A → B1 → B2 → C → D

Child-issue titles below are the long form; each MR’s commit subject is the ≤72-byte shortening.

U-CFG-FRAME (w1) — docs(plan): add the one-config-struct-per-prefix plan (#1773)

Branch chore/1773-config-one-struct-plan. This page; nav line under ** Code Quality & Infrastructure after the code-quality-gating.adoc entry; CHANGELOG.adoc == Unreleased / === Added one line. GitLab: an epic in group 127623789 titled epic: one config struct per prefix — deny_unknown_fields + jurisdiction home (#1773) (Summary / clickable plan link / task list - [ ] #N title (weight: W)); five child issues carrying their unit section verbatim — refactor(common): partitioned loader + reserved keys + bootstrap_with (U-CFG-A) w5 service::shared-crates; refactor(services): deny_unknown_fields on 14 service configs (U-CFG-B1) w3; refactor(services): gate applications, notices, security, web; delete bootstrap (U-CFG-B2) w5; refactor(portal): PortalConfig under the same gate (U-CFG-C) w5 service::portal; chore(config): jurisdiction in every default.yaml, retire the 19 compose keys, docs (U-CFG-D) w3 service::devstack — labels type::refactor/type::chore as titled, priority::low, program::infrastructure, planning::has-plan, workflow::ready, milestone T3 — Upkeep, epic_id the new epic; /relate each to #1773 and to its predecessor. #1773 → planning::has-plan, weight 21, epic_id, plus one comment recording the measured figures (48 undeclared compose keys, 11 mirrored jurisdiction fields), the moot roadmap criterion, the AC1-mechanism deviation (partition, not flatten) and the D6 reading of AC4/AC5. Gates: asciidoctor --failure-level WARN, cargo xtask plan-lint. MR Relates to #1773.

U-CFG-A (w5) — partitioned loader + reserved keys + bootstrap split

Files: crates/canopy-common/src/settings.rs; crates/canopy-api/src/bootstrap.rs (+ lib.rs re-exports); the two other load_typed_internal callers, moved to the new signatures — xtask/src/cmd/processing_days_lint.rs (load_internal / load_single) and the snap test in services/canopy-snap/src/config.rs; docs that name the deleted API — docs/modules/ROOT/pages/shared-crates.adoc, nist-architecture-mapping.adoc, docs/modules/ROOT/pages/runbooks/secret-management.adoc (the audit seam is now bootstrap_with / resolve_secrets), configuration-reference.adoc (precedence paragraph, CANOPY_JURISDICTION row, the key-names-only debug line), coding-conventions.adoc (the config-loading pattern); CHANGELOG.adoc. Ships D1 and D3 with bootstrap(prefix, ..) still present as described in D3. Tests in settings.rs, beside a test struct Own { own: u16, #[serde(default)] flag: bool } with deny_unknown_fields: fields_const_matches_the_struct; misspelled_shared_key_is_rejected_naming_it (db_max_connectons); misspelled_service_key_is_rejected_naming_it; todays_coercions_still_load (YAML port: "8001", env ACCEPT_OWN_AUDIENCE=1, SKIP_MIGRATIONS=on, OIDC_SERVICE_CLIENT_SECRET=123456 → the same typed values as on main); reserved_key_never_reaches_serde (a reserved SIGNING_KEY loads clean; unreserved fails naming signing_key); mirrored_key_lands_in_both_halves; canopy_jurisdiction_precedence (global beats YAML; CANOPY_<P>__JURISDICTION beats global; empty global ignored); non_utf8_unrelated_env_entry_is_ignored; non_utf8_value_under_the_prefix_is_an_error. Property tests (proptest, already a canopy-common dev-dependency): prefixed_env_keeps_exactly_the_unreserved_prefixed_keys over arbitrary byte-string environments (never panics; exact-name removal only — SIGNING_KEY never removes SIGNING_KEY_ID); loader_preserves_config_rs_coercion — arbitrary baseline values rendered in any spelling the config crate accepts today (bools as true/1/on/yes, numbers quoted or bare, in YAML or env) load to the same typed struct; unknown_key_anywhere_is_rejected_naming_it — an arbitrary identifier outside both field sets, in YAML or env, fails and the error names it. In bootstrap.rs: resolve_secrets against a recording SecretProvider — all five keys requested with the given prefix, values overwritten, the optional three requested only when is_set, a provider error surfaces; the former never-set test becomes two (load_config surfaces the config error; bootstrap_with surfaces a missing secret). cargo xtask validate green; every service still boots (the battery’s devstack step). MR Relates to #1773, Closes the child.

U-CFG-B1 (w3) — deny_unknown_fields on 14 service configs

rules, persons, exchange, eligibility, verification, enrollment, renewals, appeals, reporting, snap, tanf, medicaid, caps, wic. Per service: the D2 attribute and consts (persons/exchange new files), the two main.rs lines of D3, deferral module docs removed (snap config.rs module doc + ALLOW_EXPIRED_PARAM_SET_VAR doc; tanf/caps/wic module docs; any other that mentions the missing gate). Two tests per config.rs, modelled on the existing snap precedent (services/canopy-snap/src/config.rs, the CARGO_MANIFEST_DIR → repo root → config/ derivation; its env map gains the baseline keys): default_yaml_loads_under_deny_unknown_fields (the checked-in config/<svc>/default.yaml plus a baseline env map loads both halves — the pin that every checked-in YAML key is a field) and reserved_keys_are_not_fields (for each RESERVED_KEYS entry, the same fixture plus CANOPY_<SVC>__<KEY>=x with reserved_keys: &[] fails with unknown field <key_lowercase> , and with RESERVED_KEYS loads clean). cargo xtask dev reload (full profile) boots all 14 with today’s compose keys, recorded on the MR. MR Relates to #1773, Closes the child.

U-CFG-B2 (w5) — gate applications, notices, security, web; delete bootstrap

Same per-service steps; canopy-web’s fifteen URL fields, InternalClients::from_config and security_base_url (D4); security’s two dead FTI compose keys removed; bootstrap(prefix, ..) and load_typed(prefix, config_root) deleted with their last callers; #[serde(deny_unknown_fields)] added to ServiceSettings; the settings.rs NOTE (which describes the two-load shape) rewritten to the as-built single-load statement. Devstack boot recorded on the MR. MR Relates to #1773, Closes the child.

U-CFG-C (w5) — PortalConfig

Files: services/canopy-portal/src/config.rs (new), main.rs, captcha.rs, ratelimit.rs, jurisdiction.rs (module doc), services/canopy-portal/Dockerfile, config/canopy-portal/default.yaml, docker-compose.yml (portal CANOPY_CONFIG_ROOT), xtask/src/devstack_guard.rs (CONFIG_DIRS), docs/modules/ROOT/pages/configuration-reference.adoc (portal rows), local-dev.adoc (baked, guard-tracked portal config), CHANGELOG.adoc (Changed: unparseable numeric portal keys fail boot). Per D5. Tests: the two B1 tests for PortalConfig; resolve_prefers_configured_then_mapped_port_then_default for the URL / OIDC / Redis chains (three cases each through an injected port_of); exact_literal_booleans_keep_todays_semantics (TRUE and 1 do not enable trust_forwarded_for; FALSE does not disable cookie_secure); portal e2e specs green (the battery). MR Relates to #1773, Closes the child.

U-CFG-D (w3) — jurisdiction home, compose retirement, docs

Files: the 8 config/<svc>/default.yaml, docker-compose.yml (anchor + 19 deletions + 19 merges), crates/canopy-common/src/settings.rs (the jurisdiction field doc: YAML home, two overrides), docs/modules/ROOT/pages/{deployment-guide,rulesets,coding-conventions,configuration-reference,jurisdiction-onboarding}.adoc, services/canopy-web/src/studio/bundle.rs (the README template, the single-tenant sentence and their test), the stale CANOPY_*JURISDICTION comments at crates/canopy-composition/src/jurisdiction.rs, config/canopy-verification/default.yaml, services/canopy-portal/Dockerfile, services/canopy-web/src/api/composition.rs (comment only — the handler code stays, the mirrored field remains) and xtask/src/cmd/e2e.rs (the flag’s doc comment only), CHANGELOG.adoc (Changed: ops contract). Per D6. Checks: grep -n 'JURISDICTION' docker-compose.yml empty; cargo xtask rules processing-days resolves every tier; cargo xtask dev reload boots on the default and, with CANOPY_JURISDICTION=test-max exported, on the fixture (the fixture-smoke lane is schedule-gated, so the MR records one manual schedule run on main after merge as the closing evidence). Closes #1773 with the merge SHA and the measured before/after key counts.

Files touched / must not change

Area Files

canopy-common

crates/canopy-common/src/settings.rs (collector, partition, LoadOptions, JURISDICTION_ENV, FIELDS, ServiceSettings gate + docs)

canopy-api

crates/canopy-api/src/bootstrap.rs (load_config, bootstrap_with, resolve_secrets; bootstrap deleted in B2), crates/canopy-api/src/lib.rs

services

every services/*/src/config.rs (attribute + consts; persons/exchange/portal new), every main.rs boot block, services/canopy-web/src/clients.rs, portal captcha.rs / ratelimit.rs / Dockerfile, services/canopy-web/src/studio/bundle.rs

xtask

xtask/src/cmd/processing_days_lint.rs (loader signature only), xtask/src/devstack_guard.rs (CONFIG_DIRS)

config / compose

8 config/<svc>/default.yaml + config/canopy-portal/default.yaml; docker-compose.yml

docs

the Antora pages named per unit, the plan page, nav.adoc, CHANGELOG.adoc

must not change

crates/canopy-common/src/env.rs (the recognizer and its doctrine); every guard.rs / override read site (only their keys become reserved); canopy_secrets; the migration arms; .gitlab-ci.yml; the --jurisdiction flag code in xtask/src/cmd/e2e.rs; CANOPY_TEST__* (canopy-test-lib); CANOPY_ENV handling; secrets/dev.yaml key names; every existing <Svc>Config field set (only web gains fields)

Erratum (2026-09-10): U-CFG-C also adds config/canopy-portal/*/ to the .artifact-inputs anchor in .gitlab-ci.yml — the ADR-040 CI-config lint requires every Dockerfile COPY source to be an image-build trigger, so baking the portal’s config dir (D5) entails it; the "must not change .gitlab-ci.yml" row meant the fixture-smoke lane and its CANOPY_JURISDICTION matrix, which stay untouched. U-CFG-D corrected two comments only — the lane’s header comment (it said compose interpolates the variable) and the --jurisdiction flag’s doc comment in xtask/src/cmd/e2e.rs — and added jurisdiction: to seven default.yaml, not eight: the portal’s landed with U-CFG-C.

Verification

Property Layer

FIELDS matches the struct; a typo in either half is rejected naming the key; today’s coercions still load

unit tests in settings.rs (U-CFG-A)

The reserved filter is exact-name only and never panics; the loader preserves config-crate coercion; any unknown key is rejected naming it

three proptests in settings.rs (U-CFG-A)

CANOPY_JURISDICTION precedence; mirrored keys in both halves; non-UTF-8 handling

unit tests in settings.rs

ADR-017 re-read: five keys, right prefix, optional-when-set, provider error surfaces

resolve_secrets recording-provider test (U-CFG-A)

Every checked-in config/<svc>/default.yaml deserializes under the gate; no reserved key names a field

two tests in each of 19 config.rs (B1 / B2 / C)

Portal fallback chains and exact-literal booleans unchanged

portal unit tests (U-CFG-C)

All 19 services boot with today’s compose keys after each sweep

cargo xtask dev reload (full profile) on the MR; the pre-push battery’s devstack step

A portal YAML edit invalidates the baked image

devstack_guard marker inputs (U-CFG-C)

Fixture jurisdiction still switches the whole stack

CANOPY_JURISDICTION=test-max cargo xtask dev reload on the U-CFG-D MR; one manual fixture-smoke schedule run after merge

No per-service jurisdiction key remains; every tier resolves statically

grep -n '__JURISDICTION' docker-compose.yml empty; cargo xtask rules processing-days

Per commit

cargo fmt --all, cargo clippy --all-targets — -D warnings, unit lanes, the flagless cargo xtask quality-budgets, rustdoc -D warnings on canopy-common / canopy-api; the pre-push battery

GitLab

  • Epic created by FRAME; #1773 planning::needs-plan → planning::has-plan, weight 21, epic_id, the FRAME comment (measured figures, moot roadmap criterion, the AC1-mechanism deviation, the D6 reading of AC4/AC5); closed by the U-CFG-D MR.

  • Children A, B1, B2, C, D each carry their unit section verbatim; /relate to #1773 and in sequence.

  • Notes carried as GitLab material, not plan changes: #1300 AC line 11 wording; #518 sequenced after B2.

Review log

round vendor resolved model verdict

1

Anthropic

claude-opus (fresh Plan subagent)

no-ship — 2 rule blockers (SHAs in the body; no proptest on a deserializer) + 4 implementability blockers (the reserved-key/field overlap check had no mechanism; bootstrap_with lacked the prefix its audit re-read keys on; two load_typed_internal callers missing from U-CFG-A; the portal’s repo-relative locales_dir would break the image) + load_typed flagged as pre-1.0 scaffolding — all fixed in-plan the same day

2

OpenAI (run by the maintainer; read-only review against the repo and the installed serde / config crates)

gpt-6-astra

no-ship — 3 P1 (the partial move of cfg.base broke whole-config consumers; removing jurisdiction reached request handlers and fixtures; persons' reserved keys contradicted D4) + 9 P2 (flatten drops the config crate’s coercion; std::env::vars() panics on non-Unicode; Docker COPY destination; portal URL fallback chains and exact-literal boolean semantics; baked portal config outside the devstack-guard inputs; no real secret-audit assertion; the reserved-key logging claim exceeded the design; the proptest did not exercise the deserializer) + 2 corrections (cargo xtask rules processing-days; eight portal URLs) — all fixed in-plan the same day: serde(flatten) replaced by the loader-side partition (D1–D3), D5 rewritten, D6 corrected

Edit this page · default