Description
pkg/typeutil/lookup.go (e.g. LookupMap/LookupString, lines 20-41) and pkg/cli/token_usage_parse.go (e.g. extractUsageRecord/usageNumericValue/usageStringValue, lines 146-190) both center their logic on map[string]any lookups with repeated ad-hoc type assertions. These sit on the hot path for frontmatter parsing and token-usage-log parsing — two frequently-touched, easy-to-regress areas, per the 2026-10-08 Typist (Go Type Consistency Analysis) report.
Expected Impact
Fewer silent type-assertion failures (value.(map[string]any) returning ok=false is easy to miss downstream), and better compile-time safety on two parsing paths that are touched often.
Suggested Fix
Introduce small generic helpers in pkg/typeutil (e.g. LookupTyped[T any](m map[string]any, key string) (T, bool)) to replace the repeated per-type Lookup* functions, and introduce a concrete struct for usage records in token_usage_parse.go instead of threading any/map[string]any through multiple helper functions.
Code Region: pkg/typeutil/lookup.go:20-90, pkg/cli/token_usage_parse.go:146-190
Suggested Agent
Developer (Go, generics-savvy)
Estimated Effort
Medium (2-4 hours)
Data Source
DeepReport Intelligence Briefing, 2026-10-08 (cycle 3). Source discussion #66860 (Typist). Live-verified today: both files still use the any/map[string]any patterns described.
Generated by 🔬 Deep Report · claude · agent · 343.4 AIC · ⌖ 9.25 AIC · ⊞ 7.1K · ◷
Description
pkg/typeutil/lookup.go(e.g.LookupMap/LookupString, lines 20-41) andpkg/cli/token_usage_parse.go(e.g.extractUsageRecord/usageNumericValue/usageStringValue, lines 146-190) both center their logic onmap[string]anylookups with repeated ad-hoc type assertions. These sit on the hot path for frontmatter parsing and token-usage-log parsing — two frequently-touched, easy-to-regress areas, per the 2026-10-08 Typist (Go Type Consistency Analysis) report.Expected Impact
Fewer silent type-assertion failures (
value.(map[string]any)returningok=falseis easy to miss downstream), and better compile-time safety on two parsing paths that are touched often.Suggested Fix
Introduce small generic helpers in
pkg/typeutil(e.g.LookupTyped[T any](m map[string]any, key string) (T, bool)) to replace the repeated per-typeLookup*functions, and introduce a concrete struct for usage records intoken_usage_parse.goinstead of threadingany/map[string]anythrough multiple helper functions.Code Region:
pkg/typeutil/lookup.go:20-90,pkg/cli/token_usage_parse.go:146-190Suggested Agent
Developer (Go, generics-savvy)
Estimated Effort
Medium (2-4 hours)
Data Source
DeepReport Intelligence Briefing, 2026-10-08 (cycle 3). Source discussion #66860 (Typist). Live-verified today: both files still use the
any/map[string]anypatterns described.