Skip to content

Commit fdc02fc

Browse files
committed
Keep current main codex cache producer key compatible
1 parent f42a88d commit fdc02fc

4 files changed

Lines changed: 32 additions & 24 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Generated by Scripts/regenerate-codex-parser-hash.sh. Do not edit by hand.
22

33
enum CodexParserHash {
4-
static let value = "6eb528b2f170f060"
4+
static let value = "d3df003a9bff32af"
55
}

Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ enum CostUsageCacheIO {
2424
/// catch-up report calendar normalization do not change stored totals or cache layout,
2525
/// so the immediate predecessors remain reusable.
2626
private static let compatibleCodexProducerKeys: Set<String> = [
27+
"codex:cu:p1cd29792d9ca2b11",
2728
"codex:cu:p37aedd661c4272a8",
2829
"codex:cu:p843ca061c36bbea1",
2930
]

Tests/CodexBarTests/CostUsageCacheTests.swift

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,29 +229,36 @@ struct CostUsageCacheTests {
229229
}
230230

231231
@Test
232-
func `current codex cache accepts the calendar normalization predecessor`() throws {
232+
func `current codex cache accepts calendar normalization predecessors`() throws {
233233
let root = try self.makeTemporaryCacheRoot()
234234
defer { try? FileManager.default.removeItem(at: root) }
235235

236-
// A cache persisted by the immediately preceding build (bounded-cost-cache hash)
237-
// stays loadable: the catch-up report calendar normalization did not change stored
238-
// totals or cache layout, so upgrading must not force a rebuild.
239-
var cache = CostUsageCache()
240-
cache.lastScanUnixMs = 456
241-
cache.days = ["2026-07-02": ["gpt-5.5": [1, 2, 3]]]
242-
CostUsageCacheIO.save(
243-
provider: .codex,
244-
cache: cache,
245-
cacheRoot: root,
246-
producerKey: "codex:cu:p37aedd661c4272a8")
236+
// Caches persisted by builds since the bounded-cost-cache work stay loadable: the
237+
// catch-up report calendar normalization did not change stored totals or cache
238+
// layout, so upgrading must not force a rebuild.
239+
for (index, producerKey) in [
240+
"codex:cu:p37aedd661c4272a8",
241+
"codex:cu:p1cd29792d9ca2b11",
242+
].enumerated() {
243+
let root = root.appendingPathComponent("case-\(index)", isDirectory: true)
244+
try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
245+
var cache = CostUsageCache()
246+
cache.lastScanUnixMs = 456
247+
cache.days = ["2026-07-02": ["gpt-5.5": [1, 2, 3]]]
248+
CostUsageCacheIO.save(
249+
provider: .codex,
250+
cache: cache,
251+
cacheRoot: root,
252+
producerKey: producerKey)
247253

248-
let loaded = CostUsageCacheIO.load(provider: .codex, cacheRoot: root)
249-
let migration = CostUsageCacheIO.loadCodexForMigration(cacheRoot: root)
254+
let loaded = CostUsageCacheIO.load(provider: .codex, cacheRoot: root)
255+
let migration = CostUsageCacheIO.loadCodexForMigration(cacheRoot: root)
250256

251-
#expect(loaded.lastScanUnixMs == 456)
252-
#expect(loaded.days["2026-07-02"]?["gpt-5.5"] == [1, 2, 3])
253-
#expect(migration.cache.lastScanUnixMs == 456)
254-
#expect(migration.incompatibleCache == nil)
257+
#expect(loaded.lastScanUnixMs == 456)
258+
#expect(loaded.days["2026-07-02"]?["gpt-5.5"] == [1, 2, 3])
259+
#expect(migration.cache.lastScanUnixMs == 456)
260+
#expect(migration.incompatibleCache == nil)
261+
}
255262
}
256263

257264
@Test

Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ struct ProviderArchitectureGatekeeperTests {
15271527
reason: "This provider-specific core branch passes its already-selected identity to a shared helper."),
15281528
SuppressedProviderReference(
15291529
path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift",
1530-
line: 94,
1530+
line: 95,
15311531
anchor: "let url = self.cacheFileURL(provider: .codex, cacheRoot: cacheRoot)",
15321532
expectedProviderIDs: ["codex"],
15331533
reason: "This provider-specific core branch passes its already-selected identity to a shared helper."),
@@ -3613,31 +3613,31 @@ struct ProviderArchitectureGatekeeperTests {
36133613
reason: "This exact shared construct dispatches a provider-owned capability at the generic integration boundary."),
36143614
AllowedProviderConstruct(
36153615
path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift",
3616-
line: 102,
3616+
line: 103,
36173617
anchor: "let expectedProducerKey = producerKey ?? self.currentProducerKey(provider: .codex)",
36183618
expectedProviderIDs: ["codex"],
36193619
expectedReferenceCount: 1,
36203620
expectedReferenceFingerprint: ["codex@0"],
36213621
reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."),
36223622
AllowedProviderConstruct(
36233623
path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift",
3624-
line: 165,
3624+
line: 166,
36253625
anchor: "if provider == .codex {",
36263626
expectedProviderIDs: ["codex"],
36273627
expectedReferenceCount: 1,
36283628
expectedReferenceFingerprint: ["codex@0"],
36293629
reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."),
36303630
AllowedProviderConstruct(
36313631
path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift",
3632-
line: 193,
3632+
line: 194,
36333633
anchor: "if provider == .codex, data.count > maxCacheBytes {",
36343634
expectedProviderIDs: ["codex"],
36353635
expectedReferenceCount: 1,
36363636
expectedReferenceFingerprint: ["codex@0"],
36373637
reason: "This exact cost scanner dispatch selects a provider-owned transcript, cache, or pricing format."),
36383638
AllowedProviderConstruct(
36393639
path: "Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift",
3640-
line: 222,
3640+
line: 223,
36413641
anchor: "if provider == .codex, data.count > maxCacheLoadBytes {",
36423642
expectedProviderIDs: ["codex"],
36433643
expectedReferenceCount: 1,

0 commit comments

Comments
 (0)