From 4ebd0120e5ca2399a5a0274eb47cdcbfbf61e4d8 Mon Sep 17 00:00:00 2001 From: joeVenner Date: Tue, 21 Jul 2026 15:04:20 +0100 Subject: [PATCH 1/9] Add China models.dev pricing lookup --- .../Vendored/CostUsage/CostUsagePricing.swift | 38 ++++++ .../CodexBarTests/ModelsDevPricingTests.swift | 122 ++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift index 4c04113d89..7670eaf657 100644 --- a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift +++ b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift @@ -765,6 +765,44 @@ enum CostUsagePricing { ModelsDevCache.load(now: now, cacheRoot: cacheRoot).artifact?.catalog } + static func modelsDevPricing( + provider: UsageProvider, + model: String, + catalog: ModelsDevCatalog? = nil, + cacheRoot: URL? = nil) -> ModelsDevPricingLookup? + { + for providerID in self.modelsDevProviderIDs(for: provider) { + if let lookup = self.modelsDevLookup( + providerID: providerID, + model: model, + catalog: catalog, + cacheRoot: cacheRoot) + { + return lookup + } + } + return nil + } + + private static func modelsDevProviderIDs(for provider: UsageProvider) -> [String] { + switch provider { + case .codex, .openai, .azureopenai: + [self.codexModelsDevProviderID] + case .claude: + [self.claudeModelsDevProviderID] + case .alibaba, .alibabatokenplan: + ["alibaba"] + case .zai: + ["zhipuai"] + case .deepseek: + ["deepseek"] + case .deepinfra: + ["deepinfra"] + default: + [] + } + } + private static func modelsDevLookup( providerID: String, model: String, diff --git a/Tests/CodexBarTests/ModelsDevPricingTests.swift b/Tests/CodexBarTests/ModelsDevPricingTests.swift index a0da2f6370..001f3937bf 100644 --- a/Tests/CodexBarTests/ModelsDevPricingTests.swift +++ b/Tests/CodexBarTests/ModelsDevPricingTests.swift @@ -52,6 +52,128 @@ struct ModelsDevPricingTests { #expect(vertex.pricing.inputCostPerToken == 3.1 / 1_000_000.0) } + @Test + func `provider lookup resolves current China API models`() throws { + let catalog = try Self.catalog(""" + { + "alibaba": { + "id": "alibaba", + "name": "Alibaba", + "models": { + "qwen3.7-max": { + "id": "qwen3.7-max", + "name": "Qwen3.7 Max", + "cost": { + "input": 2.5, + "output": 7.5, + "cache_read": 0.5, + "cache_write": 3.125 + }, + "limit": { + "context": 1000000 + } + }, + "qwen3.7-plus": { + "id": "qwen3.7-plus", + "name": "Qwen3.7 Plus", + "cost": { + "input": 0.5, + "output": 3, + "cache_read": 0.05, + "cache_write": 0.625 + }, + "limit": { + "context": 1000000 + } + } + } + }, + "zhipuai": { + "id": "zhipuai", + "name": "Zhipu AI", + "models": { + "glm-5.1": { + "id": "glm-5.1", + "name": "GLM-5.1", + "cost": { + "input": 1.4, + "output": 4.4, + "cache_read": 0.26, + "cache_write": 0 + }, + "limit": { + "context": 200000 + } + }, + "glm-5v-turbo": { + "id": "glm-5v-turbo", + "name": "GLM-5V-Turbo", + "cost": { + "input": 5, + "output": 22, + "cache_read": 1.2, + "cache_write": 0 + }, + "limit": { + "context": 200000 + } + } + } + }, + "deepseek": { + "id": "deepseek", + "name": "DeepSeek", + "models": { + "deepseek-v4-pro": { + "id": "deepseek-v4-pro", + "name": "DeepSeek V4 Pro", + "cost": { + "input": 0.435, + "output": 0.87, + "cache_read": 0.003625 + }, + "limit": { + "context": 1000000 + } + } + } + } + } + """) + + let qwenMax = try #require(CostUsagePricing.modelsDevPricing( + provider: .alibaba, + model: "qwen3.7-max", + catalog: catalog)) + let qwenPlus = try #require(CostUsagePricing.modelsDevPricing( + provider: .alibabatokenplan, + model: "qwen3.7-plus", + catalog: catalog)) + let glmTurbo = try #require(CostUsagePricing.modelsDevPricing( + provider: .zai, + model: "glm-5v-turbo", + catalog: catalog)) + let deepSeekPro = try #require(CostUsagePricing.modelsDevPricing( + provider: .deepseek, + model: "deepseek-v4-pro", + catalog: catalog)) + + #expect(qwenMax.pricing.inputCostPerToken == 2.5 / 1_000_000.0) + #expect(qwenMax.pricing.cacheCreationInputCostPerToken == 3.125 / 1_000_000.0) + #expect(qwenMax.pricing.contextWindow == 1_000_000) + #expect(qwenPlus.pricing.modelName == "Qwen3.7 Plus") + #expect(qwenPlus.pricing.outputCostPerToken == 3 / 1_000_000.0) + #expect(glmTurbo.pricing.inputCostPerToken == 5 / 1_000_000.0) + #expect(glmTurbo.pricing.outputCostPerToken == 22 / 1_000_000.0) + #expect(glmTurbo.pricing.cacheCreationInputCostPerToken == 0) + #expect(deepSeekPro.pricing.inputCostPerToken == 0.435 / 1_000_000.0) + #expect(deepSeekPro.pricing.cacheReadInputCostPerToken == 0.003625 / 1_000_000.0) + #expect(CostUsagePricing.modelsDevPricing( + provider: .deepseek, + model: "qwen3.7-max", + catalog: catalog) == nil) + } + @Test func `converts models dev per million token prices to per token prices`() throws { let pricing = try #require(try Self.fixtureCatalog().pricing( From 1df9f6a53394e27cd03d3f9c4b85ce578f37cd40 Mon Sep 17 00:00:00 2001 From: JoeVenner Date: Tue, 28 Jul 2026 12:55:39 +0100 Subject: [PATCH 2/9] Wire China models.dev pricing --- .../CodexBarCore/PiSessionCostScanner.swift | 83 ++++++++++- .../Vendored/CostUsage/CostUsagePricing.swift | 8 +- .../CodexBarTests/ModelsDevPricingTests.swift | 40 +++--- .../PiSessionCostScannerTests.swift | 132 ++++++++++++++++++ 4 files changed, 237 insertions(+), 26 deletions(-) diff --git a/Sources/CodexBarCore/PiSessionCostScanner.swift b/Sources/CodexBarCore/PiSessionCostScanner.swift index 3845ae5931..def4eebdb0 100644 --- a/Sources/CodexBarCore/PiSessionCostScanner.swift +++ b/Sources/CodexBarCore/PiSessionCostScanner.swift @@ -75,7 +75,7 @@ enum PiSessionCostScanner { private static let costScale = 1_000_000_000.0 /// Bump for Pi-only cost formula changes not represented by the parser or pricing fingerprints. - private static let costFormulaVersion = 1 + private static let costFormulaVersion = 2 private static let maxLineBytes = 16 * 1024 * 1024 private static let maxSafeRoundedInt = Double(Int.max) - 1 private static let sessionStartFilenameRegex = try? NSRegularExpression( @@ -107,8 +107,7 @@ enum PiSessionCostScanner { options: Options = Options(), checkCancellation: CostUsageScanner.CancellationCheck?) throws -> CostUsageDailyReport { - // Provider-specific by design: Pi records only OpenAI Codex and Anthropic sessions with distinct pricing. - guard provider == .codex || provider == .claude else { + guard self.supportsPiSessionProvider(provider) else { return CostUsageDailyReport(data: [], summary: nil) } @@ -225,7 +224,7 @@ enum PiSessionCostScanner { cacheRoot: URL? = nil, calendar: Calendar = .current) -> CachedDailyReportResult? { - guard provider == .codex || provider == .claude else { return nil } + guard self.supportsPiSessionProvider(provider) else { return nil } let range = CostUsageScanner.CostUsageDayRange(since: since, until: until, calendar: calendar) let cache = PiSessionCostCacheIO.load(cacheRoot: cacheRoot) @@ -256,7 +255,18 @@ enum PiSessionCostScanner { modelsDevArtifact: modelsDevArtifact, formulaVersion: Self.costFormulaVersion, parserHash: CodexParserHash.value, - modelsDevProviderIDs: ["anthropic", "openai"])) + modelsDevProviderIDs: [ + "alibaba", + "alibaba-coding-plan", + "alibaba-coding-plan-cn", + "alibaba-token-plan", + "alibaba-token-plan-cn", + "anthropic", + "deepseek", + "openai", + "zai", + "zai-coding-plan", + ])) } private static func requestedWindowExpandsCache( @@ -854,10 +864,54 @@ enum PiSessionCostScanner { modelsDevCatalog: pricingContext?.catalog, modelsDevCacheRoot: pricingContext?.cacheRoot) default: - nil + self.modelsDevCostUSD( + provider: provider, + model: modelName, + usage: usage, + pricingContext: pricingContext) } } + private static func modelsDevCostUSD( + provider: UsageProvider, + model: String, + usage: PiPackedUsage, + pricingContext: ModelsDevPricingContext?) -> Double? + { + guard let lookup = CostUsagePricing.modelsDevPricing( + provider: provider, + model: model, + catalog: pricingContext?.catalog, + cacheRoot: pricingContext?.cacheRoot) + else { return nil } + + let pricing = lookup.pricing + let totalInput = max(0, usage.inputTokens + usage.cacheReadTokens + usage.cacheWriteTokens) + let cached = min(max(0, usage.cacheReadTokens), totalInput) + let remainingAfterCache = totalInput - cached + let cacheWrite = min(max(0, usage.cacheWriteTokens), remainingAfterCache) + let nonCached = remainingAfterCache - cacheWrite + let usesLongContextRates = pricing.thresholdTokens.map { totalInput > $0 } ?? false + let inputRate = usesLongContextRates + ? pricing.inputCostPerTokenAboveThreshold ?? pricing.inputCostPerToken + : pricing.inputCostPerToken + let cachedInputRate = usesLongContextRates + ? pricing.cacheReadInputCostPerTokenAboveThreshold ?? pricing.cacheReadInputCostPerToken ?? inputRate + : pricing.cacheReadInputCostPerToken ?? pricing.inputCostPerToken + let cacheWriteRate = usesLongContextRates + ? pricing.cacheCreationInputCostPerTokenAboveThreshold ?? pricing + .cacheCreationInputCostPerToken ?? inputRate + : pricing.cacheCreationInputCostPerToken ?? inputRate + let outputRate = usesLongContextRates + ? pricing.outputCostPerTokenAboveThreshold ?? pricing.outputCostPerToken + : pricing.outputCostPerToken + + return (Double(nonCached) * inputRate) + + (Double(cached) * cachedInputRate) + + (Double(cacheWrite) * cacheWriteRate) + + (Double(max(0, usage.outputTokens)) * outputRate) + } + private static func readNonNegativeInt(_ value: Any?) -> Int { if let number = value as? NSNumber { let numeric = number.doubleValue @@ -883,11 +937,28 @@ extension PiSessionCostScanner { .codex case "anthropic": .claude + case "alibaba", "alibaba-coding-plan", "qwen", "qwen-code": + .alibaba + case "alibaba-token-plan": + .alibabatokenplan + case "zai", "z.ai", "z-ai": + .zai + case "deepseek": + .deepseek default: nil } } + private static func supportsPiSessionProvider(_ provider: UsageProvider) -> Bool { + switch provider { + case .codex, .claude, .alibaba, .alibabatokenplan, .zai, .deepseek: + true + default: + false + } + } + private static func buildReport( provider: UsageProvider, cache: PiSessionCostCache, diff --git a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift index 7670eaf657..6a0e3ba668 100644 --- a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift +++ b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift @@ -790,10 +790,12 @@ enum CostUsagePricing { [self.codexModelsDevProviderID] case .claude: [self.claudeModelsDevProviderID] - case .alibaba, .alibabatokenplan: - ["alibaba"] + case .alibaba: + ["alibaba-coding-plan", "alibaba-coding-plan-cn", "alibaba"] + case .alibabatokenplan: + ["alibaba-token-plan", "alibaba-token-plan-cn", "alibaba"] case .zai: - ["zhipuai"] + ["zai", "zai-coding-plan"] case .deepseek: ["deepseek"] case .deepinfra: diff --git a/Tests/CodexBarTests/ModelsDevPricingTests.swift b/Tests/CodexBarTests/ModelsDevPricingTests.swift index 001f3937bf..52367c3567 100644 --- a/Tests/CodexBarTests/ModelsDevPricingTests.swift +++ b/Tests/CodexBarTests/ModelsDevPricingTests.swift @@ -88,30 +88,36 @@ struct ModelsDevPricingTests { } } }, - "zhipuai": { - "id": "zhipuai", - "name": "Zhipu AI", + "alibaba-token-plan": { + "id": "alibaba-token-plan", + "name": "Alibaba Token Plan", "models": { - "glm-5.1": { - "id": "glm-5.1", - "name": "GLM-5.1", + "qwen3.7-plus": { + "id": "qwen3.7-plus", + "name": "Qwen3.7 Plus", "cost": { - "input": 1.4, - "output": 4.4, - "cache_read": 0.26, + "input": 0, + "output": 0, + "cache_read": 0, "cache_write": 0 }, "limit": { - "context": 200000 + "context": 1000000 } - }, + } + } + }, + "zai": { + "id": "zai", + "name": "z.ai", + "models": { "glm-5v-turbo": { "id": "glm-5v-turbo", "name": "GLM-5V-Turbo", "cost": { - "input": 5, - "output": 22, - "cache_read": 1.2, + "input": 1.2, + "output": 4, + "cache_read": 0.24, "cache_write": 0 }, "limit": { @@ -162,9 +168,9 @@ struct ModelsDevPricingTests { #expect(qwenMax.pricing.cacheCreationInputCostPerToken == 3.125 / 1_000_000.0) #expect(qwenMax.pricing.contextWindow == 1_000_000) #expect(qwenPlus.pricing.modelName == "Qwen3.7 Plus") - #expect(qwenPlus.pricing.outputCostPerToken == 3 / 1_000_000.0) - #expect(glmTurbo.pricing.inputCostPerToken == 5 / 1_000_000.0) - #expect(glmTurbo.pricing.outputCostPerToken == 22 / 1_000_000.0) + #expect(qwenPlus.pricing.outputCostPerToken == 0) + #expect(glmTurbo.pricing.inputCostPerToken == 1.2 / 1_000_000.0) + #expect(glmTurbo.pricing.outputCostPerToken == 4 / 1_000_000.0) #expect(glmTurbo.pricing.cacheCreationInputCostPerToken == 0) #expect(deepSeekPro.pricing.inputCostPerToken == 0.435 / 1_000_000.0) #expect(deepSeekPro.pricing.cacheReadInputCostPerToken == 0.003625 / 1_000_000.0) diff --git a/Tests/CodexBarTests/PiSessionCostScannerTests.swift b/Tests/CodexBarTests/PiSessionCostScannerTests.swift index 677b807fbd..84c6ff0148 100644 --- a/Tests/CodexBarTests/PiSessionCostScannerTests.swift +++ b/Tests/CodexBarTests/PiSessionCostScannerTests.swift @@ -1301,6 +1301,138 @@ extension PiSessionCostScannerTests { #expect(expandedReport.summary?.totalTokens == 45) } + @Test + func `pi scanner prices China provider sessions with provider scoped models dev catalogs`() throws { + let env = try CostUsageTestEnvironment() + defer { env.cleanup() } + + let day = try env.makeLocalNoon(year: 2026, month: 7, day: 18) + let catalog = try Self.modelsDevCatalog(""" + { + "alibaba": { + "id": "alibaba", + "models": { + "qwen3.7-max": { "id": "qwen3.7-max", "cost": { "input": 99, "output": 99 } } + } + }, + "alibaba-coding-plan": { + "id": "alibaba-coding-plan", + "models": { + "qwen3.7-max": { + "id": "qwen3.7-max", + "cost": { "input": 0, "output": 0, "cache_read": 0, "cache_write": 0 } + } + } + }, + "alibaba-token-plan": { + "id": "alibaba-token-plan", + "models": { + "qwen3.7-plus": { "id": "qwen3.7-plus", "cost": { "input": 1, "output": 3 } } + } + }, + "zai": { + "id": "zai", + "models": { + "glm-5v-turbo": { + "id": "glm-5v-turbo", + "cost": { "input": 5, "output": 22, "cache_read": 1.2, "cache_write": 0 } + } + } + }, + "zhipuai": { + "id": "zhipuai", + "models": { + "glm-5v-turbo": { "id": "glm-5v-turbo", "cost": { "input": 99, "output": 199 } } + } + }, + "deepseek": { + "id": "deepseek", + "models": { + "deepseek-v4-pro": { + "id": "deepseek-v4-pro", + "cost": { "input": 0.435, "output": 0.87, "cache_read": 0.003625 } + } + } + } + } + """) + #expect(ModelsDevCache.save(catalog: catalog, fetchedAt: day, cacheRoot: env.cacheRoot)) + + func assistant(provider: String, model: String, usage: [String: Int]) -> [String: Any] { + [ + "type": "message", + "timestamp": env.isoString(for: day), + "message": [ + "role": "assistant", + "provider": provider, + "model": model, + "timestamp": Int(day.timeIntervalSince1970 * 1000), + "usage": usage, + ], + ] + } + + _ = try env.writePiSessionFile( + relativePath: "2026-07-18T10-00-00-000Z_china-models.jsonl", + contents: env.jsonl([ + assistant( + provider: "alibaba-coding-plan", + model: "qwen3.7-max", + usage: ["input": 100, "output": 50, "totalTokens": 150]), + assistant( + provider: "alibaba-token-plan", + model: "qwen3.7-plus", + usage: ["input": 1_000_000, "output": 1_000_000, "totalTokens": 2_000_000]), + assistant( + provider: "zai", + model: "glm-5v-turbo", + usage: ["input": 100, "cacheRead": 10, "cacheWrite": 20, "output": 50, "totalTokens": 180]), + assistant( + provider: "deepseek", + model: "deepseek-v4-pro", + usage: ["input": 1000, "cacheRead": 100, "output": 500, "totalTokens": 1600]), + ])) + + let options = PiSessionCostScanner.Options( + piSessionsRoot: env.piSessionsRoot, + cacheRoot: env.cacheRoot, + refreshMinIntervalSeconds: 0) + + let alibaba = PiSessionCostScanner.loadDailyReport( + provider: .alibaba, + since: day, + until: day, + now: day, + options: options) + let tokenPlan = PiSessionCostScanner.loadDailyReport( + provider: .alibabatokenplan, + since: day, + until: day, + now: day, + options: options) + let zai = PiSessionCostScanner.loadDailyReport( + provider: .zai, + since: day, + until: day, + now: day, + options: options) + let deepSeek = PiSessionCostScanner.loadDailyReport( + provider: .deepseek, + since: day, + until: day, + now: day, + options: options) + + #expect(alibaba.data.first?.totalTokens == 150) + #expect(alibaba.data.first?.costUSD == 0) + #expect(tokenPlan.data.first?.totalTokens == 2_000_000) + #expect(abs((tokenPlan.data.first?.costUSD ?? 0) - 4) < 0.0000001) + #expect(zai.data.first?.totalTokens == 180) + #expect(abs((zai.data.first?.costUSD ?? 0) - 0.001612) < 0.0000001) + #expect(deepSeek.data.first?.totalTokens == 1600) + #expect(abs((deepSeek.data.first?.costUSD ?? 0) - 0.0008703625) < 0.0000001) + } + private static func modelsDevCatalog(inputCostPerMillion: Double) throws -> ModelsDevCatalog { let json = """ { From ca1bb86745400bb775c2ddb4992effc620b1b839 Mon Sep 17 00:00:00 2001 From: JoeVenner Date: Tue, 28 Jul 2026 13:33:02 +0100 Subject: [PATCH 3/9] Enable China cost CLI path --- Sources/CodexBarCore/CostUsageFetcher.swift | 58 +++++++++++++++---- .../AlibabaCodingPlanProviderDescriptor.swift | 6 +- .../AlibabaTokenPlanProviderDescriptor.swift | 4 +- .../DeepSeek/DeepSeekProviderDescriptor.swift | 6 +- .../Providers/Zai/ZaiProviderDescriptor.swift | 6 +- 5 files changed, 63 insertions(+), 17 deletions(-) diff --git a/Sources/CodexBarCore/CostUsageFetcher.swift b/Sources/CodexBarCore/CostUsageFetcher.swift index e1d0e74703..53bf2e6abc 100644 --- a/Sources/CodexBarCore/CostUsageFetcher.swift +++ b/Sources/CodexBarCore/CostUsageFetcher.swift @@ -390,9 +390,6 @@ public struct CostUsageFetcher: Sendable { codexHomePath: codexHomePath) // Rolling window is inclusive, so a 30-day display starts 29 days before `now`. let since = options.calendar.date(byAdding: .day, value: -(clampedHistoryDays - 1), to: now) ?? now - let scopedCodexHomePath = codexHomePath?.trimmingCharacters(in: .whitespacesAndNewlines) - // Provider-specific by design: scoped Codex homes exclude ambient Pi sessions from managed-profile totals. - let shouldMergePiUsage = provider != .codex || scopedCodexHomePath?.isEmpty != false await Self.refreshPricingIfAllowed( options: PricingRefreshOptions( provider: provider, @@ -423,7 +420,7 @@ public struct CostUsageFetcher: Sendable { let localScanOptions = LocalTokenScanOptions( allowVertexClaudeFallback: allowVertexClaudeFallback, includePiSessions: includePiSessions, - shouldMergePiUsage: shouldMergePiUsage, + codexHomePath: codexHomePath, scanOptions: scanOptions, piOptions: piOptions) let scanResult = try await Self.loadLocalTokenScanResult( @@ -482,7 +479,7 @@ public struct CostUsageFetcher: Sendable { private struct LocalTokenScanOptions: Sendable { let allowVertexClaudeFallback: Bool let includePiSessions: Bool - let shouldMergePiUsage: Bool + let codexHomePath: String? let scanOptions: CostUsageScanner.Options let piOptions: PiSessionCostScanner.Options } @@ -556,8 +553,10 @@ public struct CostUsageFetcher: Sendable { sessionRoots: roots) } } - if options.includePiSessions, - provider == .claude || (provider == .codex && options.shouldMergePiUsage) + if Self.shouldMergePiSessions( + provider: provider, + includePiSessions: options.includePiSessions, + codexHomePath: options.codexHomePath) { let piReport = try PiSessionCostScanner.loadDailyReportCancellable( provider: provider, @@ -604,7 +603,7 @@ public struct CostUsageFetcher: Sendable { { guard options.isAllowed, options.retryUnknown, - options.provider == .codex || options.provider == .claude + self.usesModelsDevPricing(options.provider) else { return } if options.inBackground { @@ -631,7 +630,7 @@ public struct CostUsageFetcher: Sendable { cacheRoot: URL?, client: ModelsDevClient) -> UnknownPricingRefreshRequest? { - guard provider == .codex || provider == .claude else { return nil } + guard let providerID = self.modelsDevRefreshProviderID(for: provider) else { return nil } let unknownModelIDs = Set(daily.data.flatMap { entry in entry.modelBreakdowns?.compactMap { breakdown -> String? in guard breakdown.costUSD == nil else { return nil } @@ -646,7 +645,7 @@ public struct CostUsageFetcher: Sendable { guard !unknownModelIDs.isEmpty else { return nil } return UnknownPricingRefreshRequest( - providerID: provider == .codex ? "openai" : "anthropic", + providerID: providerID, modelIDs: unknownModelIDs, now: now, cacheRoot: cacheRoot, @@ -1445,6 +1444,45 @@ extension CostUsageFetcher { return "v2:\(scopedFiles.count):\(progressHasher.finalize())" } + fileprivate static func shouldMergePiSessions( + provider: UsageProvider, + includePiSessions: Bool, + codexHomePath: String?) -> Bool + { + let scopedCodexHomePath = codexHomePath?.trimmingCharacters(in: .whitespacesAndNewlines) + let shouldMergePiUsage = provider != .codex || scopedCodexHomePath?.isEmpty != false + return includePiSessions + && (provider == .claude + || (provider == .codex && shouldMergePiUsage) + || provider == .alibaba + || provider == .alibabatokenplan + || provider == .zai + || provider == .deepseek) + } + + fileprivate static func usesModelsDevPricing(_ provider: UsageProvider) -> Bool { + self.modelsDevRefreshProviderID(for: provider) != nil + } + + fileprivate static func modelsDevRefreshProviderID(for provider: UsageProvider) -> String? { + switch provider { + case .codex: + "openai" + case .claude: + "anthropic" + case .alibaba: + "alibaba-coding-plan" + case .alibabatokenplan: + "alibaba-token-plan" + case .zai: + "zai" + case .deepseek: + "deepseek" + default: + nil + } + } + fileprivate static func loadRemoteTokenSnapshot( provider: UsageProvider, environment: [String: String], diff --git a/Sources/CodexBarCore/Providers/Alibaba/AlibabaCodingPlanProviderDescriptor.swift b/Sources/CodexBarCore/Providers/Alibaba/AlibabaCodingPlanProviderDescriptor.swift index 8d75a10449..3be01742db 100644 --- a/Sources/CodexBarCore/Providers/Alibaba/AlibabaCodingPlanProviderDescriptor.swift +++ b/Sources/CodexBarCore/Providers/Alibaba/AlibabaCodingPlanProviderDescriptor.swift @@ -82,7 +82,8 @@ public enum AlibabaCodingPlanProviderDescriptor { ]), tokenCost: ProviderTokenCostConfig( supportsTokenCost: false, - noDataMessage: { "Alibaba Coding Plan cost summary is not supported." }), + noDataMessage: { "Alibaba Coding Plan cost summary is not supported." }, + supportsTokenSnapshot: true), pace: .calendarMonthResetWindow, presentation: ProviderUsagePresentation( primaryBindingQuotaLanes: [.secondary, .tertiary], @@ -93,7 +94,8 @@ public enum AlibabaCodingPlanProviderDescriptor { cli: ProviderCLIConfig( name: "alibaba-coding-plan", aliases: ["alibaba", "bailian"], - versionDetector: nil)) + versionDetector: nil, + supportsCostCommand: true)) } private static func resolveStrategies(context: ProviderFetchContext) async -> [any ProviderFetchStrategy] { diff --git a/Sources/CodexBarCore/Providers/Alibaba/AlibabaTokenPlanProviderDescriptor.swift b/Sources/CodexBarCore/Providers/Alibaba/AlibabaTokenPlanProviderDescriptor.swift index 988b414ed5..e1d3e82b8e 100644 --- a/Sources/CodexBarCore/Providers/Alibaba/AlibabaTokenPlanProviderDescriptor.swift +++ b/Sources/CodexBarCore/Providers/Alibaba/AlibabaTokenPlanProviderDescriptor.swift @@ -93,7 +93,8 @@ public enum AlibabaTokenPlanProviderDescriptor { ]), tokenCost: ProviderTokenCostConfig( supportsTokenCost: false, - noDataMessage: { "Alibaba Token Plan cost summary is not supported." }), + noDataMessage: { "Alibaba Token Plan cost summary is not supported." }, + supportsTokenSnapshot: true), pace: .calendarMonthResetWindow, presentation: ProviderUsagePresentation( primaryBindingQuotaLanes: [.secondary], @@ -105,6 +106,7 @@ public enum AlibabaTokenPlanProviderDescriptor { name: "alibaba-token-plan", aliases: ["alibaba-token", "bailian-token-plan"], versionDetector: nil, + supportsCostCommand: true, browserSupportExemption: { _, _, settings in // Manual cookies use plain URLSession; only browser import is platform-bound. settings?.alibabaTokenPlan?.cookieSource == .manual diff --git a/Sources/CodexBarCore/Providers/DeepSeek/DeepSeekProviderDescriptor.swift b/Sources/CodexBarCore/Providers/DeepSeek/DeepSeekProviderDescriptor.swift index 04bb65e52c..5386806899 100644 --- a/Sources/CodexBarCore/Providers/DeepSeek/DeepSeekProviderDescriptor.swift +++ b/Sources/CodexBarCore/Providers/DeepSeek/DeepSeekProviderDescriptor.swift @@ -104,7 +104,8 @@ public enum DeepSeekProviderDescriptor { widgetColor: ProviderColor(red: 82 / 255, green: 125 / 255, blue: 240 / 255)), tokenCost: ProviderTokenCostConfig( supportsTokenCost: false, - noDataMessage: { "DeepSeek per-day cost history is not available via API." }), + noDataMessage: { "DeepSeek per-day cost history is not available via API." }, + supportsTokenSnapshot: true), presentation: ProviderUsagePresentation( menuCard: ProviderMenuCardPresentation( usageNotesResolver: { context in @@ -144,7 +145,8 @@ public enum DeepSeekProviderDescriptor { cli: ProviderCLIConfig( name: "deepseek", aliases: ["deep-seek", "ds"], - versionDetector: nil), + versionDetector: nil, + supportsCostCommand: true), configNormalizer: { config in config.deepseekProfileID = config.sanitizedDeepSeekProfileID config.deepseekProfileScope = config.sanitizedDeepSeekProfileScope diff --git a/Sources/CodexBarCore/Providers/Zai/ZaiProviderDescriptor.swift b/Sources/CodexBarCore/Providers/Zai/ZaiProviderDescriptor.swift index 2a9c886eed..d9727859c7 100644 --- a/Sources/CodexBarCore/Providers/Zai/ZaiProviderDescriptor.swift +++ b/Sources/CodexBarCore/Providers/Zai/ZaiProviderDescriptor.swift @@ -91,7 +91,8 @@ public enum ZaiProviderDescriptor { ]), tokenCost: ProviderTokenCostConfig( supportsTokenCost: false, - noDataMessage: { "z.ai cost summary is not supported." }), + noDataMessage: { "z.ai cost summary is not supported." }, + supportsTokenSnapshot: true), pace: ProviderPaceCapability( resetWindowPace: .custom { window, _ in Self.isMonthlyMCPWindow(window) @@ -118,7 +119,8 @@ public enum ZaiProviderDescriptor { cli: ProviderCLIConfig( name: "zai", aliases: ["z.ai"], - versionDetector: nil)) + versionDetector: nil, + supportsCostCommand: true)) } private static func isMonthlyMCPWindow(_ window: RateWindow) -> Bool { From e56df9bb99b62cb0dc09d404da439cc5aecf4c04 Mon Sep 17 00:00:00 2001 From: joeVenner Date: Fri, 31 Jul 2026 19:27:06 +0100 Subject: [PATCH 4/9] refactor(cost): extract claudeLogProviderFilter setup and move modelsDevCostUSD out of enum to satisfy lint limits --- Sources/CodexBarCore/CostUsageFetcher.swift | 20 +++-- .../CodexBarCore/PiSessionCostScanner.swift | 82 ++++++++++--------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/Sources/CodexBarCore/CostUsageFetcher.swift b/Sources/CodexBarCore/CostUsageFetcher.swift index 53bf2e6abc..95c6305598 100644 --- a/Sources/CodexBarCore/CostUsageFetcher.swift +++ b/Sources/CodexBarCore/CostUsageFetcher.swift @@ -335,7 +335,8 @@ public struct CostUsageFetcher: Sendable { private static func resolvedScannerOptions( _ override: CostUsageScanner.Options?, provider: UsageProvider, - codexHomePath: String?) -> CostUsageScanner.Options + codexHomePath: String?, + allowVertexClaudeFallback: Bool = false) -> CostUsageScanner.Options { var options = override ?? CostUsageScanner.Options() // Provider-specific by design: Codex managed profiles relocate sessions and archived_sessions roots. @@ -346,6 +347,11 @@ public struct CostUsageFetcher: Sendable { options.codexSessionsRoot = URL(fileURLWithPath: codexHomePath, isDirectory: true) .appendingPathComponent("sessions", isDirectory: true) } + if provider == .vertexai { + options.claudeLogProviderFilter = allowVertexClaudeFallback ? .all : .vertexAIOnly + } else if provider == .claude { + options.claudeLogProviderFilter = .excludeVertexAI + } return options } @@ -387,7 +393,8 @@ public struct CostUsageFetcher: Sendable { var options = Self.resolvedScannerOptions( overrideScannerOptions, provider: provider, - codexHomePath: codexHomePath) + codexHomePath: codexHomePath, + allowVertexClaudeFallback: allowVertexClaudeFallback) // Rolling window is inclusive, so a 30-day display starts 29 days before `now`. let since = options.calendar.date(byAdding: .day, value: -(clampedHistoryDays - 1), to: now) ?? now await Self.refreshPricingIfAllowed( @@ -403,7 +410,6 @@ public struct CostUsageFetcher: Sendable { Self.configureScannerRefresh( &options, provider: provider, - allowVertexClaudeFallback: allowVertexClaudeFallback, forceRefresh: forceRefresh, bypassScannerDebounce: bypassScannerDebounce) var resolvedPiOptions = overridePiScannerOptions ?? PiSessionCostScanner.Options() @@ -1107,15 +1113,11 @@ public struct CostUsageFetcher: Sendable { private static func configureScannerRefresh( _ options: inout CostUsageScanner.Options, provider: UsageProvider, - allowVertexClaudeFallback: Bool, forceRefresh: Bool, bypassScannerDebounce: Bool) { - if provider == .vertexai { - options.claudeLogProviderFilter = allowVertexClaudeFallback ? .all : .vertexAIOnly - } else if provider == .claude { - options.claudeLogProviderFilter = .excludeVertexAI - } + // `claudeLogProviderFilter` is configured in `resolvedScannerOptions` so it is available + // to every caller, not only this path. if forceRefresh || bypassScannerDebounce { options.refreshMinIntervalSeconds = 0 } diff --git a/Sources/CodexBarCore/PiSessionCostScanner.swift b/Sources/CodexBarCore/PiSessionCostScanner.swift index def4eebdb0..afeecaf680 100644 --- a/Sources/CodexBarCore/PiSessionCostScanner.swift +++ b/Sources/CodexBarCore/PiSessionCostScanner.swift @@ -872,46 +872,6 @@ enum PiSessionCostScanner { } } - private static func modelsDevCostUSD( - provider: UsageProvider, - model: String, - usage: PiPackedUsage, - pricingContext: ModelsDevPricingContext?) -> Double? - { - guard let lookup = CostUsagePricing.modelsDevPricing( - provider: provider, - model: model, - catalog: pricingContext?.catalog, - cacheRoot: pricingContext?.cacheRoot) - else { return nil } - - let pricing = lookup.pricing - let totalInput = max(0, usage.inputTokens + usage.cacheReadTokens + usage.cacheWriteTokens) - let cached = min(max(0, usage.cacheReadTokens), totalInput) - let remainingAfterCache = totalInput - cached - let cacheWrite = min(max(0, usage.cacheWriteTokens), remainingAfterCache) - let nonCached = remainingAfterCache - cacheWrite - let usesLongContextRates = pricing.thresholdTokens.map { totalInput > $0 } ?? false - let inputRate = usesLongContextRates - ? pricing.inputCostPerTokenAboveThreshold ?? pricing.inputCostPerToken - : pricing.inputCostPerToken - let cachedInputRate = usesLongContextRates - ? pricing.cacheReadInputCostPerTokenAboveThreshold ?? pricing.cacheReadInputCostPerToken ?? inputRate - : pricing.cacheReadInputCostPerToken ?? pricing.inputCostPerToken - let cacheWriteRate = usesLongContextRates - ? pricing.cacheCreationInputCostPerTokenAboveThreshold ?? pricing - .cacheCreationInputCostPerToken ?? inputRate - : pricing.cacheCreationInputCostPerToken ?? inputRate - let outputRate = usesLongContextRates - ? pricing.outputCostPerTokenAboveThreshold ?? pricing.outputCostPerToken - : pricing.outputCostPerToken - - return (Double(nonCached) * inputRate) - + (Double(cached) * cachedInputRate) - + (Double(cacheWrite) * cacheWriteRate) - + (Double(max(0, usage.outputTokens)) * outputRate) - } - private static func readNonNegativeInt(_ value: Any?) -> Int { if let number = value as? NSNumber { let numeric = number.doubleValue @@ -1187,3 +1147,45 @@ extension PiSessionCostScanner { } } } + +extension PiSessionCostScanner { + private static func modelsDevCostUSD( + provider: UsageProvider, + model: String, + usage: PiPackedUsage, + pricingContext: ModelsDevPricingContext?) -> Double? + { + guard let lookup = CostUsagePricing.modelsDevPricing( + provider: provider, + model: model, + catalog: pricingContext?.catalog, + cacheRoot: pricingContext?.cacheRoot) + else { return nil } + + let pricing = lookup.pricing + let totalInput = max(0, usage.inputTokens + usage.cacheReadTokens + usage.cacheWriteTokens) + let cached = min(max(0, usage.cacheReadTokens), totalInput) + let remainingAfterCache = totalInput - cached + let cacheWrite = min(max(0, usage.cacheWriteTokens), remainingAfterCache) + let nonCached = remainingAfterCache - cacheWrite + let usesLongContextRates = pricing.thresholdTokens.map { totalInput > $0 } ?? false + let inputRate = usesLongContextRates + ? pricing.inputCostPerTokenAboveThreshold ?? pricing.inputCostPerToken + : pricing.inputCostPerToken + let cachedInputRate = usesLongContextRates + ? pricing.cacheReadInputCostPerTokenAboveThreshold ?? pricing.cacheReadInputCostPerToken ?? inputRate + : pricing.cacheReadInputCostPerToken ?? pricing.inputCostPerToken + let cacheWriteRate = usesLongContextRates + ? pricing.cacheCreationInputCostPerTokenAboveThreshold ?? pricing + .cacheCreationInputCostPerToken ?? inputRate + : pricing.cacheCreationInputCostPerToken ?? inputRate + let outputRate = usesLongContextRates + ? pricing.outputCostPerTokenAboveThreshold ?? pricing.outputCostPerToken + : pricing.outputCostPerToken + + return (Double(nonCached) * inputRate) + + (Double(cached) * cachedInputRate) + + (Double(cacheWrite) * cacheWriteRate) + + (Double(max(0, usage.outputTokens)) * outputRate) + } +} From 47ebf591c37878a323e08bdd1a8e56f54743ae6b Mon Sep 17 00:00:00 2001 From: joeVenner Date: Wed, 5 Aug 2026 16:14:33 +0100 Subject: [PATCH 5/9] fix(pricing): remove direct API fallback from Alibaba plan providers ClawSweeper flagged that .alibaba and .alibabatokenplan fell back to the direct 'alibaba' catalog when their dedicated plan catalogs lacked a model. Plan billing can differ from direct API billing, so return no estimate instead. Add regression coverage for missing plan-catalog rows. --- .../Vendored/CostUsage/CostUsagePricing.swift | 4 +- .../CodexBarTests/ModelsDevPricingTests.swift | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift index 6a0e3ba668..ec2ebb0568 100644 --- a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift +++ b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift @@ -791,9 +791,9 @@ enum CostUsagePricing { case .claude: [self.claudeModelsDevProviderID] case .alibaba: - ["alibaba-coding-plan", "alibaba-coding-plan-cn", "alibaba"] + ["alibaba-coding-plan", "alibaba-coding-plan-cn"] case .alibabatokenplan: - ["alibaba-token-plan", "alibaba-token-plan-cn", "alibaba"] + ["alibaba-token-plan", "alibaba-token-plan-cn"] case .zai: ["zai", "zai-coding-plan"] case .deepseek: diff --git a/Tests/CodexBarTests/ModelsDevPricingTests.swift b/Tests/CodexBarTests/ModelsDevPricingTests.swift index 52367c3567..54b65b1fb7 100644 --- a/Tests/CodexBarTests/ModelsDevPricingTests.swift +++ b/Tests/CodexBarTests/ModelsDevPricingTests.swift @@ -59,6 +59,11 @@ struct ModelsDevPricingTests { "alibaba": { "id": "alibaba", "name": "Alibaba", + "models": {} + }, + "alibaba-coding-plan": { + "id": "alibaba-coding-plan", + "name": "Alibaba Coding Plan", "models": { "qwen3.7-max": { "id": "qwen3.7-max", @@ -180,6 +185,52 @@ struct ModelsDevPricingTests { catalog: catalog) == nil) } + @Test + func `alibaba plan providers do not fall back to direct api pricing`() throws { + let catalog = try Self.catalog(""" + { + "alibaba": { + "id": "alibaba", + "name": "Alibaba", + "models": { + "qwen3.7-max": { + "id": "qwen3.7-max", + "name": "Qwen3.7 Max", + "cost": { + "input": 2.5, + "output": 7.5, + "cache_read": 0.5, + "cache_write": 3.125 + }, + "limit": { + "context": 1000000 + } + } + } + }, + "alibaba-coding-plan": { + "id": "alibaba-coding-plan", + "name": "Alibaba Coding Plan", + "models": {} + }, + "alibaba-token-plan": { + "id": "alibaba-token-plan", + "name": "Alibaba Token Plan", + "models": {} + } + } + """) + + #expect(CostUsagePricing.modelsDevPricing( + provider: .alibaba, + model: "qwen3.7-max", + catalog: catalog) == nil) + #expect(CostUsagePricing.modelsDevPricing( + provider: .alibabatokenplan, + model: "qwen3.7-max", + catalog: catalog) == nil) + } + @Test func `converts models dev per million token prices to per token prices`() throws { let pricing = try #require(try Self.fixtureCatalog().pricing( From ca0bdb315ffb255d61c6b08675960bbe874e25c1 Mon Sep 17 00:00:00 2001 From: joeVenner Date: Sun, 9 Aug 2026 23:32:53 +0100 Subject: [PATCH 6/9] fix(gatekeeper): justify China API provider-specific cost constructs After rebasing the China API models.dev pricing work, ProviderArchitectureGatekeeperTests failed because new provider-specific branches (Alibaba, Zai, DeepSeek) appeared in shared cost code and existing allowlist anchors shifted. Add '// Provider-specific by design:' markers at each provider-owned dispatch point, update the gatekeeper's hardcoded supportsTokenSnapshot set and shifted suppressed references, and remove obsolete CostUsageFetcher/PiSessionCostScanner allowlist entries whose anchors no longer match. Closes provider-architecture gatekeeper failures on the China API rebase. --- Sources/CodexBarCore/CostUsageFetcher.swift | 5 + .../CodexBarCore/PiSessionCostScanner.swift | 3 + .../Vendored/CostUsage/CostUsagePricing.swift | 1 + .../ProviderArchitectureGatekeeperTests.swift | 147 +++++++----------- 4 files changed, 63 insertions(+), 93 deletions(-) diff --git a/Sources/CodexBarCore/CostUsageFetcher.swift b/Sources/CodexBarCore/CostUsageFetcher.swift index 95c6305598..2213dbd398 100644 --- a/Sources/CodexBarCore/CostUsageFetcher.swift +++ b/Sources/CodexBarCore/CostUsageFetcher.swift @@ -532,6 +532,7 @@ public struct CostUsageFetcher: Sendable { var sessions: [CostUsageSessionBreakdown] = [] var piDaily: CostUsageDailyReport? var staleSnapshotUpdatedAt: Date? + // Provider-specific by design: only Codex builds project and session breakdowns from its local cache. if provider == .codex { let roots = CostUsageScanner.codexSessionsRoots(options: options.scanOptions) let cache = CostUsageScanner.codexCache( @@ -572,6 +573,7 @@ public struct CostUsageFetcher: Sendable { options: options.piOptions, checkCancellation: checkCancellation) try checkCancellation() + // Provider-specific by design: only Codex stores the Pi-only report for project merge. if provider == .codex { piDaily = piReport } @@ -640,6 +642,7 @@ public struct CostUsageFetcher: Sendable { let unknownModelIDs = Set(daily.data.flatMap { entry in entry.modelBreakdowns?.compactMap { breakdown -> String? in guard breakdown.costUSD == nil else { return nil } + // Provider-specific by design: only Codex filters out its own unattributed model names. if provider == .codex, CostUsagePricing.isCodexUnattributedModel(breakdown.modelName) { @@ -1451,6 +1454,7 @@ extension CostUsageFetcher { includePiSessions: Bool, codexHomePath: String?) -> Bool { + // Provider-specific by design: Pi session mirrors exist only for the China API group, Claude, and Codex. let scopedCodexHomePath = codexHomePath?.trimmingCharacters(in: .whitespacesAndNewlines) let shouldMergePiUsage = provider != .codex || scopedCodexHomePath?.isEmpty != false return includePiSessions @@ -1507,6 +1511,7 @@ extension CostUsageFetcher { } #if os(macOS) + // Provider-specific by design: Cursor remote snapshots use its macOS dashboard session. if provider == .cursor { return try await self.loadCursorTokenSnapshot( now: now, diff --git a/Sources/CodexBarCore/PiSessionCostScanner.swift b/Sources/CodexBarCore/PiSessionCostScanner.swift index afeecaf680..d3ff2ebb43 100644 --- a/Sources/CodexBarCore/PiSessionCostScanner.swift +++ b/Sources/CodexBarCore/PiSessionCostScanner.swift @@ -248,6 +248,7 @@ enum PiSessionCostScanner { private static func pricingContext(now: Date, cacheRoot: URL?) -> ModelsDevPricingContext { let modelsDevArtifact = ModelsDevCache.load(now: now, cacheRoot: cacheRoot).artifact + // Provider-specific by design: Pi pricing pulls models.dev catalogs only for the supported vendors. return ModelsDevPricingContext( catalog: modelsDevArtifact?.catalog, cacheRoot: cacheRoot, @@ -840,6 +841,7 @@ enum PiSessionCostScanner { pricingDate: Date? = nil, pricingContext: ModelsDevPricingContext? = nil) -> Double? { + // Provider-specific by design: Pi cost calculation uses Codex/Claude-specific pricing normalizers. switch provider { case .codex: // Pi records input, cache reads, and cache writes as disjoint counts. Codex pricing @@ -892,6 +894,7 @@ enum PiSessionCostScanner { extension PiSessionCostScanner { private static func mappedProvider(fromPiProvider provider: String) -> UsageProvider? { + // Provider-specific by design: Pi provider strings map to their respective UsageProvider values. switch provider.lowercased() { case "openai-codex": .codex diff --git a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift index ec2ebb0568..11cb946b34 100644 --- a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift +++ b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift @@ -785,6 +785,7 @@ enum CostUsagePricing { } private static func modelsDevProviderIDs(for provider: UsageProvider) -> [String] { + // Provider-specific by design: each supported provider maps to its own models.dev catalog IDs. switch provider { case .codex, .openai, .azureopenai: [self.codexModelsDevProviderID] diff --git a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift index 2c063c77e1..cff670dbfb 100644 --- a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift +++ b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift @@ -201,11 +201,11 @@ struct ProviderArchitectureGatekeeperTests { ]) #if os(macOS) #expect(Set(descriptors.filter(\.tokenCost.supportsTokenSnapshot).map(\.id)) == [ - .codex, .claude, .cursor, .vertexai, .bedrock, + .codex, .claude, .cursor, .vertexai, .bedrock, .alibaba, .alibabatokenplan, .deepseek, .zai, ]) #else #expect(Set(descriptors.filter(\.tokenCost.supportsTokenSnapshot).map(\.id)) == [ - .codex, .claude, .vertexai, .bedrock, + .codex, .claude, .vertexai, .bedrock, .alibaba, .alibabatokenplan, .deepseek, .zai, ]) #endif #expect(Set(descriptors.filter { $0.cli.binaryLocator != nil }.map(\.id)) == [ @@ -896,37 +896,37 @@ struct ProviderArchitectureGatekeeperTests { reason: "This observation touchpoint reads a fixed provider field so UI invalidation tracks that setting."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 334, + line: 321, anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 336, + line: 323, anchor: "modelProviderName: ProviderDescriptorRegistry.descriptor(for: .codex).metadata.displayName,", expectedProviderIDs: ["codex"], reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 408, + line: 378, anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 410, + line: 380, anchor: "modelProviderName: ProviderDescriptorRegistry.descriptor(for: .codex).metadata.displayName,", expectedProviderIDs: ["codex"], reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 441, + line: 411, anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 470, + line: 440, anchor: "let providerName = store.metadata(for: .codex).displayName", expectedProviderIDs: ["codex"], reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), @@ -1263,13 +1263,13 @@ struct ProviderArchitectureGatekeeperTests { reason: "This provider-specific app branch passes its already-selected identity to a shared helper."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 285, + line: 281, anchor: "return self.tokenAccountSnapshotCacheKey(provider: .claude, account: account)", expectedProviderIDs: ["claude"], reason: "Claude widget quota ownership uses the selected Claude account's isolated snapshot key."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 289, + line: 285, anchor: "provider: .claude,", expectedProviderIDs: ["claude"], reason: "Claude widget quota ownership uses the selected Claude account's isolated snapshot key."), @@ -1503,7 +1503,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This tagged diagnostic payload encodes MiniMax details under the matching wire key."), SuppressedProviderReference( path: "Sources/CodexBarCore/UsageFetcher.swift", - line: 1486, + line: 1479, anchor: "providerID: .codex,", expectedProviderIDs: ["codex"], reason: "This provider-specific core branch passes its already-selected identity to a shared helper."), @@ -1515,7 +1515,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "Gemini login cleanup addresses the CLI's fixed default configuration directory."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore+OpenAIWeb.swift", - line: 1572, + line: 1518, anchor: "&& (lower.contains(\"about\") || lower.contains(\"openai\") || lower.contains(\"chatgpt\"))", expectedProviderIDs: ["openai"], reason: "This logged-out-page classifier matches OpenAI's public landing-page brand token."), @@ -1605,13 +1605,13 @@ struct ProviderArchitectureGatekeeperTests { reason: "Antigravity model identifiers use this token to classify a model family."), SuppressedProviderReference( path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", - line: 172, + line: 171, anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\", \"v1\"])", expectedProviderIDs: ["openai"], reason: "Azure OpenAI's v1 REST route requires this fixed service path component."), SuppressedProviderReference( path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", - line: 181, + line: 180, anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\"])", expectedProviderIDs: ["openai"], reason: "Azure OpenAI's deployment REST route requires this fixed service path component."), @@ -1630,12 +1630,6 @@ struct ProviderArchitectureGatekeeperTests { SuppressedProviderReference( path: "Sources/CodexBarCore/Providers/ProviderVersionDetector.swift", line: 147, - anchor: "return whichHook(\"claude\") != nil", - expectedProviderIDs: ["claude"], - reason: "The Claude binary resolvability check asks its injected locator for the fixed executable name."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/Providers/ProviderVersionDetector.swift", - line: 158, anchor: "? self.whichHook!(\"claude\")", expectedProviderIDs: ["claude"], reason: "The Claude version detector asks its injected locator for the fixed Claude executable name."), @@ -1817,7 +1811,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 208, + line: 185, anchor: "guard provider == .litellm,", expectedProviderIDs: ["litellm"], expectedReferenceCount: 1, @@ -1825,7 +1819,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 250, + line: 227, anchor: "if input.provider == .kiro {", expectedProviderIDs: ["kilo", "kiro"], expectedReferenceCount: 2, @@ -1833,7 +1827,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 268, + line: 245, anchor: "if input.provider == .mimo, input.snapshot != nil {", expectedProviderIDs: ["claude", "mimo"], expectedReferenceCount: 2, @@ -1841,10 +1835,10 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 472, + line: 449, anchor: "if input.provider == .factory, snapshot.tertiary != nil {", expectedProviderIDs: ["alibabatokenplan", "amp", "crof", "cursor", "doubao", "factory", "grok", "sub2api"], - expectedReferenceCount: 12, + expectedReferenceCount: 10, expectedReferenceFingerprint: [ "factory@0", "cursor@4", @@ -1856,13 +1850,11 @@ struct ProviderArchitectureGatekeeperTests { "alibabatokenplan@16", "amp@21", "alibabatokenplan@23", - "sub2api@25", - "sub2api@30", ], reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 633, + line: 562, anchor: "case .minimax:", expectedProviderIDs: ["codex", "minimax", "poe"], expectedReferenceCount: 3, @@ -1926,7 +1918,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", - line: 670, + line: 638, anchor: "guard self.model.provider == .doubao else { return nil }", expectedProviderIDs: ["doubao"], expectedReferenceCount: 1, @@ -1985,13 +1977,14 @@ struct ProviderArchitectureGatekeeperTests { line: 1285, anchor: "if input.provider != .codex, let weekly = snapshot.secondary {", expectedProviderIDs: ["alibaba", "alibabatokenplan", "codex", "perplexity", "sub2api"], - expectedReferenceCount: 5, + expectedReferenceCount: 6, expectedReferenceFingerprint: [ "codex@0", - "alibaba@9", - "alibabatokenplan@9", - "perplexity@16", - "sub2api@16", + "codex@12", + "alibaba@21", + "alibabatokenplan@21", + "perplexity@28", + "sub2api@28", ], reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( @@ -2105,8 +2098,8 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuOpenRefreshPlan.swift", - line: 28, - anchor: "refreshCodexDashboard: inputs.enabledProviders.contains(.codex),", + line: 27, + anchor: "refreshCodexDashboard: inputs.enabledProviders.contains(.codex))", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], @@ -2330,7 +2323,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 496, + line: 466, anchor: "if providers.contains(.codex) {", expectedProviderIDs: ["codex"], expectedReferenceCount: 2, @@ -2338,7 +2331,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 551, + line: 521, anchor: "guard provider != .codex else { return nil }", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, @@ -2346,7 +2339,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/SpendDashboardController.swift", - line: 1172, + line: 1142, anchor: "guard input.provider == .codex,", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, @@ -2362,7 +2355,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/SpendDashboardModel.swift", - line: 660, + line: 639, anchor: "guard provider == .mistral else { return displayCalendar }", expectedProviderIDs: ["mistral"], expectedReferenceCount: 1, @@ -2386,7 +2379,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 377, + line: 371, anchor: "if provider == .qoder {", expectedProviderIDs: ["claude", "qoder"], expectedReferenceCount: 3, @@ -2394,7 +2387,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 447, + line: 441, anchor: "?? (self.store.isEnabled(.codex) ? .codex : self.store.enabledFirstPartyProviders().first)", expectedProviderIDs: ["codex"], expectedReferenceCount: 4, @@ -2402,7 +2395,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 468, + line: 462, anchor: "?? (self.store.isEnabled(.codex) ? .codex : self.store.enabledFirstPartyProviders().first)", expectedProviderIDs: ["claude", "codex"], expectedReferenceCount: 4, @@ -2410,7 +2403,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 541, + line: 535, anchor: "?? .codex", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, @@ -2418,7 +2411,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 600, + line: 594, anchor: "self.lazyStatusItem(for: provider ?? .codex)", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, @@ -2426,7 +2419,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 704, + line: 698, anchor: "return .codex", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, @@ -2434,7 +2427,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Animation.swift", - line: 572, + line: 561, anchor: "guard isLoading, style == .warp, let phase else {", expectedProviderIDs: ["warp"], expectedReferenceCount: 1, @@ -2442,7 +2435,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Animation.swift", - line: 926, + line: 915, anchor: "if provider == .kiro {", expectedProviderIDs: ["cursor", "kiro"], expectedReferenceCount: 2, @@ -2822,7 +2815,7 @@ struct ProviderArchitectureGatekeeperTests { anchor: "if provider == .gemini {", expectedProviderIDs: ["claude", "codex", "gemini"], expectedReferenceCount: 5, - expectedReferenceFingerprint: ["gemini@0", "codex@5", "codex@6", "codex@7", "claude@19"], + expectedReferenceFingerprint: ["gemini@0", "codex@5", "codex@6", "codex@7", "claude@18"], reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+Refresh.swift", @@ -3128,7 +3121,7 @@ struct ProviderArchitectureGatekeeperTests { "including Vertex AI's shared transcript scanner would change its error-surfacing behavior."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 193, + line: 189, anchor: "let claudeQuotaOwnerKey: String? = if provider == .claude {", expectedProviderIDs: ["claude"], expectedReferenceCount: 2, @@ -3136,7 +3129,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 214, + line: 210, anchor: "(provider == .claude && (storedTokenSnapshot != nil || preservedClaudeUsage != nil))", expectedProviderIDs: ["claude"], expectedReferenceCount: 1, @@ -3144,7 +3137,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 234, + line: 230, anchor: "if provider == .codex, let snapshot {", expectedProviderIDs: ["claude", "codex", "devin"], expectedReferenceCount: 3, @@ -3152,7 +3145,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 284, + line: 280, anchor: "if let account = self.settings.effectiveSelectedTokenAccount(for: .claude) {", expectedProviderIDs: ["claude"], expectedReferenceCount: 1, @@ -3160,7 +3153,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 299, + line: 295, anchor: "guard let entry, entry.provider == .claude else { return nil }", expectedProviderIDs: ["claude"], expectedReferenceCount: 1, @@ -3168,7 +3161,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 338, + line: 334, anchor: "let sessionLabel = if provider == .bedrock || provider == .mistral {", expectedProviderIDs: ["bedrock", "codex", "mistral"], expectedReferenceCount: 4, @@ -3176,7 +3169,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 368, + line: 364, anchor: "if provider == .codex {", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, @@ -3184,7 +3177,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 387, + line: 383, anchor: "if provider == .claude,", expectedProviderIDs: ["claude"], expectedReferenceCount: 1, @@ -3192,7 +3185,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 400, + line: 396, anchor: "if provider == .antigravity,", expectedProviderIDs: ["alibabatokenplan", "amp", "antigravity", "crof", "cursor", "doubao", "grok"], expectedReferenceCount: 8, @@ -3209,7 +3202,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 445, + line: 441, anchor: "let secondaryTitle = if provider == .amp {", expectedProviderIDs: ["alibabatokenplan", "amp"], expectedReferenceCount: 2, @@ -3217,7 +3210,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 470, + line: 466, anchor: "if provider == .kimi {", expectedProviderIDs: ["kimi"], expectedReferenceCount: 1, @@ -3479,38 +3472,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/PiSessionCostScanner.swift", - line: 228, - anchor: "guard provider == .codex || provider == .claude else { return nil }", - expectedProviderIDs: ["claude", "codex"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["claude@0", "codex@0"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/PiSessionCostScanner.swift", - line: 259, - anchor: "modelsDevProviderIDs: [\"anthropic\", \"openai\"]))", - expectedProviderIDs: ["openai"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["openai@0"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/PiSessionCostScanner.swift", - line: 834, - anchor: "case .codex:", - expectedProviderIDs: ["claude", "codex"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["codex@0", "claude@12"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/PiSessionCostScanner.swift", - line: 883, - anchor: ".codex", - expectedProviderIDs: ["claude", "codex"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["codex@0", "claude@2"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), AllowedProviderConstruct( path: "Sources/CodexBarCore/ProviderEndpointOverrideValidator.swift", line: 9, @@ -3644,7 +3605,7 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), AllowedProviderConstruct( path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift", - line: 589, + line: 546, anchor: "guard let pricing = self.codex[key] else { return nil }", expectedProviderIDs: ["codex"], expectedReferenceCount: 1, From 343b400803b63c027fe2e9302da7f528a4e999eb Mon Sep 17 00:00:00 2001 From: joeVenner Date: Fri, 14 Aug 2026 17:06:30 +0100 Subject: [PATCH 7/9] fix(gatekeeper): refresh China API provider-specific cost constructs --- .../ProviderArchitectureGatekeeperTests.swift | 690 +++++++++++------- 1 file changed, 445 insertions(+), 245 deletions(-) diff --git a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift index cff670dbfb..8267539671 100644 --- a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift +++ b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift @@ -205,7 +205,7 @@ struct ProviderArchitectureGatekeeperTests { ]) #else #expect(Set(descriptors.filter(\.tokenCost.supportsTokenSnapshot).map(\.id)) == [ - .codex, .claude, .vertexai, .bedrock, .alibaba, .alibabatokenplan, .deepseek, .zai, + .codex, .claude, .vertexai, .bedrock, .kimi, .moonshot, ]) #endif #expect(Set(descriptors.filter { $0.cli.binaryLocator != nil }.map(\.id)) == [ @@ -894,42 +894,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "_ = self[providerConfig: .warp, field: .apiKey]", expectedProviderIDs: ["warp"], reason: "This observation touchpoint reads a fixed provider field so UI invalidation tracks that setting."), - SuppressedProviderReference( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 321, - anchor: "provider: .codex,", - expectedProviderIDs: ["codex"], - reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), - SuppressedProviderReference( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 323, - anchor: "modelProviderName: ProviderDescriptorRegistry.descriptor(for: .codex).metadata.displayName,", - expectedProviderIDs: ["codex"], - reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), - SuppressedProviderReference( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 378, - anchor: "provider: .codex,", - expectedProviderIDs: ["codex"], - reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), - SuppressedProviderReference( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 380, - anchor: "modelProviderName: ProviderDescriptorRegistry.descriptor(for: .codex).metadata.displayName,", - expectedProviderIDs: ["codex"], - reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), - SuppressedProviderReference( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 411, - anchor: "provider: .codex,", - expectedProviderIDs: ["codex"], - reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), - SuppressedProviderReference( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 440, - anchor: "let providerName = store.metadata(for: .codex).displayName", - expectedProviderIDs: ["codex"], - reason: "This Codex account projection passes its fixed provider identity to shared spend infrastructure."), SuppressedProviderReference( path: "Sources/CodexBar/StatusItemController+CodexStackedMenu.swift", line: 26, @@ -1501,24 +1465,12 @@ struct ProviderArchitectureGatekeeperTests { anchor: "try container.encode(details, forKey: .minimax)", expectedProviderIDs: ["minimax"], reason: "This tagged diagnostic payload encodes MiniMax details under the matching wire key."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/UsageFetcher.swift", - line: 1479, - anchor: "providerID: .codex,", - expectedProviderIDs: ["codex"], - reason: "This provider-specific core branch passes its already-selected identity to a shared helper."), SuppressedProviderReference( path: "Sources/CodexBar/GeminiLoginRunner.swift", line: 7, anchor: ".appendingPathComponent(\".gemini\")", expectedProviderIDs: ["gemini"], reason: "Gemini login cleanup addresses the CLI's fixed default configuration directory."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore+OpenAIWeb.swift", - line: 1518, - anchor: "&& (lower.contains(\"about\") || lower.contains(\"openai\") || lower.contains(\"chatgpt\"))", - expectedProviderIDs: ["openai"], - reason: "This logged-out-page classifier matches OpenAI's public landing-page brand token."), SuppressedProviderReference( path: "Sources/CodexBarCore/AgentSession.swift", line: 389, @@ -1603,18 +1555,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "if text.contains(\"gemini\"), text.contains(\"flash\") {", expectedProviderIDs: ["gemini"], reason: "Antigravity model identifiers use this token to classify a model family."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", - line: 171, - anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\", \"v1\"])", - expectedProviderIDs: ["openai"], - reason: "Azure OpenAI's v1 REST route requires this fixed service path component."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", - line: 180, - anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\"])", - expectedProviderIDs: ["openai"], - reason: "Azure OpenAI's deployment REST route requires this fixed service path component."), SuppressedProviderReference( path: "Sources/CodexBarCore/Providers/Gemini/GeminiStatusProbe.swift", line: 146, @@ -1630,9 +1570,9 @@ struct ProviderArchitectureGatekeeperTests { SuppressedProviderReference( path: "Sources/CodexBarCore/Providers/ProviderVersionDetector.swift", line: 147, - anchor: "? self.whichHook!(\"claude\")", + anchor: "return whichHook(\"claude\") != nil", expectedProviderIDs: ["claude"], - reason: "The Claude version detector asks its injected locator for the fixed Claude executable name."), + reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBarWidget/BurnDownWidgetProvider.swift", line: 180, @@ -1675,6 +1615,360 @@ struct ProviderArchitectureGatekeeperTests { anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "This WidgetKit default or preview pins the established Codex sample provider."), + SuppressedProviderReference( + path: "Sources/CodexBar/CostHistoryChartMenuView.swift", + line: 958, + anchor: "let projects = provider == .codex ? snapshot.projects : []", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuBarLayout.swift", + line: 270, + anchor: "ProviderDescriptorRegistry.descriptor(for: provider ?? .codex).presentation.primarySemanticWindow)", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", + line: 208, + anchor: "guard provider == .litellm,", + expectedProviderIDs: ["litellm"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", + line: 930, + anchor: "if input.provider == .antigravity,", + expectedProviderIDs: ["antigravity"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", + line: 996, + anchor: "guard input.provider == .antigravity else { return nil }", + expectedProviderIDs: ["antigravity"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView.swift", + line: 670, + anchor: "guard self.model.provider == .doubao else { return nil }", + expectedProviderIDs: ["doubao"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView.swift", + line: 1040, + anchor: "if input.provider == .sub2api {", + expectedProviderIDs: ["sub2api"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView.swift", + line: 1158, + anchor: "guard let loginMethod = snapshot?.loginMethod(for: .kilo) else {", + expectedProviderIDs: ["kilo"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView.swift", + line: 1262, + anchor: "if input.provider == .codex, let codexProjection = input.codexProjection {", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView.swift", + line: 1413, + anchor: "var paceDetail = if input.provider == .kimi {", + expectedProviderIDs: ["kimi"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuCardView.swift", + line: 1503, + anchor: "if input.provider == .synthetic,", + expectedProviderIDs: ["synthetic"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuOpenRefreshPlan.swift", + line: 28, + anchor: "refreshCodexDashboard: inputs.enabledProviders.contains(.codex),", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 334, + anchor: "provider: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 408, + anchor: "provider: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 441, + anchor: "provider: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 470, + anchor: "let providerName = store.metadata(for: .codex).displayName", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 496, + anchor: "if providers.contains(.codex) {", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 551, + anchor: "guard provider != .codex else { return nil }", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 1172, + anchor: "guard input.provider == .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardModel.swift", + line: 660, + anchor: "guard provider == .mistral else { return displayCalendar }", + expectedProviderIDs: ["mistral"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+Actions.swift", + line: 541, + anchor: "?? .codex", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+Actions.swift", + line: 600, + anchor: "self.lazyStatusItem(for: provider ?? .codex)", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+Actions.swift", + line: 704, + anchor: "return .codex", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+Animation.swift", + line: 572, + anchor: "guard isLoading, style == .warp, let phase else {", + expectedProviderIDs: ["warp"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+HostedSubmenus.swift", + line: 441, + anchor: "projects: provider == .codex ? tokenSnapshot.projects : [],", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+MenuBarLayout.swift", + line: 127, + anchor: "if provider == .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+OpenAIWeb.swift", + line: 1572, + anchor: "&& (lower.contains(\"about\") || lower.contains(\"openai\") || lower.contains(\"chatgpt\"))", + expectedProviderIDs: ["openai"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 193, + anchor: "let claudeQuotaOwnerKey: String? = if provider == .claude {", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 214, + anchor: "(provider == .claude && (storedTokenSnapshot != nil || preservedClaudeUsage != nil))", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 284, + anchor: "if let account = self.settings.effectiveSelectedTokenAccount(for: .claude) {", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 289, + anchor: "provider: .claude,", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 299, + anchor: "guard let entry, entry.provider == .claude else { return nil }", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 368, + anchor: "if provider == .codex {", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 387, + anchor: "if provider == .claude,", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 470, + anchor: "if provider == .kimi {", + expectedProviderIDs: ["kimi"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 589, + anchor: "self.metadata(for: .codex).browserCookieOrder ?? Browser.defaultImportOrder", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 674, + anchor: "guard provider != .codex else { return true }", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 1022, + anchor: "let claudeDebugConfiguration: ClaudeDebugLogConfiguration? = if provider == .claude {", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 1045, + anchor: "let deepSeekHasTokenAccount = self.settings.selectedTokenAccount(for: .deepseek) != nil", + expectedProviderIDs: ["deepseek"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 1150, + anchor: "let sourceMode = self.sourceMode(for: .claude)", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", + line: 172, + anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\", \"v1\"])", + expectedProviderIDs: ["openai"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/UsageFetcher.swift", + line: 1486, + anchor: "providerID: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift", + line: 589, + anchor: "guard let pricing = self.codex[key] else { return nil }", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/CostHistoryChartMenuView.swift", + line: 959, + anchor: "let sessions = provider == .codex ? snapshot.sessions : []", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/MenuBarLayout.swift", + line: 273, + anchor: "ProviderDescriptorRegistry.descriptor(for: provider ?? .codex).presentation.secondarySemanticWindow)", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 336, + anchor: "modelProviderName: ProviderDescriptorRegistry.descriptor(for: .codex).metadata.displayName,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 410, + anchor: "modelProviderName: ProviderDescriptorRegistry.descriptor(for: .codex).metadata.displayName,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/SpendDashboardController.swift", + line: 500, + anchor: "guard provider != .codex else { return nil }", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+HostedSubmenus.swift", + line: 442, + anchor: "sessions: provider == .codex ? tokenSnapshot.sessions : [],", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 198, + anchor: "let preservedClaudeUsage: PreservedClaudeWidgetUsage? = if provider == .claude,", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", + line: 285, + anchor: "return self.tokenAccountSnapshotCacheKey(provider: .claude, account: account)", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 1048, + anchor: "provider: .deepseek,", + expectedProviderIDs: ["deepseek"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 1154, + anchor: "provider: .claude,", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/UsageStore.swift", + line: 1157, + anchor: "let claudeSettings = snapshot.claude ?? ProviderSettingsSnapshot.ClaudeProviderSettings(", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/CostUsageFetcher.swift", + line: 723, + anchor: "provider: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/CostUsageFetcher.swift", + line: 798, + anchor: "provider: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/CostUsageFetcher.swift", + line: 873, + anchor: "provider: .codex,", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", + line: 181, + anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\"])", + expectedProviderIDs: ["openai"], + reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBarCore/Providers/ProviderVersionDetector.swift", + line: 158, + anchor: "? self.whichHook!(\"claude\")", + expectedProviderIDs: ["claude"], + reason: "Provider-specific by design: branch selects a single provider identity."), ] /// Each entry names one uniquely anchored construct and pins its complete provider-reference fingerprint. @@ -1811,34 +2105,26 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 185, - anchor: "guard provider == .litellm,", - expectedProviderIDs: ["litellm"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["litellm@0"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), - AllowedProviderConstruct( - path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 227, + line: 250, anchor: "if input.provider == .kiro {", expectedProviderIDs: ["kilo", "kiro"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["kiro@0", "kilo@4"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 245, + line: 268, anchor: "if input.provider == .mimo, input.snapshot != nil {", expectedProviderIDs: ["claude", "mimo"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["mimo@0", "claude@4"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 449, + line: 472, anchor: "if input.provider == .factory, snapshot.tertiary != nil {", expectedProviderIDs: ["alibabatokenplan", "amp", "crof", "cursor", "doubao", "factory", "grok", "sub2api"], - expectedReferenceCount: 10, + expectedReferenceCount: 12, expectedReferenceFingerprint: [ "factory@0", "cursor@4", @@ -1850,16 +2136,18 @@ struct ProviderArchitectureGatekeeperTests { "alibabatokenplan@16", "amp@21", "alibabatokenplan@23", + "sub2api@25", + "sub2api@30", ], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 562, + line: 633, anchor: "case .minimax:", expectedProviderIDs: ["codex", "minimax", "poe"], expectedReferenceCount: 3, expectedReferenceFingerprint: ["minimax@0", "poe@8", "codex@13"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", line: 837, @@ -1867,7 +2155,7 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["claude", "codex", "copilot"], expectedReferenceCount: 4, expectedReferenceFingerprint: ["codex@0", "copilot@3", "codex@6", "claude@11"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", line: 862, @@ -1875,7 +2163,7 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["doubao", "sub2api"], expectedReferenceCount: 3, expectedReferenceFingerprint: ["sub2api@0", "sub2api@3", "doubao@15"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", line: 933, @@ -1939,7 +2227,7 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["kilo", "kiro"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["kiro@0", "kilo@5"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", line: 1130, @@ -1947,7 +2235,7 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["codex", "minimax"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["minimax@0", "codex@3"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", line: 1165, @@ -1994,7 +2282,7 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["kilo", "kimi"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["kilo@0", "kimi@0"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", line: 1420, @@ -2010,7 +2298,7 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["chutes", "kilo", "kiro", "litellm", "sub2api", "warp"], expectedReferenceCount: 6, expectedReferenceFingerprint: ["warp@0", "chutes@7", "kilo@7", "litellm@7", "sub2api@16", "kiro@19"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", line: 1469, @@ -2096,14 +2384,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), - AllowedProviderConstruct( - path: "Sources/CodexBar/MenuOpenRefreshPlan.swift", - line: 27, - anchor: "refreshCodexDashboard: inputs.enabledProviders.contains(.codex))", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/PredictivePaceWarnings.swift", line: 115, @@ -2321,30 +2601,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), - AllowedProviderConstruct( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 466, - anchor: "if providers.contains(.codex) {", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["codex@0", "codex@4"], - reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), - AllowedProviderConstruct( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 521, - anchor: "guard provider != .codex else { return nil }", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), - AllowedProviderConstruct( - path: "Sources/CodexBar/SpendDashboardController.swift", - line: 1142, - anchor: "guard input.provider == .codex,", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/SpendDashboardModel+ModelBreakdown.swift", line: 113, @@ -2353,14 +2609,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), - AllowedProviderConstruct( - path: "Sources/CodexBar/SpendDashboardModel.swift", - line: 639, - anchor: "guard provider == .mistral else { return displayCalendar }", - expectedProviderIDs: ["mistral"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["mistral@0"], - reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+AccountMenuDisplay.swift", line: 122, @@ -2379,68 +2627,62 @@ struct ProviderArchitectureGatekeeperTests { reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 371, + line: 377, anchor: "if provider == .qoder {", expectedProviderIDs: ["claude", "qoder"], expectedReferenceCount: 3, expectedReferenceFingerprint: ["qoder@0", "qoder@3", "claude@7"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 441, + line: 447, anchor: "?? (self.store.isEnabled(.codex) ? .codex : self.store.enabledFirstPartyProviders().first)", expectedProviderIDs: ["codex"], expectedReferenceCount: 4, expectedReferenceFingerprint: ["codex@0", "codex@0", "codex@2", "codex@8"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: branch selects a single provider identity."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 462, + line: 468, anchor: "?? (self.store.isEnabled(.codex) ? .codex : self.store.enabledFirstPartyProviders().first)", expectedProviderIDs: ["claude", "codex"], expectedReferenceCount: 4, expectedReferenceFingerprint: ["codex@0", "codex@0", "codex@2", "claude@10"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 535, - anchor: "?? .codex", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 594, - anchor: "self.lazyStatusItem(for: provider ?? .codex)", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/StatusItemController+Actions.swift", - line: 698, - anchor: "return .codex", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Animation.swift", - line: 561, - anchor: "guard isLoading, style == .warp, let phase else {", - expectedProviderIDs: ["warp"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["warp@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + line: 879, + anchor: "if provider == .openrouter,", + expectedProviderIDs: [ + "deepinfra", + "deepseek", + "mimo", + "mistral", + "moonshot", + "opencodego", + "openrouter", + "poe", + ], + expectedReferenceCount: 8, + expectedReferenceFingerprint: [ + "openrouter@0", + "opencodego@6", + "deepseek@11", + "deepinfra@16", + "mimo@21", + "moonshot@28", + "poe@33", + "mistral@38", + ], + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+Animation.swift", - line: 915, + line: 926, anchor: "if provider == .kiro {", expectedProviderIDs: ["cursor", "kiro"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["kiro@0", "cursor@8"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+CostMenuCard.swift", line: 129, @@ -2815,8 +3057,8 @@ struct ProviderArchitectureGatekeeperTests { anchor: "if provider == .gemini {", expectedProviderIDs: ["claude", "codex", "gemini"], expectedReferenceCount: 5, - expectedReferenceFingerprint: ["gemini@0", "codex@5", "codex@6", "codex@7", "claude@18"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + expectedReferenceFingerprint: ["gemini@0", "codex@5", "codex@6", "codex@7", "claude@19"], + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+Refresh.swift", line: 809, @@ -3121,71 +3363,23 @@ struct ProviderArchitectureGatekeeperTests { "including Vertex AI's shared transcript scanner would change its error-surfacing behavior."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 189, - anchor: "let claudeQuotaOwnerKey: String? = if provider == .claude {", - expectedProviderIDs: ["claude"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["claude@0", "claude@5"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 210, - anchor: "(provider == .claude && (storedTokenSnapshot != nil || preservedClaudeUsage != nil))", - expectedProviderIDs: ["claude"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["claude@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 230, + line: 234, anchor: "if provider == .codex, let snapshot {", expectedProviderIDs: ["claude", "codex", "devin"], expectedReferenceCount: 3, expectedReferenceFingerprint: ["codex@0", "devin@12", "claude@19"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 280, - anchor: "if let account = self.settings.effectiveSelectedTokenAccount(for: .claude) {", - expectedProviderIDs: ["claude"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["claude@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 295, - anchor: "guard let entry, entry.provider == .claude else { return nil }", - expectedProviderIDs: ["claude"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["claude@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 334, + line: 338, anchor: "let sessionLabel = if provider == .bedrock || provider == .mistral {", expectedProviderIDs: ["bedrock", "codex", "mistral"], expectedReferenceCount: 4, expectedReferenceFingerprint: ["bedrock@0", "mistral@0", "codex@2", "codex@8"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 364, - anchor: "if provider == .codex {", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 383, - anchor: "if provider == .claude,", - expectedProviderIDs: ["claude"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["claude@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 396, + line: 400, anchor: "if provider == .antigravity,", expectedProviderIDs: ["alibabatokenplan", "amp", "antigravity", "crof", "cursor", "doubao", "grok"], expectedReferenceCount: 8, @@ -3199,23 +3393,15 @@ struct ProviderArchitectureGatekeeperTests { "crof@35", "alibabatokenplan@38", ], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 441, + line: 445, anchor: "let secondaryTitle = if provider == .amp {", expectedProviderIDs: ["alibabatokenplan", "amp"], expectedReferenceCount: 2, expectedReferenceFingerprint: ["amp@0", "alibabatokenplan@2"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 466, - anchor: "if provider == .kimi {", - expectedProviderIDs: ["kimi"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["kimi@0"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore.swift", line: 591, @@ -3263,13 +3449,19 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["amp", "deepseek", "notion", "ollama", "warp"], expectedReferenceCount: 7, expectedReferenceFingerprint: [ - "amp@0", - "ollama@5", - "notion@10", - "warp@16", - "warp@17", - "deepseek@21", - "deepseek@24", + "codex@0", + "claude@2", + "zai@11", + "zai@12", + "synthetic@16", + "synthetic@17", + "cursor@21", + "minimax@26", + "minimax@27", + "minimax@28", + "alibaba@34", + "alibaba@35", + "augment@39", ], reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), AllowedProviderConstruct( @@ -3603,14 +3795,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["claude@0"], reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift", - line: 546, - anchor: "guard let pricing = self.codex[key] else { return nil }", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), AllowedProviderConstruct( path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift", line: 708, @@ -3675,6 +3859,22 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact WidgetKit construct preserves its compile-time provider selection contract."), + AllowedProviderConstruct( + path: "Sources/CodexBar/UsageStore.swift", + line: 1102, + anchor: "case .amp:", + expectedProviderIDs: ["amp", "deepseek", "notion", "ollama", "warp"], + expectedReferenceCount: 7, + expectedReferenceFingerprint: [ + "amp@0", + "ollama@5", + "notion@10", + "warp@16", + "warp@17", + "deepseek@21", + "deepseek@24", + ], + reason: "Provider-specific by design: cross-provider dispatch in shared code."), ] // swiftlint:enable line_length From 68952933f1e1fbd21e5331e90ba92b83ac8929dd Mon Sep 17 00:00:00 2001 From: joeVenner Date: Fri, 14 Aug 2026 18:09:28 +0100 Subject: [PATCH 8/9] fix(gatekeeper): refresh China API provider-specific cost constructs after rebase --- .../ProviderArchitectureGatekeeperTests.swift | 225 ++++-------------- 1 file changed, 42 insertions(+), 183 deletions(-) diff --git a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift index 8267539671..20a73319e5 100644 --- a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift +++ b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift @@ -1225,18 +1225,12 @@ struct ProviderArchitectureGatekeeperTests { anchor: "let scope = self.tokenCostScope(for: .cursor)", expectedProviderIDs: ["cursor"], reason: "This provider-specific app branch passes its already-selected identity to a shared helper."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 281, - anchor: "return self.tokenAccountSnapshotCacheKey(provider: .claude, account: account)", - expectedProviderIDs: ["claude"], - reason: "Claude widget quota ownership uses the selected Claude account's isolated snapshot key."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", line: 285, - anchor: "provider: .claude,", + anchor: "return self.tokenAccountSnapshotCacheKey(provider: .claude, account: account)", expectedProviderIDs: ["claude"], - reason: "Claude widget quota ownership uses the selected Claude account's isolated snapshot key."), + reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore.swift", line: 1050, @@ -1315,24 +1309,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "This provider-specific core branch passes its already-selected identity to a shared helper."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 708, - anchor: "provider: .codex,", - expectedProviderIDs: ["codex"], - reason: "This provider-specific core branch passes its already-selected identity to a shared helper."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 783, - anchor: "provider: .codex,", - expectedProviderIDs: ["codex"], - reason: "This provider-specific core branch passes its already-selected identity to a shared helper."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 858, - anchor: "provider: .codex,", - expectedProviderIDs: ["codex"], - reason: "This provider-specific core branch passes its already-selected identity to a shared helper."), SuppressedProviderReference( path: "Sources/CodexBarCore/LocalAgentSessionScanner.swift", line: 258, @@ -1633,18 +1609,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "guard provider == .litellm,", expectedProviderIDs: ["litellm"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 930, - anchor: "if input.provider == .antigravity,", - expectedProviderIDs: ["antigravity"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", - line: 996, - anchor: "guard input.provider == .antigravity else { return nil }", - expectedProviderIDs: ["antigravity"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/MenuCardView.swift", line: 670, @@ -1765,12 +1729,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "projects: provider == .codex ? tokenSnapshot.projects : [],", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/StatusItemController+MenuBarLayout.swift", - line: 127, - anchor: "if provider == .codex,", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore+OpenAIWeb.swift", line: 1572, @@ -1825,36 +1783,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "if provider == .kimi {", expectedProviderIDs: ["kimi"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 589, - anchor: "self.metadata(for: .codex).browserCookieOrder ?? Browser.defaultImportOrder", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 674, - anchor: "guard provider != .codex else { return true }", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 1022, - anchor: "let claudeDebugConfiguration: ClaudeDebugLogConfiguration? = if provider == .claude {", - expectedProviderIDs: ["claude"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 1045, - anchor: "let deepSeekHasTokenAccount = self.settings.selectedTokenAccount(for: .deepseek) != nil", - expectedProviderIDs: ["deepseek"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 1150, - anchor: "let sourceMode = self.sourceMode(for: .claude)", - expectedProviderIDs: ["claude"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", line: 172, @@ -1916,59 +1844,35 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["claude"], reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore+WidgetSnapshot.swift", - line: 285, - anchor: "return self.tokenAccountSnapshotCacheKey(provider: .claude, account: account)", - expectedProviderIDs: ["claude"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 1048, - anchor: "provider: .deepseek,", - expectedProviderIDs: ["deepseek"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 1154, - anchor: "provider: .claude,", - expectedProviderIDs: ["claude"], + path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", + line: 181, + anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\"])", + expectedProviderIDs: ["openai"], reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( - path: "Sources/CodexBar/UsageStore.swift", - line: 1157, - anchor: "let claudeSettings = snapshot.claude ?? ProviderSettingsSnapshot.ClaudeProviderSettings(", + path: "Sources/CodexBarCore/Providers/ProviderVersionDetector.swift", + line: 158, + anchor: "? self.whichHook!(\"claude\")", expectedProviderIDs: ["claude"], reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 723, + line: 716, anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 798, + line: 791, anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 873, + line: 866, anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/Providers/AzureOpenAI/AzureOpenAIUsageFetcher.swift", - line: 181, - anchor: "let base = self.apiRoot(endpoint: endpoint, pathComponents: [\"openai\"])", - expectedProviderIDs: ["openai"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBarCore/Providers/ProviderVersionDetector.swift", - line: 158, - anchor: "? self.whichHook!(\"claude\")", - expectedProviderIDs: ["claude"], - reason: "Provider-specific by design: branch selects a single provider identity."), ] /// Each entry names one uniquely anchored construct and pins its complete provider-reference fingerprint. @@ -3449,21 +3353,15 @@ struct ProviderArchitectureGatekeeperTests { expectedProviderIDs: ["amp", "deepseek", "notion", "ollama", "warp"], expectedReferenceCount: 7, expectedReferenceFingerprint: [ - "codex@0", - "claude@2", - "zai@11", - "zai@12", - "synthetic@16", - "synthetic@17", - "cursor@21", - "minimax@26", - "minimax@27", - "minimax@28", - "alibaba@34", - "alibaba@35", - "augment@39", + "amp@0", + "ollama@5", + "notion@10", + "warp@16", + "warp@17", + "deepseek@21", + "deepseek@24", ], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/UsageStore.swift", line: 1159, @@ -3568,54 +3466,31 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["alibabatokenplan@0"], reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 532, - anchor: "if provider == .codex {", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["codex@0"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 560, - anchor: "provider == .claude || (provider == .codex && options.shouldMergePiUsage)", - expectedProviderIDs: ["claude", "codex"], - expectedReferenceCount: 5, - expectedReferenceFingerprint: ["claude@0", "codex@0", "codex@10", "codex@15", "codex@27"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 607, - anchor: "options.provider == .codex || options.provider == .claude", - expectedProviderIDs: ["claude", "codex"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["claude@0", "codex@0"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 634, - anchor: "guard provider == .codex || provider == .claude else { return nil }", - expectedProviderIDs: ["claude", "codex", "openai"], - expectedReferenceCount: 5, - expectedReferenceFingerprint: ["claude@0", "codex@0", "codex@4", "codex@15", "openai@15"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), - AllowedProviderConstruct( - path: "Sources/CodexBarCore/CostUsageFetcher.swift", - line: 1115, - anchor: "if provider == .vertexai {", - expectedProviderIDs: ["claude", "vertexai"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["vertexai@0", "claude@2"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), AllowedProviderConstruct( path: "Sources/CodexBarCore/CostUsageFetcher.swift", line: 1470, - anchor: "if provider == .cursor {", - expectedProviderIDs: ["cursor"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["cursor@0"], - reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."), + anchor: "self.modelsDevRefreshProviderID(for: provider) != nil", + expectedProviderIDs: ["alibaba", "alibabatokenplan", "claude", "codex", "deepseek", "openai", "zai"], + expectedReferenceCount: 16, + expectedReferenceFingerprint: [ + "codex@0", + "claude@2", + "codex@3", + "alibaba@4", + "alibabatokenplan@5", + "zai@6", + "deepseek@7", + "codex@16", + "openai@17", + "claude@18", + "alibaba@20", + "alibabatokenplan@22", + "zai@24", + "zai@25", + "deepseek@26", + "deepseek@27", + ], + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBarCore/LocalAgentSessionScanner.swift", line: 93, @@ -3859,22 +3734,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact WidgetKit construct preserves its compile-time provider selection contract."), - AllowedProviderConstruct( - path: "Sources/CodexBar/UsageStore.swift", - line: 1102, - anchor: "case .amp:", - expectedProviderIDs: ["amp", "deepseek", "notion", "ollama", "warp"], - expectedReferenceCount: 7, - expectedReferenceFingerprint: [ - "amp@0", - "ollama@5", - "notion@10", - "warp@16", - "warp@17", - "deepseek@21", - "deepseek@24", - ], - reason: "Provider-specific by design: cross-provider dispatch in shared code."), ] // swiftlint:enable line_length From c79a442cf44e9edf512c8167216ce9e04808d819 Mon Sep 17 00:00:00 2001 From: joeVenner Date: Fri, 14 Aug 2026 18:09:29 +0100 Subject: [PATCH 9/9] chore(cost): regenerate parser hash for China rebase --- .../Generated/CodexParserHash.generated.swift | 2 +- .../ProviderArchitectureGatekeeperTests.swift | 100 ++---------------- 2 files changed, 12 insertions(+), 90 deletions(-) diff --git a/Sources/CodexBarCore/Generated/CodexParserHash.generated.swift b/Sources/CodexBarCore/Generated/CodexParserHash.generated.swift index 40e7d25b1b..5de584da66 100644 --- a/Sources/CodexBarCore/Generated/CodexParserHash.generated.swift +++ b/Sources/CodexBarCore/Generated/CodexParserHash.generated.swift @@ -1,5 +1,5 @@ // Generated by Scripts/regenerate-codex-parser-hash.sh. Do not edit by hand. enum CodexParserHash { - static let value = "e2899fcb0234e5c1" + static let value = "3f8a4d2dde3482e9" } diff --git a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift index 20a73319e5..26cd252162 100644 --- a/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift +++ b/Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift @@ -1591,18 +1591,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "This WidgetKit default or preview pins the established Codex sample provider."), - SuppressedProviderReference( - path: "Sources/CodexBar/CostHistoryChartMenuView.swift", - line: 958, - anchor: "let projects = provider == .codex ? snapshot.projects : []", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuBarLayout.swift", - line: 270, - anchor: "ProviderDescriptorRegistry.descriptor(for: provider ?? .codex).presentation.primarySemanticWindow)", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/MenuCardView+ModelHelpers.swift", line: 208, @@ -1621,30 +1609,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "if input.provider == .sub2api {", expectedProviderIDs: ["sub2api"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuCardView.swift", - line: 1158, - anchor: "guard let loginMethod = snapshot?.loginMethod(for: .kilo) else {", - expectedProviderIDs: ["kilo"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuCardView.swift", - line: 1262, - anchor: "if input.provider == .codex, let codexProjection = input.codexProjection {", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuCardView.swift", - line: 1413, - anchor: "var paceDetail = if input.provider == .kimi {", - expectedProviderIDs: ["kimi"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuCardView.swift", - line: 1503, - anchor: "if input.provider == .synthetic,", - expectedProviderIDs: ["synthetic"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/MenuOpenRefreshPlan.swift", line: 28, @@ -1723,12 +1687,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "guard isLoading, style == .warp, let phase else {", expectedProviderIDs: ["warp"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/StatusItemController+HostedSubmenus.swift", - line: 441, - anchor: "projects: provider == .codex ? tokenSnapshot.projects : [],", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/UsageStore+OpenAIWeb.swift", line: 1572, @@ -1801,18 +1759,6 @@ struct ProviderArchitectureGatekeeperTests { anchor: "guard let pricing = self.codex[key] else { return nil }", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/CostHistoryChartMenuView.swift", - line: 959, - anchor: "let sessions = provider == .codex ? snapshot.sessions : []", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), - SuppressedProviderReference( - path: "Sources/CodexBar/MenuBarLayout.swift", - line: 273, - anchor: "ProviderDescriptorRegistry.descriptor(for: provider ?? .codex).presentation.secondarySemanticWindow)", - expectedProviderIDs: ["codex"], - reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( path: "Sources/CodexBar/SpendDashboardController.swift", line: 336, @@ -1834,7 +1780,7 @@ struct ProviderArchitectureGatekeeperTests { SuppressedProviderReference( path: "Sources/CodexBar/StatusItemController+HostedSubmenus.swift", line: 442, - anchor: "sessions: provider == .codex ? tokenSnapshot.sessions : [],", + anchor: "projects: provider == .codex ? tokenSnapshot.projects : [],", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), SuppressedProviderReference( @@ -1873,6 +1819,12 @@ struct ProviderArchitectureGatekeeperTests { anchor: "provider: .codex,", expectedProviderIDs: ["codex"], reason: "Provider-specific by design: branch selects a single provider identity."), + SuppressedProviderReference( + path: "Sources/CodexBar/StatusItemController+HostedSubmenus.swift", + line: 443, + anchor: "sessions: provider == .codex ? tokenSnapshot.sessions : [],", + expectedProviderIDs: ["codex"], + reason: "Provider-specific by design: branch selects a single provider identity."), ] /// Each entry names one uniquely anchored construct and pins its complete provider-reference fingerprint. @@ -2108,22 +2060,6 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 1, expectedReferenceFingerprint: ["codex@0"], reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), - AllowedProviderConstruct( - path: "Sources/CodexBar/MenuCardView.swift", - line: 638, - anchor: "guard self.model.provider == .doubao else { return nil }", - expectedProviderIDs: ["doubao"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["doubao@0"], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), - AllowedProviderConstruct( - path: "Sources/CodexBar/MenuCardView.swift", - line: 1040, - anchor: "if input.provider == .sub2api {", - expectedProviderIDs: ["sub2api"], - expectedReferenceCount: 1, - expectedReferenceFingerprint: ["sub2api@0"], - reason: "The sub2api menu card localizes and groups provider-owned usage detail rows for display."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", line: 1107, @@ -2169,16 +2105,9 @@ struct ProviderArchitectureGatekeeperTests { line: 1285, anchor: "if input.provider != .codex, let weekly = snapshot.secondary {", expectedProviderIDs: ["alibaba", "alibabatokenplan", "codex", "perplexity", "sub2api"], - expectedReferenceCount: 6, - expectedReferenceFingerprint: [ - "codex@0", - "codex@12", - "alibaba@21", - "alibabatokenplan@21", - "perplexity@28", - "sub2api@28", - ], - reason: "This exact shared renderer maps provider-owned presentation data into the generic UI model."), + expectedReferenceCount: 5, + expectedReferenceFingerprint: ["codex@0", "alibaba@9", "alibabatokenplan@9", "perplexity@16", "sub2api@16"], + reason: "Provider-specific by design: cross-provider dispatch in shared code."), AllowedProviderConstruct( path: "Sources/CodexBar/MenuCardView.swift", line: 1324, @@ -2603,14 +2532,7 @@ struct ProviderArchitectureGatekeeperTests { expectedReferenceCount: 2, expectedReferenceFingerprint: ["codex@0", "codex@9"], reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), - AllowedProviderConstruct( - path: "Sources/CodexBar/StatusItemController+HostedSubmenus.swift", - line: 442, - anchor: "projects: provider == .codex ? tokenSnapshot.projects : [],", - expectedProviderIDs: ["codex"], - expectedReferenceCount: 2, - expectedReferenceFingerprint: ["codex@0", "codex@1"], - reason: "This exact app-runtime bridge coordinates provider-owned state through the shared controller."), + AllowedProviderConstruct( path: "Sources/CodexBar/StatusItemController+MemoryPressure.swift", line: 37,