GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(aggregator): filter exhaustion rate samples by recency, not just … · developing-today/code@9141f3f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pm-stack/aggregator
    • src
      • quota-exhaustion.ts
    • test
      • quota-exhaustion.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pm-stack/aggregator/src/quota-exhaustion.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/src/quota-exhaustion.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ export function deriveExhaustionForecasts(
114114
if (prev.resetsAt !== w.resetsAt || last.resetsAt !== w.resetsAt) continue;
115115
const dtMs = Date.parse(last.at) - Date.parse(prev.at);
116116
const delta = last.used - prev.used;
117-
if (dtMs > 0 && dtMs <= RATE_WINDOW_MS && delta >= 0) {
117+
// Recency, not just separation (Codex P2 on PR #8522): a pair
118+
// whose later side is itself older than RATE_WINDOW_MS before
119+
// now measures obsolete activity, not current burn — two
120+
// qualifying pairs from yesterday plus one observation now
121+
// must not publish a forecast from yesterday's rates.
122+
const ageMs = nowMs - Date.parse(last.at);
123+
if (dtMs > 0 && dtMs <= RATE_WINDOW_MS && ageMs <= RATE_WINDOW_MS && delta >= 0) {
118124
rates.push(delta / (dtMs / 60000));
119125
}
120126
}
Collapse file

‎pm-stack/aggregator/test/quota-exhaustion.test.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/test/quota-exhaustion.test.ts
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ describe("deriveExhaustionForecasts (#3983)", () => {
5454
expect(f.sampleRates).toBe(3);
5555
});
5656

57+
test("obsolete pairs do not publish a forecast from yesterday's rates (Codex P2, PR #8522)", () => {
58+
// Two qualifying pairs yesterday (10min apart, inside the rate
59+
// window by separation) plus one observation now: the bridging
60+
// pair spans > RATE_WINDOW_MS, and yesterday's pairs end more
61+
// than RATE_WINDOW_MS before now, so no recent pair remains.
62+
const stale = [
63+
obs(1000, "2026-10-31T01:00:00Z"),
64+
obs(2000, "2026-10-31T01:10:00Z"), // +100/min, obsolete
65+
obs(4000, "2026-10-31T01:20:00Z"), // +200/min, obsolete
66+
obs(7000, "2026-11-01T01:59:00Z"), // now-side, no recent pair
67+
];
68+
const [f] = deriveExhaustionForecasts([pool()], stale, NOW);
69+
expect(f.state).toBe("unknown");
70+
expect(f.reason).toBe("no_measured_burn");
71+
});
72+
5773
test("slow measured burn puts P50 after reset while P80 lands before", () => {
5874
const slow = [
5975
obs(3900, "2026-11-01T01:00:00Z"),

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.