Description
Three nearly-identical entry types in pkg/cli/audit_diff.go each repeat the same anomaly-flagging fields inline:
DomainDiffEntry (line ~24)
MCPToolDiffEntry (line ~224)
ToolCallDiffEntry (line ~282)
All three follow the same pattern: Status string, IsAnomaly bool, AnomalyNote string. The run1/run2 count pairs differ per type (intentionally), but the anomaly fields are identical copy-pastes.
Suggested Changes
- Define a new
DiffEntryBase struct in pkg/cli/audit_diff.go with fields:
Status string json:"status"``
IsAnomaly bool json:"is_anomaly"``
AnomalyNote string json:"anomaly_note"``
- Replace the inline copies of those fields in
DomainDiffEntry, MCPToolDiffEntry, and ToolCallDiffEntry with an embedded DiffEntryBase
- Verify JSON serialization is unchanged (
json:",inline" or direct embedding preserves flat JSON keys)
Files Affected
pkg/cli/audit_diff.go — DomainDiffEntry, MCPToolDiffEntry, ToolCallDiffEntry (lines ~24, ~224, ~282)
Success Criteria
DiffEntryBase struct defined and embedded in all three types
- JSON output for audit diff is unchanged (field names preserved)
make build and make test pass
Source
Extracted from Typist Go Type Consistency Analysis discussion #46823
Priority
Low — reduces copy-paste drift; effort ~1–2 hours
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · 46.7 AIC · ⌖ 7.94 AIC · ⊞ 7K · ◷
Description
Three nearly-identical entry types in
pkg/cli/audit_diff.goeach repeat the same anomaly-flagging fields inline:DomainDiffEntry(line ~24)MCPToolDiffEntry(line ~224)ToolCallDiffEntry(line ~282)All three follow the same pattern:
Status string,IsAnomaly bool,AnomalyNote string. The run1/run2 count pairs differ per type (intentionally), but the anomaly fields are identical copy-pastes.Suggested Changes
DiffEntryBasestruct inpkg/cli/audit_diff.gowith fields:Status stringjson:"status"``IsAnomaly booljson:"is_anomaly"``AnomalyNote stringjson:"anomaly_note"``DomainDiffEntry,MCPToolDiffEntry, andToolCallDiffEntrywith an embeddedDiffEntryBasejson:",inline"or direct embedding preserves flat JSON keys)Files Affected
pkg/cli/audit_diff.go—DomainDiffEntry,MCPToolDiffEntry,ToolCallDiffEntry(lines ~24, ~224, ~282)Success Criteria
DiffEntryBasestruct defined and embedded in all three typesmake buildandmake testpassSource
Extracted from Typist Go Type Consistency Analysis discussion #46823
Priority
Low — reduces copy-paste drift; effort ~1–2 hours