#7772 · Provider plan metadata ignores profile plan fields
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high for the BB metadata path; upstream cache provenance and refresh timing remain unverified.
1. TL;DR
The Claude Code provider derives its plan label and plan identifier exclusively from the account returned by SDK initialization. A synthetic test changes a real isolated profile file from one plan to another while holding that initialization account stale; both provider usage and health still report the old plan. This result repeats in a second clean checkout of the same trusted main commit. It confirms that refreshing the profile file alone cannot correct BB's output if the SDK continues returning the old account value. It does not establish that the reported Claude Code version actually returns stale data after its daily refresh, or where that version obtains its subscription type. No production account, token, credential file, or user runtime was inspected.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| BB uses the SDK subscription type to populate its plan metadata. | Verified | Production claudePlan() and both clean boundary runs. |
| Changing the local profile's organization plan can correct the badge without a changed SDK account. | Refuted on current BB | The profile is read for its UUID only; usage and health retain the stale synthetic plan. |
| The reported Claude Code version keeps its subscription type in login-time credential metadata rather than refreshed profile metadata. | Unverified | SDK initialization is deliberately mocked. No real credentials, live CLI session, or linked PR code was executed. |
| A real downgrade remains incorrect after the CLI's daily profile refresh. | Unverified | No controlled live downgrade or 24-hour refresh was performed. |
| Profile organization fields are a safe replacement for the SDK plan in every account mode. | Unverified | Precedence, identity matching, account-pool overrides, and unsupported account types require a source-of-truth decision. |
3. Environment
- Public target:
get-bb/bb; trusted base:48c3a78488667fde6883d13da7ef54f8175b4671, fetched directly from the target repository's main branch. - Linux 4.19.0-gvisor; Node 22.19.0; pnpm 9.15.0; frozen-lockfile dependency installation in each checkout.
- Locked Claude Agent SDK: 0.3.318. The SDK initialization and usage probes are stubbed; no actual Claude Code version is claimed as tested.
- No app server, host daemon, browser, port, production data directory, or real account was needed. Each test creates and removes a different temporary profile directory.
- This is a metadata-boundary reproduction, not a verified live UI or styling reproduction. No screenshot is presented as evidence.
4. Minimal reproduction
- Clone trusted main and check out the recorded base. Install the locked dependencies, then build the SDK runtime and types:
git clone https://github.com/get-bb/bb.git bb-7772 cd bb-7772 git checkout --detach 48c3a78488667fde6883d13da7ef54f8175b4671 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
- Save the test below as
plugins/provider-claude-code/src/bridge/issue-7772.repro.test.ts. It uses the existing exported provider usage and health functions, real temporary files, and no new production seam. - Run:
pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/issue-7772.repro.test.ts
- The baseline returns a successful old-plan usage result. The test then changes only the on-disk profile's organization type and invokes the provider again. Its final proposed-behavior assertion fails with:
- "planLabel": "Pro", + "planLabel": "Max", - "id": "pro", + "id": "max", Test Files 1 failed (1) Tests 1 failed (1)The failure is intentional and demonstrates a missing profile override, not a confirmed contract that these undocumented fields must take precedence.
Complete reproduction test
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterEach, expect, it, vi } from "vitest";
vi.mock("./initialization-probe.js", () => ({
probeClaudeInitialization: async () => ({
account: {
subscriptionType: "max",
tokenSource: "oauth",
apiProvider: "firstParty",
},
}),
probeClaudeUsage: async () => ({
account: {
subscriptionType: "max",
tokenSource: "oauth",
apiProvider: "firstParty",
},
usage: {
rate_limits_available: true,
rate_limits: { five_hour: { utilization: 12 } },
},
}),
}));
vi.mock("@get-bb/plugin-sdk/provider-bridge", async (importOriginal) => ({
...(await importOriginal<
typeof import("@get-bb/plugin-sdk/provider-bridge")
>()),
experimental_resolveExecutablePath: async () => "/synthetic/claude",
experimental_readCliVersion: async () => "synthetic",
}));
import {
getClaudeProviderHealth,
getClaudeProviderUsage,
} from "./provider-maintenance.js";
let profileDirectory: string | null = null;
afterEach(async () => {
vi.unstubAllEnvs();
if (profileDirectory !== null)
await fs.rm(profileDirectory, { recursive: true, force: true });
profileDirectory = null;
});
it("reflects a refreshed profile plan when the initialization account stays stale", async () => {
profileDirectory = await fs.mkdtemp(
path.join(os.tmpdir(), "issue-7772-profile-"),
);
vi.stubEnv("CLAUDE_CONFIG_DIR", profileDirectory);
const profileFile = path.join(profileDirectory, ".claude.json");
const accountUuid = "11111111-2222-4333-8444-555555555555";
await fs.writeFile(
profileFile,
JSON.stringify({
oauthAccount: { accountUuid, organizationType: "claude_max" },
}),
);
expect(await getClaudeProviderUsage()).toMatchObject({
usage: { status: "ok", planLabel: "Max" },
});
await fs.writeFile(
profileFile,
JSON.stringify({
oauthAccount: { accountUuid, organizationType: "claude_pro" },
}),
);
const usage = await getClaudeProviderUsage();
const health = await getClaudeProviderHealth();
console.log(
JSON.stringify({ phase: "after-profile-refresh", usage, health }),
);
expect({ usage, health }).toMatchObject({
usage: {
usage: {
status: "ok",
planLabel: "Pro",
plan: { id: "pro", multiplier: null },
},
},
health: { health: { status: "ready", planLabel: "Pro" } },
});
});
Observed provider result
All values below are synthetic. This JSON is the test's actual logged observation, formatted for readability.
{
"phase": "after-profile-refresh",
"usage": {
"supported": true,
"usage": {
"status": "ok",
"accountEmail": null,
"planLabel": "Max",
"plan": {
"id": "max",
"multiplier": null
},
"windows": [
{
"label": "Current session",
"kind": "five-hour",
"usedPercent": 12,
"resetsAt": null
}
],
"accountKey": "anthropic:account:11111111-2222-4333-8444-555555555555"
}
},
"health": {
"supported": true,
"health": {
"status": "ready",
"statusMessage": null,
"accountEmail": null,
"planLabel": "Max",
"installedVersion": "synthetic",
"minimumSupportedVersion": null,
"canInstall": true,
"canUpdate": true,
"loginCommand": "claude auth login"
}
}
}
5. Root cause
The usage probe returns initialization.account. The provider plan normalizer formats account.subscriptionType and does not consult any profile plan field. The profile schema keeps only oauthAccount.accountUuid; the reader returns that UUID, not plan metadata.
const name = account.subscriptionType?.replace(/^claude\s+/iu, "").trim(); ... const accountUuid = await readAccountUuid(args.env); ... ...normalizeUsage(usage.rate_limits, account)
Successful usage emits both the label and the structured plan from that same SDK account. The consumer normalizer can derive its display label from the structured plan ID, and the UI renders the resulting plan label. Thus a future repair must keep plan ID and display label consistent; changing the label alone is insufficient.
The conditional BB mechanism is established with high confidence. The deeper assertion about a particular Claude Code version's credential cache remains unverified: the test supplies that stale initialization account instead of proving that the CLI creates it. The experiment therefore warrants partial-repro, not confirmation of the full real-world refresh claim.
6. Proposed next test and simple-fix decision
Next, use an isolated, explicitly authorized test account to compare SDK initialization metadata with a documented current-plan signal before and after a controlled subscription change and the CLI's refresh. Establish which fields are authoritative and how they bind to the probed account, including alternate configuration directories and externally supplied accounts. Prefer an upstream correction or a documented SDK signal rather than assuming internal organization names are a stable plan contract.
No fix PR is safe from this evidence. The report only partially reproduces the issue. Overriding the SDK using undocumented profile fields would require a product/source-of-truth decision, and a synthetic failing assertion does not settle it. No production fix, branch, commit, or push was attempted in the target repository. There is no binary, dependency, protocol, schema, credential, or stored-data change.
7. Related issues and PR context
The issue's cross-reference timeline and an open-PR search returned no open PR linked to #7772 at investigation time. Previous issue #7644 is closed; PR #7645 is also closed without merging. Only their GitHub metadata and discussion were read as untrusted context; their branch, scripts, tests, and patches were not checked out or executed. The earlier rejection assigns plan freshness to Claude Code. This report verifies BB's conditional behavior but does not resolve the disagreement about that upstream cache.
8. Verification
The same agent created a second fresh detached checkout, <verification-checkout>, directly at 48c3a78488667fde6883d13da7ef54f8175b4671. It was clean before installation and adding the same authored test. It received a separate frozen install, a separate SDK build, and a new temporary profile directory created by mkdtemp. No tracked production file differed from the recorded base in either checkout.
| Run | Command | Observed result |
|---|---|---|
| First checkout | pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/issue-7772.repro.test.ts | Exit 1; one assertion failure; expected Pro/pro, received Max/max. Usage and health both retain Max. |
| Second clean checkout | Same command with the identical authored test. | Exit 1; identical intended assertion failure and logged provider output; no infrastructure failure. |
| Existing maintenance coverage | pnpm exec turbo run test --filter=bb-plugin-provider-claude-code -- src/bridge/provider-maintenance.account.test.ts src/bridge/provider-maintenance.test.ts src/bridge/provider-maintenance.installation.test.ts src/bridge/provider-maintenance.discovery.test.ts | 17 passed, 1 failed across 4 files. The unrelated discovery test resolved a host-installed CLI rather than its synthetic native executable. No source fix was attempted for that baseline/environment failure. |
This is a second clean run by the same agent, not independent verification. It supports the partial verdict only; it does not convert the mocked upstream premise into a live reproduction. No report correction was needed after the second run.
9. Appendix and limits
The initial all-workspace pnpm exec turbo run build failed because plugins started before the SDK dist was available. An explicit SDK runtime/types build succeeded in the first checkout; focused Turbo test prerequisites then completed in both checkouts. This investigation does not claim an all-workspace build or full-suite pass. Source was rechecked against main after the runs; no newer change to the maintenance path was found.
Raw logs, checkout paths, dependency output, the reproduction test, and the investigation brief remain in local investigation storage rather than the public report repository. The HTML contains the full repeatable test and expected-versus-actual evidence. Temporary profile files were removed by test teardown; no development server was started.
Untrusted-data handling: issue content and linked discussion were treated only as hypotheses. No commands, patches, branches, external URLs, or behavioral instructions from those sources were executed. Only trusted target-main code and the test authored from repository evidence were run.
> AGENT GENERATED