Skip to content

Carry quota severity on the struct, not per-reader#24

Merged
stxkxs merged 1 commit into
mainfrom
uplift-renderer-registry
Jun 5, 2026
Merged

Carry quota severity on the struct, not per-reader#24
stxkxs merged 1 commit into
mainfrom
uplift-renderer-registry

Conversation

@stxkxs
Copy link
Copy Markdown
Member

@stxkxs stxkxs commented Jun 5, 2026

What

cloud.QuotaUsage recomputed its severity from Utilization at every read site — JSON output (WriteQuotas), the quota summary (quota.Summarize), comparison normalization (compare.normalizeQuotas), and the HTML report generator. Severity now travels with the finding.

How

  • cloud.QuotaUsage gains a Severity field (json:"severity").
  • The AWS provider's ListQuotas sets it once (derived from utilization) — the single source of truth, now serialized in --output json.
  • A QuotaUsage.EffectiveSeverity() accessor returns the stored Severity, falling back to QuotaSeverity(Utilization) when unset — keeps reports saved before the field (and hand-built test data) correct.
  • All four readers now call EffectiveSeverity() instead of recomputing.

The other findingless structs (OrphanResource, CostDiff, InventoryResource) carry no severity by nature, so QuotaUsage was the one that needed this.

Tests

EffectiveSeverity (stored value wins; fallback computes from utilization) and ListQuotas sets Severity on every quota. All read sites verified converted by grep. task build / go test ./... / go vet / golangci-lint green.

Scope note

This is sub-item 9a of the output-renderer cleanup. 9b — splitting the 715-line output/table.go into per-domain files — is reframed from the original "runtime FindingRenderer registry": commands dispatch type-specifically (compile-time-safe), the renderers have heterogeneous signatures (IAM principal counts, audit *Report, compare CompareResult), and the one generic consumer (report) already routes through the centralized compare.NormalizeReport switch — so a uniform any-typed registry would cost type safety with no caller that needs it. The achievable win is the per-domain file split.

cloud.QuotaUsage recomputed its severity from Utilization at every read site
(JSON output, the quota summary, comparison normalization, and the HTML
report). Severity now travels with the finding instead.

  - cloud.QuotaUsage gains a Severity field (json:"severity").
  - The AWS provider's ListQuotas sets it once, derived from utilization, so
    it's the single source of truth and is serialized in --output json.
  - A QuotaUsage.EffectiveSeverity() accessor returns the stored Severity,
    falling back to QuotaSeverity(Utilization) when unset — keeping reports
    saved before the field (and hand-built test data) correct.
  - WriteQuotas, quota.Summarize, compare.normalizeQuotas, and the report
    generator now read EffectiveSeverity() rather than recomputing.

The other findingless structs (OrphanResource, CostDiff, InventoryResource)
carry no severity by nature, so QuotaUsage was the one that needed this.

Tests: EffectiveSeverity (stored value wins; fallback computes from
utilization) and ListQuotas sets Severity on every quota. All read sites
verified converted by grep.

This is sub-item 9a of the output-renderer cleanup. 9b — splitting the
715-line output/table.go into per-domain files — is reframed from the
original "runtime FindingRenderer registry": commands dispatch
type-specifically, the renderers have heterogeneous signatures, and the one
generic consumer already routes through compare.NormalizeReport, so a
uniform any-typed registry would cost type safety with no caller that needs
it. The achievable win is the per-domain file split.
@stxkxs stxkxs merged commit ae0fa87 into main Jun 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant