[sergo] Sergo Report: Error-Handling & Dead-Code Analysis - 2026-02-20 #17303
Replies: 6 comments
-
|
/plan |
Beta Was this translation helpful? Give feedback.
-
|
/a investigate if the cache-memory is working in sergo |
Beta Was this translation helpful? Give feedback.
-
|
/q investigate if the cache-memory is working in sergo |
Beta Was this translation helpful? Give feedback.
-
🔍 Cache-Memory Investigation: SergoTL;DR: Cache-memory was broken in sergo for all past runs due to a key mismatch bug. The fix is already in the current lock file and will take effect from the next daily run. Root CauseThe Meanwhile, the agent job correctly tried to restore from Smoking gun from run #22243186214 (Feb 20) logs: When the next run tried to restore with EvidenceEvery run across 5 analyzed runs (Feb 11–20) reported: cat /tmp/gh-aw/cache-memory/sergo-strategies.jsonl → NO_CACHE
cat /tmp/gh-aw/cache-memory/sergo-tools-list.json → NO_CACHEAnd each run claimed "this is the first run" — even run #37 (the 5th scheduled run). The artifact was being uploaded correctly (3 files, ~1440 bytes of valid cache data), but the cache save key was wrong, so no future run could restore it. FixAlready in the current lock file ( # update_cache_memory job now has:
env:
GH_AW_WORKFLOW_ID_SANITIZED: sergo ← this was missing before!The compiler was fixed to always include Current Status
No code changes needed — the fix is already deployed. The cache will start working from the second run after tonight's scheduled execution. Side Note: 67 Blocked Network RequestsEach sergo run also shows ~67 blocked network requests (domain listed as
|
Beta Was this translation helpful? Give feedback.
-
|
/q review sergo blocked domains from serena |
Beta Was this translation helpful? Give feedback.
-
🔍 Sergo Blocked Domains — Investigation CompleteTL;DR: The 78–91 "blocked" domain InvestigationEvidence 1: AWF Binary Reports 0 BlockedThe authoritative source — the AWF binary ( Run #22243186214 (Feb 20). Zero blocked requests. Evidence 2: Audit Tool DiscrepancyThe "blocked_domains": ["-"],
"blocked_requests": 78,
"requests_by_domain": { "-": { "allowed": 0, "blocked": 78 } }
```
This is a discrepancy: AWF says **0 blocked**, audit tool says **78 blocked**.
#### Evidence 3: Root Cause — Squid `NONE_NONE:HIER_NONE` Log Entries
The squid access log contains entries in this format:
```
1761332530.500 - - - - - 0 NONE_NONE:HIER_NONE - "-"These are entries where all fields are The Go firewall parser in Evidence 4: All Serena Network Needs Are CoveredCross-checking Serena's observed actual domains across runs against the allowed list:
No external domain is actually being blocked. Evidence 5: TypeScript LSP Timeout — Not a Network IssueThe Serena container starts TypeScript and Bash language servers in addition to Go (due to the What the
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Date: 2026-02-20
Strategy:
error-handling-dead-code(first run — full new exploration)Success Score: 7/10
Run: §22243186214
Executive Summary
This is the inaugural Sergo run on the
gh-awrepository. Using Serena's symbolic search and pattern-matching tools, a deep analysis of 559 production Go files (129,789 LOC) was performed, focusing on error-handling idioms and dead-code patterns — two areas that frequently escape static analysis when key linters are disabled.The analysis uncovered 4 distinct findings across 3 severity tiers. Most critically, 9 instances of
fmt.Errorf("%v", err)should use%wto allow proper error chain traversal viaerrors.Is/errors.As. Additionally, theMCPConfigProvider.RenderMCPConfiginterface design silently discards errors from the underlyingRenderJSONMCPConfighelper across 4 engine implementations. Finally, 5 dead-code git-fallback functions inpkg/cli/download_workflow.gocarry//nolint:unusedsuppressions rather than being wired into the call path or removed.Three improvement tasks are proposed below.
🛠️ Serena Tools Update
Tools Snapshot
Tool Capabilities Used Today
find_symbolsearch_for_patternget_symbols_overviewfind_filefind_referencing_symbols📊 Strategy Selection
Cached Reuse Component (50%)
No cache existed — this is the first run. The 50% cached slot was replaced with a second new-exploration axis.
New Exploration Component (100% for run 1)
Novel Approach A — Error Wrapping Audit
%vand%wfor error formatting, especially after fast-moving feature work. Witherrcheckdisabled in golangci-lint, this is invisible to CI.search_for_patternwith regexfmt\.Errorf\("[^"]*%v[^"]*", .*erracrosspkg/Novel Approach B — Dead-Code & nolint Survey
nolint:unusedrather than being integrated or deleted.search_for_patternfornolint:unused,find_symbolto inspect suppressed functionspkg/cli/download_workflow.go,pkg/workflow/Combined Strategy Rationale
Both axes share a common theme: gaps in linting coverage. With
errcheck,gocritic, andreviveall disabled in.golangci.yml(documented as "configuration bugs in golangci-lint v2"), entire categories of Go quality checks are dark. Error-wrapping and dead-code are precisely the issues these linters would normally catch.🔍 Analysis Execution
Codebase Context
pkg/workflow,pkg/parser,pkg/cliFindings Summary
📋 Detailed Findings
Medium Priority Issues
F1 —
fmt.Errorfuses%vfor error arguments instead of%wGo 1.13+ introduced
%winfmt.Errorfto wrap errors so callers can useerrors.Is()anderrors.As()to inspect the error chain. Using%vformats the error as a string, permanently discarding the original error type and preventing chain traversal.Confirmed instances (non-test production code):
pkg/workflow/frontmatter_error.gofmt.Errorf("%s: %v", filePath, err)pkg/workflow/compiler_orchestrator_frontmatter.gofmt.Errorf("failed to read file: %v", err)pkg/workflow/schema_validation.gofmt.Errorf("%v. %s", err, example)pkg/cli/logs_command.gofmt.Errorf("invalid ... format '%s': %v", ...)pkg/cli/enable.gofmt.Errorf("no workflow files found to %s: %v", ...)pkg/parser/tools_merger.gofmt.Errorf("MCP tool conflict ...: %v", err)F2 —
MCPConfigProvider.RenderMCPConfigcannot propagate errorsThe
MCPConfigProviderinterface (pkg/workflow/agentic_engine.go:154) declares:This method has no error return. The underlying helper
RenderJSONMCPConfig(pkg/workflow/mcp_renderer.go:890) does returnerror, so all four engine implementations must discard it:Currently
RenderJSONMCPConfigalways returnsnil, so there is no active bug. However, if the function is extended to return real errors (e.g., from renderer callbacks that may be enhanced), those errors will be silently swallowed. The interface design makes correct error propagation impossible without a breaking change.F3 — Dead fallback functions in
pkg/cli/download_workflow.gosuppressed withnolint:unusedFive fully-implemented git-fallback functions carry
//nolint:unusedto silence the linter rather than being wired into callers:resolveLatestReleaseViaGitFallback implementation for when GitHub API is unavailableisBranchRefViaGitFallback implementationisBranchRefReserved for future useresolveBranchHeadViaGitFallback implementationresolveBranchHeadReserved for future useresolveDefaultBranchHeadViaGitFallback implementationresolveDefaultBranchHeadReserved for future useThese 300 LOC are invisible to callers and increase cognitive overhead when reading the file. The "reserved for future use" tag in particular suggests they were never used and may never be needed.
Low Priority Findings
F4 —
errchecklinter disabled in golangci-lint v2.golangci.ymlexplicitly disableserrcheckwith the comment "Disabled due to exclude-functions not working properly in golangci-lint v2". This means unchecked error returns (beyond the visible_ = ...patterns) are not caught in CI. Thegocriticandrevivelinters are also disabled for similar reasons.Impact: Any new
_ = expr()patterns, or calls to functions that return errors without assignment, go undetected. This reduces the safety net for all future contributions.Suggested mitigation: Track a follow-up to upgrade or reconfigure golangci-lint so
errcheckcan be re-enabled with the needed exclusions.✅ Improvement Tasks Generated
Task 1: Replace
%vwith%wfor error wrapping in 9 call sitesIssue Type: Error Handling
Problem:
Nine
fmt.Errorfcalls pass error arguments with%vinstead of%w, discarding the error chain. This prevents callers from usingerrors.Is()/errors.As()for structured error handling and makes debugging harder.Locations:
pkg/workflow/frontmatter_error.go:94pkg/workflow/compiler_orchestrator_frontmatter.go:40pkg/workflow/schema_validation.go:144pkg/cli/logs_command.go:168,177pkg/cli/enable.go:66,93pkg/parser/tools_merger.go:120,223Impact:
errors.Is()calls upstream of these sites fail silentlyRecommendation: Replace
%vwith%wfor the error argument in each call site. For the two cases incompiler_orchestrator_frontmatter.go:40where the comment says "Don't wrap os.PathError - format it instead to avoid exposing internals" — if this is intentional, add an explicit comment stating so to differentiate from oversight.Before (
pkg/workflow/compiler_orchestrator_frontmatter.go:40):After:
Validation:
go test ./pkg/workflow/... ./pkg/parser/... ./pkg/cli/...errors.Is()/errors.As()can now traverse the error chain in relevant test casesEstimated Effort: Small
Task 2: Update
MCPConfigProvider.RenderMCPConfiginterface to returnerrorIssue Type: Interface Design / Error Propagation
Problem:
The
MCPConfigProviderinterface methodRenderMCPConfighas no error return value. The underlying helperRenderJSONMCPConfigreturnserror, so all four engine implementations (ClaudeEngine,GeminiEngine,CodexEngine,CopilotEngine) must discard the error with_ = RenderJSONMCPConfig(...). As the helper evolves, any errors it starts returning will be silently swallowed.Locations:
pkg/workflow/agentic_engine.go:154pkg/workflow/agentic_engine.go:296pkg/workflow/claude_mcp.go:12pkg/workflow/gemini_mcp.go:12pkg/workflow/codex_mcp.go:13pkg/workflow/copilot_mcp.go:12Impact:
RenderJSONMCPConfig(e.g., from renderer callbacks) will be silently droppedRecommendation: Add an
errorreturn toRenderMCPConfigin the interface and update all implementations to return the error fromRenderJSONMCPConfig. Update callers ofRenderMCPConfigto handle the error.Before (interface):
After:
Before (engine implementation):
After:
Validation:
RenderMCPConfig(viaMCPConfigProviderinterface) check the returned errorgo build ./...to confirm no compile errorsgo test ./pkg/workflow/...Estimated Effort: Medium
Task 3: Wire or remove git-fallback dead code in
pkg/cli/download_workflow.goIssue Type: Dead Code / Code Quality
Problem:
Seven functions in
pkg/cli/download_workflow.go(≈300 LOC) are annotated with//nolint:unusedbecause they are never called. The annotations indicate these are "Fallback implementations for when GitHub API is unavailable" or are "Reserved for future use." They have been in this state long enough that thenolintsuppression was committed, yet no caller exists.Locations:
pkg/cli/download_workflow.go:20—resolveLatestReleaseViaGitpkg/cli/download_workflow.go:102—isBranchRefViaGitpkg/cli/download_workflow.go:135—isBranchRefpkg/cli/download_workflow.go:166—resolveBranchHeadViaGitpkg/cli/download_workflow.go:203—resolveBranchHeadpkg/cli/download_workflow.go:236—resolveDefaultBranchHeadViaGitpkg/cli/download_workflow.go:293—resolveDefaultBranchHeadImpact:
nolintsuppressions reduces signal quality of the linter output and creates maintenance overhead. If the fallback behavior is genuinely needed, it should be integrated with tests; if not, it should be deleted.Recommendation:
update_actions.gowhere the dual-fallback pattern already exists for other operations).nolintsuppressions._git_fallback.gofile with a package-level doc comment explaining the intent, and add a tracking issue reference.Validation:
go build ./...after removal/wiringgo test ./pkg/cli/...golangci-lint run ./pkg/cli/...passes without new suppressions neededEstimated Effort: Small (delete path) or Medium (wire path)
📈 Success Metrics
This Run
Reasoning for Score
📊 Historical Context
Strategy Performance
Cumulative Statistics
🎯 Recommendations
Immediate Actions
%v→%wfor error wrapping in 9 call sites (Task 1) — small effort, high correctness benefiterrorreturn toMCPConfigProvider.RenderMCPConfiginterface (Task 2) — prevents silent future failuresdownload_workflow.go(Task 3)Long-term Improvements
errcheck: The linter suppression oferrcheck,gocritic, andreviveis a lint-debt accumulator. Once golangci-lint v2 configuration stabilizes, re-enabling these would surface many of the patterns found in this run automatically.%wvia linting:wrapcheckor customreviverules can enforce%wusage when wrapping external errors.🔄 Next Run Preview
Suggested Focus Areas
pkg/workflow/andpkg/cli/for consistency — especially method signatures that could benefit from error returns.context.Background()usages in production code; check if they could accept a passed context from callers.pkg/parser/import_processor.go(1,109 LOC),pkg/cli/trial_command.go(1,013 LOC) — candidate for complexity/cyclomatic analysis.Strategy Evolution
Next run should use 50% cached (repeat error-handling analysis on packages not yet covered:
pkg/types,pkg/gitutil,internal/) + 50% new (context propagation audit usingfind_referencing_symbolson context-accepting functions).References:
Beta Was this translation helpful? Give feedback.
All reactions