Skip to content

Split the output renderers into per-domain files#25

Merged
stxkxs merged 1 commit into
mainfrom
uplift-split-renderers
Jun 5, 2026
Merged

Split the output renderers into per-domain files#25
stxkxs merged 1 commit into
mainfrom
uplift-split-renderers

Conversation

@stxkxs
Copy link
Copy Markdown
Member

@stxkxs stxkxs commented Jun 5, 2026

What

output/table.go (715 lines) and output/json.go (252 lines) were two shared monoliths every domain's rendering threaded through. They're now per-domain files: output/<domain>.go owns that domain's table renderer + JSON report struct + writer (iam, storage, orphans, cost, network, certs, tags, drift, compliance, lambda, k8s, secrets, audit, inventory, quota, compare, platform). Shared infrastructure moved to:

  • style.go — lipgloss styles, colorSeverity, formatTags, truncate
  • jsoncore.gowriteJSON

Adding a domain now adds one file instead of editing two shared files. sarif.go is left intact as the cohesive SARIF concern.

Pure move — verified two ways

  1. Line conservation: 869 non-import code lines in the old files, 869 in the new files, sorted-identical (zero logic added/dropped/altered).
  2. Behavior pin: the unchanged output test suite (table/json/sarif round-trips) passes, plus task build / go test ./... / go vet / golangci-lint all green.

Scope note

This is sub-item 9b. The original "runtime FindingRenderer registry" was reframed after empirical review — 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 compare.NormalizeReport — so a uniform any-typed registry would trade type safety for indirection with no caller that needs it. The per-domain file split is the achievable maintainability win.

output/table.go (715 lines) and output/json.go (252 lines) were two shared
monoliths that every domain's rendering had to be threaded through. They're
now per-domain files: output/<domain>.go owns that domain's table renderer,
JSON report struct, and JSON writer (iam, storage, orphans, cost, network,
certs, tags, drift, compliance, lambda, k8s, secrets, audit, inventory,
quota, compare, platform). Shared infrastructure moved to:

  - style.go    — lipgloss styles, colorSeverity, formatTags, truncate
  - jsoncore.go — writeJSON

Adding a domain now adds one file instead of editing two shared files.
sarif.go is left intact as the cohesive SARIF concern.

This is a pure code reorganization with no behavior change, verified two
ways: line-conservation (869 non-import code lines in the old files, 869 in
the new files, sorted-identical) and the unchanged output test suite
(table/json/sarif round-trips) passing.

Sub-item 9b of the output-renderer cleanup. The original "runtime
FindingRenderer registry" was reframed after empirical review — commands
dispatch type-specifically, the renderers have heterogeneous signatures, and
the one generic consumer already routes through compare.NormalizeReport, so a
uniform registry would cost type safety with no caller that needs it.
@stxkxs stxkxs merged commit 2dd5c82 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