Skip to content

app/: one typed config read from VISUALCI_ variables, with generated docs and warnings for unknown ones (sc-9026) - #140

Merged
ndbroadbent merged 1 commit into
mainfrom
app-visualci-env-config
Dec 3, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
app-visualci-env-config

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Shortcut: sc-9026.

Merge only after talira-ai/infra adds the new names (step 1 below). With the old names alone, production stops at boot: S3, the renderer token, GitHub, Stripe and Postmark would all be missing.

What changes

  • One typed config for app/ (app/src/config.rs). Config holds every setting app/ reads, in groups: storage, renderers, hosts, network and database, sign-ups, development sign-in, GitHub App, GitLab, email, team, payments, Cloudflare, gallery and heartbeats. Each group is still its own config section (Section<Stripe> and the rest), now defined in config.rs. Every VisualCI setting is a VISUALCI_ variable. Laravel Rust's variables (APP_*, DATABASE_URL, DB_*, CACHE_STORE, GITHUB_CLIENT_ID/SECRET, …) and the OAuth server's (OAUTH_*) keep their names and are described in the same file, so the docs list everything one server needs.

  • Each setting has a description (its doc comment), a type, a default, and flags for required, required in production and secret.

  • At boot the app:

    • refuses to start when a required setting is missing, a value is invalid, or (in production) a setting production needs is unset, and lists every problem at once;
    • logs the settings it runs with, with secrets masked;
    • warns about each VISUALCI_ variable it doesn't read, naming the closest known one (VISUALCI_S3_BUKET is set, but nothing reads it (did you mean VISUALCI_S3_BUCKET?)). The CLI's, the renderers' and CI scripts' VISUALCI_ variables are ignored.
  • Generated docs:

    • a new page, frontend/content/docs/self-hosting/environment-variables.md (in the Reference section, after Self-hosting);
    • app/.env.example.

    config::tests::the_generated_docs_match_the_schema fails in CI when either differs from the schema. VISUALCI_GOLDEN_UPDATE=1 rewrites them.

  • Presence checks. These now come from the schema's required_in_production flags, which replace the presence-only boot checks (SignUps::check, postmark::check, github_app::check). Kept as they were: the Stripe live-key check, the host URL checks, the OAuth/host check and the dev-login check.

  • Smaller fixes along the way:

    • ForgeApps and SignInApps both read GITHUB_CLIENT_ID; they're replaced by the framework's own social config.
    • LiveDatabase read DATABASE_URL itself; it now uses the framework's database config.
    • Frontend read S3_PUBLIC_ENDPOINT a second time.
    • AppUrl read VISUALCI_APP_URL a second time; it's now HostUrls::app_url().
    • The heartbeats were read with std::env::var(format!(…)).
    • VISUALCI_MCP_HOSTS and TRUSTED_PROXIES were read straight from the process.
    • UPDATE_GOLDENS in tests/forge_reports.rs is now VISUALCI_GOLDEN_UPDATE, like the other golden tests.

The crate: crates/envschema (+ envschema-derive), publish = false

I looked at the existing crates first. Talira search 01a23c9c-13e1-76d6-bda5-a3ff7bef6bfe returned only confique and Figment. I also read confique 0.5.0's source.

  • confique is the closest fit. It has a typed derive, env names per field, defaults, and doc comments kept in Config::META. It doesn't fit here for two reasons:
    • It reads std::env::var directly (confique::internal::from_env), with no other source. Laravel Rust's Env merges .env, treats null/empty as unset, and gives each test app its own variables (with_envs) without touching the process environment. Setting process variables from parallel tests isn't an option.
    • It has nothing for secrets, required-in-production, unknown variables, or Markdown and .env output. Its templates are TOML, YAML and JSON5.
  • figment (Env::prefixed) is about layering providers, which we don't need. It has no schema to document, no secrets and no unknown-variable check.
  • envy has from_iter, but no metadata at all.
  • config-rs is loosely typed.
  • derive_from_env, envious, clapfig: none adds the missing parts.

None of them warns about unknown prefixed variables. So the crate is small, and everything is built from one derive:

  • a typed struct read from any Source (the process environment, a map, a closure);
  • every problem collected at once;
  • required_in_production;
  • secrets masked in the derived Debug and in Summary;
  • Schema::unknown(prefix, names) with the closest name by edit distance;
  • Schema::markdown() and dotenv_example();
  • external groups, to document variables a framework reads.

No adapter crates. The Laravel side is about 20 lines in config::install (a closure source over Env::get, then config.set for each group). A Loco app would use the crate directly with ProcessEnv and keep the struct in its shared store. Its YAML config is a separate layer that this doesn't replace.

Every variable app/ reads

Old name → new name. "Secret" values are masked in logs. "Prod" means required in production (the app refuses to start without it there). "Always" means required everywhere.

