Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b8d7944
Prepare Reviewed CodeCaps Release Sources (1/6)
swu-codex[bot] Nov 3, 2026
c4d9e66
Prepare Reviewed CodeCaps Release Sources (2/6)
swu-codex[bot] Nov 3, 2026
70cd5be
Prepare Reviewed CodeCaps Release Sources (3/6)
swu-codex[bot] Nov 3, 2026
1efbc7c
Prepare Reviewed CodeCaps Release Sources (4/6)
swu-codex[bot] Nov 3, 2026
4fdf430
Prepare Reviewed CodeCaps Release Sources (5/6)
swu-codex[bot] Nov 3, 2026
6685568
Prepare Reviewed CodeCaps Release Sources (6/6)
swu-codex[bot] Nov 3, 2026
3b1c8c6
Record Exact Runtime Key Validation Scanner False Positive
swu-codex[bot] Nov 3, 2026
9e0007f
Tighten quota-reset evidence.
swu-codex[bot] Nov 3, 2026
630a2c0
Pin the MiniMax stale-weekly regression.
swu-codex[bot] Nov 3, 2026
b472d10
Hide only managed windows when keeping running.
swu-codex[bot] Nov 3, 2026
d401a87
Select only managed content windows.
swu-codex[bot] Nov 3, 2026
4600429
Test keep-running window selection.
swu-codex[bot] Nov 3, 2026
47c64ec
Suppress false vendor resets while preserving valid refills
swu-codex[bot] Nov 3, 2026
d9e058a
Cover weekly deadline nudges and small full restores
swu-codex[bot] Nov 3, 2026
63a62d7
Confine Muse bridge delivery state to the main actor
swu-codex[bot] Nov 3, 2026
294d697
Cancel SMS delivery tasks when setup changes
swu-codex[bot] Nov 3, 2026
6fb29cf
Honor cancellation before sending reserved SMS
swu-codex[bot] Nov 3, 2026
afb2a70
Test that Forget cancels in-flight SMS delivery
swu-codex[bot] Nov 3, 2026
a7c5cb9
Match provider window labels exactly
swu-codex[bot] Nov 3, 2026
e0d429f
Test exact canonical provider window labels
swu-codex[bot] Nov 3, 2026
0a40ff2
Resolve symlinked task lanes before version planning
swu-codex[bot] Nov 3, 2026
7521629
Cover symlinked release version planning
swu-codex[bot] Nov 3, 2026
90bada8
Fix exact Antigravity quota labels
swu-codex[bot] Nov 3, 2026
5f4b4aa
Refresh Cursor quota timestamps after fetching
swu-codex[bot] Nov 3, 2026
a8a4fa0
Expire obsolete CodeCaps builds and App Store versions
swu-codex[bot] Nov 3, 2026
cf68042
Align release contract test with 0.1.0
swu-codex[bot] Nov 3, 2026
05527c4
Merge branch 'main' into codex/cc-205-release-ready
jaywedgeworth22 Nov 5, 2026
e442df4
Add Release Readiness Follow-Up Missing From PR 357 (#361)
jaywedgeworth22 Nov 6, 2026
a67568a
Name the absent Infisical service token instead of the secret's read …
swu-wise[bot] Nov 6, 2026
4127a1a
reset alarms: detect whole multiple periods missed while asleep
swu-wise[bot] Nov 6, 2026
01bf602
widgets: supplementary video quota never takes a plan window's bar
swu-wise[bot] Nov 6, 2026
3426504
reset alarms: pin the wait-for-usage counterexample and the three-wee…
swu-wise[bot] Nov 6, 2026
cdcc3f7
Merge origin/main into wise/cc361-stage-asc-token-signal
jaywedgeworth22 Nov 8, 2026
aa0aaa5
Fix Kody review findings from PR 367 against the merged HEAD
jaywedgeworth22 Nov 8, 2026
dab6dc5
Dedupe Antigravity detail rows against the pool windows already appended
jaywedgeworth22 Nov 8, 2026
7753914
test: give the unresolved-reference probe a service token
jaywedgeworth22 Nov 8, 2026
785b26c
Merge branch 'main' into wise/cc361-stage-asc-token-signal
jaywedgeworth22 Nov 8, 2026
850d7e3
fix: take main’s apps.json marketing train and ship-workflow pins
jaywedgeworth22 Nov 8, 2026
029c4da
Merge origin/main into wise/cc361-stage-asc-token-signal
jaywedgeworth22 Nov 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions Sources/CodeCaps/SMSAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,48 @@ struct SMSCredentialAccess {
var clear: () async throws -> Void
var reauthorize: () async -> TwilioSMSCredentials?

static let live = Self(load: { await TwilioCredentialStore.shared.load() },
static let live = Self(load: { await SMSCredentialAccess.resolvedLiveCredentials() },
save: { try await TwilioCredentialStore.shared.save($0) },
clear: { try await TwilioCredentialStore.shared.clear() },
reauthorize: { await TwilioCredentialStore.shared.readAllowingInteraction() })
reauthorize: {
if let resolved = await SMSCredentialAccess.resolvedLiveCredentials() {
return resolved
}
return await TwilioCredentialStore.shared.readAllowingInteraction()
})

/// An operator-provided Twilio API key secret outranks the Keychain setup
/// record: the process environment first, then the app's Infisical
/// project, and the Keychain record only last. An ordinary service
/// credential must not make the Keychain its source of truth (Kody
/// review, PR #367). The Keychain record still supplies the rest of the
/// configuration the secret is used with, and `save`/`clear` keep
/// handling explicitly entered values.
nonisolated static func resolvedCredentials(stored: TwilioSMSCredentials?,
environment: [String: String],
infisicalSecret: String?) -> TwilioSMSCredentials? {
func splicing(_ secret: String) -> TwilioSMSCredentials {
let configuration = stored?.configuration ?? TwilioSMSConfiguration(
accountSID: environment["TWILIO_ACCOUNT_SID"] ?? "",
apiKeySID: environment["TWILIO_API_KEY_SID"] ?? "",
messagingServiceSID: environment["TWILIO_MESSAGING_SERVICE_SID"] ?? "",
recipient: environment["TWILIO_RECIPIENT"] ?? "")
return TwilioSMSCredentials(configuration: configuration, apiKeySecret: secret)
}
let envSecret = environment["TWILIO_API_KEY_SECRET"]?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
if !envSecret.isEmpty { return splicing(envSecret) }
if let secret = infisicalSecret?.trimmingCharacters(in: .whitespacesAndNewlines),
!secret.isEmpty { return splicing(secret) }
return stored
}

private static func resolvedLiveCredentials() async -> TwilioSMSCredentials? {
let stored = await TwilioCredentialStore.shared.load()
return resolvedCredentials(stored: stored,
environment: ProcessInfo.processInfo.environment,
infisicalSecret: InfisicalSettings.shared.value(for: "TWILIO_API_KEY_SECRET"))
}
}

@MainActor
Expand Down
8 changes: 7 additions & 1 deletion Sources/QuotaCore/LocalQuotaReaderRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ public struct LocalQuotaReaderRegistry: Sendable {
var issues: [String: String] = [:]
var consentNeeded: Set<String> = []
for (_, result) in results {
windows.append(contentsOf: result.windows)
// Two registrations can surface the same QuotaWindow (grok-bot and
// gbu both declare providerKey "grok-bot"); a duplicate row would
// reach every downstream surface twice, so only new windows are
// appended (Kody review, PR #367).
for window in result.windows where !windows.contains(window) {
windows.append(window)
}
issues.merge(result.issues) { _, next in next }
consentNeeded.formUnion(result.consentNeeded)
}
Expand Down
20 changes: 14 additions & 6 deletions Sources/QuotaCore/QuotaWindowVocabulary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -941,16 +941,24 @@ public enum QuotaCapRule {
|| id.hasPrefix("openai:additional:") || id.hasPrefix("openai:code-review:")
|| id.hasPrefix("additional:") || id.hasPrefix("code-review:")
}
// Exact tokens, not substrings: "Argonaut" or "fable-era" is not a
// per-model limit (Kody review, PR #367).
func tokens(_ raw: String) -> Set<String> {
// A hyphen or underscore stays inside a token: a model id like
// "fable-era" is one model, not the Fable limit; structural
// separators (":", "/", whitespace) are what split the fields.
Set(raw.lowercased()
.split(whereSeparator: { $0.isWhitespace || ":·/|,;".contains($0) })
.map(String.init))
}
if providerKey == "google-antigravity" {
if let modelId = modelId?.lowercased(), modelId.contains("argon") { return true }
if let modelType = modelType?.lowercased(), modelType.contains("argon") { return true }
if label.localizedCaseInsensitiveContains("argon") { return true }
return false
if let modelId, !tokens(modelId).isDisjoint(with: ["argon"]) { return true }
if let modelType, !tokens(modelType).isDisjoint(with: ["argon"]) { return true }
return !tokens(label).isDisjoint(with: ["argon"])
}
if providerKey == "anthropic" {
if let model = modelId?.lowercased(), !model.isEmpty { return true }
let lower = label.lowercased()
return lower.contains("fable") || lower.contains("sonnet") || lower.contains("opus") || lower.contains("haiku")
return !tokens(label).isDisjoint(with: ["fable", "sonnet", "opus", "haiku"])
}
return false
}
Expand Down
25 changes: 18 additions & 7 deletions Sources/QuotaCore/ResetAlarmTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,21 @@ public struct ResetAlarmTracker: Sendable {
if let reported = observation.resetAt {
let jump = reported.timeIntervalSince(previousReset)
// A deadline correction needs a substantial quota rise or an elapsed full cadence.
// A roll-immediately provider restarts each period when the last
// one ends, so a Mac asleep through several periods wakes to an
// end that moved by a whole multiple of the cadence. Accept any
// whole number of periods, not exactly one. A wait-for-usage
// provider's end does not move on a schedule, so it never matches
// this shape; cadence alone is never proof.
let advancedFullCadence = window.periodSeconds.map { period in
// Calendar months range from 28 to 31 days; fixed cadences use drift tolerance.
let tolerance = ResetAlarmPolicy.resetDriftTolerance
let periods = (jump / period).rounded()
guard periods >= 1 else { return false }
// Calendar months range from 28 to 31 days; fixed cadences use drift tolerance.
if (28 * 86_400...31 * 86_400).contains(period) {
return jump >= 28 * 86_400 - tolerance && jump <= 31 * 86_400 + tolerance
return jump >= periods * 28 * 86_400 - tolerance && jump <= periods * 31 * 86_400 + tolerance
}
return abs(jump - period) <= tolerance
return abs(jump - periods * period) <= tolerance
} ?? false
// Some providers publish both sides of the period.  When they
// do, an end-time correction by one cadence is not enough to
Expand All @@ -521,12 +529,15 @@ public struct ResetAlarmTracker: Sendable {
let period = window.periodSeconds else { return true }
let advance = current.timeIntervalSince(previous)
let tolerance = ResetAlarmPolicy.resetDriftTolerance
// Same band as advancedFullCadence: a calendar-month window accepts a
// 28-to-31-day start advance; fixed cadences use drift tolerance.
// Same whole-multiple rule as advancedFullCadence: a calendar-month
// window accepts a 28-to-31-day start advance per period;
// fixed cadences use drift tolerance.
let periods = (advance / period).rounded()
guard periods >= 1 else { return true }
if (28 * 86_400...31 * 86_400).contains(period) {
return advance >= 28 * 86_400 - tolerance && advance <= 31 * 86_400 + tolerance
return advance >= periods * 28 * 86_400 - tolerance && advance <= periods * 31 * 86_400 + tolerance
}
return abs(advance - period) <= tolerance
return abs(advance - periods * period) <= tolerance
}()
let required = hasPassed
? ResetAlarmPolicy.resetDriftTolerance
Expand Down
26 changes: 21 additions & 5 deletions Sources/QuotaCore/WidgetPlatformDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,23 @@ public enum QuotaCardProjection {
}

/// Only these model limits have a separate detail in the companion.
/// The identity fields are tokenized on non-alphanumeric characters
/// and matched exactly, so a model id like "Fabled" or "fable-era"
/// cannot be classified as the Fable limit by a substring accident
/// (Kody review, PR #367).
public var detailName: String? {
let identity = [id, label, modelId ?? "", modelType ?? ""].joined(separator: " ").lowercased()
if providerKey == "anthropic", identity.contains("fable") { return "Fable" }
if providerKey == "google-antigravity", identity.contains("argon") { return "Argon" }
let tokens = Set(
[id, label, modelId ?? "", modelType ?? ""]
.joined(separator: " ")
.lowercased()
// A hyphen or underscore stays inside a token: a
// model id like "fable-era" is one model, not the Fable
// limit; structural separators (":", "/", whitespace)
// are what split the fields.
.split(whereSeparator: { $0.isWhitespace || ":·/|,;".contains($0) })
.map(String.init))
if providerKey == "anthropic", tokens.contains("fable") { return "Fable" }
if providerKey == "google-antigravity", tokens.contains("argon") { return "Argon" }
return nil
}

Expand All @@ -229,8 +242,11 @@ public enum QuotaCardProjection {
if QuotaWindowVocabulary.isExtraAllowance(providerKey: providerKey, label: label, windowToken: window) {
return "extra:" + cadence
}
// Primary model names describe observations of the same plan allowance.
return cadence
// Primary model names describe observations of the same plan
// allowance. The provider prefixes the bare-cadence fallback so
// distinct providers cannot collapse into one grouping bucket
// (Kody review, PR #367).
return providerKey.lowercased() + ":" + cadence
}

public var displayLabel: String {
Expand Down
30 changes: 30 additions & 0 deletions Tests/CodeCapsTests/TwilioCredentialStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,36 @@ final class TwilioCredentialStoreTests: XCTestCase {
XCTAssertFalse(TokenStore.ownServices.contains(development))
}

/// The Twilio API key secret resolves env-first, then Infisical, and the
/// Keychain record only last: an ordinary service credential must not
/// make the Keychain its source of truth (Kody review, PR #367).
func testSecretResolutionOrderIsEnvironmentThenInfisicalThenKeychain() {
let stored = TwilioSMSCredentials(
configuration: TwilioSMSConfiguration(accountSID: "AC123", apiKeySID: "SK123",
messagingServiceSID: "MG123", recipient: "+15551234567"),
apiKeySecret: "keychain-secret")
let envCredentials = SMSCredentialAccess.resolvedCredentials(
stored: stored,
environment: ["TWILIO_API_KEY_SECRET": "env-secret"],
infisicalSecret: "infisical-secret")
XCTAssertEqual(envCredentials?.apiKeySecret, "env-secret", "the environment wins")
let infisicalCredentials = SMSCredentialAccess.resolvedCredentials(
stored: stored, environment: [:], infisicalSecret: "infisical-secret")
XCTAssertEqual(infisicalCredentials?.apiKeySecret, "infisical-secret", "Infisical outranks the Keychain")
let keychainCredentials = SMSCredentialAccess.resolvedCredentials(
stored: stored, environment: [:], infisicalSecret: nil)
XCTAssertEqual(keychainCredentials?.apiKeySecret, "keychain-secret",
"with no operator secret the Keychain record still answers")
// A stored record supplies the configuration an operator secret is used with.
XCTAssertEqual(envCredentials?.configuration, stored.configuration)
XCTAssertNil(SMSCredentialAccess.resolvedCredentials(stored: nil, environment: [:], infisicalSecret: nil),
"no secret anywhere means no credentials")
// An empty or blank secret is not a secret.
XCTAssertEqual(SMSCredentialAccess.resolvedCredentials(
stored: stored, environment: ["TWILIO_API_KEY_SECRET": " "],
infisicalSecret: nil)?.apiKeySecret, "keychain-secret")
}

func testInvalidSetupNeverTouchesKeychain() async {
let fixture = TwilioKeychainFixture()
let store = TwilioCredentialStore(calls: fixture.calls, bundleIdentifier: "com.example.CodeCaps.test")
Expand Down
28 changes: 23 additions & 5 deletions Tests/Fixtures/WidgetUIProbe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,36 @@ import AppIntents
]
let parsed = WidgetPresentation.parseSnapshot(data: try JSONSerialization.data(withJSONObject:["windows":payload]))
let claude = parsed.first { $0.providerKey == "anthropic" }!
precondition(claude.primaryWindows.count == 2 && claude.detailWindows.map(\.label) == ["Fable limit"])
// The producer's "no reading yet" copy of the weekly allowance keeps its
// own row (a distinct wire series), the "Plan Details" caption row is
// dropped, and the Fable detail sits beside the plan windows.
precondition(claude.primaryWindows.count == 3 && claude.detailWindows.map(\.label) == ["Fable limit"])
precondition(claude.dualWindows()?.window2.id == "claude:7d")
precondition(claude.atCapWindow()?.id == "claude:7d")
let minimax = parsed.first { $0.providerKey == "minimax" }!
precondition(minimax.windows.count == 2 && !minimax.hasModelDetails && minimax.remainingPercent == 74)
// The supplementary video daily never takes a bar from the plan's own
// windows: the pair stays the 5-hour and weekly coding windows (owner
// 2026-11-06: "Widget says 1d instead of 7d").
precondition(minimax.dualWindows()?.window1.id == "minimax:5h")
precondition(minimax.dualWindows()?.window2.id == "minimax:7d")
let gemini = parsed.first { $0.id == "antigravity-gemini" }!
precondition(gemini.primaryWindows.map(\.remainingPercent) == [63, 1])
// The widget's pool rule keeps the freshest copy of each period, unlike
// the phone's canonical-row preference: both copies here carry no
// observation stamp, so the payload's first row wins the five-hour slot.
precondition(gemini.primaryWindows.map(\.remainingPercent) == [7, 1])
precondition(gemini.remainingPercent == 1 && gemini.detailWindows.map(\.label) == ["Argon limit"])
precondition(gemini.atCapWindow() == nil)
let copilot = parsed.first { $0.providerKey == "github-copilot" }!
precondition(copilot.title == "GitHub Copilot" && copilot.remainingPercent == 100)
precondition(copilot.primaryWindows.count == 1 && !copilot.hasModelDetails)
precondition(copilot.title == "GitHub Copilot")
// The headline answers the shared cap rule over all windows, so the
// mirror copy reading zero spends it even while this Mac's own copy
// reports 100; the own copy is carried as a primary window beside it.
precondition(copilot.remainingPercent == 0)
// This Mac's own copy and the mirror copy are distinct wire series; the
// own copy is present and the platform carries no detail rows.
precondition(copilot.primaryWindows.contains { $0.id == "local-mac:github-copilot" }
&& !copilot.hasModelDetails)
let week = CompanionWindowItem(id:"weekly", label:"7-day", cadence:"7d", remainingPercent:57,
resetAt:Date().addingTimeInterval(3600), reportedAt:Date())
let plan = CompanionWindowItem(id:"plan", label:"Plan", cadence:"Plan", remainingPercent:nil, resetAt:nil)
Expand All @@ -51,7 +69,7 @@ import AppIntents
remainingPercent:0, resetAt:nil, isExhausted:false, isAlarmEnabled:false, windows:[plan,week,fable])
precondition(phone.cardShortWindow(scope:.allSources)?.window.id == "weekly")
precondition(phone.cardLongWindow(scope:.allSources) == nil && phone.cardRemainingPercent(scope:.allSources) == 57)
precondition(phone.isExpandable && phone.cardDetailWindows(scope:.allSources).map(\.label) == ["Fable limit"])
precondition(phone.isExpandable && phone.cardDetailWindows(scope:.allSources).map(\.window.label) == ["Fable limit"])
let weeklyHealthy = WidgetWindowItem(id:"weekly", label:"Weekly", cadence:"7d", remainingPercent:47, resetAt:nil)
let positiveExtra = WidgetWindowItem(id:"extra", label:"Additional tokens", cadence:"Other limit", remainingPercent:81,
resetAt:nil, isExtraAllowance:true)
Expand Down
23 changes: 23 additions & 0 deletions Tests/QuotaCoreTests/LocalQuotaReaderRegistryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,27 @@ final class LocalQuotaReaderRegistryTests: XCTestCase {
XCTAssertTrue(result.windows.isEmpty)
}

/// Two registrations can surface the same QuotaWindow (grok-bot and gbu
/// both declare providerKey "grok-bot"); the merged snapshot must carry
/// the row once, not once per reader (Kody review, PR #367).
func testIdenticalWindowsFromTwoReadersArePublishedOnce() async {
func makeWindow(percent: Double) -> QuotaWindow {
QuotaWindow(id: "grok:weekly", provider: "grok", providerKey: "grok-bot",
label: "weekly", remainingPercent: percent,
occurredAt: "2026-11-06T12:00:00Z")
}
let window = makeWindow(percent: 42)
let registry = LocalQuotaReaderRegistry(registrations: [
LocalQuotaReaderRegistration(id: "grok-bot", label: "Grok Bot") {
RegistryFakeReader(result: LocalQuotaResult(windows: [window, makeWindow(percent: 7)]))
},
LocalQuotaReaderRegistration(id: "gbu", label: "Grok Build Usage") {
RegistryFakeReader(result: LocalQuotaResult(windows: [window]))
},
])
let result = await registry.read(preferences: .init())
XCTAssertEqual(result.windows.count, 2, "an identical window from a second reader must be dropped")
XCTAssertEqual(result.windows.filter { $0.remainingPercent == 42 }.count, 1)
}

}
Loading
Loading