feat: production mode with one APP_ENV switch #212
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #212"
general
weight: 0.35
abendrothj
What and why
Closes #42 (P18): production mode. Previously nothing defined a production
build, and dev-only paths (in-memory vault, HS256, unattested or simulated
execution, demo tenant, fixture sources, local-vault frontend) shipped in
release binaries, selected by env vars or a stray
.env. ADR 0009 recordsthe mechanism.
APP_ENV. Onlydevelopmentselects development; unset,blank or unknown means production. It is read from the process env
before
.env, which is loaded only in development(
PlatformConfig::load, with the env and loader injected for tests).PlatformConfig::check_production(service), wrapped byenforce_production, which emits oneservice.start"denied" auditevent so both services refuse identically. It runs first in
platform_api::wiring::build_stateand the newplatform_connectors::startup::build. It is not infrom_source, sotests can build any config. Production refuses to start when:
-
JWT_HS256_SECRETis set-
STORAGE_BUCKETis unset-
TEE_ATTESTATION_REQUIRED=false-
SIM_ATTESTATION_URLorKEY_RELEASE_URLis set-
connector-workeronly: the demo tenant is set, or jobs are fixtures(always, for now)
All reasons are listed at once, by key name only.
devtokenrequires thedevfeature.PlatformConfig::from_env_dev_tool(used bydevstackanddevtoken)sits behind a new
platform-config/devfeature, so release builds can'treach it.
check.shalso clippies the release binaries withoutdev.npm run build:releasefails unlessVITE_VAULT_MODE=http,and fails if
VITE_DEV_JWTorVITE_ADMIN_JWTis set.release.ymlruns it before packaging
frontend/dist.release build has no dev binariesrunwith
APP_ENV=development, so they still test what a non-devbuildrefuses on its own. A new step checks the production-mode refusal.
ARCHITECTURE.md;PROJECT_SCOPE.mddefinition-of-done item 3; threat model A2 row and anew residual risk; README run commands;
CHANGELOG.md;.env.exampleand
docker-compose.simulated-tee.ymlopt into development.Production mode cannot boot yet (expected by the issue) until P28, P51,
P62, P63 and P67 land. Local runs, CI and the simulated TEE use
APP_ENV=development:export APP_ENV=development
cargo run -p platform-api
cargo run -p platform-api --features dev --bin devtoken
Residual risk:
APP_ENVis operator-set, and the in-memory vault,HS256 verifier and demo seed are still compiled into release binaries, so
APP_ENV=developmenton a production host re-enables them. The simulatorand key-release stand-in stay
dev-only. This is recorded in the threatmodel and in ADR 0009's Consequences.
Maintainer decisions (ADR marked Proposed until confirmed):
existing
devfeature as the compile-time layer.FEATURE_ZK_ENABLED=falseis not refused in production.How it was tested
platform-configunit tests: each refusal throughfrom_source; unknownAPP_ENVis production; development accepts dev paths; all reasons arereported together; refusal text never contains values.
.envloading, throughPlatformConfig::loadwith a stand-in loader:-
dotenv_is_not_loaded_in_production: unset,productionandstagingnever load.env, even when it saysAPP_ENV=development.I checked that it fails if the load is made unconditional.
-
dotenv_is_loaded_in_development_and_read_afterplatform-api/tests/startup.rs(viawiring::build_state): each refusal;an unknown
APP_ENVrefuses; development boots with dev paths.platform-connectors/tests/startup.rs: fixture sources, demo tenant anddev settings refused, with an audit event; development builds the
fixture jobs.
platform-api/tests/audit_coverage.rs: a refusal emitsservice.start"denied", no "ok", and never the secret value.
platform-api/tests/research_wiring.rs(from P43) now setsAPP_ENV=development, because its HS256 secret and in-memory vault aredevelopment paths.
release build has no dev binaries:- New step: both release binaries, with no
APP_ENV, exit with theproduction-mode error and a
service.start"denied" event.- The attestation and
KEY_RELEASE_URLsteps still check the build-levelrefusals.
frontend/src/config/release.test.ts: unset,localor unknown vaultmode refused; dev tokens refused without echoing values. Manually checked
that
vite build --mode releaseaborts on each case.Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rsdocs/DATA_POLICY.md)CHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made