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
Analysis Date: 2026-10-01 Focus Area: Uncancellable time.Sleep in production retry loops + sleep-based timing in tests Strategy Type: Custom Custom Area: Yes — the timesleepnocontext linter is enabled in CI but only flags functions that already take a context.Context. The 4 production sleeps are all in ctx-less functions, so the linter never sees them (the same blind spot as the 2026-09-29 exec.Command finding). Tests also lean on wall-clock sleeps.
Executive Summary
Non-test code under pkg/cmd has 4 real time.Sleep calls, all in retry/backoff paths: run_workflow_tracking.go:73, trial_repository.go:199, update_extension_check.go:412 and docker_validation.go:220. None can be interrupted by Ctrl-C or a cancelled context. The worst is the Docker pull backoff, which sleeps 5s→10s→20s-style (doubling) with no cancellation path.
The CI linter -timesleepnocontext is enabled (cgo.yml:1487), so CI is green while these sites stay unchecked. They are in functions with no ctx parameter, so the linter cannot flag them.
Tests contain 29 time.Sleep calls. Ten of those sit in files with no t.Parallel(). pkg/workflow/compiler_skip_write_test.go sleeps 100ms three times to separate file mtimes, and pkg/cli/run_push_test.go sleeps 100ms three times. Both patterns are fragile on slow filesystems and add serial wall time.
Full Analysis Report
Focus Area: Sleep usage
Current State Assessment
Metrics Collected:
Metric
Value
Status
Production time.Sleep sites (excluding linter testdata)
A dedicated timesleepnocontext linter exists and is wired into CI for native and WASM builds.
Retry delays are mostly named constants (trialRepoInitDelay, backupCleanupRetryDelay).
Areas for Improvement
High: pkg/workflow/docker_validation.go:220 backs off exponentially with a bare sleep inside validateDockerImage(image, verbose, requireDocker), which has no ctx.
Medium: pkg/cli/run_workflow_tracking.go:73 polls getLatestWorkflowRunWithRetry with a bare sleep and no ctx.
Medium: pkg/cli/trial_repository.go:199 has a fixed trialRepoInitDelay sleep in ensureTrialRepository.
Low: pkg/cli/update_extension_check.go:412 sleeps in cleanupStaleWindowsBackups; the delay is short.
Medium: tests use sleeps to force distinct mtimes (compiler_skip_write_test.go:59,112,180) or to wait on goroutines (run_push_test.go:240,300,544, logs_orchestrator_test.go:173).
Medium: the linter's scope is the gap that lets this recur.
🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Make Docker image validation retry cancellable
Priority: High Estimated Effort: Medium Focus Area: Cancellation
Description: Thread a context.Context into validateDockerImage and replace the backoff sleep with a ctx-aware select.
Acceptance Criteria:
validateDockerImage accepts ctx; all callers updated
Backoff uses select { case <-ctx.Done(): ...; case <-time.After(d): } (or a shared helper)
Unit test shows cancellation returns promptly during backoff
make fmt and targeted go test ./pkg/workflow pass
Code Region:pkg/workflow/docker_validation.go
Add a context.Context parameter to validateDockerImage in pkg/workflow/docker_validation.go. Replace time.Sleep(time.Duration(waitTime)*time.Second) with a ctx-aware wait that returns ctx.Err() on cancellation. Update callers (use context.Background() only where no ctx exists), keep the WASM stub signature in sync, and add a test that cancels during backoff.
Task 2: Add a shared sleepCtx helper and use it in CLI retry loops
Priority: Medium Estimated Effort: Medium Focus Area: Cancellation
Description: Add one helper (e.g. pkg/cli or pkg/fileutil/pkg/timeutil) that sleeps and honors ctx. Adopt it in getLatestWorkflowRunWithRetry, ensureTrialRepository, and cleanupStaleWindowsBackups, passing ctx from the command layer.
Introduce sleepCtx(ctx, d) error. Thread context.Context into getLatestWorkflowRunWithRetry, ensureTrialRepository and cleanupStaleWindowsBackups and replace time.Sleep with the helper. Preserve behavior when ctx is not cancelled. Add tests.
Task 3: Extend timesleepnocontext to flag sleeps in retry loops of ctx-less functions
Priority: Medium Estimated Effort: Medium Focus Area: Linters
Description: After Tasks 1–2, extend the analyzer (or add an option) to report bare time.Sleep inside for loops in non-test code, regardless of ctx parameter, with (nolint/redacted):timesleepnocontext // reason for justified cases. Add testdata and keep the CI flag.
Acceptance Criteria:
New testdata covers ctx-less loop sleeps (positive and negative)
Repo passes make golint-custom with the flag
Linter docs updated
Code Region:pkg/linters/timesleepnocontext/
Extend pkg/linters/timesleepnocontext to also flag time.Sleep in loops within non-test functions lacking a ctx parameter. Add analysistest cases and fix or justify any remaining findings.
Task 4: Replace sleep-based mtime and goroutine synchronization in tests
Priority: Low Estimated Effort: Small Focus Area: Test reliability
Description: Use os.Chtimes to set explicit mtimes in compiler_skip_write_test.go (3 sleeps) and use channels/require.Eventually instead of 100ms sleeps in run_push_test.go (3) and logs_orchestrator_test.go:173.
Replace time.Sleep in the listed tests with os.Chtimes (for mtime separation) or deterministic synchronization. Remove timestampDifferentiationDelay if unused. Run the tests with -race -count=5.
📊 Historical Context
Previous Focus Areas
Date
Focus Area
Type
Custom
Key Outcomes
2026-09-28
Skill doc JS path drift (3rd audit)
Custom
Y
22 stale refs
2026-09-29
exec.Command without ctx
Custom
Y
93 call sites
2026-09-30
Frontmatter reference coverage
Custom
Y
11/68 fields undocumented
🎯 Recommendations
Immediate Actions (This Week)
Task 1: ctx-aware Docker pull backoff — Priority: High
Short-term Actions (This Month)
Tasks 2–3: shared helper and linter extension — Priority: Medium
Long-term Actions (This Quarter)
Task 4: remove sleep-based test sync — Priority: Low
📈 Success Metrics
Uncancellable production sleeps: 4 → 0
Test time.Sleep calls: 29 → ≤ 20
Next Steps
Review and prioritise the tasks above
Assign tasks to Copilot coding agent via planner agent
Track progress on improvement items
Re-evaluate in 4 weeks
Generated by Repository Quality Improvement Agent Next analysis: 2026-10-02 — Focus area selected by diversity algorithm
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
🎯 Repository Quality Improvement Report - Uncancellable Sleep & Sleep-Based Test Synchronization
Analysis Date: 2026-10-01
Focus Area: Uncancellable
time.Sleepin production retry loops + sleep-based timing in testsStrategy Type: Custom
Custom Area: Yes — the
timesleepnocontextlinter is enabled in CI but only flags functions that already take acontext.Context. The 4 production sleeps are all in ctx-less functions, so the linter never sees them (the same blind spot as the 2026-09-29 exec.Command finding). Tests also lean on wall-clock sleeps.Executive Summary
Non-test code under
pkg/cmdhas 4 realtime.Sleepcalls, all in retry/backoff paths:run_workflow_tracking.go:73,trial_repository.go:199,update_extension_check.go:412anddocker_validation.go:220. None can be interrupted by Ctrl-C or a cancelled context. The worst is the Docker pull backoff, which sleeps 5s→10s→20s-style (doubling) with no cancellation path.The CI linter
-timesleepnocontextis enabled (cgo.yml:1487), so CI is green while these sites stay unchecked. They are in functions with noctxparameter, so the linter cannot flag them.Tests contain 29
time.Sleepcalls. Ten of those sit in files with not.Parallel().pkg/workflow/compiler_skip_write_test.gosleeps 100ms three times to separate file mtimes, andpkg/cli/run_push_test.gosleeps 100ms three times. Both patterns are fragile on slow filesystems and add serial wall time.Full Analysis Report
Focus Area: Sleep usage
Current State Assessment
Metrics Collected:
time.Sleepsites (excluding linter testdata)ctx)-timesleepnocontextenabled in CItime.Sleepcallst.Parallel()pkg/console/spinner_test.go(7)10 * time.Millisecond(10),100 * time.Millisecond(5) +timestampDifferentiationDelay(3)Strengths
timesleepnocontextlinter exists and is wired into CI for native and WASM builds.trialRepoInitDelay,backupCleanupRetryDelay).Areas for Improvement
pkg/workflow/docker_validation.go:220backs off exponentially with a bare sleep insidevalidateDockerImage(image, verbose, requireDocker), which has no ctx.pkg/cli/run_workflow_tracking.go:73pollsgetLatestWorkflowRunWithRetrywith a bare sleep and no ctx.pkg/cli/trial_repository.go:199has a fixedtrialRepoInitDelaysleep inensureTrialRepository.pkg/cli/update_extension_check.go:412sleeps incleanupStaleWindowsBackups; the delay is short.compiler_skip_write_test.go:59,112,180) or to wait on goroutines (run_push_test.go:240,300,544,logs_orchestrator_test.go:173).🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Make Docker image validation retry cancellable
Priority: High
Estimated Effort: Medium
Focus Area: Cancellation
Description: Thread a
context.ContextintovalidateDockerImageand replace the backoff sleep with a ctx-aware select.Acceptance Criteria:
validateDockerImageaccepts ctx; all callers updatedselect { case <-ctx.Done(): ...; case <-time.After(d): }(or a shared helper)make fmtand targetedgo test ./pkg/workflowpassCode Region:
pkg/workflow/docker_validation.goAdd a context.Context parameter to validateDockerImage in pkg/workflow/docker_validation.go. Replace time.Sleep(time.Duration(waitTime)*time.Second) with a ctx-aware wait that returns ctx.Err() on cancellation. Update callers (use context.Background() only where no ctx exists), keep the WASM stub signature in sync, and add a test that cancels during backoff.Task 2: Add a shared
sleepCtxhelper and use it in CLI retry loopsPriority: Medium
Estimated Effort: Medium
Focus Area: Cancellation
Description: Add one helper (e.g.
pkg/cliorpkg/fileutil/pkg/timeutil) that sleeps and honors ctx. Adopt it ingetLatestWorkflowRunWithRetry,ensureTrialRepository, andcleanupStaleWindowsBackups, passing ctx from the command layer.Acceptance Criteria:
time.Sleepinpkg/cliCode Region:
pkg/cli/run_workflow_tracking.go,pkg/cli/trial_repository.go,pkg/cli/update_extension_check.goTask 3: Extend
timesleepnocontextto flag sleeps in retry loops of ctx-less functionsPriority: Medium
Estimated Effort: Medium
Focus Area: Linters
Description: After Tasks 1–2, extend the analyzer (or add an option) to report bare
time.Sleepinsideforloops in non-test code, regardless of ctx parameter, with(nolint/redacted):timesleepnocontext // reasonfor justified cases. Add testdata and keep the CI flag.Acceptance Criteria:
make golint-customwith the flagCode Region:
pkg/linters/timesleepnocontext/Task 4: Replace sleep-based mtime and goroutine synchronization in tests
Priority: Low
Estimated Effort: Small
Focus Area: Test reliability
Description: Use
os.Chtimesto set explicit mtimes incompiler_skip_write_test.go(3 sleeps) and use channels/require.Eventuallyinstead of 100ms sleeps inrun_push_test.go(3) andlogs_orchestrator_test.go:173.Acceptance Criteria:
go test -race -count=5t.Parallel()where safeCode Region:
pkg/workflow/compiler_skip_write_test.go,pkg/cli/run_push_test.go,pkg/cli/logs_orchestrator_test.go📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
Short-term Actions (This Month)
Long-term Actions (This Quarter)
📈 Success Metrics
time.Sleepcalls: 29 → ≤ 20Next Steps
Generated by Repository Quality Improvement Agent
Next analysis: 2026-10-02 — Focus area selected by diversity algorithm
All reactions