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
14 changes: 14 additions & 0 deletions pm-stack/aggregator/src/quota-current.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ function applyEntry(pool: QuotaPool, entry: QuotaCurrentEntry, state: FreshState
pool.state = poolState(pool);
return false;
}
// #9358: meta's base quota-view row can be a fallback transcription
// rather than the retained quota-current read. When its provider leg
// failed, keep the retained read's windows (including a zero window)
// instead of letting that older transcription mask them. Freshness
// remains stale under #1268; this does not turn a failed tick into ok.
if (pool.id === "meta" && legError && entry.retainedFromFailedTick) {
const windows = pctWindows(entry);
if (windows.length > 0) {
pool.windows = windows;
delete pool.note;
}
pool.state = "stale";
return false;
}
// #6942: a retained entry whose gatherer leg errored is that
// read error surfacing, not mere staleness — but only a pool
// with no dated windows of its own changes rendering for it.
Expand Down
31 changes: 31 additions & 0 deletions pm-stack/aggregator/test/quota-current.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,37 @@ describe("shell-pool stale/retained path (#6942)", () => {
expect(cline.freshness).toEqual({ measuredAt: iso(5 * 60_000), source: "openchamber-quota", state: "stale" });
expect(cline.windows[0].percent).toBe(69); // dated read, not the retained gatherer value
});

test("meta retained errored-leg read replaces its fallback windows but stays stale (#9358)", () => {
const f = legErrorFile([
entry({
providerId: "_muse",
serviceId: "meta",
source: "opencode-quota",
measuredAt: iso(45 * 60_000),
retainedFromFailedTick: iso(4 * 60_000),
windows: [win("5h", 0, iso(45 * 60_000)), win("weekly", 100, iso(45 * 60_000))],
}),
]);
f.heartbeat.perProvider = { _muse: { state: "error", ms: 12, rows: 1, error: LEG_ERROR } };
const view = baseView();
view.pools.find((p) => p.id === "meta")!.windows = [
{ name: "weekly", unit: "other", limit: 100, used: 98, percent: 98, resetsAt: null },
];

const out = overlayQuotaCurrent(view, f, NOW);
const meta = out.pools.find((p) => p.id === "meta")!;
expect(meta.windows.map((w) => [w.name, w.percent])).toEqual([
["5-hour", 0],
["weekly", 100],
]);
expect(meta.freshness).toEqual({
measuredAt: iso(45 * 60_000),
source: "opencode-quota",
state: "stale",
});
expect(meta.state).toBe("stale");
});
});

describe("spec-pool retained path with dead base windows (#7033)", () => {
Expand Down