Old New Secret Required
S3_ENDPOINT VISUALCI_S3_ENDPOINT always
S3_PUBLIC_ENDPOINT VISUALCI_S3_PUBLIC_ENDPOINT
S3_BUCKET VISUALCI_S3_BUCKET always
S3_REGION VISUALCI_S3_REGION
S3_ACCESS_KEY_ID VISUALCI_S3_ACCESS_KEY_ID yes always
S3_SECRET_ACCESS_KEY VISUALCI_S3_SECRET_ACCESS_KEY yes always
RENDERER_TOKEN VISUALCI_RENDERER_TOKEN (same name the renderers read) yes always
RENDERER_VERSION VISUALCI_RENDERER_VERSION (the image sets it; this PR's Dockerfile) always
METRICS_TOKEN VISUALCI_METRICS_TOKEN yes
TRUSTED_PROXIES VISUALCI_TRUSTED_PROXIES
DB_ACQUIRE_TIMEOUT VISUALCI_DB_ACQUIRE_TIMEOUT
DB_APPLICATION_NAME VISUALCI_DB_APPLICATION_NAME
GITHUB_APP_ID VISUALCI_GITHUB_APP_ID prod
GITHUB_APP_PRIVATE_KEY_BASE64 VISUALCI_GITHUB_APP_PRIVATE_KEY_BASE64 yes prod
GITHUB_WEBHOOK_SECRET VISUALCI_GITHUB_WEBHOOK_SECRET yes prod
STRIPE_SECRET_KEY VISUALCI_STRIPE_SECRET_KEY yes prod
STRIPE_WEBHOOK_SECRET VISUALCI_STRIPE_WEBHOOK_SECRET yes prod
POSTMARK_SERVER_TOKEN VISUALCI_POSTMARK_SERVER_TOKEN yes prod
MAIL_FROM VISUALCI_MAIL_FROM
MAIL_REPLY_TO VISUALCI_MAIL_REPLY_TO
DEV_LOGIN VISUALCI_DEV_LOGIN
VISUALCI_SITE_URL, VISUALCI_APP_URL, VISUALCI_API_URL, VISUALCI_MCP_URL unchanged
VISUALCI_MCP_HOSTS unchanged (now typed config)
VISUALCI_WAITLIST unchanged prod
VISUALCI_TEAM_EMAIL unchanged
VISUALCI_GITLAB_URL, VISUALCI_GITLAB_BOT_USERNAME, VISUALCI_FORGE_PRIVATE_ADDRESSES unchanged
VISUALCI_GITLAB_BOT_TOKEN unchanged yes
VISUALCI_CLOUDFLARE_ZONE_ID unchanged
VISUALCI_CLOUDFLARE_PURGE_TOKEN unchanged yes
VISUALCI_GALLERY_DAILY_CREDITS unchanged
VISUALCI_<JOB>_HEARTBEAT_URL (9 jobs) unchanged
VISUALCI_<JOB>_HEARTBEAT_TOKEN (9 jobs) unchanged yes
Laravel Rust (framework names kept)
APP_KEY unchanged yes prod
APP_ENV, APP_URL, APP_BASE_PATH, SERVER_HOST, SERVER_PORT, LOG_CHANNEL unchanged
DATABASE_URL unchanged yes
DB_CONNECTION, DB_MAX_CONNECTIONS, CACHE_STORE, SESSION_DRIVER, QUEUE_CONNECTION unchanged
GITHUB_CLIENT_ID unchanged (Laravel's social login reads <PROVIDER>_CLIENT_ID) prod
GITHUB_CLIENT_SECRET unchanged yes prod
GITLAB_CLIENT_ID unchanged
GITLAB_CLIENT_SECRET unchanged yes
oauth-provider-laravel (library names kept)
OAUTH_ISSUER, OAUTH_AUTHORIZATION_ENDPOINT unchanged
Development and tests only
VISUALCI_NOW, VISUALCI_APP_TEST_DATABASE_URL, VISUALCI_EMAIL_SNAPSHOTS, VISUALCI_GOLDEN_UPDATE unchanged (UPDATE_GOLDENS → VISUALCI_GOLDEN_UPDATE)

GITHUB_CLIENT_ID/SECRET stay under the framework's names on purpose. Laravel's social config builds a client for every *_CLIENT_ID variable, so VISUALCI_GITHUB_CLIENT_ID would register a provider called visualci_github.

Collisions with the CLI. No app setting takes a CLI variable's name with a different meaning. VISUALCI_API_URL and VISUALCI_MCP_URL mean the same address to the CLI and the server. VISUALCI_RENDERER_TOKEN and VISUALCI_RENDERER_VERSION are the renderers' own values. The test no_setting_takes_another_programs_name keeps it that way.

Infra change (talira-ai/infra, k3s/resources/visualci/laravel)

No 1Password item, field or ExternalSecret remote key changes. Only the variable names inside the cluster change.

Step 1, before this PR merges (additive: today's app ignores the new names):

  • config.yaml (ConfigMap visualci-app-env): add

    • VISUALCI_TRUSTED_PROXIES
    • VISUALCI_DB_ACQUIRE_TIMEOUT
    • VISUALCI_S3_ENDPOINT
    • VISUALCI_S3_BUCKET
    • VISUALCI_MAIL_FROM
    • VISUALCI_MAIL_REPLY_TO

    Each takes the same value as the variable without the prefix.

  • web.yaml, worker.yaml, scheduler.yaml, migrate.yaml env:: add the following with the same valueFrom/value as their old names:

    • VISUALCI_DB_APPLICATION_NAME
    • VISUALCI_GITHUB_APP_ID
    • VISUALCI_GITHUB_APP_PRIVATE_KEY_BASE64
    • VISUALCI_GITHUB_WEBHOOK_SECRET
    • VISUALCI_STRIPE_SECRET_KEY
    • VISUALCI_STRIPE_WEBHOOK_SECRET
    • VISUALCI_POSTMARK_SERVER_TOKEN

    The secretKeyRef keys stay as they are.

  • The same four Deployments: add VISUALCI_RENDERER_TOKEN (secretKeyRef visualci-renderer-token/RENDERER_TOKEN) and VISUALCI_METRICS_TOKEN (secretKeyRef visualci-metrics-token/METRICS_TOKEN). Today these arrive through envFrom under the old names. The Secrets' keys stay, because renderer.yaml and podmonitors.yaml read them.

  • visualci-r2: add VISUALCI_S3_ACCESS_KEY_ID and VISUALCI_S3_SECRET_ACCESS_KEY, either as env entries from the Secret's S3_ACCESS_KEY_ID/S3_SECRET_ACCESS_KEY keys or by renaming the ExternalSecret's target keys in step 2.

Step 2, after this PR is deployed:

  • Remove the old names:
    • TRUSTED_PROXIES, DB_ACQUIRE_TIMEOUT, DB_APPLICATION_NAME
    • S3_*
    • MAIL_FROM, MAIL_REPLY_TO
    • GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY_BASE64, GITHUB_WEBHOOK_SECRET
    • STRIPE_*
    • POSTMARK_SERVER_TOKEN
    • the envFrom'd RENDERER_TOKEN/METRICS_TOKEN, if you switch those to explicit entries.
  • The image no longer sets RENDERER_VERSION. It sets VISUALCI_RENDERER_VERSION instead (docker/app.Dockerfile, in this PR).

Leftover old names are harmless: the unknown-variable warning only covers VISUALCI_ names.

VisualCI build

The PR's build shows the docs home (docs/index) with the new Environment variables entry in the sidebar's Reference section. The new page itself isn't captured: since 2 Dec only the docs home is (scripts/screenshots/pages.mjs). Add it there if you want it reviewed visually.

Tests (agents-build-1, Postgres 17 and RustFS 1.0.6)

  • cargo fmt --all --check, cargo clippy --locked --workspace --all-targets -- -D warnings: clean.
  • cargo test --locked --workspace (app/ against its own test database): all passed. New tests:
    • config::tests::an_unknown_variable_is_warned_about_with_the_closest_known_one (captures the WARN log line);
    • hosts::production_needs_github_stripe_and_email_configured (missing GitHub, Stripe, Postmark or App settings stop production at boot, listed together) and production_doesnt_boot_without_saying_whether_sign_ups_are_open;
    • config::tests::secrets_are_masked_when_the_configuration_is_logged (summary, Debug and the log line);
    • config::tests::the_generated_docs_match_the_schema (the CI check for the page and .env.example);
    • the_schema_has_no_mistakes, no_setting_takes_another_programs_name, every_default_is_valid;
    • crates/envschema's own tests and doctest.
  • frontend: pnpm install --frozen-lockfile && pnpm build && pnpm test (43 passed), node scripts/skills.mjs --check: clean.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…docs and warnings for unknown ones (sc-9026)

Every setting app/ reads is now declared once in app/src/config.rs, a struct derived with the new
crates/envschema (typed settings from prefixed environment variables). Its doc comments, types, defaults and
required / required-in-production / secret flags drive loading, boot checks, secret masking in logs, warnings
for unknown VISUALCI_ variables (naming the closest known one) and the generated docs: the new
self-hosting/environment-variables page and app/.env.example, checked by a test.

App-owned settings that had other names now start with VISUALCI_ (S3_*, RENDERER_*, METRICS_TOKEN,
GITHUB_APP_*, GITHUB_WEBHOOK_SECRET, STRIPE_*, POSTMARK_SERVER_TOKEN, MAIL_*, DEV_LOGIN, TRUSTED_PROXIES,
DB_ACQUIRE_TIMEOUT, DB_APPLICATION_NAME). Laravel Rust's and the OAuth server's variables keep their names.
@visualci-com

visualci-com Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #175 · 3 changed, 336 unchanged · approved by visualci features agent for Nathan Broadbent

This PR vs base: 3 changed since #172, across 1 build

Snapshot Before After
screenshots/docs/index/1440-dark (changed)
screenshots/docs/index/1440-light (changed)
site/llms (changed) text text, see the build

docspring/visualci · journeys · build #174 · 12 unchanged · no changes

This PR vs base: nothing since #173, across 1 build

Updated as builds change. Agents can review with VisualCI's MCP tools.

@ndbroadbent
ndbroadbent merged commit bf020dd into main Dec 3, 2026
14 checks passed
@ndbroadbent
ndbroadbent deleted the app-visualci-env-config branch December 3, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant