Skip to content

Commit b103818

Browse files
fix: treat a renewed Base credential as changed, and scope the backoff docs
- The register route's credential identity now includes the expiry. An expired credential loads as absent, so a renewal that reissues the same key and URL still reloads the provider caches. - Docs: the retry backoff follows only network errors, rate limits and gateway server errors. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_016x3nbZU5Vb6HnSTqE7vELm
1 parent 9f6b95b commit b103818

5 files changed

Lines changed: 38 additions & 6 deletions

File tree

‎docs/docs/configure/providers.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ Choose **Altimate Base** from the first-run picker or `/connect` — or do nothi
6666
install that is not yet registered registers it automatically at startup, so it works the same way
6767
headlessly (`run`, `serve`, `acp`, `web`). Startup waits up to three seconds for this; a slower
6868
registration finishes in the background and applies from the next launch (a `serve` client can
69-
apply it sooner through the register route). After a failed attempt, startup skips registration
70-
for a retry backoff of one hour (longer if the gateway asks, up to 24 hours). This happens whether or not you
69+
apply it sooner through the register route). After a network error, rate limit or gateway server error, startup skips
70+
registration for a retry backoff of one hour (longer if the gateway asks, up to 24 hours). This happens whether or not you
7171
also have a model of your own; a registered Base only becomes your default when nothing you
7272
configured is usable. There is no confirmation dialog to accept.
7373
The disclosure above is shown once per install: in the TUI as a toast the first time Base becomes

‎docs/docs/reference/network.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ altimate needs outbound HTTPS access to:
4141
| Destination | Purpose |
4242
|-------------|---------|
4343
| Your LLM provider API | Model inference (Anthropic, OpenAI, etc.) |
44-
| Official Altimate Base gateway (embedded in release), or the host set by `ALTIMATE_BASE_GATEWAY_URL` | Altimate Base registration (automatic at startup on any install not yet registered, unless `ALTIMATE_BASE_AUTO_REGISTER=0`, after logging out of Base, or during the 1–24 h retry backoff after a failed attempt) and inference |
44+
| Official Altimate Base gateway (embedded in release), or the host set by `ALTIMATE_BASE_GATEWAY_URL` | Altimate Base registration (automatic at startup on any install not yet registered, unless `ALTIMATE_BASE_AUTO_REGISTER=0`, after logging out of Base, or during the 1–24 h retry backoff after a network error, rate limit or gateway server error) and inference |
4545
| `registry.npmjs.org` | Package updates |
4646
| `models.dev` | Model catalog (can be disabled) |
4747
| Your warehouse endpoints | Database connections |

‎docs/docs/reference/security-faq.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Altimate Base is Altimate's own hosted free model. By default, every install tha
1717
registered registers it automatically at startup, whether or not you also have a model of your own.
1818
Registration sends only a hash of a random per-install secret and the CLI version, not your prompts or code. It is skipped when
1919
`ALTIMATE_BASE_AUTO_REGISTER=0` is set, after you log out of Base, when no gateway is configured, and
20-
during the retry backoff that follows a failed attempt. There is
20+
during the retry backoff that follows a network error, rate limit or gateway server error. There is
2121
no confirmation dialog to accept. It only becomes your default model when nothing you configured is
2222
usable. Requests and responses are
2323
logged and may be used to improve Altimate products and services, including the model; secrets are

‎packages/opencode/src/server/server.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,15 @@ export namespace Server {
821821
// pure disruption for zero benefit.
822822
if (outcome.ok) {
823823
const after = await FreeTier.credentials().catch(() => undefined)
824-
const changed = before?.apiKey !== after?.apiKey || before?.baseURL !== after?.baseURL
824+
// Expiry is part of the identity: an expired credential loads as absent, so renewing it
825+
// with the same key and URL still changes what a provider loader sees.
826+
const identity = (value: typeof after) =>
827+
value ? `${value.baseURL}\n${value.apiKey}\n${value.expiresAt ?? ""}` : undefined
828+
const fingerprint = identity(after)
829+
const changed = identity(before) !== fingerprint
825830
// An unchanged file is not enough to skip: a startup registration that finished in the
826831
// background leaves caches built before it without Base, in any directory and in either
827832
// registry. Skip only when this process has already reloaded for this exact credential.
828-
const fingerprint = after ? `${after.baseURL}\n${after.apiKey}` : undefined
829833
if (!changed && fingerprint !== undefined && fingerprint === appliedBaseCredential) {
830834
return c.json(outcome)
831835
}

‎packages/opencode/test/server/altimate-base-registration.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,34 @@ describe("Altimate Base registration route", () => {
177177
}
178178
})
179179

180+
test("reloads when an applied credential is renewed with the same key and URL", async () => {
181+
// An expired credential loads as absent, so directories opened after it expired cached no Base.
182+
// Renewing it can reissue the same key and URL with only a new expiry; that still has to reload.
183+
const expired = { apiKey: "sk-renew", baseURL: "https://gateway.test", installSecret: "s", expiresAt: "2026-01-01T00:00:00Z" }
184+
const renewed = { ...expired, expiresAt: "2099-01-01T00:00:00Z" }
185+
const disposeAll = spyOn(Instance, "disposeAll")
186+
const post = () =>
187+
app().request("/altimate/base/register", {
188+
method: "POST",
189+
headers: { "content-type": "application/json" },
190+
body: JSON.stringify({}),
191+
})
192+
try {
193+
mockCredentialsSequence(expired)
194+
mockRegister(async () => expired)
195+
await post()
196+
expect(disposeAll).toHaveBeenCalledTimes(1)
197+
credentialsSpy?.mockRestore()
198+
registerSpy?.mockRestore()
199+
mockCredentialsSequence(expired, renewed)
200+
mockRegister(async () => renewed)
201+
expect(await (await post()).json()).toMatchObject({ ok: true })
202+
expect(disposeAll).toHaveBeenCalledTimes(2)
203+
} finally {
204+
disposeAll.mockRestore()
205+
}
206+
})
207+
180208
test("reloads for a credential registered in the background, even if one directory already sees Base", async () => {
181209
// A startup auto-registration that finished after the server started leaves the file unchanged
182210
// across this request, while caches built earlier (another directory, or the /api registry)

0 commit comments

Comments
 (0)