Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(doctor): a refused token is not a dead database
KageBinaryd2b8a0b54c4e
diff --git a/ix-cli/src/cli/__tests__/status-doctor-honest.test.ts b/ix-cli/src/cli/__tests__/status-doctor-honest.test.tsindex b5db9395..841e71b3 100644--- a/ix-cli/src/cli/__tests__/status-doctor-honest.test.ts+++ b/ix-cli/src/cli/__tests__/status-doctor-honest.test.ts@@ -178,6 +178,12 @@ describe("doctor checks", () => {expect(await assessDatabase({ status: "ok" }, async () => ({ rev: 3 }))).toMatchObject({ ok: true });expect(await assessDatabase({ status: "ok" }, async () => { throw new Error("500: arango connection refused"); })).toMatchObject({ ok: false, detail: expect.stringMatching(/could not read its database: 500/) });+ // A 1.0.32 backend enforcing the token: health is exempt, the probe is not.+ // A refused token is not a dead database.+ const { LocalTokenRequiredError } = await import("../../client/api.js");+ expect(await assessDatabase({ status: "ok" }, async () => {+ throw new LocalTokenRequiredError('{"error":"unauthorized","code":"local_token_required"}');+ })).toMatchObject({ ok: true, detail: expect.stringMatching(/refused this CLI's token/) });});it("a 503 health body is an answer, anything else is not", async () => {diff --git a/ix-cli/src/cli/commands/doctor.ts b/ix-cli/src/cli/commands/doctor.tsindex 509fa81e..ea455b1d 100644--- a/ix-cli/src/cli/commands/doctor.ts+++ b/ix-cli/src/cli/commands/doctor.ts@@ -275,6 +275,11 @@ export async function assessDatabase(await probe();return { ok: true, detail: "reachable (read the current revision)" };} catch (e) {+ // The read was refused for want of the token, so it says nothing about the+ // database; "Backend token" reports the refusal.+ if ((e as Error)?.name === "LocalTokenRequiredError") {+ return { ok: true, detail: "not checked: the backend refused this CLI's token (see Backend token)" };+ }const msg = (e as Error)?.message ?? String(e);return { ok: false, detail: `the backend could not read its database: ${msg.slice(0, 200)}` };}