Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion pm-stack/aggregator/src/derive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,12 @@ export function projectPace(records: SnapshotRecord[], metricId: string): PacePr
if (Number.isFinite(candidate.getTime())) projectedExhaustionAt = candidate.toISOString();
}
let projectedPercentAtReset: number | null = null;
if (last.resetsAt) {
// Same out-of-domain guard as projectedExhaustionAt above (#6316):
// a negative last pct cannot support a percent-at-reset projection
// either -- the unguarded extrapolation rendered absurd values
// (e.g. -999999995.5) for poisoned series whose last record carried
// a future resetsAt. Slope and points are still reported.
if (lastVal >= 0 && last.resetsAt) {
const toReset = (Date.parse(last.resetsAt) - Date.parse(last.ts)) / 86_400_000;
if (toReset > 0) projectedPercentAtReset = Math.round((lastVal + slope * toReset) * 10) / 10;
}
Expand Down
13 changes: 13 additions & 0 deletions pm-stack/aggregator/test/usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,19 @@ describe("pace + freshness (§4, §1.1)", () => {
const ok = projectPace([rec("2026-10-22T00:00:00Z", 30), rec("2026-10-24T00:00:00Z", 40)], "weekly")!;
expect(ok.projectedExhaustionAt?.slice(0, 10)).toBe("2026-11-05");
});
test("pace: negative pct with a future resetsAt yields no percent-at-reset projection (#6316)", () => {
// The #2346 poison fixture, now with resetsAt on the last record:
// -1e9 -> -999999999 over 2 days, reset +7 days. Before the guard,
// projectPace returned projectedPercentAtReset -999999995.5.
const poison = projectPace(
[rec("2026-10-22T00:00:00Z", -1e9), rec("2026-10-24T00:00:00Z", -999999999, "2026-10-31T00:00:00Z")],
"weekly",
)!;
expect(poison.projectedPercentAtReset).toBeNull();
expect(poison.projectedExhaustionAt).toBeNull();
expect(poison.slopePerDay).toBe(0.5);
expect(poison.points).toBe(2);
});
test("no projection from a single point or a flat series", () => {
expect(projectPace([rec("2026-10-24T00:00:00Z", 30)], "weekly")).toBeNull();
expect(projectPace([rec("2026-10-22T00:00:00Z", 30), rec("2026-10-24T00:00:00Z", 30)], "weekly")).toBeNull();
Expand Down
Loading