Documentation
¶
Overview ¶
Package report defines audit results, summaries, and verdict aggregation. This file adds a derived action summary that groups findings by rule for human reports. input: report.Result findings and rule catalog entries output: derived action summary items ordered by remediation priority pos: derived human-report helper; does not change Result JSON and does not run the audit note: if this file changes, update this header and module README.md.
Package report defines audit results, summaries, and verdict aggregation. input: statement findings and global findings from audit evaluation output: normalized audit results for CLI, APIs, and future integrations pos: domain reporting model and verdict aggregation logic note: if this file changes, update this header and module README.md.
Index ¶
Constants ¶
const ( ImpactSourceShape = spec.ImpactSourceShape ImpactSourceMetadata = spec.ImpactSourceMetadata ImpactSourcePlan = spec.ImpactSourcePlan ImpactRiskLow = spec.ImpactRiskLow ImpactRiskMedium = spec.ImpactRiskMedium ImpactRiskHigh = spec.ImpactRiskHigh ImpactRiskUnknown = spec.ImpactRiskUnknown ImpactConfidenceLow = spec.ImpactConfidenceLow ImpactConfidenceMedium = spec.ImpactConfidenceMedium ImpactConfidenceHigh = spec.ImpactConfidenceHigh )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionItem ¶ added in v0.300.0
type ActionItem struct {
RuleID string
Level rule.Level
Count int
Summary string
Suggestion string
StatementIndexes []int
HasGlobalFindings bool
ExplainCommand string
}
ActionItem describes one rule group in the action summary. It carries rule-level priority and counts only; it does not hold raw SQL or finding metadata, so it is safe to render in human reports.
type ActionSummary ¶ added in v0.300.0
type ActionSummary struct {
Items []ActionItem
TotalItems int
}
ActionSummary is the derived, human-oriented grouping of audit findings by rule. It is derived from report.Result and does not change the Result JSON shape. It uses rule.Level (blocker, warning, notice) and never introduces a severity field.
func BuildActionSummary ¶ added in v0.300.0
func BuildActionSummary(result Result, entries []catalog.Entry, options ActionSummaryOptions) ActionSummary
BuildActionSummary derives an action summary from a report result and rule catalog entries.
It groups statement findings and global findings by rule ID, derives each group's highest-priority level and total count, prefers catalog summary/suggestion text and falls back to finding text when a rule is absent from the catalog, and orders groups by remediation priority (blocker, warning, notice; then count descending; then rule ID ascending).
BuildActionSummary is a pure derivation: it does not parse SQL, run the audit, inspect raw SQL, or mutate result or entries. Statement indexes are 1-based positions into result.Statements and are deduplicated within a group. An empty result returns a non-nil Items slice and TotalItems 0.
type ActionSummaryOptions ¶ added in v0.300.0
type ActionSummaryOptions struct {
Limit int
}
ActionSummaryOptions controls action summary derivation. A Limit of zero or less means the core performs no truncation.
type Explanation ¶ added in v0.6.2
type Explanation struct {
Summary string `json:"summary,omitempty"`
Reasons []string `json:"reasons,omitempty"`
}
Explanation captures additive human- and machine-readable context for a result.
type Impact ¶ added in v0.14.0
type Impact struct {
EstimatedRows *int64 `json:"estimated_rows,omitempty"`
EstimatedRatio *float64 `json:"estimated_ratio,omitempty"`
RiskLevel ImpactRisk `json:"risk_level,omitempty"`
Confidence ImpactConfidence `json:"confidence,omitempty"`
Source ImpactSource `json:"source,omitempty"`
ReasonCodes []string `json:"reason_codes,omitempty"`
Notes []string `json:"notes,omitempty"`
}
Impact captures the additive statement-level DML impact estimate exposed on results.
type ImpactConfidence ¶ added in v0.14.0
type ImpactConfidence = spec.ImpactConfidence
ImpactConfidence mirrors the shared DML impact confidence contract on report outputs.
type ImpactRisk ¶ added in v0.14.0
type ImpactRisk = spec.ImpactRisk
ImpactRisk mirrors the shared DML impact risk contract on report outputs.
type ImpactSource ¶ added in v0.14.0
type ImpactSource = spec.ImpactSource
ImpactSource mirrors the shared DML impact source contract on report outputs.
type Result ¶
type Result struct {
Verdict Verdict `json:"verdict"`
Summary Summary `json:"summary"`
Statements []StatementResult `json:"statements,omitempty"`
GlobalFindings []rule.Finding `json:"global_findings,omitempty"`
Unsupported []spec.UnsupportedDetail `json:"unsupported,omitempty"`
Explanation *Explanation `json:"explanation,omitempty"`
RuleSummary *RuleSummary `json:"rule_summary,omitempty"`
Diagnostics []spec.Diagnostic `json:"diagnostics,omitempty"`
}
Result is the aggregated audit output.
type RuleSummary ¶ added in v0.19.0
type RuleSummary struct {
Loaded int `json:"loaded"`
Applicable int `json:"applicable"`
Skipped []rule.SkippedRule `json:"skipped,omitempty"`
}
RuleSummary captures rule applicability statistics across the full audit.
type StatementResult ¶
type StatementResult struct {
Index int `json:"index"`
Kind string `json:"kind"`
RawSQL string `json:"raw_sql,omitempty"`
NormalizedSQL string `json:"normalized_sql,omitempty"`
Findings []rule.Finding `json:"findings,omitempty"`
Impact *Impact `json:"impact,omitempty"`
Explanation *Explanation `json:"explanation,omitempty"`
}
StatementResult stores findings for a single SQL statement.