-
Notifications
You must be signed in to change notification settings - Fork 0
fix(codex): fence propagated quota recovery aliases #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Dev
Are you sure you want to change the base?
Changes from all commits
d35592b
71c57ea
d560ac6
08ada6f
ec51e42
e25b653
80fff9a
fc4de77
c7d8407
54e2274
2c4dca1
a34e8b7
ebb4d55
682112e
af6113a
2b754b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -105,6 +105,18 @@ export function settleQuotaRecovery( | |||||||||||||
| records.set(accountId, { state: "spent", lineage: fenced }); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Fence a same-grant alias that adopted the credential produced by another account's refresh. | ||||||||||||||
| * | ||||||||||||||
| * Propagation advances the alias without making it a separate credential lineage. Leaving its | ||||||||||||||
| * committed generation unspent would let a later quota poll rotate the same refresh grant again. | ||||||||||||||
| * This deliberately supersedes an old live claim for the alias: that claim targets the | ||||||||||||||
| * pre-propagation generation, and its eventual settlement must not erase this newer fence. | ||||||||||||||
| */ | ||||||||||||||
| export function fencePropagatedQuotaRecovery(accountId: string, lineage: number): void { | ||||||||||||||
| records.set(accountId, { state: "spent", lineage }); | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Preserve recovery records for equal or newer lineages. Line 117 overwrites a claim that can target a generation newer than Only replace an older record. Preserve equal or newer active claims and terminal fences. Add a regression test that creates a newer alias claim before this fence runs and verifies that its settlement remains effective. Proposed direction export function fencePropagatedQuotaRecovery(accountId: string, lineage: number): void {
+ const existing = records.get(accountId);
+ if (existing?.lineage !== undefined && existing.lineage >= lineage) return;
records.set(accountId, { state: "spent", lineage });
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Record a refresh that failed with proof the grant itself is dead. | ||||||||||||||
| * | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a propagated alias is polled concurrently, it can read its new generation and claim quota recovery after
commitRefreshedCodexCredentialWithAliasespersists the credential but before thisonSettledcallback runs, becauseaccount-store.tsawaits plan reconciliation between the commit and completion. That alias can therefore start a second OAuth refresh; this later fence cannot undo it and may even overwrite the second flight's newer recovery record. Fence the propagated generations immediately after the commit and before any awaited work exposes a scheduling gap, or atomically reject claims for those generations.AGENTS.md reference: AGENTS.md:L329-L332
Useful? React with 👍 / 👎.