You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Semantic clustering analysis of the precomputed package slice for this run: pkg/testutil and pkg/timeutil (2 non-test .go files, 8 functions total). Each package contains exactly one non-test source file, so the analysis is narrow by design.
pkg/timeutil/format.go — clean, single-purpose, no findings.
pkg/testutil/tempdir.go — 2 of 4 functions are outliers relative to the file's name/purpose (temp-directory management), violating the one-file-per-feature convention.
No duplicate or near-duplicate implementations found within the analyzed scope.
Function Inventory
pkg/testutil/tempdir.go (package testutil)
GetTestRunDir() string — creates/returns the shared per-process test-run temp directory
TempDir(t *testing.T, pattern string) string — creates an isolated temp dir with t.Cleanup
CaptureStderr(t *testing.T, fn func()) string — pipes and captures os.Stderr during fn
StripYAMLCommentHeader(yamlContent string) string — strips leading # comment lines from YAML text
FormatDurationMs(ms int) string — millisecond-input wrapper with overflow guard
FormatDurationNs(ns int64) string — nanosecond-input wrapper with zero/negative guard
Identified Issues
1. Outlier functions in pkg/testutil/tempdir.go
The file is named and documented around temp-directory lifecycle (GetTestRunDir, TempDir), but also contains two functions with unrelated responsibilities:
CaptureStderr(t *testing.T, fn func()) string (tempdir.go:76-100) — stderr piping/capture utility, unrelated to temp directories. Widely used (20+ call sites across pkg/workflow, pkg/cli, pkg/parser, pkg/actionpins).
StripYAMLCommentHeader(yamlContent string) string (tempdir.go:105-115) — YAML text-processing helper, unrelated to temp directories. Used in pkg/testutil/tempdir_test.go, pkg/testutil/spec_test.go, and 2 files in pkg/workflow.
Recommendation: Split tempdir.go by feature, per the one-file-per-feature convention:
Keep GetTestRunDir and TempDir in tempdir.go.
Move CaptureStderr to a new pkg/testutil/capture.go.
Move StripYAMLCommentHeader to a new pkg/testutil/yaml.go (or fold into an existing YAML-focused test helper file if one exists outside this scope).
No implementation changes needed — this is a same-package file move, so all existing testutil.XxxYyy call sites remain valid.
Estimated impact: Low effort (pure file split within one package), improves discoverability and keeps each file's contents matching its name.
2. pkg/timeutil/format.go — no issues found
All four functions (round1, FormatDuration, FormatDurationMs, FormatDurationNs) are duration-formatting concerns consistent with the file name. round1 is a small private helper (<5 lines) used only within this file — acceptable per the "trivial helper" exclusion.
3. Duplicate detection
No duplicate or near-duplicate functions were found. A repo-wide search for sibling capture/strip helpers (e.g. CaptureStdout, StripComment*) found none, so CaptureStderr and StripYAMLCommentHeader are not consolidation candidates — only relocation candidates.
Refactoring Recommendations
Priority 1 (low effort, do when touching this package)
Executive Summary
Semantic clustering analysis of the precomputed package slice for this run:
pkg/testutilandpkg/timeutil(2 non-test.gofiles, 8 functions total). Each package contains exactly one non-test source file, so the analysis is narrow by design.pkg/timeutil/format.go— clean, single-purpose, no findings.pkg/testutil/tempdir.go— 2 of 4 functions are outliers relative to the file's name/purpose (temp-directory management), violating the one-file-per-feature convention.Function Inventory
pkg/testutil/tempdir.go(packagetestutil)GetTestRunDir() string— creates/returns the shared per-process test-run temp directoryTempDir(t *testing.T, pattern string) string— creates an isolated temp dir witht.CleanupCaptureStderr(t *testing.T, fn func()) string— pipes and capturesos.StderrduringfnStripYAMLCommentHeader(yamlContent string) string— strips leading#comment lines from YAML textpkg/timeutil/format.go(packagetimeutil)round1(v float64) float64— private rounding helperFormatDuration(d time.Duration) string— npm-debug-style duration formattingFormatDurationMs(ms int) string— millisecond-input wrapper with overflow guardFormatDurationNs(ns int64) string— nanosecond-input wrapper with zero/negative guardIdentified Issues
1. Outlier functions in
pkg/testutil/tempdir.goThe file is named and documented around temp-directory lifecycle (
GetTestRunDir,TempDir), but also contains two functions with unrelated responsibilities:CaptureStderr(t *testing.T, fn func()) string(tempdir.go:76-100) — stderr piping/capture utility, unrelated to temp directories. Widely used (20+ call sites acrosspkg/workflow,pkg/cli,pkg/parser,pkg/actionpins).StripYAMLCommentHeader(yamlContent string) string(tempdir.go:105-115) — YAML text-processing helper, unrelated to temp directories. Used inpkg/testutil/tempdir_test.go,pkg/testutil/spec_test.go, and 2 files inpkg/workflow.Recommendation: Split
tempdir.goby feature, per the one-file-per-feature convention:GetTestRunDirandTempDirintempdir.go.CaptureStderrto a newpkg/testutil/capture.go.StripYAMLCommentHeaderto a newpkg/testutil/yaml.go(or fold into an existing YAML-focused test helper file if one exists outside this scope).No implementation changes needed — this is a same-package file move, so all existing
testutil.XxxYyycall sites remain valid.Estimated impact: Low effort (pure file split within one package), improves discoverability and keeps each file's contents matching its name.
2.
pkg/timeutil/format.go— no issues foundAll four functions (
round1,FormatDuration,FormatDurationMs,FormatDurationNs) are duration-formatting concerns consistent with the file name.round1is a small private helper (<5 lines) used only within this file — acceptable per the "trivial helper" exclusion.3. Duplicate detection
No duplicate or near-duplicate functions were found. A repo-wide search for sibling capture/strip helpers (e.g.
CaptureStdout,StripComment*) found none, soCaptureStderrandStripYAMLCommentHeaderare not consolidation candidates — only relocation candidates.Refactoring Recommendations
Priority 1 (low effort, do when touching this package)
CaptureStderr→pkg/testutil/capture.go.StripYAMLCommentHeader→pkg/testutil/yaml.go.No Priority 2/3 items identified in this scope.
Analysis Metadata
pkg/testutil,pkg/timeutil(precomputed slice only)tempdir.go,format.go)tempdir.go)Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
api.anthropic.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.