File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,6 +76,31 @@ describe("normalizeCodexUsageSnapshot", () => {
7676 ] ) ;
7777 } ) ;
7878
79+ it ( "does not treat wrapped payload metadata as a direct bucket" , ( ) => {
80+ const snapshot = normalizeCodexUsageSnapshot ( {
81+ providerInstanceId : instanceId ,
82+ source : "read" ,
83+ payload : {
84+ planType : "plus" ,
85+ rateLimitReachedType : "secondary" ,
86+ rateLimits : {
87+ primary : { usedPercent : 60 , windowDurationMins : 300 } ,
88+ } ,
89+ } ,
90+ } ) ;
91+
92+ expect ( snapshot ?. windows ) . toEqual ( [
93+ {
94+ kind : "five-hour" ,
95+ usedPercent : 60 ,
96+ remainingPercent : 40 ,
97+ resetsAt : null ,
98+ windowDurationMins : 300 ,
99+ } ,
100+ ] ) ;
101+ expect ( snapshot ?. rateLimitReachedType ) . toBeNull ( ) ;
102+ } ) ;
103+
79104 it ( "accepts a direct rate-limit snapshot payload" , ( ) => {
80105 const snapshot = normalizeCodexUsageSnapshot ( {
81106 providerInstanceId : instanceId ,
Original file line number Diff line number Diff line change @@ -116,15 +116,7 @@ function normalizeWindow(
116116}
117117
118118function isRateLimitBucketPayload ( payload : RateLimitPayload ) : boolean {
119- return (
120- "primary" in payload ||
121- "secondary" in payload ||
122- "limitId" in payload ||
123- "limitName" in payload ||
124- "credits" in payload ||
125- "planType" in payload ||
126- "rateLimitReachedType" in payload
127- ) ;
119+ return "primary" in payload || "secondary" in payload ;
128120}
129121
130122function selectCodexBucket ( payload : RateLimitPayload ) : RateLimitBucket | null {
You can’t perform that action at this time.
0 commit comments