fix(gateway): boot-seed challenge backends on restart - #93
Conversation
Survive gateway-only restarts without empty in-memory registry / 503s by seeding prism+design from BASE_GATEWAY_BACKENDS on process start.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe gateway now parses backend seed lists, loads them from environment configuration, seeds the registry during startup, and provides Compose defaults. Deployment scripts and runbooks document boot seeding and idempotent reseeding. ChangesBackend boot seeding
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ComposeEnvironment
participant GatewayStartup
participant gw_config
participant Registry
ComposeEnvironment->>gw_config: BASE_GATEWAY_BACKENDS configuration
GatewayStartup->>gw_config: seed_registry_from_env()
gw_config->>gw_config: load and parse backend seeds
gw_config->>Registry: seed(Vec<CreateBackend>)
Registry-->>gw_config: created count
gw_config-->>GatewayStartup: seed result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docker-compose.yml`:
- Around line 96-98: Update the BASE_GATEWAY_BACKENDS interpolation in
docker-compose.yml to use the single-dash default form so an explicitly empty
environment variable is preserved. Keep the existing empty-override claims
unchanged in deploy/scripts/remote-deploy.sh (lines 441-443) and
docs/runbooks/staging-testnet-e2e.md (lines 56-58); those sibling sites require
no direct changes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fd508f06-aa67-4a8e-9755-7e5d6fb0bf24
📒 Files selected for processing (9)
crates/gateway-registry/src/lib.rscrates/gateway/src/gw_config.rscrates/gateway/src/lib.rsdeploy/AGENTS.mddeploy/scripts/register-challenge-backends.shdeploy/scripts/remote-deploy.shdocker-compose.ymldocs/SITE_API.mddocs/runbooks/staging-testnet-e2e.md
| # Durable boot seed for the in-memory challenge registry (survives | ||
| # gateway-only restarts; remote-deploy POST reseed stays idempotent). | ||
| BASE_GATEWAY_BACKENDS: "${BASE_GATEWAY_BACKENDS:-prism=http://prism-challenge:8092,design=http://design-challenge:8093}" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
BASE_GATEWAY_BACKENDS='' docker compose -f docker-compose.yml config |
sed -n '/BASE_GATEWAY_BACKENDS:/,+1p'Repository: BaseIntelligence/base
Length of output: 203
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== candidate files =="
git ls-files | rg '(^docker-compose\.yml$|^deploy/scripts/remote-deploy\.sh$|^docs/runbooks/staging-testnet-e2e\.md$)'
echo
echo "== docker-compose relevant lines =="
nl -ba docker-compose.yml | sed -n '85,105p'
echo
echo "== remote-deploy relevant lines =="
nl -ba deploy/scripts/remote-deploy.sh | sed -n '430,450p'
echo
echo "== staging runbook relevant lines =="
nl -ba docs/runbooks/staging-testnet-e2e.md | sed -n '48,62p'
echo
echo "== Bash expansion probe =="
(set -u; unset BASE_GATEWAY_BACKENDS; echo "unset=${BASE_GATEWAY_BACKENDS:-PROVISIONAL}" "${BASE_GATEWAY_BACKENDS-PROVISIONAL}" | tr ' ' '\n')
(BASE_GATEWAY_BACKENDS=''; set -u; echo "empty=${BASE_GATEWAY_BACKENDS:-PROVISIONAL}" "${BASE_GATEWAY_BACKENDS-PROVISIONAL}" | tr ' ' '\n')Repository: BaseIntelligence/base
Length of output: 346
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for path in ["docker-compose.yml", "deploy/scripts/remote-deploy.sh", "docs/runbooks/staging-testnet-e2e.md"]:
p = Path(path)
lines = p.read_text().splitlines()
print(f"== {path} ==")
if path == "docker-compose.yml":
start, end = 85, 105
elif path == "deploy/scripts/remote-deploy.sh":
start, end = 430, 450
else:
start, end = 48, 62
for i in range(start, min(end, len(lines)) + 1):
print(f"{i}\t{lines[i-1]}")
PY
echo "== Bash expansion probe =="
(set -u; unset BASE_GATEWAY_BACKENDS; echo "unset=${BASE_GATEWAY_BACKENDS:-PROVISIONAL}" "${BASE_GATEWAY_BACKENDS-PROVISIONAL}" | tr ' ' '\n')
(BASE_GATEWAY_BACKENDS=''; set -u; echo "empty=${BASE_GATEWAY_BACKENDS:-PROVISIONAL}" "${BASE_GATEWAY_BACKENDS-PROVISIONAL}" | tr ' ' '\n')Repository: BaseIntelligence/base
Length of output: 3135
Allow an explicit empty backend seed.
Compose treats :- the same for unset and empty variables, so running BASE_GATEWAY_BACKENDS='' docker compose ... still applies the Prism and Design defaults. Use - in the Compose file so the empty override takes effect, then keep the empty-override claims in deploy/scripts/remote-deploy.sh and docs/runbooks/staging-testnet-e2e.md.
📍 Affects 3 files
docker-compose.yml#L96-L98(this comment)deploy/scripts/remote-deploy.sh#L441-L443docs/runbooks/staging-testnet-e2e.md#L56-L58
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docker-compose.yml` around lines 96 - 98, Update the BASE_GATEWAY_BACKENDS
interpolation in docker-compose.yml to use the single-dash default form so an
explicitly empty environment variable is preserved. Keep the existing
empty-override claims unchanged in deploy/scripts/remote-deploy.sh (lines
441-443) and docs/runbooks/staging-testnet-e2e.md (lines 56-58); those sibling
sites require no direct changes.
Prebuilt docker builds COPY challenge-review; without syncing it, remote-deploy --build-from prebuilt fails the image context.
Deploy / verificationRoot cause: in-memory registry; only Fix shipped: Staging (
|
Summary
remote-deploy.sh, so a plain gateway restart left[]and/challenge/*returned503 no healthy backends.BASE_GATEWAY_BACKENDS(compose default:prism+designDocker DNS URLs) on every gateway process start; admin POST reseed stays idempotent.Test plan
cargo test -p gateway-registry --libcargo clippy -p gateway-registry -p gateway --all-targets -- -D warnings./deploy/scripts/assert-compose-matrix.shdocker compose restart gateway, confirmGET /v1/admin/backendslists design+prism and site submissions non-emptySummary by CodeRabbit
New Features
Documentation