Problem
In pkg/agentdrain/types.go, the AnomalyReport struct has two fields with nearly identical documentation that are always assigned the same value:
// types.go:59 — "IsNewTemplate is true when the log line created a new cluster"
IsNewTemplate bool
// types.go:65 — "NewClusterCreated is true when this event produced a brand-new cluster"
NewClusterCreated bool
In pkg/agentdrain/anomaly.go:31-33, both fields are set to the same variable:
report := &AnomalyReport{
IsNewTemplate: isNew,
NewClusterCreated: isNew, // Always identical to IsNewTemplate
...
}
Verified via Serena LSP (find_referencing_symbols):
NewClusterCreated is only set in one place (anomaly.go:32) and is only checked in tests
IsNewTemplate is used in scoring logic, logging, buildReason(), and tests
buildReason() checks IsNewTemplate but not NewClusterCreated
- The debug log at anomaly.go:62 prints
IsNewTemplate but omits NewClusterCreated
Impact
- Severity: Medium
- Affected files:
pkg/agentdrain/types.go, pkg/agentdrain/anomaly.go, pkg/agentdrain/anomaly_test.go, pkg/agentdrain/miner_test.go, pkg/agentdrain/spec_test.go
- Risk: API confusion — consumers of
AnomalyReport cannot know which field to read. The redundant field makes the struct harder to reason about and wastes space. The near-identical documentation masks the problem.
Recommendation
If IsNewTemplate and NewClusterCreated are truly always synonymous, remove NewClusterCreated and update all consumers to use IsNewTemplate:
// types.go — remove NewClusterCreated field
type AnomalyReport struct {
// IsNewTemplate is true when the log line produced a brand-new log cluster.
IsNewTemplate bool
LowSimilarity bool
RareCluster bool
AnomalyScore float64
Reason string
}
If the two fields were intended to capture distinct concepts (e.g., IsNewTemplate = the input was new, NewClusterCreated = a persistent cluster was actually persisted), clarify the documentation and ensure they are set independently.
Validation
Estimated Effort: Small
Found by Sergo — Serena Go static analysis (LSP-confirmed), run 2026-05-07
Generated by Sergo - Serena Go Expert · ● 578.5K · ◷
Problem
In
pkg/agentdrain/types.go, theAnomalyReportstruct has two fields with nearly identical documentation that are always assigned the same value:In
pkg/agentdrain/anomaly.go:31-33, both fields are set to the same variable:Verified via Serena LSP (
find_referencing_symbols):NewClusterCreatedis only set in one place (anomaly.go:32) and is only checked in testsIsNewTemplateis used in scoring logic, logging,buildReason(), and testsbuildReason()checksIsNewTemplatebut notNewClusterCreatedIsNewTemplatebut omitsNewClusterCreatedImpact
pkg/agentdrain/types.go,pkg/agentdrain/anomaly.go,pkg/agentdrain/anomaly_test.go,pkg/agentdrain/miner_test.go,pkg/agentdrain/spec_test.goAnomalyReportcannot know which field to read. The redundant field makes the struct harder to reason about and wastes space. The near-identical documentation masks the problem.Recommendation
If
IsNewTemplateandNewClusterCreatedare truly always synonymous, removeNewClusterCreatedand update all consumers to useIsNewTemplate:If the two fields were intended to capture distinct concepts (e.g.,
IsNewTemplate= the input was new,NewClusterCreated= a persistent cluster was actually persisted), clarify the documentation and ensure they are set independently.Validation
serena find_referencing_symbolsto locate allNewClusterCreatedusagesbuildReason()and scoring logic still cover all intended casesEstimated Effort: Small
Found by Sergo — Serena Go static analysis (LSP-confirmed), run 2026-05-07