Skip to content

Extract shared AnalysisBase from DomainAnalysis/FirewallAnalysis - #46063

Merged
pelikhan merged 6 commits into
mainfrom
copilot/deep-report-refactor-analysis-base
Jul 16, 2026
Merged

Extract shared AnalysisBase from DomainAnalysis/FirewallAnalysis#46063
pelikhan merged 6 commits into
mainfrom
copilot/deep-report-refactor-analysis-base

Conversation

CopilotAI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

DomainAnalysis and FirewallAnalysis duplicated DomainBuckets + TotalRequests + allowed/blocked counts with parallel AddMetrics implementations, creating drift risk.

Changes

  • domain_buckets.go — New AnalysisBase struct embedding DomainBuckets, TotalRequests, AllowedRequests, BlockedRequests; single addBaseMetrics implementation; mergeDomainList helper for deduped domain union
  • access_log.goDomainAnalysis embeds AnalysisBase; renames AllowedCount/BlockedCountAllowedRequests/BlockedRequests; AddMetrics reduced to one call
  • firewall_log.goFirewallAnalysis embeds AnalysisBase instead of three separate fields; AddMetrics only handles RequestsByDomain merging
  • logs_report_firewall.go, logs_usage_activity.go — Field reference updates
  • 15 test files — Updated to nested struct literal syntax
// Before: two hand-synced structstypeDomainAnalysisstruct {
DomainBucketsTotalRequestsintAllowedCountintBlockedCountint
}
typeFirewallAnalysisstruct {
DomainBucketsTotalRequestsintAllowedRequestsintBlockedRequestsintRequestsByDomainmap[string]DomainRequestStats
}
// After: one base, each type adds only what's uniquetypeAnalysisBasestruct {
DomainBucketsTotalRequestsintAllowedRequestsintBlockedRequestsint
}
typeDomainAnalysisstruct{ AnalysisBase }
typeFirewallAnalysisstruct {
AnalysisBaseRequestsByDomainmap[string]DomainRequestStats
}

Domain-list merging (previously only in FirewallAnalysis.AddMetrics) is now handled once in addBaseMetrics, so both types get it automatically.

CopilotAIand others added 2 commits July 16, 2026 19:14
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Refactor to extract shared analysis base for DomainAnalysis and FirewallAnalysisExtract shared AnalysisBase from DomainAnalysis/FirewallAnalysisJul 16, 2026
CopilotAI requested a review from pelikhanJuly 16, 2026 19:16
@pelikhan
pelikhan marked this pull request as ready for review July 16, 2026 19:19
CopilotAI review requested due to automatic review settings July 16, 2026 19:19

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extracts shared domain counters and merging logic into AnalysisBase, reducing duplication between access and firewall analysis.

Changes:

  • Adds shared metrics and domain-union logic.
  • Embeds AnalysisBase in both analysis types.
  • Updates consumers and tests for renamed fields and nested literals.
Show a summary per file
FileDescription
pkg/cli/domain_buckets.goAdds AnalysisBase and domain merging.
pkg/cli/access_log.goMigrates access analysis to the shared base.
pkg/cli/firewall_log.goMigrates firewall analysis to the shared base.
pkg/cli/logs_report_firewall.goUpdates access counter references.
pkg/cli/logs_usage_activity.goBuilds nested shared-base values.
pkg/cli/access_log_test.goUpdates access-analysis tests.
pkg/cli/audit_agent_example_test.goUpdates example firewall fixtures.
pkg/cli/audit_agent_output_test.goUpdates agent-output fixtures.
pkg/cli/audit_cross_run_test.goUpdates cross-run fixtures.
pkg/cli/audit_diff_test.goUpdates firewall-diff fixtures.
pkg/cli/audit_report_test.goUpdates audit-report fixtures.
pkg/cli/audit_test.goUpdates audit fixtures.
pkg/cli/firewall_log_integration_test.goUpdates integration fixtures.
pkg/cli/firewall_log_test.goUpdates firewall merge tests.
pkg/cli/log_aggregation_test.goUpdates shared aggregation tests.
pkg/cli/logs_episode_test.goUpdates episode fixtures.
pkg/cli/logs_report_test.goUpdates report aggregation fixtures.
pkg/cli/logs_summary_test.goUpdates summary serialization fixture.
pkg/cli/logs_usage_activity_test.goUpdates usage-summary fixture.
pkg/cli/observability_insights_test.goUpdates observability fixtures.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 20/20 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment threadpkg/cli/access_log.go
TotalRequests int `json:"total_requests"`
AllowedCount int `json:"allowed_count"`
BlockedCount int `json:"blocked_count"`
AnalysisBase
Comment threadpkg/cli/log_aggregation_test.go Outdated
Comment on lines +70 to +74
AnalysisBase: AnalysisBase{TotalRequests: 10, AllowedRequests: 6, BlockedRequests: 4},
}

analysis2 := &DomainAnalysis{
TotalRequests: 5,
AllowedCount: 3,
BlockedCount: 2,
AnalysisBase: AnalysisBase{TotalRequests: 5, AllowedRequests: 3, BlockedRequests: 2},
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address any unresolved review feedback, investigate the failed checks listed on this PR if applicable, and rerun checks once the branch is ready.

Generated by 👨‍🍳 PR Sous Chef · 8.18 AIC · ⌖ 7.29 AIC · ⊞ 7.5K ·
Comment /souschef to run again

CopilotAIand others added 2 commits July 16, 2026 22:10
…und-trip tests
- Add MarshalJSON/UnmarshalJSON to DomainAnalysis to preserve the original
allowed_count/blocked_count JSON keys from before the AnalysisBase refactor,
maintaining backward-compat for cached RunSummary.access_analysis JSON and
AccessLogSummary.by_workflow consumers.
- Expand TestDomainAnalysisAddMetrics to cover domain-list merging/dedup
(the new behavior delivered by addBaseMetrics for DomainAnalysis).
- Add TestDomainAnalysisJSONWireNames to assert the stable wire names and
full round-trip fidelity.
- Fix interface{} → any (modernize lint).
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…nAnalysisAddMetrics
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

CopilotAI commented Jul 16, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot please run the pr-finisher skill, address any unresolved review feedback, investigate the failed checks listed on this PR if applicable, and rerun checks once the branch is ready.

...

Both review threads addressed in commits 2bc78cf and c1cf401:

  1. JSON wire-name break (pkg/cli/access_log.go) — Added MarshalJSON/UnmarshalJSON to DomainAnalysis that map AllowedRequests/BlockedRequests to/from the original allowed_count/blocked_count JSON keys. A TestDomainAnalysisJSONWireNames test verifies the stable wire names and full round-trip.

  2. Missing domain-merge test coverage (pkg/cli/log_aggregation_test.go) — Expanded TestDomainAnalysisAddMetrics with domain data containing duplicates across the two analyses, asserting that addBaseMetrics produces a sorted, deduplicated union for both AllowedDomains and BlockedDomains.

Local fmt, lint, and targeted tests are all green. Pre-existing failures (TestCloseExistingOrgIssuesByMarkerSkipsPRsAndPaginates) are confirmed pre-existing on the base commit and unrelated to these changes. CI re-trigger needed for final green signal.

CopilotAI requested a review from gh-aw-botJuly 16, 2026 22:13
@pelikhan
pelikhan merged commit c19fd53 into mainJul 16, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-refactor-analysis-base branch July 16, 2026 22:21
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.12

Sign up for freeto 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.

[deep-report] [Code Quality] Extract shared analysis base for DomainAnalysis/FirewallAnalysis (access_log.go/firewall_log.go)

4 participants

@gh-aw-bot@pelikhan