## Summary
Separates Fabro server secrets into two explicit scopes: **bootstrap**
secrets that come from process env or `server.env`, and **optional
integration** secrets that come exclusively from the vault. This makes
secret resolution simple and predictable, and removes all `process env →
server.env` fallback paths for optional integrations such as GitHub App,
Slack, Daytona, Brave Search, and LLM provider keys.
## What changed
**New `ToolSecrets` struct in `fabro-agent`** — Brave Search API key is
now passed explicitly through `SessionOptions.tool_secrets` rather than
read from process env inside the tool. The standalone CLI reads the key
at the CLI boundary (with an explicit
`#[expect(clippy::disallowed_methods)]` annotation); the server will
read it from the vault. The error message changes from
`"BRAVE_SEARCH_API_KEY environment variable is not set"` to
`"BRAVE_SEARCH_API_KEY is not configured"`.
**`VaultCredentialSource::vault_only` constructor in `fabro-auth`** —
Adds a constructor that passes `|_| None` as the env lookup, ensuring
the server LLM credential source never resolves provider keys from
process env.
**GitHub App secrets move to vault in install flows** — Both the CLI
`fabro install github` path and the browser install finish handler now
write `GITHUB_APP_PRIVATE_KEY`, `GITHUB_APP_CLIENT_SECRET`, and
`GITHUB_APP_WEBHOOK_SECRET` to the vault instead of `server.env`.
Switching strategies removes stale secrets from the other strategy's
storage location. The `vault_set` field type changes from `Vec<(String,
String)>` to `Vec<VaultSecretWrite>` to carry per-secret type metadata
(file vs. token).
**`fabro-vault` gains a `fabro-static` dependency** — Needed so the
vault crate can reference canonical env-var names from the shared
registry without a cycle.
**`GH_TOKEN` fallback removed** — `GITHUB_TOKEN` is now read from the
vault only; the changelog and `server-configuration.mdx` note drops
mention of `GH_TOKEN` as an accepted fallback.
**Version bump** — Workspace crates promoted from `0.244.0-nightly.0` to
`0.244.0`.
**Docs** — Internal strategy doc, public admin docs (Docker, Railway,
server-configuration, security, troubleshooting), and integration docs
(GitHub, Slack, Daytona, Brave Search, LiteLLM, tools reference, models)
all updated to reflect vault-only optional secrets and direct users to
`fabro secret set` rather than process env or `server.env`.
### Plan Summary
- **Task 1** (secret registry) — not yet present in this diff;
classification lives in the places that consume it.
- **Task 3–6** (vault-only lookups for GitHub, Slack, Daytona, LLM) —
implemented via `vault_only` constructor, `tool_secrets` threading, and
install-path changes.
- **Task 7** (Brave Search explicit injection) — `ToolSecrets`,
`register_core_tools` wiring, CLI boundary read.
- **Task 8** (install persistence) — GitHub App secrets written to
vault; token strategy writes `GITHUB_TOKEN` to vault and clears app
vault keys; app strategy clears `GITHUB_TOKEN` vault key.
- **Task 9** (docs) — all public and internal docs updated.
### Fabro Details
<details>
<summary>Ran 0 stages in 155m 26s for $60.85</summary>
| Stage | Duration | Cost | Retries |
|---|---|---|---|
| **Total** | **155m 26s** | **$60.85** | **0** |
</details>
<details>
<summary>Ran <code>ImplementPlan.fabro</code> (11 nodes and 14
edges)</summary>
```dot
digraph ImplementPlan {
graph [
goal="Implement and simplify",
model_stylesheet="
* { model: claude-opus-4-7; }
"
]
rankdir=LR
start [shape=Mdiamond, label="Start"]
exit [shape=Msquare, label="Exit"]
toolchain [label="Toolchain", shape=parallelogram, script="command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1", max_retries=0]
preflight_compile [label="Preflight Compile", shape=parallelogram, script="cargo check -q --workspace 2>&1", max_retries=0]
preflight_lint [label="Preflight Lint", shape=parallelogram, script="cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1", max_retries=0]
fix_lints [label="Fix Lints", prompt="The preflight lint step failed. Read the build output from context and fix all clippy lint warnings.", max_visits=3]
implement [label="Implement", prompt="Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD.", model="gpt-55", reasoning_effort="xhigh"]
simplify_opus [label="Simplify (Opus)", prompt="@prompts/simplify.md"]
simplify_gpt [label="Simplify (GPT-55)", prompt="@prompts/simplify.md", model="gpt-55"]
verify [label="Verify", shape=parallelogram, script="git fetch origin main 2>&1 && git merge --no-edit --no-stat origin/main 2>&1 && cargo +nightly-2026-04-14 fmt --all 2>&1 && cargo dev docs refresh 2>&1 && cargo +nightly-2026-04-14 fmt --check --all 2>&1 && { command -v rg >/dev/null 2>&1 || { echo 'rg is required for verify'; exit 127; }; } && ! rg -n 'AuthMode::Disabled|RunAuthMethod|RunSubjectProvenance|\bActorRef\b|\bActorKind\b|AuthenticatedSubject|AuthenticatedService|AuthorizeRunScoped|AuthorizeRunBlob|AuthorizeStageArtifact|AuthorizeCommandLog|auth_method\s*==\s*\"disabled\"' lib/crates apps lib/packages docs/public/api-reference/fabro-api.yaml 2>&1 && cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --workspace --status-level slow --profile ci 2>&1 && cargo dev docs check 2>&1 && bun install --frozen-lockfile 2>&1 && (cd apps/fabro-web && bun run typecheck) 2>&1 && (cd apps/fabro-web && bun run test) 2>&1 && (cd lib/packages/fabro-api-client && bun run typecheck) 2>&1 && cargo dev build -- -p fabro-cli --release 2>&1", goal_gate=true, retry_target="fixup"]
fixup [label="Fixup", prompt="The verify step failed. Read the build output from context and fix all format, clippy, Rust test, docs, TypeScript typecheck/test, and build failures.", max_visits=3]
start -> toolchain
toolchain -> preflight_compile [condition="outcome=succeeded"]
toolchain -> exit
preflight_compile -> preflight_lint [condition="outcome=succeeded"]
preflight_compile -> exit
preflight_lint -> implement [condition="outcome=succeeded"]
preflight_lint -> fix_lints
fix_lints -> preflight_lint
implement -> simplify_opus -> simplify_gpt -> verify
verify -> exit [condition="outcome=succeeded"]
verify -> fixup
fixup -> verify
}
```
</details>
⚒️ Generated with [Fabro](https://fabro.sh)
---------
Co-authored-by: Fabro <noreply@fabro.sh>
Co-authored-by: Bryan Helmkamp <bryan@brynary.com>
52 KiB
| title | type | status | date | deepened |
|---|---|---|---|---|
| refactor: Lock down server-level secrets handling | refactor | active | 2026-04-22 | 2026-04-23 |
Lock down server-level secrets handling
Overview
Server-level secrets (SESSION_SECRET, FABRO_DEV_TOKEN, GitHub App credentials, JWT keypair) flow through three independent paths today:
ServerSecrets::getreads process env live on every call, with on-disk envfile fallback.load_or_create_local_session_secretreads env first, then envfile, then auto-generates if missing.execute_foregroundmutates parent process env viastd::env::set_varso the in-process server's live env reads see the resolved value.
Worker subprocess scrubs FABRO_DEV_TOKEN; daemon spawn does not — accidental inconsistency.
This refactor:
- Makes
ServerSecretssnapshot-based. Reads env and envfile once at construction, exposes the merged result. Both env and file remain valid sources (env wins on conflict — 12-factor convention). The bug was live env reads coupled with parent-process mutation, not env reads themselves. - Eliminates parent-process env mutation. With snapshot semantics, the foreground
set_varbecomes unnecessary; the daemoncmd.env(SESSION_SECRET)becomes redundant. - CLI install and web install share a common orchestration path for
server.envwrites. Coordinated install flows may update server-level secrets while a server is running, but they must also own restart/handoff (web install already does this via/install/finish). - Worker and render-graph subprocesses use
env_clear+ strict fail-closed allowlists. Worker is the trust boundary — it dispatches user-supplied workflow stages viaSandbox. Daemon child inherits parent env unchanged (12-factor pattern works). - Foreground and daemon startup share one validation path. Daemon preflight builds the same
ServerSecretssnapshot and runs the same server-side auth/startup validation foreground does — no separate parent-CLI validator with drift risk. - Legacy
FABRO_JWT_PRIVATE_KEY/FABRO_JWT_PUBLIC_KEYdrift is removed. SESSION_SECRET remains the sole auth master (HKDF source for cookie key + JWT signing key per2026-04-19-003-feat-cli-auth-login-plan.md); install stops generating those keys and actively removes them fromserver.envon subsequent runs. clippy::disallowed_methodsdeniesstd::env::set_var/remove_varworkspace-wide including tests; narrow documented post-fork/pre-exec exceptions only.
Problem Frame
- Live env reads + parent-process mutation is unsound.
std::env::set_varinexecute_foregroundmutates global process state inside an async runtime. Rust 2024 marks thisunsafebecause it races concurrent readers. Workspace is on 2021; moving to 2024 forces the issue. The set_var is load-bearing becauseServerSecrets::getreads env live, not at construction. - Worker subprocess env leakage. Workers run user-supplied workflow stages (via
Sandbox). Today they inherit the operator's full process env — any credential the operator exported leaks to user-controlled commands. SESSION_SECRETautogeneration is the real startup bypass.load_or_create_local_session_secretmints a value and writes the envfile if missing — a server can boot with a freshly-minted secret that bypassed the install flow's full setup. Same precedent already removed forFABRO_DEV_TOKEN(commit7cb6c65d5); SESSION_SECRET is the leftover.FABRO_JWT_*is stale config drift. The CLI auth migration (2026-04-19-003-feat-cli-auth-login-plan.md) consolidated cookie + JWT signing into a single HKDF chain rooted at SESSION_SECRET. The legacyFABRO_JWT_PRIVATE_KEY/FABRO_JWT_PUBLIC_KEYenvfile entries no longer participate in the runtime auth model but install still generates them and diagnostics still inspects them — they obscure the actual auth model and risk operator confusion.- CLI install and web install have drifted into separate persistence/restart behaviors. They write to
server.envvia parallel code paths today; the bug-surface of "what does install actually persist" is twice as large as it should be. They should reconverge on a shared orchestration with consistent contracts.
Requirements Trace
- R1.
ServerSecretsreads env and envfile once at boot and exposes the merged snapshot. No live env reads fromServerSecrets::getor its callers on the resolution path. Env wins on conflict. - R2.
fabro server startdoes not generate any server-level secret. Missing → fail fast pointing at the install flows (CLI or web) or direct env-set. - R3.
execute_foregrounddoes not mutate parent process env. - R4.
execute_daemondoes not pass server-level secrets viacmd.env(...)(no longer needed; daemon child reads env+file at its own boot). - R5. Worker and render-graph subprocesses use
env_clear+ strict fail-closed allowlists. New inherited env vars require demonstrated need plus tests. Authority-bearing values re-injected explicitly. - R6. Tests use construction-time env stubs (via a small
EnvSourcetrait) or explicit child-processCommand::env. No test mutates process-wide env. - R7. Foreground and daemon startup use one shared validation path; required secrets mirror current auth rules (SESSION_SECRET always; FABRO_DEV_TOKEN when dev-token auth enabled; GITHUB_APP_CLIENT_SECRET when GitHub auth enabled).
- R8. CLI install and web install share orchestration for coordinated
server.envwrites and restart/handoff. - R9.
FABRO_JWT_PRIVATE_KEY/FABRO_JWT_PUBLIC_KEYare removed from install output, diagnostics, docs, and existingserver.envfiles during install flows. - R10. Behavior changes are documented in a strategy doc and enforced via workspace-wide
clippy::disallowed_methods— including tests — with narrow documented exceptions only.
Scope Boundaries
In scope, active — server-level secrets read via state.server_secret(...), sourced from process env or <storage>/server.env:
| Secret | Consumer | Sources |
|---|---|---|
SESSION_SECRET |
AppState::session_key (server.rs:713); HKDF source for cookie key + JWT signing key |
env (12-factor) or server.env (install) |
FABRO_DEV_TOKEN |
worker_command (server.rs:3825) |
env or server.env |
GITHUB_APP_PRIVATE_KEY |
AppState::github_credentials (server.rs:726) |
env or server.env |
GITHUB_APP_WEBHOOK_SECRET |
github_webhook_routes (server.rs:983) |
env or server.env |
GITHUB_APP_CLIENT_SECRET |
web_auth.rs:536 |
env or server.env |
Both install flows (CLI fabro install and web install via /install/finish) write the envfile; neither mutates process env. Operators on 12-factor PaaS set secrets in platform env; operators on local/server installs use one of the install flows.
In scope, removal targets:
FABRO_JWT_PRIVATE_KEY,FABRO_JWT_PUBLIC_KEY— legacy entries that no longer participate in the runtime auth model. Install stops generating them; diagnostics stops inspecting them; existing entries are actively removed fromserver.envon subsequent install flows.
Startup-critical subset: SESSION_SECRET (always), FABRO_DEV_TOKEN (when dev-token auth is enabled), and GITHUB_APP_CLIENT_SECRET (when GitHub auth is enabled). The other in-scope active secrets (GITHUB_APP_PRIVATE_KEY, GITHUB_APP_WEBHOOK_SECRET) are not boot blockers — they continue to surface where they did before (conditional route mounts, per-request errors). The plan does not promote every server secret to a startup gate.
Out of scope:
- Vault +
ProviderCredentials(secrets.json, REST-managed, runtime-mutable). Different lifecycle. - Legacy vault-or-process-env helper for run-level credentials (
GITHUB_TOKEN,DAYTONA_API_KEY). Same env-as-source pattern, different track at the time of this plan. {{ env.FOO }}config interpolation. Operator-supplied templating, different feature.- Workflow-stage env (Sandbox). Stages run inside
Sandbox(local/Docker/Daytona); their env is configured by the workflow definition + Sandbox config. Anything a workflow stage needs to execute (e.g.git pushrequiringGITHUB_TOKEN) routes via Vault → Sandbox, not subprocess inheritance. validate_api_keyset_varinprovider_auth.rs. Vault-side smell, deferred.- Tailscale and
bun --watch-webspawns. Different surfaces.
Context & Research
Relevant code
lib/crates/fabro-server/src/server_secrets.rs—ServerSecretsdefinition; today's liveenv_lookupclosure is the bug.lib/crates/fabro-server/src/server.rs:697-699—state.server_secret(name)wrapper.lib/crates/fabro-server/src/server.rs:703,712-715andjwt_auth.rs:84-99—resolve_auth_mode_with_lookup, currently routed through the liveenv_lookup.lib/crates/fabro-server/src/server.rs:3776-3834(worker_command) — worker spawn site.lib/crates/fabro-server/src/server.rs:7232-7235—__render-graphspawn site.lib/crates/fabro-cli/src/commands/server/start.rs:229-274—load_or_create_local_session_secretandexecute_foregroundset_varblock.lib/crates/fabro-cli/src/commands/server/start.rs:319-362—execute_daemonspawn flow.lib/crates/fabro-cli/src/commands/install.rs:1816,1856,1864— install SESSION_SECRET generation and persistence.lib/crates/fabro-config/src/envfile.rs:204-256—write_env_entries, already atomic via tmp + fsync + rename.Cargo.toml:111andclippy.toml— existingdisallowed_methodsmechanism.
Institutional learnings
docs/plans/2026-04-05-server-canonical-secrets-doctor-repo-plan.md— architectural anchor: server is canonical, install provisions, request-time reads from store.docs/plans/2026-04-19-003-feat-cli-auth-login-plan.md—SESSION_SECRETis now HKDF master for JWT signing + cookie key. Higher stakes.docs/plans/2026-04-18-001-feat-webhook-strategy-plan.md— webhook secret already plumbed viaAppStatefrom the resolved store.- Commit
7cb6c65d5— "Remove dev-token minting from server start." SESSION_SECRET autogenerate is the leftover.
Key Technical Decisions
ServerSecretsis a snapshot, not a live reader. A smallEnvSourcetrait exists only at construction time and immediately materializes into an ownedHashMap<String, String>. No trait object or callback survives into runtime lookup.get(name)returns from the merged (env ∪ file) snapshot; env wins on conflict (12-factor). Role: the resolved-secrets API; the source mix is the operator's choice.- Production uses a real process-env
EnvSource; tests use a map-backed stub. No live env reads anywhere on the secret resolution path. NoEnvLookupclosure surviving into runtime. resolve_auth_mode_with_lookupmigrates to read fromserver_secrets, not raw env. Closure passed in delegates toself.server_secrets.get(...). Without this, auth-mode resolution remains a live env reader.- Worker and render-graph allowlists are strict fail-closed. Worker is the trust boundary (dispatches user stages via
Sandbox); render-graph is hygiene. New inherited env vars require demonstrated need (failing test) and intentional addition. Proxy/cert env vars are not auto-inherited.- Worker list:
PATH,HOME,TMPDIR,USER,RUST_LOG,RUST_BACKTRACE,FABRO_HOME,FABRO_STORAGE_ROOT. Plus explicitFABRO_DEV_TOKENre-injection when dev-token auth is enabled. - Render-graph list:
PATH,HOME,TMPDIR. Plus explicitFABRO_TELEMETRY=off.
- Worker list:
- Daemon child spawn inherits parent env unchanged (modulo existing
cmd.env_remove("FABRO_JSON")for output-format hygiene). The daemon is fabro's own server code, not a security boundary against itself. 12-factor env vars (SESSION_SECRET, AWS_, RAILWAY_) flow through naturally to the daemon child's snapshot. - Daemon preflight reuses the same shared auth/startup validation as foreground startup. Both modes construct the same
ServerSecretssnapshot and call the same server-side validation logic (today'sjwt_auth::resolve_auth_mode_with_lookupalready encodes "what's required for this auth mode" — that's the shared path). No separate parent-CLI validator with drift risk. Required secrets remain exactly the current startup-critical set: SESSION_SECRET (always), FABRO_DEV_TOKEN (when dev-token auth enabled), GITHUB_APP_CLIENT_SECRET (when GitHub auth enabled). GITHUB_APP_PRIVATE_KEY and GITHUB_APP_WEBHOOK_SECRET remain in-scope server secrets but are not new universal boot blockers. - Install coordination policy lives in shared install orchestration, not in low-level envfile helpers. Coordinated install flows (CLI and web) may write to
server.envwhile a server is running — but only when they also own restart/handoff. Web install already does this via/install/finish. CLI install joins the same orchestration. Manual edits toserver.envoutside the orchestration still require operator restart discipline. pub(crate) server_secretsfield tightened topub(super). No production code legitimately bypasses the wrapper.- Workspace-wide clippy ban including tests. Add
std::env::set_var/remove_vartoclippy.tomldisallowed-methods— applies to production AND test code. Tests must use construction-timeEnvSourcestubs or explicit child-processCommand::env. Narrow documented exceptions only (fabro-telemetry/src/spawn.rs:73-76post-fork pre-execvp). - Legacy
FABRO_JWT_*is removed, not preserved. Install stops generating; diagnostics stops reading; existing envfile entries are actively cleaned up on subsequent install flows. SESSION_SECRET is the sole auth master.
Open Questions
Resolved during planning
ServerSecretsreads env AND file, snapshots, env wins. Process env is a legitimate source (12-factor). The bug was live env reads + parent mutation, not env-as-source.EnvSourceexists only at construction time. A small trait used to materialize an ownedHashMaponce; no callback or trait object survives into runtime lookup. Production uses a real process-env source; tests use a map-backed stub.- Daemon child inherits parent env; only worker/render-graph scrub. Daemon is fabro's own server code and must see whatever the operator/platform set in env. Worker is the trust boundary (dispatches user stages via
Sandbox). - No carve-out for AWS / cloud-platform credentials. Daemon inherits parent env, so AWS env names reach the object-store layer naturally.
- Active scope is 5 server secrets plus 2 legacy removal targets. SESSION_SECRET, FABRO_DEV_TOKEN, GITHUB_APP_PRIVATE_KEY, GITHUB_APP_WEBHOOK_SECRET, GITHUB_APP_CLIENT_SECRET are active. FABRO_JWT_PRIVATE_KEY and FABRO_JWT_PUBLIC_KEY are legacy — install stops generating them; diagnostics stops reading them; existing entries are actively removed.
- Workflow stage env is the Sandbox's job. This plan does not address workflow
bash/git/etc. stage env — that's per-workflow Sandbox config. Workflows requiring credentials route them through Vault. - Web install keeps its existing restart-handoff contract.
/install/finishstill returns the restart URL and the SPA still waits for the server to come back. No newrestart_requiredflag, no manual-restart message proposal, no API surface change. - CLI and web install share orchestration for coordinated writes while running. Blanket "refuse-while-running" is out. The orchestration is responsible for restart/handoff; both flows call into it.
- Test migration shape: full migration in Unit 1.
ServerSecrets::with_env_lookupis deleted; tests use eitherServerSecrets::load(path, env_source)with a map-backedEnvSourcestub, orprovision_server_secrets(env_path, &[(name,value)])helper (file-based injection). No#[cfg(test)]backdoor. - Visibility tightening:
pub(crate) server_secretsatserver.rs:579→pub(super)as part of Unit 1. - Install lock window for interactive flows: install orchestration's job;
gather inputs → persist + restart-handoff. Serialization window is sub-second regardless of OAuth duration. - Dev-loop friction: no
--quickflag. Contributors runfabro installor set secrets directly via env (SESSION_SECRET=$(openssl rand -hex 32) cargo run -- server startworks under the env-as-source model). - Compliance-driven rotation: deferred. Captured as a known limitation in the strategy doc.
Implementation Units
- Unit 1:
ServerSecretsbecomes a snapshot built fromEnvSource(construction-time only)
Goal: ServerSecrets reads env and envfile once at construction via a small EnvSource trait, materializes both into owned HashMaps, and exposes the merged snapshot. No trait object or closure survives into runtime lookup. Auth-mode resolution stops being a live env reader.
Requirements: R1, R6
Dependencies: None.
Files:
- Modify:
lib/crates/fabro-server/src/server_secrets.rs— replaceenv_lookupclosure field withenv_entries: HashMap<String, String>(owned). Introduce a smallEnvSourcetrait used only at construction:pub trait EnvSource { fn snapshot(&self) -> HashMap<String, String>; }pub struct ProcessEnv;implssnapshotviastd::env::vars().collect().pub struct StubEnv(pub HashMap<String, String>);implssnapshotby cloning. (cfg-test or cfg(any(test, feature = "test-support")) — implementer picks based on existing patterns.)pub fn load(path: PathBuf, env: &dyn EnvSource) -> Result<Self, Error>— callsenv.snapshot()once, stores the result, never referencesenvagain.get(name)returnsself.env_entries.get(name).cloned().or_else(|| self.file_entries.get(name).cloned()).
- Modify:
lib/crates/fabro-server/src/server.rs—build_app_stateaccepts pre-builtServerSecretsandAuthModefrom the caller (no longer constructsServerSecretsitself). The single production caller isserve_command(viaresolve_startupfrom Unit 4); test helpers construct both in the same way. Tightenpub(crate) server_secretsfield atserver.rs:579topub(super). Migrate theresolve_auth_mode_with_lookupcall (server.rs:703) to pass a closure delegating toself.server_secrets.get(...). - Modify:
lib/crates/fabro-server/src/serve.rs:512andinstall.rs:910,965,2108— minimal API migration:ServerSecrets::load(path, &ProcessEnv)instead ofwith_env_lookupat any non-startup construction sites (e.g. install-time inspection, install_object_store_lookup test helper). The startup construction sites atserve.rs:594-607are NOT modified by Unit 1 — Unit 4 collapses them into a singleresolve_startup(...)call. To keep the workspace compiling between Unit 1 and Unit 4, Unit 1 may leave a temporaryServerSecrets::load(path, &ProcessEnv)call atserve.rs:594if needed; Unit 4 deletes it. Sequencing is documented in Unit 4's Dependencies. - Modify:
lib/crates/fabro-server/src/server.rs:7864-7885— replaceserver_secrets_resolve_process_env_before_server_envwith a snapshot test usingStubEnv(assert env-wins-on-conflict from the snapshot). - Modify:
lib/crates/fabro-server/tests/it/api/cli_auth_token.rs:34,routing.rs:21,35-36,tcp.rs:28,68,173-174,lib/crates/fabro-cli/tests/it/support/auth_harness.rs:39-86— migrate fromenv_lookupinjection (for secret values) to constructing the test'sServerSecretswith&StubEnv(...), or writing to a tempserver.envvia theprovision_server_secrets(env_path, &[(name, value)])helper. Tests that currently passenv_lookuponly to feed secret values intoServerSecretsswitch to the new mechanism. - Modify: test helpers like
create_app_state_with_env_lookup(server.rs:2488and similar) — oncebuild_app_state(server.rs:2631) requires precomputedServerSecretsandAuthMode, the helpers must produce both internally and pass them through. Theenv_lookupparameter on these helpers is retained (still consumed downstream byresolve_canonical_originatserver.rs:708and slack{{ env.FOO }}interpolation atserver.rs:2676, both out of scope). New shape: helper accepts an additional&dyn EnvSourceparameter (or constructs aStubEnv/ProcessEnvbased on the call site's intent), internally callsresolve_startup(...)(or directly constructsServerSecrets+ computesAuthModeif the helper bypasses settings — auditor's choice per call site), and passes the resultingServerSecretsandAuthModeintobuild_app_state. Tests that set up specific auth modes (e.g. dev-token enabled) now thread settings +EnvSourcethrough the helper rather than relying on a single closure to drive both secret resolution and auth-mode computation. - Test: existing files plus new snapshot-semantics tests in
server_secrets.rs.
Approach:
EnvSource::snapshot()is called exactly once duringServerSecrets::load. The trait reference is dropped immediately after; only the materializedHashMapis retained. No risk of live env reads via trait object dispatch.- Object-store credential resolution at
serve.rs:340-401, 520-522, 540-542usesstd::env::var(...)directly (daemon child inherits parent env, so AWS names are present).
Test scenarios:
- Happy path:
ServerSecrets::load(path, &StubEnv([("SESSION_SECRET", "from-env")].into()))returns "from-env" even when file has a different value. - Edge: env empty, file has the value → file wins (single fallback path).
- Edge: neither env nor file has the value →
getreturnsNone. - Edge: env has it, file does too, different values → env wins (12-factor).
- Edge: missing file path → empty
file_entries, env-only resolution. - Snapshot semantics: after construction, mutating the source
EnvSource(or process env, if production source) does not affectgetreturns. The snapshot is owned and immutable. - Auth-mode happy path:
resolve_auth_mode_with_lookupresolves correctly when secrets come from env, file, or both. - Migration:
cli_auth_token,routing,tcp,auth_harnesstests pass after migration toEnvSourcestubs.
Verification:
cargo nextest run -p fabro-server -p fabro-clipasses.grep -rn 'std::env::var\|std::env::vars' lib/crates/fabro-server/src/ | grep -v 'serve.rs\|object_store\|spawn_env\|server_secrets.rs'shows no live env reads on the server-secret resolution path (the onlystd::env::vars()is insideProcessEnv::snapshot, called once at construction).
- Unit 2: Drop foreground
set_var; drop daemoncmd.env(SESSION_SECRET)
Goal: Eliminate parent-process env mutation. Daemon parent stops passing SESSION_SECRET via cmd.env; daemon child reads env+file at its own boot.
Requirements: R3, R4
Dependencies: Unit 1.
Files:
- Modify:
lib/crates/fabro-cli/src/commands/server/start.rs:265-274— delete theset_var/scopeguard block inexecute_foreground. - Modify:
lib/crates/fabro-cli/src/commands/server/start.rs:350,352—execute_daemonremovescmd.env("SESSION_SECRET", ...). Keep existingcmd.env_remove("FABRO_JSON")(output-format hygiene). - Modify:
lib/crates/fabro-test/src/lib.rs:931— dropcmd.env("SESSION_SECRET", ...)for spawned test servers; tests provision viaserver.envor by setting env on the spawnedCommandexplicitly when the test simulates a 12-factor PaaS scenario. - Test: existing
cmd/server_start.rstests cover both modes.
Approach:
- Unit 1's snapshot semantics make both
set_varandcmd.env(SESSION_SECRET)unnecessary. The in-process foreground server'sServerSecrets::load(path, &ProcessEnv)snapshots whatever env the parent CLI had. The daemon child inherits parent env (today's behavior — unchanged) and snapshots it at its own boot. - A
SESSION_SECRETexported in the operator's parent shell does flow through to both modes — that's the 12-factor design intent.
Test scenarios:
Tests proving env behavior must use construction-time EnvSource stubs or explicit child-process Command::env — not std::env::set_var. Any old test using process-env mutation is migrated as part of this unit (or Unit 7's clippy enforcement will fail it).
- Happy path (foreground, env source): in-process server constructed with
&StubEnv([("SESSION_SECRET", "from-env")].into()); running server uses that value. - Happy path (foreground, file source): empty
EnvSource, value inserver.env; running server uses the file value. - Happy path (foreground, env-wins): env and file have different values; env wins.
- Happy path (daemon, env source): test passes
SESSION_SECRETto spawned daemon via explicitCommand::env; daemon child inherits and snapshots it. NOT viastd::env::set_varin the test process. - Happy path (daemon, file source): no env on the spawned
Command, value inserver.env; daemon child uses the file value.
Verification:
grep -rn 'std::env::set_var\|remove_var' lib/crates/fabro-cli/src/returns no hits in production code.grep -rn 'cmd\.env."SESSION_SECRET"' lib/crates/fabro-cli/src/returns no hits in production code (test code may still useCommand::envfor daemon spawn simulation; that's fine — it's setting child env, not parent env).
- Unit 3: Worker and render-graph spawns use
env_clear+ strict fail-closed allowlists
Goal: Worker and render-graph subprocesses inherit only an explicit allowlist. The lists are strict fail-closed — new env vars require demonstrated need (a failing test that proves a workflow execution path needs them) plus intentional addition. Authority-bearing values re-injected explicitly. Daemon child spawn is unchanged (inherits parent env per 12-factor).
Proxy and TLS env vars (HTTPS_PROXY, SSL_CERT_FILE, etc.) are not inherited unless usage-proven by a failing test and intentionally added — they were never part of the worker's documented contract.
Requirements: R5
Dependencies: None.
Files:
- Create:
lib/crates/fabro-server/src/spawn_env.rs— defines two helpers:apply_worker_env(&mut tokio::process::Command)—env_clear+ worker list.apply_render_graph_env(&mut tokio::process::Command)—env_clear+ render-graph list.
- Modify:
lib/crates/fabro-server/src/server.rs:3776-3834—worker_commandcallsapply_worker_env(&mut cmd)first, then existingcmd.env("FABRO_DEV_TOKEN", token)re-injection. Remove existingenv_remove("FABRO_JSON")andenv_remove("FABRO_DEV_TOKEN")(covered byenv_clear). - Modify:
lib/crates/fabro-server/src/server.rs:7232-7235—__render-graphspawn callsapply_render_graph_env(&mut cmd). Keep explicitcmd.env("FABRO_TELEMETRY", "off"). - Test: new tests in
spawn_env.rs.
Approach:
WORKER list (each entry has // reason: ... in the source):
PATH, HOME, TMPDIR, USER // process essentials
RUST_LOG, RUST_BACKTRACE // diagnostics
FABRO_HOME, FABRO_STORAGE_ROOT // worker reads its own state
+ explicit cmd.env("FABRO_DEV_TOKEN", token) when dev-token auth enabled
RENDER_GRAPH list:
PATH, HOME, TMPDIR
+ explicit cmd.env("FABRO_TELEMETRY", "off")
DAEMON spawn: no helper. Inherits parent env. Keeps existing cmd.env_remove("FABRO_JSON").
The lists are constants in spawn_env.rs. Each entry is one named env var with a one-line // comment. A worker that needs a new env var must be amended in source — that's the entire mechanism.
Test scenarios:
- Happy path (worker): with allowlisted names in parent env, all reach the worker. Random names (
MY_API_KEY,NEW_RELIC_LICENSE_KEY,DATABASE_URL,SESSION_SECRET=leak) do not. - Happy path (worker, dev-token enabled):
FABRO_DEV_TOKENis set to the install-provisioned value via explicit re-injection. - Negative (worker): parent's
FABRO_DEV_TOKEN=garbagedoes not reach the worker; explicit re-injection sets the correct value. - Happy path (render-graph):
PATHandHOMEreach the child; arbitrary parent vars do not. - Integration (render-graph): with
FABRO_TELEMETRY=onin parent env, child seesoff(explicit override afterenv_clear). - Integration: real worker subprocess executes a workflow end-to-end with leak probes (
MY_API_TOKEN=leak,NEW_RELIC_LICENSE_KEY=leak) exported in parent env. Workflow completes; leak probes do not appear in worker logs or in stage env (Sandbox-configured).
Verification:
cargo nextest run -p fabro-serverpasses.- A test asserts the worker spawn sees only names in the allowlist plus the explicit
FABRO_DEV_TOKEN— i.e. "no ambient inheritance except allowlisted names." Same for render-graph. The check operates by enumerating the child's actual env, not by grepingenv_removecalls. grep -rn 'env_remove' lib/crates/fabro-server/src/returns no hits for the worker (server.rs:3776-3834) or render-graph (server.rs:7232-7235) spawn sites — both routes are now viaenv_clear+ the helpers.grep -rn 'env_remove' lib/crates/fabro-cli/src/commands/server/start.rsreturns the single intentionalcmd.env_remove("FABRO_JSON")on the daemon-spawn path (output-format hygiene; daemon child unchanged per Unit 2). No otherenv_removecalls in CLI server code.
- Unit 4: Shared startup validation via snapshot-backed
ServerSecrets
Goal: Server start no longer auto-generates. Daemon preflight constructs the same ServerSecrets snapshot foreground startup uses and runs the same server-side auth/startup validation logic. No separate parent-CLI validator that could drift from the server-side rules.
Requirements: R1, R2, R7
Dependencies: Units 1-3.
Files:
-
Create:
lib/crates/fabro-server/src/startup.rs(or extend an existing module) — define the shared validation logic. Two entry points around it: a public preflight wrapper (CLI calls this; never seesServerSecrets), and a crate-internal full-resolution function (serve_commandcalls this; consumes the snapshot directly). Both share a single internal implementation so there is no possibility of drift.// Crate-internal: returns full state for in-process consumption. pub(crate) struct StartupResolution { pub(crate) auth_mode: AuthMode, pub(crate) server_secrets: ServerSecrets, } pub(crate) fn resolve_startup( env_path: &Path, env: &dyn EnvSource, settings: &ResolvedServerSettings, ) -> Result<StartupResolution, StartupValidationError> // Public: thin wrapper for CLI preflight. Calls resolve_startup, drops the // StartupResolution after validating, returns just the success/failure. pub fn validate_startup( env_path: &Path, env: &dyn EnvSource, settings: &ResolvedServerSettings, ) -> Result<(), StartupValidationError>Internally
resolve_startupconstructsServerSecrets::load(env_path, env), then runs the existingjwt_auth::resolve_auth_mode_with_lookupagainst a closure delegating to that snapshot, then returns both.validate_startupisresolve_startup(...).map(|_| ())— the literal sharing of code makes drift impossible.Function takes
&ResolvedServerSettings(not just&ServerAuthSettings) because validation already depends onserver.web.enabledandserver.integrations.github.client_id(jwt_auth.rs:63) — narrowing would silently weaken the validation surface.StartupValidationErrorwraps or re-uses the existing error type returned byjwt_auth::resolve_auth_mode_with_lookupplus the secret-loading errors fromServerSecrets::load. It must cover the full surface that path rejects today: missing required secret (SESSION_SECRET,FABRO_DEV_TOKENwhen dev-token auth enabled,GITHUB_APP_CLIENT_SECRETwhen GitHub auth enabled), invalid secret value (e.g., malformedFABRO_DEV_TOKEN), empty auth methods, GitHub auth configured withserver.web.enabled = false, missingserver.integrations.github.client_id. Implementer auditsjwt_auth.rs:67to enumerate the full variant set; the plan does not invent a narrow new one.CLI never sees
ServerSecrets.ServerSecretsandresolve_startupstaypub(crate). Onlyvalidate_startup+EnvSource+ProcessEnv+StartupValidationErrorcross the crate boundary. -
Modify:
lib/crates/fabro-server/src/lib.rs— re-exportstartup::{validate_startup, EnvSource, ProcessEnv, StartupValidationError}from the crate root. Notresolve_startuporStartupResolution. -
Modify:
lib/crates/fabro-cli/src/commands/server/start.rs:229-250— deleteload_or_create_local_session_secret. Daemon preflight callsfabro_server::validate_startup(runtime_directory.env_path(), &fabro_server::ProcessEnv, &resolved_settings). OnErr: surface the error to stderr exactly as returned (text comes from the shared error type'sDisplay). -
Modify:
lib/crates/fabro-cli/src/commands/server/start.rs:264—execute_foregrounddoes not run a separate validator. The in-process server'sserve_commandcallsresolve_startupinternally and threads the returned(ServerSecrets, AuthMode)intobuild_app_state(replacing today's separateServerSecrets::with_env_lookup+resolve_auth_mode_with_lookupcalls atserve.rs:594-607). Single source of truth: foreground's resolution and daemon's preflight share the same internalresolve_startup; only the calling surface differs. -
Modify:
lib/crates/fabro-server/src/serve.rs:594-607— replace today's ad-hoc two-step construction with a singleresolve_startup(...)call. The returnedServerSecretsandAuthModeare passed intobuild_app_state(per Unit 1's revised signature). -
Modify:
lib/crates/fabro-cli/src/commands/server/start.rs:350—execute_daemonrunsvalidate_startupbefore spawning the child. -
Test:
tests/it/cmd/server_start.rsadds missing-secret tests for each required secret across both modes, plus tests demonstrating env-source success, file-source success, and each non-missing-key rejection (empty auth methods, web-disabled with GitHub auth, missing client_id, invalid dev token). A unit test infabro-serverassertsvalidate_startupandresolve_startupreturn identical accept/reject decisions for the same inputs.
Approach:
- Required secrets remain exactly the current startup-critical set, encoded once in the shared validation: SESSION_SECRET (always), FABRO_DEV_TOKEN (when dev-token auth is enabled), GITHUB_APP_CLIENT_SECRET (when GitHub auth is enabled). GITHUB_APP_PRIVATE_KEY and GITHUB_APP_WEBHOOK_SECRET remain in-scope server secrets but are NOT new universal boot blockers — they continue to surface where they did before (conditional route mounts, per-request errors).
- Daemon preflight and foreground startup run the same validation function with the same
ServerSecretssnapshot type; "drift" is impossible by construction.
Test scenarios:
- Happy path: required secrets in env → boots (both modes).
- Happy path: required secrets in file → boots (both modes).
- Happy path: env wins when both present.
- Error path (each required secret): missing in both → fail fast naming the secret and both sources (both modes get identical error text because they call the same function).
- Negative regression: post-Unit-1 snapshot is built once; mutating env after boot doesn't change the resolved value.
Verification:
fabro server startagainst an empty env and uninstalled storage exits non-zero with the same error message in both--foregroundand daemon modes.fabro server startwith secrets in env (12-factor simulation) boots without any install flow having run.grep -rn 'generate_session_secret' lib/crates/fabro-cli/src/commands/server/returns no hits.grep -rn 'ServerSecrets\|server_secrets::\|resolve_startup\|StartupResolution' lib/crates/fabro-cli/returns no hits — CLI never seesServerSecretsor the internal resolution. Onlyvalidate_startupis reachable from outsidefabro-server.- The public secret-related surface from
fabro-server's crate root is exactly:validate_startup,EnvSource,ProcessEnv,StartupValidationError. Nothing else. - Foreground startup at
serve.rs:594-607makes exactly one call to compute(ServerSecrets, AuthMode)—resolve_startup(...)— not a separateServerSecrets::with_env_lookupfollowed byresolve_auth_mode_with_lookup. Both values are passed intobuild_app_state. build_app_stateno longer constructsServerSecrets; it accepts pre-builtServerSecretsandAuthModefrom the caller. Verified by reading the signature.
- Unit 5: Shared install orchestration for coordinated
server.envwrites and restart handoff
Goal: CLI install and web install share a single orchestration layer for server.env persistence. Both flows take the same path through generation, persistence, removal of legacy entries, and restart handoff. Web install keeps its existing /install/finish restart-handoff contract; CLI install joins the same orchestration. No blanket refuse-while-running policy.
Requirements: R8
Dependencies: Pairs naturally with Unit 6 (legacy FABRO_JWT_* removal hooks into the same orchestration). Either order works.
Files:
- Modify:
lib/crates/fabro-install/src/lib.rs— establish the shared orchestration entry points. Both CLI install and web install call into these. Orchestration owns:- input gathering (no
server.envwrite, no serialization) - persistence (atomic
server.envwrite via existingenvfile::merge_env_fileatenvfile.rs:204-256) - legacy entry removal (Unit 6 hook for
FABRO_JWT_*) - restart/handoff (web install via
/install/finish's existing restart URL contract; CLI install determines its own handoff — for the in-process case, exit cleanly; for daemon mode, respect today'sfabro server stop+ restart pattern)
- input gathering (no
- Modify:
lib/crates/fabro-cli/src/commands/install.rs:1864, 1213— routeserver.envwrites through the shared orchestration infabro-install. CLI-specific UX (prompts, progress display) remains incommands/install.rs; persistence does not. - Modify:
lib/crates/fabro-server/src/install.rs:1313, 1343-1353, 1380— server-side/install/finishhandlers route through the same orchestration. The existing/install/finishAPI contract (returns restart URL; SPA polls until server returns) is preserved exactly — norestart_requiredflag, no API surface change. - Test: parity tests in
lib/crates/fabro-install/tests/prove CLI install and web install take the same persistence/removal path with the same outputs given the same inputs.
Approach:
- The shared orchestration in
fabro-installis the single chokepoint forserver.envwrites from install flows. Manual edits toserver.envoutside the orchestration still require operator restart discipline (documented). - Coordinated install flows MAY write while a server is running — they own restart/handoff. Web install already has the handoff via
/install/finish; CLI install gets the same primitives. - Two-phase shape:
gather inputs (no serialization)→persist + restart-handoff (atomic). Serialization window is sub-second regardless of OAuth duration. - No PID-comparison logic, no refuse-while-running predicate, no new chokepoint helper in
fabro-config. The earlierwrite_server_env_serializedproposal is dropped.
Test scenarios:
- Parity: identical install inputs produce identical
server.envcontents and identical removed entries via CLI and web paths. - Happy path (CLI): install on stopped server succeeds;
server.envupdated atomically. - Happy path (web): install on running server completes via
/install/finish; restart URL returned; SPA reconnects after restart. - Legacy removal: install (CLI or web) on a
server.envcontainingFABRO_JWT_*entries leaves the file without them (Unit 6 hook). - Negative regression: install-then-start works in the common single-shell CLI sequence.
Verification:
cargo nextest run -p fabro-install -p fabro-clipasses including parity tests.grep -rn 'envfile::write_env_entries\|envfile::merge_env_file' lib/crates/fabro-cli/src lib/crates/fabro-server/srcshowsserver.envwrites routed throughfabro-installorchestration; no direct calls outside it./install/finishAPI contract unchanged (existing OpenAPI schema and SPA reconnect tests pass without modification).
- Unit 6: Remove legacy
FABRO_JWT_*drift
Goal: Stop generating FABRO_JWT_PRIVATE_KEY / FABRO_JWT_PUBLIC_KEY, stop reading them in diagnostics, remove operator/docs references that describe them as auth inputs, and actively remove existing entries from server.env during install flows. SESSION_SECRET is the sole auth master.
Requirements: R9
Dependencies: None for code shape; the active-removal hook plugs into Unit 5's shared install orchestration.
Files:
- Modify:
lib/crates/fabro-cli/src/commands/install.rs:1853-1855— deletegenerate_jwt_keypair()call and the corresponding("FABRO_JWT_PRIVATE_KEY", ...)/("FABRO_JWT_PUBLIC_KEY", ...)entries fromgenerated_server_env_pairs. - Modify:
lib/crates/fabro-server/src/install.rs(whichever lines mirror the CLI side, surfaced in research) — same deletion on the web install side. - Modify:
lib/crates/fabro-install/src/lib.rs(Unit 5's shared orchestration) — addFABRO_JWT_PRIVATE_KEYandFABRO_JWT_PUBLIC_KEYto alegacy_keys_to_removeset; the persistence step writes these as removals on every install run. - Modify:
lib/crates/fabro-server/src/diagnostics.rs:540, 552— remove thestate.server_secret("FABRO_JWT_PUBLIC_KEY")andstate.server_secret("FABRO_JWT_PRIVATE_KEY")checks. Adjust diagnostics output and tests accordingly. - Modify: all operator-facing references to
FABRO_JWT_PRIVATE_KEY/FABRO_JWT_PUBLIC_KEYacrossdocs/,apps/marketing/, README, and any in-repo runbook. The criterion is "any mention," not "mention as auth input." Concrete known-stale targets:docs/administration/server-configuration.mdx:297— remove the "future CLI login flows" reference and any surrounding prose treating these as install/runtime secrets.docs/administration/server-configuration.mdx:331— remove the row(s) from the "Server authentication" table.- Implementer must also
grep -rn 'FABRO_JWT_PRIVATE_KEY\|FABRO_JWT_PUBLIC_KEY' docs/ apps/ README*and either delete or rewrite every hit. Surviving mentions should appear only in (a) the new strategy doc's "removed" section or (b) historical plans underdocs/plans/.
- Modify: install snapshot tests, server.env fixture files, and any insta snapshots that assert on
FABRO_JWT_*lines — regenerate. - Test: install run against a
server.envpre-seeded withFABRO_JWT_*entries — assert they are absent after install completes.
Approach:
- Deletion is the entire change. No deprecation period; no compatibility shim. The keys haven't participated in runtime auth since the CLI auth login migration (
2026-04-19-003). - Operators upgrading run install once; legacy entries are silently cleaned up. The strategy doc records the cleanup for any operator who notices.
Test scenarios:
- Happy path: install on a fresh storage dir produces a
server.envwith noFABRO_JWT_*entries. - Happy path (cleanup): install on a
server.envcontainingFABRO_JWT_PRIVATE_KEY=...andFABRO_JWT_PUBLIC_KEY=...produces an updatedserver.envwithout those keys, with other entries preserved. - Diagnostics:
fabro doctor(or whichever command surfaces diagnostics) does not mentionFABRO_JWT_*.
Verification:
grep -rn 'FABRO_JWT_PRIVATE_KEY\|FABRO_JWT_PUBLIC_KEY\|generate_jwt_keypair' lib/crates apps/ docs/ README*returns hits only in (a) the new strategy doc's "removed" section, (b) historical plan files underdocs/plans/. No hits in operator-facing docs (docs/administration/,docs/quickstart/, marketing) or production crate code.cargo nextest run -p fabro-cli -p fabro-serverpasses with regenerated snapshots.- Mintlify docs build succeeds with the removed entries (no broken anchors/links from other pages that referenced the JWT-key sections).
- Unit 7: Strategy doc + workspace-wide clippy enforcement
Goal: Document the design and encode the rules as compile-time enforcement applied to all code including tests.
Requirements: R10
Dependencies: Units 1-6.
Files:
- Create:
docs-internal/server-secrets-strategy.md. - Modify:
clippy.toml— addstd::env::set_varandstd::env::remove_vartodisallowed-methodswith reason text pointing at the strategy doc. The ban is workspace-wide and applies to tests as well as production code. - Modify:
lib/crates/fabro-telemetry/src/spawn.rs:73-76— add#[expect(clippy::disallowed_methods, reason = "post-fork pre-execvp env mutation; safe because grandchild is single-threaded and about to be replaced via exec")]. - Modify: any other production caller surfaced during implementation (the count is small per Unit 1's grep) — same
#[expect]pattern with documented reason. - Modify:
CLAUDE.md(andAGENTS.mdif separate) — add "Strategy docs" entry pointing at the new doc.
Approach:
Strategy doc covers:
ServerSecretsis the resolved-secrets API. Sources are process env (12-factor) and<storage>/server.env(install/local convenience). Snapshotted at boot viaEnvSourcetrait that materializes immediately into ownedHashMap. Env wins on conflict.- The five active server-level secrets and their consumers (table from this plan).
FABRO_JWT_*is removed (Unit 6); SESSION_SECRET is the sole auth master via HKDF. - Provisioning paths: CLI install, web install (shared orchestration in
fabro-install), or platform env. Server start does not auto-generate. - Tests must not mutate process env. Enforced workspace-wide by clippy. Tests inject via construction-time
EnvSourcestubs (e.g.StubEnv) for in-process resolution, or via explicit child-processCommand::envfor subprocess simulation. - Worker and render-graph env:
env_clear+ strict fail-closed allowlist. Daemon child inherits parent env (12-factor pattern). New worker env entries require demonstrated need + intentional addition. - Install while running: allowed only through the shared install orchestration which owns restart/handoff. Manual
server.envedits still require restart discipline. - Rotation: restart required. Live rotation intentionally not supported. Compliance-driven N+1 rotation (overlap windows) is a known limitation tracked as follow-up.
- Out of scope (with reasons): Vault +
ProviderCredentials, the legacy vault-or-process-env helper for run-level credentials (different track at the time),{{ env.FOO }}config interpolation, workflow-stage env (Sandbox's job),validate_api_keyset_varsmell, Tailscale spawns,bun --watch-web. - Adding a new server-level secret: (1) provision via the install orchestration or platform env; (2) consume via
state.server_secret(...); (3) do not touch env in any other layer; (4) decide if it joins the startup-critical set (most don't). - Adding a new worker env var: add to the worker list in
spawn_env.rswith a one-line reason and a failing-without test that proves need.
Verification:
cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warningspasses.- Adding a new
std::env::set_var(...)in any production OR test file produces a clippy denial that names the strategy doc.
System-Wide Impact
- Interaction graph: all active server-level secrets (the five remaining after Unit 6) converge through
state.server_secret(name)after Unit 1, which returns from the env+file snapshot.resolve_auth_mode_with_lookupmigrates in the same unit. LegacyFABRO_JWT_*is removed across install, diagnostics, and docs (Unit 6). - Error propagation: daemon preflight (
validate_startup) and foreground startup (resolve_startup, called fromserve_command) both delegate to the same shared validation logic introduced in Unit 4 — the public preflight wrapper is literallyresolve_startup(...).map(|_| ()), so error messages and accept/reject decisions are identical by construction. Unit 1 provides only the snapshot machinery (ServerSecrets+EnvSource) that Unit 4's validation consumes. Object-store credential failures still surface from the AWS SDK / object_store crate (unchanged — daemon inherits AWS env). - State lifecycle:
ServerSecretssnapshot built once at boot from env+file; both immutable for process lifetime. Rotating any in-scope secret requires restart. Install flows MAY updateserver.envwhile a server is running when they own restart/handoff via the shared install orchestration (Unit 5). - Subprocess env: workers and render-graph processes inherit only an explicit fail-closed allowlist. Daemon child inherits parent env — that's how 12-factor SESSION_SECRET reaches the daemon.
- API surface: no public API change.
state.server_secret(...)signature unchanged.ServerSecrets::with_env_lookupremoved; replaced byload(path, &dyn EnvSource)./install/finishAPI contract unchanged (norestart_requiredflag, no new fields). - Unchanged invariants at the time:
ProviderCredentials, Vault REST API, the legacy vault-or-process-env helper for run-level credentials,{{ env.FOO }}interpolation, workflow stages (configured bySandbox) all behaved exactly as before. Later secrets-rationalization work moved optional server integration secrets to vault-only lookup.
Risks & Dependencies
| Risk | Mitigation |
|---|---|
| Snapshot semantics surprise: operator changes env after boot, expects the running server to pick it up | Documented behavior. Live rotation is intentionally not supported; restart required. Strategy doc is explicit. |
| Worker list is missing something a workflow stage runner inside Sandbox needs | Worker process itself only does HTTP callbacks — Sandbox handles stage env. Real workflow integration test in Unit 3 verification catches false negatives. |
Existing deployments without server.env AND without env-set secrets fail to start |
Intended behavior; error message names both sources. Per repo policy, accept the breakage. |
Test migration: replacing std::env::set_var calls with EnvSource stubs touches many files |
EnvSource + StubEnv pattern is mechanical; one helper per pattern. Unit 7's clippy enforcement catches stragglers at compile time so nothing slips through. |
| Shared install orchestration regression breaks CLI/web parity | Parity tests in Unit 5 explicitly assert identical persistence behavior across CLI and web paths. Both flows route through the same fabro-install entry points. |
Automatic FABRO_JWT_* removal surprises operators who believed those keys were authoritative |
Strategy doc names the cleanup explicitly. Keys haven't participated in runtime auth since 2026-04-19-003; cleanup is overdue, not novel. Operators upgrading run install once and the cleanup happens silently. |
| Rust 2024 edition migration is a separate effort | Removing set_var is a prerequisite; this work doesn't gate on the edition migration. Workspace-wide clippy enforcement (Unit 7) prevents reintroduction including in tests. |
Documentation / Operational Notes
- Operator-facing change:
fabro server startagainst an empty env AND uninstalled storage now fails fast naming both sources. Document in install/quickstart. - 12-factor PaaS deployments (Railway, Heroku, Fly): unchanged ergonomics — set secrets in platform env, run
fabro server start. Works withoutfabro installhaving run on the platform. - Container/k8s deployments: if secrets are mounted as files (e.g. via projected volume into
<storage>/server.env) or set as env vars (k8s Secret → env), both work. - Cloud object-store (S3 / IRSA / ECS): unchanged — daemon inherits AWS env from parent, object-store layer reads ambient credentials.
- Install while server running: install flows may update
server.envon a running server only when they coordinate restart/handoff via the shared install orchestration (CLI install or web install via/install/finish). Manual edits toserver.envoutside the orchestration still require restart discipline. FABRO_JWT_*removal:FABRO_JWT_PRIVATE_KEY/FABRO_JWT_PUBLIC_KEYare removed from the runtime auth model; SESSION_SECRET is the sole auth master for cookie and JWT derivation. Existing legacy entries are cleaned up automatically on subsequent install flows.- Rotation: edit env (and restart) or edit
server.env(and restart). Live rotation not supported. - Logging: the fail-fast error appears in operator log aggregators. Pair human-readable message with a structured error code (e.g.,
error_code=missing_session_secret) so log searches match without depending on the exact string.
Sources & References
- Related plans:
docs/plans/2026-04-05-server-canonical-secrets-doctor-repo-plan.md— architectural anchordocs/plans/2026-04-19-003-feat-cli-auth-login-plan.md— SESSION_SECRET as HKDF masterdocs/plans/2026-04-18-001-feat-webhook-strategy-plan.md— webhook secret precedentdocs/plans/2026-04-02-001-feat-server-daemon-management-plan.md— origin of daemon/foreground split
- Related commits:
7cb6c65d5— "Remove dev-token minting from server start" (precedent for Unit 4)
- Strategy doc precedent:
docs-internal/logging-strategy.md,docs-internal/events-strategy.md