Skip to content

cloudflare-export: GraphQL group-limit saturation flagged for only 2 of 7 datasets — workers/kv/d1/queues/r2-ops/ai-total sums at their query limit publish as exact readings, never lower bounds #6880

Closed

Description

@dezren39

cloudflare-export: GraphQL group-limit saturation is flagged for only 2 of 7 datasets — workers/kv/d1/queues/r2-ops/ai-total totals at their query limit are published as exact, never as lower bounds

Summary

pm-stack/cloudflare-export/cloudflare-quota-export.mjs states its own discipline in the header (lines 70–73): a grouped result at its query limit "is flagged as a lower bound, never silently truncated — the r2-storage discipline." That discipline is implemented for exactly two datasets and silently absent for the other five:

Implemented:

  • r2StorageAdaptiveGroups (limit 10000): parseGraphqlUsage computes saturated = storageGroups.length >= R2_STORAGE_GROUP_LIMIT and marks the r2-storage metric lowerBound: true with detail prose (lines 313–325).
  • aiInferenceAdaptiveGroupsByDay (limit 10000): aiNeuronsDayAlerts returns saturated, alerts carry lowerBound: true, and the document carries aiNeuronsByDaySaturated (lines 248–266, 385).

Missing — GRAPHQL_QUERY (lines 442–449) sets explicit limits and parseGraphqlUsage/classifyR2 sum whatever came back with no at-limit check:

  • workersInvocationsAdaptive limit 100 → workers-requests, workers-cpu-ms
  • kvOperationsAdaptiveGroups limit 100 → kv-reads, kv-writes (foldKv)
  • d1AnalyticsAdaptiveGroups limit 100 → d1-rows-read, d1-rows-written
  • queueMessageOperationsAdaptiveGroups limit 100 → queues-ops
  • r2OperationsAdaptiveGroups limit 1000 → r2-class-a, r2-class-b (classifyR2 returns only {classA, classB, unclassified, nonbillable} — no saturation field)
  • aiInferenceAdaptiveGroups limit 100 → workers-ai-neurons cycle total / per-day average (the by-day sibling got limit 10000 + a flag in cloudflare-export: alert on Workers AI neurons/day over threshold — the Oct 24–25 burn (4.11M neurons, ~$45) was invisible for days #2287; the cycle-total dataset it is compared against kept limit 100 and no flag)

If any of these datasets returns exactly its limit of rows, the published document reports the partial sum as an exact reading in a status: "ok" document — the precise failure mode the r2-storage and #2287 fixes were written to prevent.

Evidence (verified this run, laptop @ 8a5cd8e)

Probe ~/git/fleet/probe-cf-gql-limits (real cloudflare-quota-export.mjs copied verbatim, md5 780d4ee5dd2905d92c3672859c35c3dd, run under Bun against parseGraphqlUsage):

  • control payload: all metrics present, no lowerBound anywhere (correct).
  • kv groups at exactly 100 (the query limit): kv-reads = {"id":"kv-reads","used":100,"unit":"count","source":"cloudflare-graphql-analytics"} — no lowerBound.
  • workers rows at exactly 100: workers-requests used=100, no flag.
  • ai cycle-total groups at exactly 100: workers-ai-neurons published with a definitive detail string ("cycle total 1000 neurons"), no flag.
  • d1 and queues groups at exactly 100: d1-rows-read / queues-ops used=100, no flag.
  • r2 operations groups at exactly 1000 (the query limit): r2-class-b used=1000, no flag; classifyR2 result keys are only classA,classB,unclassified,nonbillable.
  • Existing suite as control: bun test on the real test file — 35 pass / 0 fail; the only saturation tests cover r2-storage (test line 155) and ai-by-day (line 419).

Dedup: no open or closed issue covers GraphQL-limit saturation for these datasets (#2574 covered REST bucket enumeration; #2287 covered only the by-day neurons dataset).

Why it matters

The aggregator's Cloudflare card and the quota registry consume these figures as exact readings. A truncated workers/kv/d1/queues/r2/ai total understates usage silently — for the AI neurons cycle total it also corrupts the per-day average that the #2287 alert is compared against. The file already solved this problem twice; the remaining datasets are the residual door of the same fix.

Acceptance criteria

  • Every dataset in GRAPHQL_QUERY with an explicit limit has a defined saturation behaviour: at-limit results mark the affected metric(s) lowerBound: true (the r2-storage pattern) or otherwise surface an explicit document-level flag — no dataset publishes an at-limit sum as an exact reading.
  • classifyR2 reports saturation for r2OperationsAdaptiveGroups (limit 1000) and the flag reaches the success document.
  • New tests in cloudflare-quota-export.test.mjs pin at-limit behaviour for each previously unflagged dataset (at-limit flagged; one-below-limit unflagged), mirroring the existing r2-storage test at line 155.
  • Existing 35 tests still pass.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. added
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-07T12:50Z
    • Found via: filed this run
    • Task: Add GraphQL group-limit saturation flagging to the five unflagged cloudflare-export datasets (workers/kv/d1/queues/ai-total at limit 100, r2-ops at limit 1000), following the existing r2-storage/ai-by-day lowerBound pattern (evidence and probe in the issue body).
    • Expectation: effort/s — done when no at-limit sum publishes as an exact reading, with the existing 35-test suite green plus new at-limit cases per dataset.
    • Links: probe ~/git/fleet/probe-cf-gql-limits (laptop); queue packet enqueued to repo-health-code-pilot this run
  5. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  6. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 8, 2026
  7. 25 remaining items

  8. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-b — Session/ID: task 11273, repo-queue-worker-shift-b 2026-11-09 run. Task 11273 (small_fix) for issue #6880: cloudflare-export GraphQL saturation flags; attempts 3/4. Fresh check: issue #6880 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels. Execution lane row 3612 = opencode. Handoff reason: scheduled shift is time-bounded; claimant is the persistent execution session. Checkpointed handed_off; parking task 11273 for 20 minutes for the claimant window.

  9. dezren39 commented on Nov 10, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off to opencode claimant — Agent: queue worker (repo-worker-code), lane code-n — Session/ID: task 11273, repo-queue-worker-shift-n 2026-11-09 run. Task 11273 (small_fix) for issue #6880: cloudflare-export GraphQL saturation flags; attempts 3/4 on this claim. Fresh check: issue #6880 OPEN, no held/user/owned/do-not-merge/do-not-auto-edit labels, no status/needs-triage. Execution lane row 3612 = opencode (repeat handoff). Checkpointed handed_off with handoff_reason "scheduled shift is time-bounded; claimant is the persistent execution session" (#8097 Rule 4); parking task 11273 for 20 minutes for the claimant window.

  10. added
    priority/lowNice to have; do when convenient
    and removed
    priority/normalOrdinary priority (the default)
    on Nov 11, 2026
  11. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    Agent note (lane code-b, task 11273): implemented and verified; PR #8693 awaits Codex disposition and merge.

    What shipped: the r2-storage saturation discipline now covers every limited GraphQL dataset. Named limit constants (WORKERS_GROUP_LIMIT/KV_GROUP_LIMIT/D1_GROUP_LIMIT/QUEUES_GROUP_LIMIT = 100, R2_OPERATIONS_GROUP_LIMIT = 1000, AI_NEURONS_GROUP_LIMIT = 100) sit next to R2_STORAGE_GROUP_LIMIT with a keep-in-step note against GRAPHQL_QUERY. At-limit results flag the affected metrics lowerBound: true — workers-requests, workers-cpu-ms, kv-reads, kv-writes, d1-rows-read, d1-rows-written, queues-ops, r2-class-a, r2-class-b, workers-ai-neurons — and classifyR2 returns a saturated field that reaches the success document via the metrics. The ai cycle-total detail prose also states LOWER BOUND, like r2-storage. Saturation is computed only after the fail-closed readers validate the groups arrays, so missing-field behaviour is unchanged.

    Verification: node --test pm-stack/cloudflare-export/cloudflare-quota-export.test.mjs — 43/43 pass (35 existing + 8 new: a table-driven at-limit/one-below test per previously unflagged dataset, a classifyR2 saturation test, and an ai-prose test).

    Resume condition: Codex review on PR #8693 dispositioned, then squash-merge and close this issue. PR CI is subject to the repo-wide runner stall; the merge rests on the local verification above per charter.

  12. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    state: done
    task: 11273
    lane: any-b
    worker: repo-worker-code

    Done — fixed_merged. Resumed PR #8693 (opened by the earlier claim of task 11273): every GraphQL dataset with an explicit limit now flags saturation — workers/kv/d1/queues/ai-total metrics carry lowerBound: true at their limit (100), and classifyR2 reports saturated for r2OperationsAdaptiveGroups (limit 1000) with the flag reaching the success document. Verified on PR head 9ca0148 in the task worktree: node --test cloudflare-quota-export.test.mjs — 43 pass, 0 fail (35 pre-existing + the new at-limit/one-below cases). Codex review on the head: no findings. PR checks stall-cancelled fleet-wide (the standing fleet CI pattern); local verification is the verdict. Merged PR #8693 (squash, merge commit d90c21b). The PR did not auto-close this issue, so closing it here with status/done. Task 11273 completes with outcome fixed_merged.

  13. added and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/pm-stackpm-stack (Pad/Grist) in developing-today/codekind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus/donestatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions