Description
pkg/parser hand-writes the value.(map[string]any) type assertion 87 times across 14 non-test files (161 including tests), even though pkg/typeutil/lookup.go already provides LookupMap, LookupString, and LookupStringPath helpers with consistent, centralized error handling. Only pkg/parser/frontmatter_hash.go currently uses the shared helpers — every other call site duplicates the same ok-check-and-error-message boilerplate independently, so a future fix to one assertion's error message or nil-handling won't propagate to the other 86.
Highest-concentration files: schema_suggestions.go (15), mcp.go (12), import_field_extractor.go (10), import_schema_validation.go (9), yaml_import.go (6), tools_merger.go (6), schema_deprecation.go (6), import_observability.go (6), schema_triggers.go (5).
Example (pkg/parser/mcp.go:99):
mcpServers, ok := mcpServersSection.(map[string]any)
if !ok {
return nil, fmt.Errorf("mcp-servers section must be a map, got %T. ...", mcpServersSection)
}
could become:
mcpServers, ok := typeutil.LookupMap(parentMap, "mcp-servers")
(adjusting call sites that assert on an already-extracted any value to instead look up from the parent map, or adding a typeutil.AsMap(value any) (map[string]any, bool) variant for that shape if needed).
Expected Impact
Removes ~87 duplicated assertion/error-handling blocks in the parser package, so future changes to map-lookup error messages or nil-safety only need to happen once in pkg/typeutil. Reduces review surface for pkg/parser changes and makes the existing typeutil helpers the single source of truth they were presumably designed to be.
Suggested Agent
New Agent (mechanical, file-by-file refactor with go build/go test ./pkg/parser/... verification after each file)
Estimated Effort
Medium (1-4 hours) — mechanical but touches 14 files; some call sites assert on an already-unwrapped any rather than a parent map key, so a small typeutil.AsMap helper may be needed for full coverage.
Data Source
DeepReport Intelligence Briefing analysis, 2026-10-05 (cycle 3), sourced from Typist: Go Type Consistency Analysis discussion (#65837).
Generated by 🔬 Deep Report · claude · agent · 282.7 AIC · ⌖ 7.05 AIC · ⊞ 7.1K · ◷
Description
pkg/parserhand-writes thevalue.(map[string]any)type assertion 87 times across 14 non-test files (161 including tests), even thoughpkg/typeutil/lookup.goalready providesLookupMap,LookupString, andLookupStringPathhelpers with consistent, centralized error handling. Onlypkg/parser/frontmatter_hash.gocurrently uses the shared helpers — every other call site duplicates the sameok-check-and-error-message boilerplate independently, so a future fix to one assertion's error message or nil-handling won't propagate to the other 86.Highest-concentration files:
schema_suggestions.go(15),mcp.go(12),import_field_extractor.go(10),import_schema_validation.go(9),yaml_import.go(6),tools_merger.go(6),schema_deprecation.go(6),import_observability.go(6),schema_triggers.go(5).Example (
pkg/parser/mcp.go:99):could become:
(adjusting call sites that assert on an already-extracted
anyvalue to instead look up from the parent map, or adding atypeutil.AsMap(value any) (map[string]any, bool)variant for that shape if needed).Expected Impact
Removes ~87 duplicated assertion/error-handling blocks in the parser package, so future changes to map-lookup error messages or nil-safety only need to happen once in
pkg/typeutil. Reduces review surface forpkg/parserchanges and makes the existingtypeutilhelpers the single source of truth they were presumably designed to be.Suggested Agent
New Agent (mechanical, file-by-file refactor with
go build/go test ./pkg/parser/...verification after each file)Estimated Effort
Medium (1-4 hours) — mechanical but touches 14 files; some call sites assert on an already-unwrapped
anyrather than a parent map key, so a smalltypeutil.AsMaphelper may be needed for full coverage.Data Source
DeepReport Intelligence Briefing analysis, 2026-10-05 (cycle 3), sourced from Typist: Go Type Consistency Analysis discussion (#65837).