audit: summary + group-by report options (#35) #36

Merged
KofTwentyTwo merged 18 commits from feature/GH-35-audit-summary-reports into develop 2026-06-09 15:17:56 +00:00
KofTwentyTwo commented 2026-06-09 12:46:17 +00:00 (Migrated from github.com)

Closes #35.

Overhauls the audit/check reporting so large repos get concise, grouped, machine-readable output without changing the default (no-flag) report.

What's in this PR

Reporting features

  • --summary (counts-only), --group-by license|category|type|directory, --sort key|count, --depth N, and --only missing,unknown,copyleft,violations across text/markdown/JSON.
  • Per-group risk markers and per-group license breakdowns (a directory/type view is no longer license-blind).
  • Attributable policy violations in every format (offending license + rule + file in text/markdown; structured violationDetails in JSON).
  • findings, per-row percentages/totals, and riskLevel/worstCategory in JSON and markdown (previously text-only).
  • JSON always emits the full report; --summary only trims the human formats.

Correctness fixes (this session)

  • Self-config exclusion: the tool's own .license-tool.yaml is YAML (commentable) and was counted as a headerless source file, inflating sourceTotal/sourceMissing; under default policy it even failed check. It is now marked skipped (reason tool config), still listed but excluded from coverage.
  • Policy-aware group risk: a group's [risk] was license-category-only, so an Apache group beside AGPL read low. It now escalates to high on a repo-level hard incompatibility (policy.Incompatible) or a file-scoped policy violation. The incompatibility set is derived from the full report so --only cannot distort a group's risk.

Testing

  • TDD throughout. Full gate green: gofmt, go vet, golangci-lint (0 issues), go test ./... -race, and the 100% coverage threshold (go-test-coverage).
  • The session delta was put through a three-agent adversarial review (correctness, test-quality, regression/doc); findings were addressed in fix(#35): harden group risk under --only; review-driven follow-ups.

Decisions recorded (see DESIGN addenda)

  • --group-by dependency: confirmed non-goal (deps aren't files; ambiguous semantics).
  • JSON explicit percentages: declined (presentation concern; derivable from counts + findings).
  • go.mod dependency resolution: not a defect (Go modules are not a supported ecosystem).

Independent of #29 (init TUI), which targets develop separately.

Closes #35. Overhauls the `audit`/`check` reporting so large repos get concise, grouped, machine-readable output without changing the default (no-flag) report. ## What's in this PR ### Reporting features - `--summary` (counts-only), `--group-by license|category|type|directory`, `--sort key|count`, `--depth N`, and `--only missing,unknown,copyleft,violations` across text/markdown/JSON. - Per-group **risk** markers and per-group license breakdowns (a `directory`/`type` view is no longer license-blind). - Attributable policy violations in every format (offending license + rule + file in text/markdown; structured `violationDetails` in JSON). - `findings`, per-row percentages/totals, and `riskLevel`/`worstCategory` in JSON and markdown (previously text-only). - JSON always emits the full report; `--summary` only trims the human formats. ### Correctness fixes (this session) - **Self-config exclusion:** the tool's own `.license-tool.yaml` is YAML (commentable) and was counted as a headerless source file, inflating `sourceTotal`/`sourceMissing`; under default policy it even failed `check`. It is now marked skipped (reason `tool config`), still listed but excluded from coverage. - **Policy-aware group risk:** a group's `[risk]` was license-category-only, so an Apache group beside AGPL read `low`. It now escalates to `high` on a repo-level hard incompatibility (`policy.Incompatible`) or a file-scoped policy violation. The incompatibility set is derived from the **full** report so `--only` cannot distort a group's risk. ## Testing - TDD throughout. Full gate green: `gofmt`, `go vet`, `golangci-lint` (0 issues), `go test ./... -race`, and the **100% coverage** threshold (`go-test-coverage`). - The session delta was put through a three-agent adversarial review (correctness, test-quality, regression/doc); findings were addressed in `fix(#35): harden group risk under --only; review-driven follow-ups`. ## Decisions recorded (see DESIGN addenda) - `--group-by dependency`: confirmed non-goal (deps aren't files; ambiguous semantics). - JSON explicit percentages: declined (presentation concern; derivable from counts + findings). - `go.mod` dependency resolution: not a defect (Go modules are not a supported ecosystem). Independent of #29 (init TUI), which targets `develop` separately.
Sign in to join this conversation.