Closes#254. First issue of the MVP-0 safety baseline (epic #253).
Why
The audits behind the production-MVP plan found that the scanner degrades quietly when auth configuration is absent:
no KEYCLOAK_URL/KEYCLOAK_REALM → no JWT validation; every request runs as a synthetic dev tenant, and /api/v1/platform/* (tenant export and delete) is fully open;
KEYCLOAK_AUDIENCE="" → validate_aud = false, so any realm token is accepted;
unset TENANT_REGISTRY_URL → entitlements never checked, and nothing checked in their place;
registry unreachable → the scheduler falls back to SCHEDULER_TENANT_IDS, then to the dev tenant, scanning <prefix>_dev with no ladder filter.
Each is a reasonable laptop default and a bad production default, and nothing in the code distinguished the two.
What changes
APP_ENV = dev (default) | staging | production. Everything but dev is hardened.
AgentConfig::validate_deployment (compliance-core) runs at load time and reports every missing setting at once, each with the reason it matters. One corrected deploy instead of five.
Second lock on each door. The dev-tenant injector, permissive CORS, the skip-entitlement path and the open platform endpoints each keep a hardened branch that denies (503 / startup error) rather than widening access, so no future refactor can reintroduce the degraded mode silently.
PLATFORM_ALLOWED_CLIENTS built-in defaults are dev-only — a prod agent no longer accepts a staging service token by default.
Scheduler: where a registry is configured its answer is authoritative; an empty list or a failed call skips the tick.
Dashboard: refuses to start hardened without all five Keycloak variables (a partial config silently served every page unauthenticated), naming the missing ones.
MCP: refuses the stdio transport when hardened — it synthesises a tenant and has no bearer check.
JWKS fetch timeout (5 s): the cache write lock is held across the call, so an unreachable Keycloak previously queued every authenticated request behind it.
AgentConfig gains a Default impl (the loader's dev defaults); the two test constructors use it instead of listing 45 fields.
Behaviour in dev is unchanged: APP_ENV unset means dev.
Follow-up (separate repo, must land together)
orca-platform sets APP_ENV=staging on pruefwerk-{agent,dashboard,mcp}-stage. The stage service file already has every required variable, so hardening it is a one-line change per service — but until it is set, staging keeps running in dev mode.
cargo test -p compliance-core -p compliance-agent -p werkbank-exec -p control-map --lib → 324 + 60 + 27 + 9 pass, including four new tests: APP_ENV parsing (typos rejected), dev requires nothing, a hardened config reports all eight missing variables, a fully configured staging config passes.
cargo test -p compliance-dashboard --features server --no-default-features → 21 pass.
Pre-existing, not from this branch: cargo clippy -p compliance-dashboard reports two manual_checked_ops errors in components/attack_chain/view.rs on newer clippy versions.
Closes #254. First issue of the MVP-0 safety baseline (epic #253).
## Why
The audits behind the production-MVP plan found that the scanner degrades quietly when auth configuration is absent:
- no `KEYCLOAK_URL`/`KEYCLOAK_REALM` → no JWT validation; every request runs as a synthetic `dev` tenant, and `/api/v1/platform/*` (tenant export and delete) is fully open;
- `KEYCLOAK_AUDIENCE=""` → `validate_aud = false`, so any realm token is accepted;
- unset `CORS_ALLOWED_ORIGINS` → `CorsLayer::permissive()`;
- unset `TENANT_REGISTRY_URL` → entitlements never checked, and nothing checked in their place;
- registry unreachable → the scheduler falls back to `SCHEDULER_TENANT_IDS`, then to the `dev` tenant, scanning `<prefix>_dev` with no ladder filter.
Each is a reasonable laptop default and a bad production default, and nothing in the code distinguished the two.
## What changes
`APP_ENV` = `dev` (default) | `staging` | `production`. Everything but `dev` is **hardened**.
- **`AgentConfig::validate_deployment`** (compliance-core) runs at load time and reports *every* missing setting at once, each with the reason it matters. One corrected deploy instead of five.
- **Second lock on each door.** The dev-tenant injector, permissive CORS, the skip-entitlement path and the open platform endpoints each keep a hardened branch that denies (503 / startup error) rather than widening access, so no future refactor can reintroduce the degraded mode silently.
- **`PLATFORM_ALLOWED_CLIENTS` built-in defaults are dev-only** — a prod agent no longer accepts a staging service token by default.
- **Scheduler**: where a registry is configured its answer is authoritative; an empty list or a failed call skips the tick.
- **Dashboard**: refuses to start hardened without all five Keycloak variables (a partial config silently served every page unauthenticated), naming the missing ones.
- **MCP**: refuses the stdio transport when hardened — it synthesises a tenant and has no bearer check.
- **JWKS fetch timeout (5 s)**: the cache write lock is held across the call, so an unreachable Keycloak previously queued every authenticated request behind it.
- `AgentConfig` gains a `Default` impl (the loader's dev defaults); the two test constructors use it instead of listing 45 fields.
Behaviour in dev is unchanged: `APP_ENV` unset means `dev`.
## Follow-up (separate repo, must land together)
`orca-platform` sets `APP_ENV=staging` on `pruefwerk-{agent,dashboard,mcp}-stage`. The stage service file already has every required variable, so hardening it is a one-line change per service — but until it is set, staging keeps running in `dev` mode.
## Verification
- `cargo fmt --all --check` clean.
- `cargo clippy -p compliance-core -p compliance-agent -p compliance-mcp -p werkbank-exec -p control-map -- -D warnings` clean.
- `cargo test -p compliance-core -p compliance-agent -p werkbank-exec -p control-map --lib` → 324 + 60 + 27 + 9 pass, including four new tests: `APP_ENV` parsing (typos rejected), dev requires nothing, a hardened config reports all eight missing variables, a fully configured staging config passes.
- `cargo test -p compliance-dashboard --features server --no-default-features` → 21 pass.
- Pre-existing, not from this branch: `cargo clippy -p compliance-dashboard` reports two `manual_checked_ops` errors in `components/attack_chain/view.rs` on newer clippy versions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
The scanner degraded quietly when auth configuration was absent: no Keycloak
meant no JWT check and a synthetic `dev` tenant for every request, an unset
CORS_ALLOWED_ORIGINS meant permissive CORS, no registry meant entitlements
were never checked, and a registry outage sent the scheduler at `<prefix>_dev`
with no ladder filter. Convenient on a laptop, unacceptable anywhere with
customer data.
`APP_ENV` (dev | staging | production) now decides. Everything but `dev` is
hardened:
- `AgentConfig::validate_deployment` runs at load and lists *every* missing
setting at once (KEYCLOAK_URL/REALM/AUDIENCE, CORS_ALLOWED_ORIGINS,
TENANT_REGISTRY_URL + client id/secret, PLATFORM_ALLOWED_CLIENTS), so one
corrected deploy is enough.
- The dev-tenant injector, the permissive-CORS fallback, the skip-entitlement
path and the open platform endpoints are all unreachable when hardened —
each keeps a second check that denies rather than widens access.
- The built-in PLATFORM_ALLOWED_CLIENTS defaults apply in dev only, so a prod
agent never accepts a staging service token.
- The scheduler treats the registry as authoritative: an empty list or a failed
call skips the tick.
- The dashboard refuses to start hardened without its five Keycloak variables
(a partial config silently served every page), and the MCP server refuses
stdio, whose synthetic tenant has no bearer check.
- The JWKS fetch gets a 5 s timeout; it holds the cache write lock, so an
unreachable Keycloak used to queue every authenticated request behind it.
`AgentConfig` gains a `Default` impl with the loader's dev defaults, which the
two test constructors now use instead of listing 45 fields.
First issue of the MVP-0 safety baseline; part of #253.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
`cargo audit` in CI started failing on every branch: RUSTSEC-2026-0285 was
published on 2026-09-14 against rustls ≤0.23.44 (TLS 1.3 handshake messages
accepted across encryption-level boundaries, medium). rustls is a transitive
dependency through reqwest's rustls-tls, so this is a lockfile-only bump to
the advisory's fixed version, pulling rustls-webpki 0.103.15 with it.
Unrelated to the fail-closed work in this branch — it is here so the branch
can go green and merge.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #254. First issue of the MVP-0 safety baseline (epic #253).
Why
The audits behind the production-MVP plan found that the scanner degrades quietly when auth configuration is absent:
KEYCLOAK_URL/KEYCLOAK_REALM→ no JWT validation; every request runs as a syntheticdevtenant, and/api/v1/platform/*(tenant export and delete) is fully open;KEYCLOAK_AUDIENCE=""→validate_aud = false, so any realm token is accepted;CORS_ALLOWED_ORIGINS→CorsLayer::permissive();TENANT_REGISTRY_URL→ entitlements never checked, and nothing checked in their place;SCHEDULER_TENANT_IDS, then to thedevtenant, scanning<prefix>_devwith no ladder filter.Each is a reasonable laptop default and a bad production default, and nothing in the code distinguished the two.
What changes
APP_ENV=dev(default) |staging|production. Everything butdevis hardened.AgentConfig::validate_deployment(compliance-core) runs at load time and reports every missing setting at once, each with the reason it matters. One corrected deploy instead of five.PLATFORM_ALLOWED_CLIENTSbuilt-in defaults are dev-only — a prod agent no longer accepts a staging service token by default.AgentConfiggains aDefaultimpl (the loader's dev defaults); the two test constructors use it instead of listing 45 fields.Behaviour in dev is unchanged:
APP_ENVunset meansdev.Follow-up (separate repo, must land together)
orca-platformsetsAPP_ENV=stagingonpruefwerk-{agent,dashboard,mcp}-stage. The stage service file already has every required variable, so hardening it is a one-line change per service — but until it is set, staging keeps running indevmode.Verification
cargo fmt --all --checkclean.cargo clippy -p compliance-core -p compliance-agent -p compliance-mcp -p werkbank-exec -p control-map -- -D warningsclean.cargo test -p compliance-core -p compliance-agent -p werkbank-exec -p control-map --lib→ 324 + 60 + 27 + 9 pass, including four new tests:APP_ENVparsing (typos rejected), dev requires nothing, a hardened config reports all eight missing variables, a fully configured staging config passes.cargo test -p compliance-dashboard --features server --no-default-features→ 21 pass.cargo clippy -p compliance-dashboardreports twomanual_checked_opserrors incomponents/attack_chain/view.rson newer clippy versions.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p