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): surface quota sanitization loss + reconcile choices … · developing-today/code@880b038

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • pm-stack/aggregator
    • src
      • feed.ts
      • model.ts
      • sources
        • live.ts
    • test
      • feed.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pm-stack/aggregator/src/feed.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/src/feed.ts
+23-3Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,31 @@ export function sanitizeQuotaView(quota: QuotaView): QuotaSanitization {
340340
return out;
341341
});
342342
const burn = arrayOf(isBurnSegment)(quota.burn);
343+
const droppedPools = pools?.dropped ?? 0;
344+
const droppedBurn = burn?.dropped ?? 0;
345+
// Guidance must describe the surviving usable pools only: the
346+
// retained choices were computed over the pre-sanitization pools,
347+
// and computeChoices() (quota-guidance.ts) gives no guidance for a
348+
// pool with no windows — so filter every list to kept pools that
349+
// still have windows. A pool whose data was discarded must not
350+
// stay recommended under hasHeadroom or burnBeforeReset.
351+
const usable = new Set(keptPools.filter((p) => p.windows.length > 0).map((p) => p.id));
352+
const choices = {
353+
hasHeadroom: quota.choices.hasHeadroom.filter((id) => usable.has(id)),
354+
burnBeforeReset: quota.choices.burnBeforeReset.filter((id) => usable.has(id)),
355+
doNotStart: quota.choices.doNotStart.filter((id) => usable.has(id)),
356+
};
357+
const view: QuotaView = { ...quota, pools: keptPools, burn: burn?.values ?? [], choices };
358+
// Surface the loss on the view itself (its consumers project the
359+
// view, e.g. /api/quota.json), not only on the feed wrapper.
360+
if (droppedPools + droppedWindows + droppedBurn > 0) {
361+
view.dropped = { pools: droppedPools, windows: droppedWindows, burn: droppedBurn };
362+
}
343363
return {
344-
view: { ...quota, pools: keptPools, burn: burn?.values ?? [] },
345-
droppedPools: pools?.dropped ?? 0,
364+
view,
365+
droppedPools,
346366
droppedWindows,
347-
droppedBurn: burn?.dropped ?? 0,
367+
droppedBurn,
348368
};
349369
}
350370

Collapse file

‎pm-stack/aggregator/src/model.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/src/model.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ export interface QuotaView {
325325
/** Gatherer overlay provenance (#1151); absent when no
326326
* quota-current.json was read. Additive for existing consumers. */
327327
gatherer?: GathererSummary;
328+
/** Feed-load sanitization counts (#2429): present only when the
329+
* loader dropped malformed pools/windows/burn segments, so an
330+
* incomplete read is distinguishable from a successful empty one
331+
* in the public payload (/api/quota.json projects this view).
332+
* Additive for existing consumers. */
333+
dropped?: { pools: number; windows: number; burn: number };
328334
burn: BurnSegment[];
329335
/** Guidance for choosing the next pool (burn order + reset rules). */
330336
choices: {
Collapse file

‎pm-stack/aggregator/src/sources/live.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/src/sources/live.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ export function liveSource(cfg: Config, opts?: { standingAuto?: () => Promise<bo
816816
if (feed) {
817817
provenance.quota = `live (fleet feed · ${feedAgeText(feed.generatedAt)} · collected ${feed.generatedAt})`;
818818
view = feed.quota;
819+
const dropped = feed.quotaDropped;
820+
if (dropped && dropped.pools + dropped.windows + dropped.burn > 0) {
821+
provenance.quota += ` · sanitized at load: dropped ${dropped.pools} pool(s), ${dropped.windows} window(s), ${dropped.burn} burn segment(s) (#2429)`;
822+
}
819823
} else {
820824
provenance.quota = "fixtures (no fleet feed file yet)";
821825
view = await fix.quota();
Collapse file

‎pm-stack/aggregator/test/feed.test.ts‎

Copy file name to clipboardExpand all lines: pm-stack/aggregator/test/feed.test.ts
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,20 @@ describe("feed quota section gate + sanitization (#2429)", () => {
203203
expect(out.view).toEqual(q);
204204
});
205205

206+
test("choices are reconciled to surviving pools with usable windows", () => {
207+
const noWindows = { ...POOL, windows: [null] };
208+
const out = sanitizeQuotaView(quotaWith([noWindows]) as never);
209+
expect(out.view.pools.length).toBe(1);
210+
expect(out.view.choices).toEqual({ hasHeadroom: [], burnBeforeReset: [], doNotStart: [] });
211+
expect(out.view.dropped).toEqual({ pools: 0, windows: 1, burn: 0 });
212+
});
213+
214+
test("a dropped pool leaves the retained choices and surfaces dropped on the view", () => {
215+
const out = sanitizeQuotaView(quotaWith([null, POOL]) as never);
216+
expect(out.view.choices.hasHeadroom).toEqual(["opencode-go"]);
217+
expect(out.view.dropped).toEqual({ pools: 1, windows: 0, burn: 0 });
218+
});
219+
206220
test("loadFeed returns the sanitized remainder with drop counts attached", async () => {
207221
const dir = mkdtempSync(join(tmpdir(), "agg-feed-quota-"));
208222
const file = join(dir, "feed.json");
@@ -213,6 +227,7 @@ describe("feed quota section gate + sanitization (#2429)", () => {
213227
expect(loaded?.quota.pools.length).toBe(1);
214228
expect(loaded?.quota.pools[0]?.windows).toEqual([WINDOW]);
215229
expect(loaded?.quotaDropped).toEqual({ pools: 1, windows: 1, burn: 0 });
230+
expect(loaded?.quota.dropped).toEqual({ pools: 1, windows: 1, burn: 0 });
216231
});
217232

218233
test("loadFeed rejects a feed missing burn/choices (fixture-fallback path)", async () => {

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.