From f28812f3eb978087ec93a0f5f52f71e0d3483423 Mon Sep 17 00:00:00 2001 From: Anindra Date: Fri, 20 Nov 2026 22:36:00 +0530 Subject: [PATCH 1/6] docs(deploy): gateway deploys on tags, never on pushes or PRs Dokploy's trigger for the compose service is now On Tag. A release tag is the only thing that restarts production; Develop pushes, pull requests and Dependabot branches do not. The compose keeps building from the tagged source instead of pulling :latest, because both webhooks fire at the same moment and a :latest pull would race the image build and could deploy the previous release. --- deploy/dokploy/README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/deploy/dokploy/README.md b/deploy/dokploy/README.md index 6969c97..4448d6f 100644 --- a/deploy/dokploy/README.md +++ b/deploy/dokploy/README.md @@ -18,7 +18,10 @@ database. The console is always a plain Application. 1. Dokploy → **Create → Compose**. 2. Source: GitHub → `an1ndra/path`, branch `main`. 3. Compose path: `deploy/dokploy/compose.yml`. -4. **Environment** (the compose file references all of these): +4. **Trigger Type: On Tag**, with auto-deploy enabled. The gateway is a production + service; a pull request or a push to `Develop` must not restart it. A release tag + (`v0.2.3`) is the only thing that deploys — see "When it deploys" below. +5. **Environment** (the compose file references all of these): ```bash POSTGRES_PASSWORD= @@ -27,10 +30,29 @@ GATEWAY_ADMIN_TOKEN= # only for token auth; ignore wi GATEWAY_CORS_ORIGINS=https://admin.example.com # omit if same hostname as the console ``` -5. Domain: point `gw.example.com` at port **8080**, enable HTTPS. -6. Deploy. First boot logs `Gateway ready. Admin API: enabled` and, if `-P release` was +6. Domain: point `gw.example.com` at port **8080**, enable HTTPS. +7. Deploy. First boot logs `Gateway ready. Admin API: enabled` and, if `-P release` was used, seeds four providers. +### When it deploys + +Dokploy is set to **On Tag**, not **On Push**. The release flow is: + +1. `Develop` is merged into `main` through a pull request (the required checks run there). +2. A `vX.Y.Z` tag is pushed on the merge commit. +3. The tag starts the GitHub release workflow (image scan, promotion to GHCR, release + notes) and the Dokploy webhook (rebuild from that tag and restart). + +Pushes to `Develop`, pull requests and Dependabot branches therefore never touch +production; only a tag does. If a deploy should be skipped for a tag, disable auto-deploy +before pushing it. + +The compose builds from the tagged source (`build: context: ../..`) rather than pulling +`:latest`. That is deliberate: both webhooks fire at the same moment, so a `:latest` pull +would race the image build and could deploy the previous release. Building the tagged +commit cannot race and guarantees the running code matches the tag. The GHCR image remains +the artifact to run elsewhere (Kubernetes, another host) and the one Trivy gates. + ### Application route (external Postgres) Create → **Application** → repository `an1ndra/path`, build type **Dockerfile**, port From 5999472259b15522cdf2bb5791a540c6f7714463 Mon Sep 17 00:00:00 2001 From: Anindra Date: Fri, 20 Nov 2026 23:53:29 +0530 Subject: [PATCH 2/6] docs(admin-ui): the console now separates configuration from settings --- docs/ADMIN-UI.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/ADMIN-UI.md b/docs/ADMIN-UI.md index d5816dd..4c82f8c 100644 --- a/docs/ADMIN-UI.md +++ b/docs/ADMIN-UI.md @@ -8,8 +8,9 @@ The admin console lives in its own repository, [an1ndra/path-admin](https://gith Read and write against this API: dashboard (spend, cache, latency, provider circuits, top models, recent failures), providers (create/edit with a provider API key, probe, delete), -routes (create, enable/disable, delete), client keys (create with budgets and allowlists, -top up, revoke). +routes (add a model, enable/disable, delete), client keys (create with budgets and +allowlists, top up, revoke), **configuration** (the gateway switches, alert email and the +daily digest) and **settings** (the session: identity, scopes, token, sign out). ## Auth From 7fe726d9dae3519e3574276ae2c74897733d72e6 Mon Sep 17 00:00:00 2001 From: Anindra Date: Mon, 23 Nov 2026 00:05:21 +0530 Subject: [PATCH 3/6] fix(seed): no example catalogue on a real deployment GATEWAY_SEED_DEFAULTS defaulted to true, so a fresh gateway showed four providers it had no credentials for plus a starter route table in the admin console. It also recreated any missing example provider by slug on every boot, so deleting one in the console brought it back after a restart. Seeding is now off unless GATEWAY_SEED_DEFAULTS=true, and it only fills a completely empty catalogue, which makes a delete stick. The quick start, the configuration reference and the operations guide describe how to remove the examples from a database that already has them; tests that assert on the example catalogue opt in explicitly. --- .env.example | 4 +- README.md | 11 +++- docs/CONFIGURATION.md | 45 ++++++++++--- docs/OPERATIONS.md | 30 +++++++++ .../path/config/GatewayProperties.java | 7 ++- .../com/anindra/path/seed/DataSeeder.java | 30 +++++---- .../src/main/resources/application.yml | 7 ++- .../java/com/anindra/path/GatewayApiTest.java | 1 + .../com/anindra/path/PublicModelsTest.java | 1 + .../anindra/path/admin/AliasServiceTest.java | 1 + .../com/anindra/path/gateway/RoutingTest.java | 1 + .../path/seed/SeedNoResurrectionTest.java | 63 +++++++++++++++++++ 12 files changed, 171 insertions(+), 30 deletions(-) create mode 100644 path-gateway/src/test/java/com/anindra/path/seed/SeedNoResurrectionTest.java diff --git a/.env.example b/.env.example index 5d81f7e..2bf3066 100644 --- a/.env.example +++ b/.env.example @@ -16,7 +16,9 @@ GEMINI_API_KEY= # Optional tuning GATEWAY_PUBLIC_MODELS=true GATEWAY_CORS_ORIGINS=* -GATEWAY_BOOTSTRAP_DEMO_KEY=true +# No demo key and no example providers/routes on a real deployment. +GATEWAY_BOOTSTRAP_DEMO_KEY=false +GATEWAY_SEED_DEFAULTS=false GATEWAY_DEFAULT_RPM=120 # GATEWAY_DEFAULT_CREDIT_USD=25 diff --git a/README.md b/README.md index 1d72be4..502ef8a 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,12 @@ export GATEWAY_ADMIN_TOKEN=pick-something-long ./mvnw -pl path-gateway spring-boot:run ``` -First boot seeds four providers and a starter route table. To also mint a demo key -(off by default, never in the `prod` profile), start with +First boot does **not** create providers or routes: a real deployment configures its own, +so the console starts empty instead of showing a catalogue nobody owns. For a 60-second +tour against example providers and routes, start with `GATEWAY_SEED_DEFAULTS=true`; it +only fills an empty database, and anything you delete stays deleted. + +To also mint a demo key (off by default, never in the `prod` profile), add `GATEWAY_BOOTSTRAP_DEMO_KEY=true`; it is printed once in the log: ``` @@ -82,6 +86,9 @@ curl -s http://localhost:8080/v1/chat/completions \ -d '{"model":"auto-fast","messages":[{"role":"user","content":"Say hi"}]}' ``` +`auto-fast` is one of the example routes, so the call above needs `GATEWAY_SEED_DEFAULTS=true` +on that boot. With real providers, use the model ids you created in the console. + Any OpenAI SDK works — point `base_url` at `http://localhost:8080/v1`: ```python diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 41075d4..2abf486 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -20,7 +20,7 @@ except the provider credentials you actually use. | Variable | Default | Meaning | |---|---|---| | `GATEWAY_BOOTSTRAP_DEMO_KEY` | `false` | create a demo key when the table is empty (ignored in `prod`) | -| `GATEWAY_SEED_DEFAULTS` | `true` | seed the example provider/route catalogue on boot; set `false` on a real deployment | +| `GATEWAY_SEED_DEFAULTS` | `false` | seed the example provider/route catalogue into an empty database (demo instances only) | | `GATEWAY_DEFAULT_RPM` | `120` | default requests/minute for new keys | | `GATEWAY_DEFAULT_CREDIT_USD` | unlimited | default credit limit for new keys | | `GATEWAY_DEFAULT_MAX_CONCURRENT` | `8` | in-flight requests per key (0 = unlimited) | @@ -97,7 +97,7 @@ way, so they are correct in a cluster regardless of this setting. | Variable | Meaning | |---|---| -| `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` / `GROQ_API_KEY` / `GEMINI_API_KEY` | credentials for the seeded providers | +| `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` / `GROQ_API_KEY` / `GEMINI_API_KEY` | credentials for the providers with those slugs | | `GATEWAY_UPSTREAM__KEY` | credential for any other provider slug (e.g. `GATEWAY_UPSTREAM_TOGETHER_KEY`) | Resolution order: **database → `application.yml` → environment**. A key stored through @@ -105,25 +105,54 @@ the admin API silently wins over the environment, which makes rotation possible a restart. Credentials in the database are AES-GCM encrypted with a key from `GATEWAY_MASTER_KEY` or the generated `./data/master.key` (0600). -A provider row must exist before its environment variable is read; `openai`, `anthropic`, -`groq` and `gemini` are seeded. +A provider row must exist before its environment variable is read. Nothing is seeded by +default any more, so create the provider once (console or `POST /admin/providers`) and the +well-known variable for that slug takes over on the next boot. The four conventional slugs +are `openai`, `anthropic`, `groq` and `gemini`; anything else uses +`GATEWAY_UPSTREAM__KEY`. + +To see the example catalogue on a throwaway instance, set `GATEWAY_SEED_DEFAULTS=true`. +It only fills an empty catalogue, and a provider deleted later stays deleted. + +### Common upstreams + +Ready-made values for the providers most people add first. Everything here is an +`OPENAI`-type row except Gemini native and Vertex: + +| Provider | Slug | Type | Base URL | +|---|---|---|---| +| ChatGPT / OpenAI | `openai` | `OPENAI` | `https://api.openai.com/v1` | +| Gemini (OpenAI-compatible) | `gemini` | `OPENAI` | `https://generativelanguage.googleapis.com/v1beta/openai` | +| Gemini native (AI Studio) | `gemini-native` | `GEMINI` | `https://generativelanguage.googleapis.com/v1beta` | +| OpenCode | `opencode` | `OPENAI` | `https://opencode.ai/inference/openai/v1` | +| OpenCode Go | `opencode-go` | `OPENAI` | `https://opencode.ai/inference/go/openai/v1` | +| Anthropic | `anthropic` | `ANTHROPIC` | `https://api.anthropic.com/v1` | +| Groq | `groq` | `OPENAI` | `https://api.groq.com/openai/v1` | + +For a slug not in this table the credential variable is `GATEWAY_UPSTREAM__KEY` +(OpenCode uses `OPENCODE_API_KEY` by convention, so set +`GATEWAY_UPSTREAM_OPENCODE_KEY` or paste the key into the console). + +Each route needs the upstream model id and a price per million tokens; a `0.00` price +records usage but never charges it. `POST /admin/models/sync` imports a provider's list +and prices only ids in its built-in table, so check anything it leaves at `0.00`. ### Gemini -Gemini is seeded as an `OPENAI`-type provider pointing at Google's -OpenAI-compatible endpoint: +Google exposes an OpenAI-compatible endpoint, so a plain `OPENAI`-type provider works: ``` base_url = https://generativelanguage.googleapis.com/v1beta/openai ``` -Set `GEMINI_API_KEY` and add a route per model you want to expose; the upstream id is +Create that provider (console → Providers → Add, or `POST /admin/providers`), set +`GEMINI_API_KEY`, and add a route per model you want to expose; the upstream id is whatever Gemini calls it (`gemini-2.5-flash`, `gemini-3-flash`, …): ```bash A='X-Admin-Token: ...' curl -s -X POST localhost:8080/admin/routes -H "$A" -H 'Content-Type: application/json' \ - -d '{"public_model_id":"gemini-2.5-flash","provider_id":4, + -d '{"public_model_id":"gemini-2.5-flash","provider_id":, "upstream_model_id":"gemini-2.5-flash", "input_price_per_million":0.30,"output_price_per_million":2.50, "priority":10}' diff --git a/docs/OPERATIONS.md b/docs/OPERATIONS.md index 9c32522..6295c5d 100644 --- a/docs/OPERATIONS.md +++ b/docs/OPERATIONS.md @@ -33,6 +33,36 @@ curl -s -X POST localhost:8080/admin/keys/1/revoke -H "$A" curl -s -X POST localhost:8080/admin/models/sync -H "$A" ``` +## Removing the example catalogue + +`GATEWAY_SEED_DEFAULTS=true` creates four providers (`openai`, `anthropic`, `groq`, +`gemini`), a starter route table and, with `GATEWAY_BOOTSTRAP_DEMO_KEY`, a `demo-local` +key. They carry no credentials, so they show up in the console as rows you cannot call. +Deleting them in the console is enough — the seeder no longer recreates a deleted provider +on the next boot. From a shell: + +```bash +A='X-Admin-Token: pick-something-long' + +# what is there, and whether the credential actually resolves +curl -s localhost:8080/admin/providers -H "$A" \ + | jq -r '.[] | [.id, .slug, (.credential_configured|tostring)] | @tsv' + +# delete each example provider; its routes cascade with it +for id in 1 2 3 4; do + curl -s -X DELETE "localhost:8080/admin/providers/$id" -H "$A"; echo +done + +# revoke the demo key if it was created +curl -s localhost:8080/admin/keys -H "$A" \ + | jq -r '.[] | select(.name == "demo-local") | .id' \ + | xargs -r -I{} curl -s -X POST "localhost:8080/admin/keys/{}/revoke" -H "$A" +``` + +Then set `GATEWAY_SEED_DEFAULTS=false` in the deployment and restart, so a fresh database +is not filled again. Usage rows already written by the examples are history, not +configuration; leave them or delete them with the retention job. + ## Projects and admin tokens Projects group keys and usage. Admin tokens carry `read` or `read,write`; the bootstrap diff --git a/path-gateway/src/main/java/com/anindra/path/config/GatewayProperties.java b/path-gateway/src/main/java/com/anindra/path/config/GatewayProperties.java index ec2a109..e46debc 100644 --- a/path-gateway/src/main/java/com/anindra/path/config/GatewayProperties.java +++ b/path-gateway/src/main/java/com/anindra/path/config/GatewayProperties.java @@ -45,10 +45,11 @@ public class GatewayProperties { private boolean bootstrapDemoKey = false; /** - * Seed the example provider/route catalogue on boot. A real deployment wants this off: - * otherwise four providers nobody configured reappear on every restart. + * Seed the example provider/route catalogue on boot. Off by default: a real deployment + * configures its own providers, and the examples would otherwise reappear on every + * restart. Only a throwaway demo instance sets this. */ - private boolean seedDefaults = true; + private boolean seedDefaults = false; private int defaultRpmLimit = 120; diff --git a/path-gateway/src/main/java/com/anindra/path/seed/DataSeeder.java b/path-gateway/src/main/java/com/anindra/path/seed/DataSeeder.java index 29ee9bc..e446378 100644 --- a/path-gateway/src/main/java/com/anindra/path/seed/DataSeeder.java +++ b/path-gateway/src/main/java/com/anindra/path/seed/DataSeeder.java @@ -40,11 +40,15 @@ public class DataSeeder implements ApplicationRunner { @Override @Transactional public void run(ApplicationArguments args) { - boolean fresh = providers.count() == 0; + // Seed only into a completely empty catalogue. Creating providers by slug on every + // boot would resurrect one an operator deleted on purpose, which is exactly the + // "dummy data keeps coming back" complaint. + boolean fresh = providers.count() == 0 && routes.count() == 0; if (props.isSeedDefaults()) { - Map bySlug = ensureProviders(); - if (fresh && routes.count() == 0) { - seedRoutes(bySlug); + if (fresh) { + seedRoutes(createExampleProviders()); + } else { + log.info("Gateway already has providers/routes: not adding the example catalogue."); } } else { log.info("Gateway seed-defaults is off: not creating the example provider/route catalogue."); @@ -71,17 +75,17 @@ public void run(ApplicationArguments args) { : "enabled (send X-Admin-Token)"); } - private Map ensureProviders() { + private Map createExampleProviders() { Map bySlug = new LinkedHashMap<>(); - bySlug.put("openai", providers.findBySlug("openai").orElseGet(() -> providers.save( - new Provider("openai", "OpenAI", ProviderType.OPENAI, "https://api.openai.com/v1")))); - bySlug.put("anthropic", providers.findBySlug("anthropic").orElseGet(() -> providers.save( - new Provider("anthropic", "Anthropic", ProviderType.ANTHROPIC, "https://api.anthropic.com/v1")))); - bySlug.put("groq", providers.findBySlug("groq").orElseGet(() -> providers.save( - new Provider("groq", "Groq", ProviderType.OPENAI, "https://api.groq.com/openai/v1")))); - bySlug.put("gemini", providers.findBySlug("gemini").orElseGet(() -> providers.save( + bySlug.put("openai", providers.save( + new Provider("openai", "OpenAI", ProviderType.OPENAI, "https://api.openai.com/v1"))); + bySlug.put("anthropic", providers.save( + new Provider("anthropic", "Anthropic", ProviderType.ANTHROPIC, "https://api.anthropic.com/v1"))); + bySlug.put("groq", providers.save( + new Provider("groq", "Groq", ProviderType.OPENAI, "https://api.groq.com/openai/v1"))); + bySlug.put("gemini", providers.save( new Provider("gemini", "Google Gemini", ProviderType.OPENAI, - "https://generativelanguage.googleapis.com/v1beta/openai")))); + "https://generativelanguage.googleapis.com/v1beta/openai"))); return bySlug; } diff --git a/path-gateway/src/main/resources/application.yml b/path-gateway/src/main/resources/application.yml index 25bf5e1..fcaf092 100644 --- a/path-gateway/src/main/resources/application.yml +++ b/path-gateway/src/main/resources/application.yml @@ -56,9 +56,10 @@ gateway: master-key: ${GATEWAY_MASTER_KEY:} master-key-path: ${GATEWAY_MASTER_KEY_PATH:./data/master.key} bootstrap-demo-key: ${GATEWAY_BOOTSTRAP_DEMO_KEY:false} - # Seed the example provider/route catalogue on boot. Turn off for a real deployment, - # otherwise four providers you never configured appear in the console on every start. - seed-defaults: ${GATEWAY_SEED_DEFAULTS:true} + # Seed the example provider/route catalogue on boot. Off by default: a real deployment + # configures its own providers, and the examples would otherwise reappear in the console + # after a restart. Set true only for a throwaway demo instance. + seed-defaults: ${GATEWAY_SEED_DEFAULTS:false} default-rpm-limit: ${GATEWAY_DEFAULT_RPM:120} default-credit-limit-usd: ${GATEWAY_DEFAULT_CREDIT_USD:} default-max-concurrent: ${GATEWAY_DEFAULT_MAX_CONCURRENT:8} diff --git a/path-gateway/src/test/java/com/anindra/path/GatewayApiTest.java b/path-gateway/src/test/java/com/anindra/path/GatewayApiTest.java index 5ab9d41..824a637 100644 --- a/path-gateway/src/test/java/com/anindra/path/GatewayApiTest.java +++ b/path-gateway/src/test/java/com/anindra/path/GatewayApiTest.java @@ -21,6 +21,7 @@ "spring.jpa.hibernate.ddl-auto=validate", "gateway.admin-token=test-admin", "gateway.bootstrap-demo-key=false", + "gateway.seed-defaults=true", "gateway.master-key-path=./target/test-master.key" }) @AutoConfigureMockMvc diff --git a/path-gateway/src/test/java/com/anindra/path/PublicModelsTest.java b/path-gateway/src/test/java/com/anindra/path/PublicModelsTest.java index 1730027..a65c3fe 100644 --- a/path-gateway/src/test/java/com/anindra/path/PublicModelsTest.java +++ b/path-gateway/src/test/java/com/anindra/path/PublicModelsTest.java @@ -20,6 +20,7 @@ "spring.jpa.hibernate.ddl-auto=validate", "gateway.admin-token=test-admin", "gateway.bootstrap-demo-key=false", + "gateway.seed-defaults=true", "gateway.master-key-path=./target/test-master.key", "gateway.public-models=true" }) diff --git a/path-gateway/src/test/java/com/anindra/path/admin/AliasServiceTest.java b/path-gateway/src/test/java/com/anindra/path/admin/AliasServiceTest.java index 153af49..cbb4f84 100644 --- a/path-gateway/src/test/java/com/anindra/path/admin/AliasServiceTest.java +++ b/path-gateway/src/test/java/com/anindra/path/admin/AliasServiceTest.java @@ -20,6 +20,7 @@ "spring.datasource.url=jdbc:h2:mem:aliastest;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", "spring.jpa.hibernate.ddl-auto=validate", "gateway.bootstrap-demo-key=false", + "gateway.seed-defaults=true", "gateway.master-key-path=./target/test-master.key" }) class AliasServiceTest { diff --git a/path-gateway/src/test/java/com/anindra/path/gateway/RoutingTest.java b/path-gateway/src/test/java/com/anindra/path/gateway/RoutingTest.java index ec26243..abce8cf 100644 --- a/path-gateway/src/test/java/com/anindra/path/gateway/RoutingTest.java +++ b/path-gateway/src/test/java/com/anindra/path/gateway/RoutingTest.java @@ -16,6 +16,7 @@ "spring.datasource.url=jdbc:h2:mem:routingtest;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", "spring.jpa.hibernate.ddl-auto=validate", "gateway.bootstrap-demo-key=false", + "gateway.seed-defaults=true", "gateway.master-key-path=./target/test-master.key" }) class RoutingTest { diff --git a/path-gateway/src/test/java/com/anindra/path/seed/SeedNoResurrectionTest.java b/path-gateway/src/test/java/com/anindra/path/seed/SeedNoResurrectionTest.java new file mode 100644 index 0000000..02d8433 --- /dev/null +++ b/path-gateway/src/test/java/com/anindra/path/seed/SeedNoResurrectionTest.java @@ -0,0 +1,63 @@ +package com.anindra.path.seed; + +import com.anindra.path.domain.Provider; +import com.anindra.path.repo.ModelRouteRepository; +import com.anindra.path.repo.ProviderRepository; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Deleting an example provider in the console must stick. The seeder used to recreate any + * missing provider by slug on every boot, so the "dummy" catalogue came back after a + * restart even when an operator had removed it. + */ +@SpringBootTest(properties = { + "spring.datasource.url=jdbc:h2:mem:seedtest;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", + "spring.jpa.hibernate.ddl-auto=validate", + "gateway.admin-token=test-admin", + "gateway.bootstrap-demo-key=false", + "gateway.master-key-path=./target/test-master.key", + "gateway.seed-defaults=true" +}) +@Transactional +class SeedNoResurrectionTest { + + @Autowired + private DataSeeder seeder; + + @Autowired + private ProviderRepository providers; + + @Autowired + private ModelRouteRepository routes; + + @Test + void aDeletedExampleProviderIsNotRecreatedOnTheNextBoot() { + Provider openai = providers.findBySlug("openai").orElseThrow(); + + routes.deleteByProviderId(openai.getId()); + providers.deleteById(openai.getId()); + + seeder.run(null); + + assertThat(providers.findBySlug("openai")).isEmpty(); + assertThat(routes.findByProviderId(openai.getId())).isEmpty(); + // The other examples are untouched, and the catalogue is not duplicated. + assertThat(providers.findBySlug("anthropic")).isPresent(); + } + + @Test + void seedingIsIdempotentAcrossRuns() { + long providerCount = providers.count(); + long routeCount = routes.count(); + + seeder.run(null); + + assertThat(providers.count()).isEqualTo(providerCount); + assertThat(routes.count()).isEqualTo(routeCount); + } +} From 9f8c0d61d418353a400eaef62944483d22198eb2 Mon Sep 17 00:00:00 2001 From: Anindra Date: Mon, 23 Nov 2026 00:10:56 +0530 Subject: [PATCH 4/6] fix(deploy): pass GATEWAY_SEED_DEFAULTS to the gateway container Docker Compose only puts a variable into the container when the compose file interpolates it, so the line in Dokploy's Environment editor never reached the process and the seeder kept inserting four providers nobody had configured. Pass it with a false default. --- deploy/dokploy/README.md | 7 +++++-- deploy/dokploy/compose.yml | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/deploy/dokploy/README.md b/deploy/dokploy/README.md index 4448d6f..7a4f00d 100644 --- a/deploy/dokploy/README.md +++ b/deploy/dokploy/README.md @@ -30,9 +30,12 @@ GATEWAY_ADMIN_TOKEN= # only for token auth; ignore wi GATEWAY_CORS_ORIGINS=https://admin.example.com # omit if same hostname as the console ``` +The compose file passes `GATEWAY_SEED_DEFAULTS` through with a `false` default, so a fresh +database starts with an empty catalogue and the console is where providers and routes are +added. Set it to `true` only on a demo instance. + 6. Domain: point `gw.example.com` at port **8080**, enable HTTPS. -7. Deploy. First boot logs `Gateway ready. Admin API: enabled` and, if `-P release` was - used, seeds four providers. +7. Deploy. First boot logs `Gateway ready. Admin API: enabled`. ### When it deploys diff --git a/deploy/dokploy/compose.yml b/deploy/dokploy/compose.yml index d37417c..476dc53 100644 --- a/deploy/dokploy/compose.yml +++ b/deploy/dokploy/compose.yml @@ -66,6 +66,9 @@ services: SPRING_MAIL_USERNAME: ${SPRING_MAIL_USERNAME:-} SPRING_MAIL_PASSWORD: ${SPRING_MAIL_PASSWORD:-} GATEWAY_API_DOCS: "false" + # An empty catalogue stays empty: providers and routes come from the console, not + # from the example rows the seeder would otherwise insert on first boot. + GATEWAY_SEED_DEFAULTS: ${GATEWAY_SEED_DEFAULTS:-false} # Provider keys are added through the console (Settings → Providers) or as # OPENAI_API_KEY / ANTHROPIC_API_KEY / GROQ_API_KEY / GEMINI_API_KEY. ports: From e67f8ab0037acd98125e0946938abfbe3abed507 Mon Sep 17 00:00:00 2001 From: Anindra Date: Mon, 23 Nov 2026 00:14:16 +0530 Subject: [PATCH 5/6] release: v0.2.4 Bumps the reactor to 0.2.4 and adds the release notes. Seeding the example provider/route catalogue is now opt-in and only fills an empty catalogue, so a real deployment starts with the providers it actually configured. --- CHANGELOG.md | 1 + changelog/v0.2.4.md | 45 ++++++++++++++++++++++++++++++++++++++++ deploy/dokploy/README.md | 2 +- docs/SPRING-AI.md | 2 +- path-gateway/pom.xml | 2 +- path-spring-ai/pom.xml | 2 +- pom.xml | 2 +- 7 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 changelog/v0.2.4.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b109d9..36230e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ verbatim as the body of the matching GitHub release. | Version | Date | Notes | |---|---|---| +| v0.2.4 | 2026-11-23 | [changelog/v0.2.4.md](changelog/v0.2.4.md) | | v0.2.3 | 2026-11-20 | [changelog/v0.2.3.md](changelog/v0.2.3.md) | | v0.2.2 | 2026-11-17 | [changelog/v0.2.2.md](changelog/v0.2.2.md) | | v0.2.1 | 2026-11-17 | [changelog/v0.2.1.md](changelog/v0.2.1.md) | diff --git a/changelog/v0.2.4.md b/changelog/v0.2.4.md new file mode 100644 index 0000000..4d61b52 --- /dev/null +++ b/changelog/v0.2.4.md @@ -0,0 +1,45 @@ +# v0.2.4 + +A small release about first-run honesty: a real deployment no longer starts with a +catalogue of providers it has no credentials for. + +Until now `GATEWAY_SEED_DEFAULTS` defaulted to `true`, so the first boot of an empty +database created `openai`, `anthropic`, `groq` and `gemini` plus a starter route table. +Those rows carried no keys, so every call through them failed, and the console showed +them as if they were configured. Deleting them did not help for long: the seeder looked +each provider up by slug on every boot and recreated any that were missing. + +Nothing changes for an existing database that already has providers and routes. To clear +the examples out of one that has them, follow +[`docs/OPERATIONS.md`](../docs/OPERATIONS.md#removing-the-example-catalogue). + +## Changed + +- **Seeding is off by default.** `GATEWAY_SEED_DEFAULTS` now defaults to `false`, and + `GatewayProperties.seedDefaults` matches it, so a fresh gateway has an empty catalogue + and the console is where providers, routes and keys are added. Set the variable to + `true` for a throwaway demo instance. +- **The example catalogue only fills an empty catalogue.** The seeder requires both the + provider and the route table to be empty, and it no longer looks providers up by slug, + so it cannot resurrect one that was deleted. +- **`deploy/dokploy/compose.yml` passes `GATEWAY_SEED_DEFAULTS` through** with a `false` + default. Docker Compose only injects a variable the compose file interpolates, so the + line in Dokploy's Environment editor never reached the process and the seeder kept + running with its built-in default. +- `README.md`, `docs/CONFIGURATION.md`, `docs/OPERATIONS.md` and + `deploy/dokploy/README.md` describe the new default, the ready-made base URLs for + ChatGPT, Gemini, OpenCode and the other common upstreams, and how to delete the example + rows from a database that already has them. + +## Fixed + +- A provider deleted in the console stays deleted across restarts. Previously it came back + on the next boot whenever the seed flag was on. + +## Tests + +- New `SeedNoResurrectionTest`: deleting an example provider and running the seeder again + leaves it deleted, and a second seed run does not duplicate rows. +- The suites that assert on the example catalogue (`GatewayApiTest`, `AliasServiceTest`, + `RoutingTest`, `PublicModelsTest`) now opt in with `gateway.seed-defaults=true` instead + of relying on the default. diff --git a/deploy/dokploy/README.md b/deploy/dokploy/README.md index 7a4f00d..cc0ed3e 100644 --- a/deploy/dokploy/README.md +++ b/deploy/dokploy/README.md @@ -20,7 +20,7 @@ database. The console is always a plain Application. 3. Compose path: `deploy/dokploy/compose.yml`. 4. **Trigger Type: On Tag**, with auto-deploy enabled. The gateway is a production service; a pull request or a push to `Develop` must not restart it. A release tag - (`v0.2.3`) is the only thing that deploys — see "When it deploys" below. + (`v0.2.4`) is the only thing that deploys — see "When it deploys" below. 5. **Environment** (the compose file references all of these): ```bash diff --git a/docs/SPRING-AI.md b/docs/SPRING-AI.md index 5006a43..b51680e 100644 --- a/docs/SPRING-AI.md +++ b/docs/SPRING-AI.md @@ -13,7 +13,7 @@ on Spring AI; the gateway never depends on it. io.github.an1ndra path-spring-ai - 0.2.3 + 0.2.4 ``` diff --git a/path-gateway/pom.xml b/path-gateway/pom.xml index fe8c2a8..0dce331 100644 --- a/path-gateway/pom.xml +++ b/path-gateway/pom.xml @@ -7,7 +7,7 @@ io.github.an1ndra path-parent - 0.2.3 + 0.2.4 ../pom.xml diff --git a/path-spring-ai/pom.xml b/path-spring-ai/pom.xml index 5577b91..37cc133 100644 --- a/path-spring-ai/pom.xml +++ b/path-spring-ai/pom.xml @@ -7,7 +7,7 @@ io.github.an1ndra path-parent - 0.2.3 + 0.2.4 ../pom.xml diff --git a/pom.xml b/pom.xml index 1c0f0f4..a5f296d 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ io.github.an1ndra path-parent - 0.2.3 + 0.2.4 pom path-parent Build parent for Path, the provider-agnostic LLM gateway, and its Spring AI adapter From 67fd265b9003855a1f8e49b4ecea3c3853ce33df Mon Sep 17 00:00:00 2001 From: Anindra Date: Mon, 23 Nov 2026 00:18:15 +0530 Subject: [PATCH 6/6] ci: the smoke suite needs the example catalogue The end-to-end job calls the seeded models by name (gpt-4o-mini, claude-3.5-haiku, auto-fast), so with seeding off by default it failed on its first admin lookup. Set GATEWAY_SEED_DEFAULTS=true for that job only and document the requirement next to the local command. --- .github/workflows/ci.yml | 1 + AGENTS.md | 2 +- docs/TESTING.md | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4eaaba..da83d17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,6 +103,7 @@ jobs: mkdir -p /tmp/opencode python3 tools/mock-upstream.py 9099 > /tmp/opencode/mock.log 2>&1 & GATEWAY_ADMIN_TOKEN=test-admin \ + GATEWAY_SEED_DEFAULTS=true \ GATEWAY_PROMPT_LOGGING=true \ GATEWAY_GUARDRAILS_MODERATION=true \ GATEWAY_SEMANTIC_MODEL=embed-test \ diff --git a/AGENTS.md b/AGENTS.md index 91d75da..706596f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,7 +21,7 @@ dependency: the gateway translates to each provider's native protocol. # full end-to-end suite against a mock upstream (no real keys) python3 tools/mock-upstream.py 9099 & -GATEWAY_ADMIN_TOKEN=test-admin java -jar path-gateway/target/path-*.jar & +GATEWAY_ADMIN_TOKEN=test-admin GATEWAY_SEED_DEFAULTS=true java -jar path-gateway/target/path-*.jar & python3 tools/smoke_test.py # run locally diff --git a/docs/TESTING.md b/docs/TESTING.md index 2ddf15e..ea17dd8 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -30,10 +30,15 @@ admin surface and metering. ```bash python3 tools/mock-upstream.py 9099 & -GATEWAY_ADMIN_TOKEN=test-admin java -jar path-gateway/target/path-0.2.2.jar & +GATEWAY_ADMIN_TOKEN=test-admin GATEWAY_SEED_DEFAULTS=true \ + java -jar path-gateway/target/path-0.2.2.jar & python3 tools/smoke_test.py ``` +The suite calls the example catalogue by name (`gpt-4o-mini`, `claude-3.5-haiku`, +`auto-fast`, …), so it needs `GATEWAY_SEED_DEFAULTS=true` against a clean database. That +flag is off by default for real deployments; CI sets it for this job. + The mock switches behaviour by model id, which is how failure paths are tested: | Model id contains | Behaviour |