Files
zero/internal/agenteval/trace.go
d66ad71532 chore: remove dead wrapper functions and unused test seams (#905)
* chore: remove dead wrapper functions and unused test seams

These five functions are unreachable from any cmd/* main even when tests are included (deadcode -test ./...), so they are genuinely dead on every platform:

- TraceEventKeys: one-line alias of ParseTraceEventKeys, no callers
- ValidateToolCapabilities: one-line alias of ValidateCapabilities, no callers
- GetLocalDiffStats and WatchPRState: test seams in internal/tui/export_test.go that no test calls
- ScanSSEData: non-context SSE scanner in internal/providers/providerio, fully superseded by ScanSSEDataWithContext

The five remaining -test findings are //go:build !linux stubs (landlock/seccomp/linux_helper) that are live on Linux, so they are left in place.

Co-Authored-By: cairn-code <[email protected]>

* Bump Go to 1.26.6 so govulncheck and Windows smoke pass.

The 1.26.5 standard library still reports GO-2026-6218 and the Punycode
label check that fail required CI; 1.26.6 matches main and clears them.

---------

Co-authored-by: euxaristia <[email protected]>
Co-authored-by: cairn-code <[email protected]>
2026-08-18 21:44:13 +08:00

82 lines
1.7 KiB
Go

package agenteval
import (
"encoding/json"
"sort"
"strings"
)
func ParseTraceEventKeys(stdout string) []string {
seen := map[string]bool{}
for _, line := range strings.Split(stdout, "\n") {
line = strings.TrimSpace(line)
if line == "" {
continue
}
var event map[string]any
if err := json.Unmarshal([]byte(line), &event); err != nil {
continue
}
if key, ok := traceEventKey(event); ok {
seen[key] = true
}
}
keys := make([]string, 0, len(seen))
for key := range seen {
keys = append(keys, key)
}
sort.Strings(keys)
return keys
}
func MissingTraceEvents(required []string, stdout string) []string {
seen := map[string]bool{}
for _, key := range ParseTraceEventKeys(stdout) {
seen[key] = true
}
missingSet := map[string]bool{}
for _, key := range required {
key = strings.TrimSpace(key)
if key == "" || seen[key] {
continue
}
missingSet[key] = true
}
missing := make([]string, 0, len(missingSet))
for key := range missingSet {
missing = append(missing, key)
}
sort.Strings(missing)
return missing
}
func traceEventKey(event map[string]any) (string, bool) {
if eventType, ok := traceString(event, "type"); ok {
return traceKey(eventType, event), true
}
if eventType, ok := traceString(event, "event"); ok {
return traceKey(eventType, event), true
}
return "", false
}
func traceKey(eventType string, event map[string]any) string {
name, ok := traceString(event, "name")
if !ok {
return eventType
}
return eventType + ":" + name
}
func traceString(event map[string]any, field string) (string, bool) {
value, ok := event[field].(string)
if !ok {
return "", false
}
value = strings.TrimSpace(value)
if value == "" {
return "", false
}
return value, true
}