Overview
Semantic function clustering analysis of the selected package slice (pkg/github, pkg/githubapi — 3 non-test Go files, 12 functions/methods). The dominant finding is not scattered helpers but a dead constants file whose values silently contradict the live default mapping it claims to mirror.
| Metric |
Count |
| Files analyzed |
3 |
| Functions/methods cataloged |
12 |
| Clusters identified |
4 |
| Outliers found |
1 |
| Dead/divergent constants |
56 |
| Duplicate logic sites |
6 |
Key issues
1. label_objective_mapping_constants.go is entirely unreferenced by production code — and diverges from DefaultObjectiveMapping()
All 28 ObjectiveLabel* and 28 ObjectiveValue* constants have zero production references. The only consumer is pkg/github/spec_test.go, which asserts them tautologically (ObjectiveValueCritical == 100 against a hardcoded 100) — so the test cannot detect drift.
The file header (label_objective_mapping_constants.go:5) states: "keep these values in sync with DefaultObjectiveMapping". They are not in sync. Six values contradict each other:
| Label |
Constants file |
DefaultObjectiveMapping() |
security-fix |
70 |
75 |
copilot-opt |
75 |
50 |
high-priority |
35 |
50 |
p1 |
35 |
50 |
medium-priority |
20 |
25 |
p2 |
20 |
25 |
A further 11 constants define scores for labels absent from the default mapping entirely — including bug (60), the highest-valued of the group: testing, reliability, workflow, engine, mcp, actions, cli, bug, lint-monster, dependencies, enhancement.
The practical effect: the constants file reads as the documented scoring policy, but LoadObjectiveMapping() never consults it. Anyone updating a constant to retune scoring changes nothing at runtime.
2. MultiLabelLogic* constants are ignored by the function they describe
MultiLabelLogicMax / Sum / First are declared at label_objective_mapping_constants.go:136-140, but ComputeObjectiveValue switches on raw string literals instead (label_objective_mapping.go:62,66,69). These constants are referenced by spec_test.go, so the test and the implementation agree only by coincidence of matching string values.
Remaining findings — duplication, outlier, and stdlib opportunities
3. Repeated normalize-and-lookup (4 sites)
The idiom strings.ToLower(strings.TrimSpace(label)) followed by an om.LabelToValue lookup appears four times in label_objective_mapping.go:
ComputeObjectiveValue:49-50
computeValueFirst:94-95
FilterObjectiveLabels:200-201
HasObjectiveLabel:233-234
Extracting func (om *ObjectiveMapping) lookup(label string) (int, bool) collapses all four and makes the normalization rule single-sourced — relevant because normalization semantics are part of the public contract (spec_test.go tests " BUG ").
4. githubapi.ClientOptions helper bypassed by two call sites
pkg/githubapi/options.go:9 exists to apply constants.DefaultHTTPClientTimeout, but has only one production caller (pkg/cli/update_check.go:236). Two other sites hand-roll the identical construction:
pkg/parser/remote_client.go:30-33
pkg/cli/secret_set_command.go:126-131
Both guard Host behind an if host != "", which is equivalent to passing it straight through since the empty string is the zero value — so both can call the helper directly. (The api.ClientOptions literals in pkg/workflow/repository_features_validation.go:289,343 are not candidates: they set EnableCache/CacheTTL, which the helper's signature does not express. Worth noting separately that those two omit the default timeout altogether.)
5. Hand-rolled stdlib equivalents
slices is already imported (label_objective_mapping.go:8) and the module targets Go 1.26:
computeValueMax:110-119 reimplements slices.Max.
GetAllLabels:243-248 builds-then-sorts where slices.Sorted(maps.Keys(...)) applies.
6. Outlier: LoadObjectiveMapping sits in a pure-semantics file
label_objective_mapping.go:148-189 performs env-var reading, filesystem access, and JSON decoding (os, encoding/json, path/filepath) inside a file otherwise dedicated to scoring semantics. Its three-tier precedence logic and error paths account for roughly a quarter of the file. Moving it to label_objective_mapping_config.go would leave the mapping file as pure, easily-testable computation.
Cluster analysis
Cluster 1 — Value computation (ComputeObjectiveValue, computeValueSum, computeValueFirst, computeValueMax)
Well organized. The dispatch-to-strategy split is clean and each helper is single-purpose. ✓
Cluster 2 — Label querying (FilterObjectiveLabels, HasObjectiveLabel, GetAllLabels)
Correctly colocated, but shares the duplicated normalization noted in finding 3.
Cluster 3 — Configuration/defaults (DefaultObjectiveMapping, LoadObjectiveMapping)
The outlier cluster — mixes I/O with the semantics file (finding 6), and DefaultObjectiveMapping duplicates the constants file's intent (finding 1).
Cluster 4 — Serialization (MarshalJSON, String)
Standard Go idioms, appropriately placed. ✓
pkg/githubapi/options.go is a single-function file with a clear purpose; its problem is under-adoption, not organization.
Next actions
Detection method: Serena-assisted symbol inventory plus reference-count verification across all .go files. Every "unused" claim above was confirmed by whole-repo grep, not inferred from the package slice.
Generated by 🔧 Semantic Function Refactoring · sonnet46 · 174.1 AIC · ⌖ 20.2 AIC · ⊞ 9.6K · ◷
Overview
Semantic function clustering analysis of the selected package slice (
pkg/github,pkg/githubapi— 3 non-test Go files, 12 functions/methods). The dominant finding is not scattered helpers but a dead constants file whose values silently contradict the live default mapping it claims to mirror.Key issues
1.
label_objective_mapping_constants.gois entirely unreferenced by production code — and diverges fromDefaultObjectiveMapping()All 28
ObjectiveLabel*and 28ObjectiveValue*constants have zero production references. The only consumer ispkg/github/spec_test.go, which asserts them tautologically (ObjectiveValueCritical == 100against a hardcoded100) — so the test cannot detect drift.The file header (
label_objective_mapping_constants.go:5) states: "keep these values in sync with DefaultObjectiveMapping". They are not in sync. Six values contradict each other:DefaultObjectiveMapping()security-fixcopilot-opthigh-priorityp1medium-priorityp2A further 11 constants define scores for labels absent from the default mapping entirely — including
bug(60), the highest-valued of the group:testing,reliability,workflow,engine,mcp,actions,cli,bug,lint-monster,dependencies,enhancement.The practical effect: the constants file reads as the documented scoring policy, but
LoadObjectiveMapping()never consults it. Anyone updating a constant to retune scoring changes nothing at runtime.2.
MultiLabelLogic*constants are ignored by the function they describeMultiLabelLogicMax/Sum/Firstare declared atlabel_objective_mapping_constants.go:136-140, butComputeObjectiveValueswitches on raw string literals instead (label_objective_mapping.go:62,66,69). These constants are referenced byspec_test.go, so the test and the implementation agree only by coincidence of matching string values.Remaining findings — duplication, outlier, and stdlib opportunities
3. Repeated normalize-and-lookup (4 sites)
The idiom
strings.ToLower(strings.TrimSpace(label))followed by anom.LabelToValuelookup appears four times inlabel_objective_mapping.go:ComputeObjectiveValue:49-50computeValueFirst:94-95FilterObjectiveLabels:200-201HasObjectiveLabel:233-234Extracting
func (om *ObjectiveMapping) lookup(label string) (int, bool)collapses all four and makes the normalization rule single-sourced — relevant because normalization semantics are part of the public contract (spec_test.gotests" BUG ").4.
githubapi.ClientOptionshelper bypassed by two call sitespkg/githubapi/options.go:9exists to applyconstants.DefaultHTTPClientTimeout, but has only one production caller (pkg/cli/update_check.go:236). Two other sites hand-roll the identical construction:pkg/parser/remote_client.go:30-33pkg/cli/secret_set_command.go:126-131Both guard
Hostbehind anif host != "", which is equivalent to passing it straight through since the empty string is the zero value — so both can call the helper directly. (Theapi.ClientOptionsliterals inpkg/workflow/repository_features_validation.go:289,343are not candidates: they setEnableCache/CacheTTL, which the helper's signature does not express. Worth noting separately that those two omit the default timeout altogether.)5. Hand-rolled stdlib equivalents
slicesis already imported (label_objective_mapping.go:8) and the module targets Go 1.26:computeValueMax:110-119reimplementsslices.Max.GetAllLabels:243-248builds-then-sorts whereslices.Sorted(maps.Keys(...))applies.6. Outlier:
LoadObjectiveMappingsits in a pure-semantics filelabel_objective_mapping.go:148-189performs env-var reading, filesystem access, and JSON decoding (os,encoding/json,path/filepath) inside a file otherwise dedicated to scoring semantics. Its three-tier precedence logic and error paths account for roughly a quarter of the file. Moving it tolabel_objective_mapping_config.gowould leave the mapping file as pure, easily-testable computation.Cluster analysis
Cluster 1 — Value computation (
ComputeObjectiveValue,computeValueSum,computeValueFirst,computeValueMax)Well organized. The dispatch-to-strategy split is clean and each helper is single-purpose. ✓
Cluster 2 — Label querying (
FilterObjectiveLabels,HasObjectiveLabel,GetAllLabels)Correctly colocated, but shares the duplicated normalization noted in finding 3.
Cluster 3 — Configuration/defaults (
DefaultObjectiveMapping,LoadObjectiveMapping)The outlier cluster — mixes I/O with the semantics file (finding 6), and
DefaultObjectiveMappingduplicates the constants file's intent (finding 1).Cluster 4 — Serialization (
MarshalJSON,String)Standard Go idioms, appropriately placed. ✓
pkg/githubapi/options.gois a single-function file with a clear purpose; its problem is under-adoption, not organization.Next actions
DefaultObjectiveMapping()'s map from the constants, or deletelabel_objective_mapping_constants.goalong with the tautological assertions inspec_test.go. The current state — two contradicting tables, one of which is dead — is the worst option.bug) belong in the default mapping."max"/"sum"/"first"literals inComputeObjectiveValuewith theMultiLabelLogic*constants.pkg/parser/remote_client.goandpkg/cli/secret_set_command.gothroughgithubapi.ClientOptions.slices.Max/slices.Sorted, and splitLoadObjectiveMappinginto a config file.Detection method: Serena-assisted symbol inventory plus reference-count verification across all
.gofiles. Every "unused" claim above was confirmed by whole-repo grep, not inferred from the package slice.