[sergo] Sergo Report: tolowerequalfold Self-Compare Precision Audit (21st Linter) — 2026-06-04 #36842
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Sergo - Serena Go Expert. A newer discussion is available at Discussion #37062. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Executive Summary
R27 (2026-06-04) combined a reverify of the previous run's finding with discovery of a newly-registered linter. The reverify confirmed a prediction:
sg26a1(seenmapbool) did NOT land —cgo.yml:1040still carries 11 enforced flags (no-seenmapbool) and the linter'sinspectBodystill has no escape filter. This breaks the 5-consecutive-run enforce-landing streak (R22→R26), validating the hypothesis that the first non-near-zero registered linter (60+ sites) would not follow the fast fix-to-zero-then-enforce pattern.The new-exploration half found the 21st registered linter,
tolowerequalfold(registry grew 20→21), which recommendsstrings.EqualFoldforstrings.ToLower/ToUpper(x) == ycomparisons. It ships with a correctness-affecting precision gap: it false-positives thestrings.ToLower(x) == xcase-detection idiom — and at one site, mechanically applying the linter's suggestion would silently invert a validation guard. Filed assg27a1.Success score: 9/10.
🛠️ Serena Tools Update
Tools Snapshot
tolowerequalfoldadded atcmd/linters/main.go:38,63)Tools Used Today
Grep/Read/Glob— primary static analysis (Serenafind_symbolremains 70s+ on broad queries; Grep preferred per cached gotchas)serena --help— tool-count verification📊 Strategy Selection
Cached Reuse Component (50%) — reverify
sg26a1reverify-plus-new-seenmapbool-20th-linter-escape-precision-audit(score 9/10)sg26a1unlanded.cgo.yml:1040= 11 flags (no-seenmapbool);seenmapbool.go:64-170inspectBodystill collects candidates and checks only same-body non-truewrites — no return/arg/field/closure escape detection. Streak stalled.sg26a1(filed 06-02, +7d expiry) remains open → not re-filed.New Exploration Component (50%) — 21st-linter precision audit
sg24a1,sg26a1).tolowerequalfoldreports whenlowerLeft || lowerRightregardless of the opposite operand, so the self-comparison idiom is flagged.Combined Rationale
Reverify guards against regression and tracks the enforce pipeline's health; the new-linter precision audit supplies an independently-landable single-file fix even when the enforce pipeline stalls on hard (non-near-zero) linters.
🔍 Analysis Execution
Codebase Context
cgo.yml:1040make golint-custom LINTER_FLAGS="..."— 11 positive flagspkg/linters/tolowerequalfold/,pkg/linters/seenmapbool/, andstrings.ToLower/ToUppercomparison sites acrosspkg/+cmd/Findings Summary
sg27a1) | Medium: 1 (sg26a1stalled, tracked) | Low/Informational: 4📋 Detailed Findings
High —
sg27a1:tolowerequalfoldfalse-positives the self-comparison idiomThe linter flags
==/!=where either operand isstrings.ToLower/ToUpper(...), ignoring whether the other operand is the same expression. This false-positives the case-detection idiomstrings.ToLower(x) != x("doesxcontain uppercase?"), which cannot becomeEqualFold—EqualFold(x, x)is alwaystrue.pkg/workflow/tools_validation_github.go:191strings.ToLower(pattern) != patternpkg/cli/logs_report_tools.go:56strings.ToLower(name) != namehasCapitaldetectionpkg/cli/codemod_discussion_trigger_categories.go:68typeString != strings.ToLower(typeString)Testdata
okExamples(testdata/src/tolowerequalfold/tolowerequalfold.go:17-26) does not cover self-comparison → genuinely unhandled. Fix: add acaseConvArg+sameOperand(viapass.TypesInfo.ObjectOf) filter that skips when the opposite operand equals the lowered inner argument. Single-file linter change + testdata.Medium —
sg26a1(tracked, stalled): seenmapbool escape-blindness + unenforcedUnchanged since R26.
inspectBodyis blind to maps that escape their declaring function (returned/passed/stored/captured), so ≥12 flaggedmap[string]boolset decls (e.g.toImportSet,managedPatternsWithInlineComment,buildForbiddenFieldsMap) would require non-local signature+caller changes to convert tomap[string]struct{}. ~60+ non-test sites overall → not near-zero. Ask remains: add escape filter, re-measure residual local-only sites, then enforce. Issue still open (not duplicated).Low / Informational findings
tolowerequalfoldenforce path: after the precision fix, ~15 genuineEqualFoldopportunities remain (yaml_import.go:39,schema_suggestions.go:666,repo_memory_validation.go:52,features.go:69/105,resolve.go:173/189/227,notify_comment.go:630,strings.go:224,codespace.go:17,forecast.go:462,add_workflow_resolution.go:459,outcome_eval_review.go:79,import_url_fetcher.go:218) → not near-zero, enforce is a separate refactor.//nolintparity gap:fmterrorfnoverbs,seenmapbool, andtolowerequalfoldall lacknolint.BuildLineIndex(no inline-suppression), unlike older siblings. A shared//nolintproposal would unblock enforcement of non-zero linters.FuncDeclbodies are walked withast.Inspect(which descends into nestedFuncLits) and eachFuncLitis separately visited — a map declared inside a closure could be reported twice. Minor; worth folding into thesg26a1fix.✅ Improvement Task Generated
Task: fix
tolowerequalfoldself-comparison false-positive (sg27a1) — addcaseConvArg/sameOperandfilter, addokExamplesfixtures forToLower(x) == xand!= x, keepflaggedExamplespassing, re-run overpkg/+cmd/to confirm the 3 FP sites drop while ~15 genuine sites remain. Severity High, effort Small.📈 Success Metrics
sg27a1)sg26a1, still open)Reasoning: clean reverify confirming a prediction (streak stall), a high-impact correctness-affecting precision finding with a verified dangerous site, and a tightly-scoped single-file fix. Not 10 because the enforce pipeline is now stalling on hard linters with no landed remediation this run.
📊 Historical Context
🎯 Recommendations
sg27a1(self-comparison filter) — prevents a dangerous mechanical fix and unblocks futuretolowerequalfoldenforcement.sg26a1(seenmapbool escape filter) to shrink the convertible set toward enforceability.//nolint(BuildLineIndex) parity for the 3 newest linters so non-zero linters gain an incremental enforce path.🔄 Next Run Preview (R28)
Reverify
sg26a1+sg27a1; watch for a 22nd linter. If neither precision fix lands, treat the enforce pipeline as saturated on hard linters and pivot to the 15-siteEqualFoldconversion or the//nolintparity proposal.Generated by Sergo — The Serena Go Expert
Run ID: 26932367410 · Strategy: reverify-plus-new-tolowerequalfold-21st-linter-selfcompare-precision-audit
References: §26932367410
Beta Was this translation helpful? Give feedback.
All reactions