Skip to content

get_reporting_status: scope-wide generations and issues grow without bound on heavily re-versioned accounts #1968

Backlog

Description

@rachitm022

Follow-up split from #1966 / #1967 (ESA scope3data/embedded-sales-agent#1362).

Problem

Every get_reporting_status summary and periods response repeats scope-wide data that grows with the account, not with the page:

  1. scope.delivery_config_generations: about 4 JSON nodes per configuration generation.
  2. For a period horizon that starts before scope.ledger_retained_from, one HISTORY_UNAVAILABLE issue per generation (status_projection._project, "history-unavailable-v1"): about 12 nodes each.
  3. The scope-level issues list also carries per-obligation issues (for example one REPORT_OVERDUE per missing report) for the whole evaluated scope.

#1967 bounds each periods page to 8,000 nodes and makes the records give way to this fixed part. Measured on the in-memory ledger: with 334 hourly generations (staging's account 6082151998) and a horizon, the fixed part is about 5,500 nodes and pages still fit, with fewer records each. Past about 500 generations with a horizon, the fixed part alone exceeds the page budget. Past about 600 it exceeds the 10,000-node cap a buyer's SDK applies, and paging cannot help. With 334 generations and no delivered revisions, (3) alone makes the fixed part 16,876 nodes.

Why this isn't in #1967

  • The scope can't be filtered per page. The response schema defines scope as the "Exact denominator evaluated for summary or periods health", and delivery_config_generations as the "Exact independently reconciled configuration generations in the denominator". Top-level health and issues describe that whole denominator. _scope_to_wire documents that it is derived from configurations "so every page of one cursor reports the identical scope". Listing only the generations that own a returned period would make health and scope disagree and change from page to page.
  • Filtering by horizon doesn't fix the staging case. A denominator restricted to generations whose active lifetime overlaps the horizon is allowed by the spec. But staging's generations were all created within days, so any realistic horizon still overlaps all of them.
  • The real driver is semantic. status_retained_from takes the latest per-generation boundary, max(as_of - retention, min(activated_at, as_of)). So ledger_retained_from jumps to the newest generation's activation, and any horizon before it reports coverage_complete: false with one HISTORY_UNAVAILABLE per generation, even though nothing was owed before that activation and no history was lost. Changing this changes health (action_required to healthy) in summary, periods and status push, because they share one projection. It needs its own review, and possibly spec clarification of ledger_retained_from ("for every selected configuration generation").

Proposal (for discussion)

  1. Restrict the denominator to generations whose active interval [activated_at, deactivated_at or publication stop + SLA + recovery window) overlaps the horizon, applied identically in summary, periods and push. Also count generations that own an obligation in the horizon.
  2. Compute ledger_retained_from from retention only (and per-generation activation only where history before activation was actually owed), so a re-version doesn't make history "unavailable".
  3. Emit one HISTORY_UNAVAILABLE per uncovered horizon (with the affected generations bounded or summarized) rather than one per generation, keeping issue ids stable for notifications. allOf/5 of the response schema only requires at least one.
  4. Decide how the scope-level issues list stays bounded for accounts with many open obligation issues (for example, aggregate per generation and code, and keep per-obligation detail on the period records).

Check against the TS SDK and the interop corpus before changing issue ids or the denominator rule.

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

    no-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions