Skip to content

fix(#272): eliminate race condition in TestOllamaAdapter_ContextCancellation - #274

Merged
yvonnedevlinrh merged 1 commit into
mainfrom
agent/272-fix-ollama-test-race
Sep 28, 2026
Merged

yvonnedevlinrh merged 1 commit into
mainfrom
agent/272-fix-ollama-test-race

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • go test -race -count=10 -run TestOllamaAdapter_ContextCancellation ./internal/aireport/ — all 10 iterations pass without hanging
  • go test -race -count=1 -short ./internal/aireport/ — full package tests pass
  • go vet ./internal/aireport/ — clean
  • Verify next 3 CI runs on main show no timeout in Unit and Integration Tests for internal/aireport

Note: golangci-lint was not available in the sandbox environment. Manual verification of lint compliance is recommended.


Closes #272

Post-script verification

  • Branch is not main/master (agent/272-fix-ollama-test-race)
  • Secret scan passed (gitleaks — 76f8ca963fcfbe6254538c6744c3bc11b0f456a7..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Sep 21, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 6:12 PM UTC · Ended 6:13 PM UTC

Commit: 42ae960 · View workflow run →

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ GO golangci-lint yes yes no no 32.37s
✅ REPOSITORY gitleaks yes no no 3.44s
✅ REPOSITORY git_diff yes no no 0.24s

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 6:14 PM UTC · Completed 6:26 PM UTC

Commit: 42ae960 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.34

@fullsend-ai-review fullsend-ai-review Bot added the risk/low PR risk: low label Sep 21, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Risk Assessment: low (1/5)

Details

Minimal-risk test-only fix: single file changed (adapter_ollama_test.go), 30 lines modified, 100% test file ratio, no production code touched. File has zero churn in last 90 days. Issue #272 precisely scopes two structural fixes for a flaky CI test confirmed at HIGH confidence. All signals unchanged from prior assessment — score anchored at 1. Composite: 0.501.0 + 0.301.0 + 0.20*1.0 = 1.0 → 1.

Previous run

Risk Assessment: low (1/5)

Details

Minimal-risk test-only fix: single file changed (adapter_ollama_test.go), 30 lines modified, 100% test file ratio, no production code touched. File has zero churn in last 90 days. Issue #272 precisely scopes two structural fixes for a flaky CI test confirmed at HIGH confidence. Composite: 0.501.0 + 0.301.0 + 0.20*1.0 = 1.0 → 1.

Previous run (2)

Risk Assessment: low (1/5)

Details

Minimal-risk test-only fix: single file changed (adapter_ollama_test.go), 30 lines modified, 100% test file ratio, no production code touched, no CI/dependency/security-sensitive changes. PR scope precisely matches issue #272's two proposed fixes. Composite: 0.501.0 + 0.302.0 + 0.20*1.75 = 1.45 → 1.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review

Findings

Low

  • [test-inadequate] internal/aireport/adapter_ollama_test.go:163 — The test verifies that cancellation produces a non-nil error but does not assert the error's content (e.g., that it wraps context.Canceled). Sibling tests in this file assert on error content (FR-003, HTTP 500, FR-016), so the pattern is inconsistent with peers. However, the cancellation error originates from http.Client.Do's internal context handling, making the exact error string an implementation detail of the Go standard library — asserting on it would create a brittle coupling.
Previous run

Review

Findings

Low

  • [test-inadequate] internal/aireport/adapter_ollama_test.go:163 — The test verifies that cancellation produces a non-nil error but does not assert the error's content (e.g., that it wraps context.Canceled). Sibling tests in this file assert on error content (FR-003, HTTP 500, FR-016), so the pattern is inconsistent with peers. However, the cancellation error originates from http.Client.Do's internal context handling, making the exact error string an implementation detail of the Go standard library — asserting on it would create a brittle coupling.
Previous run (2)

Review

Findings

Low

  • [test-inadequate] internal/aireport/adapter_ollama_test.go:163 — The test verifies that cancellation produces a non-nil error but does not assert the error's content (e.g., that it wraps context.Canceled). This is consistent with sibling tests in this file, and the test's primary purpose is to verify the cancellation mechanism rather than the exact error message.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Sep 21, 2026
@jflowers
jflowers force-pushed the agent/272-fix-ollama-test-race branch from 42ae960 to 1cbc9e7 Compare September 22, 2026 21:01
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 9:03 PM UTC · Completed 9:16 PM UTC

Commit: 1cbc9e7 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.66

fullsend-ai-review[bot]

This comment was marked as outdated.

…llation

The test had two structural issues causing intermittent CI hangs:

1. Missing synchronization: cancel() fired before the HTTP
   request reached the server. Added a started channel that
   the handler closes to signal request arrival.

2. Missing timeout: the <-done receive blocked indefinitely
   when the goroutine hung. Replaced with a select that fails
   after 5 seconds with a clear message.

Additionally, replaced r.Context().Done() in the handler with
an explicit handlerDone channel. On Go 1.24, httptest.Server
does not reliably cancel the request context when the client
disconnects, causing the handler to block forever and
srv.Close() to deadlock. The handlerDone channel is closed via
defer before t.Cleanup runs srv.Close(), breaking the deadlock.

Closes #272
@yvonnedevlinrh
yvonnedevlinrh force-pushed the agent/272-fix-ollama-test-race branch from 1cbc9e7 to 789a15c Compare September 28, 2026 12:26
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:27 PM UTC · Completed 12:40 PM UTC

Commit: 789a15c · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.12

@yvonnedevlinrh yvonnedevlinrh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yvonnedevlinrh
yvonnedevlinrh merged commit 6d6be20 into main Sep 28, 2026
35 checks passed
@fullsend-ai-retro

fullsend-ai-retro Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 1:37 PM UTC · Completed 1:47 PM UTC

Commit: 789a15c · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $6.14

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #274 — fix(#272): eliminate race condition in TestOllamaAdapter_ContextCancellation

Pipeline Quality: Excellent

This PR demonstrates the fullsend pipeline at its best — fully autonomous issue-to-merge for a test flake fix:

Stage Agent Time Cost Quality
Detection retro (on PR #242) — — HIGH confidence root cause, correctly identified 3 structural issues
Triage triage (run 35634951354) 5 min $0.57 Validated root cause, classified severity medium, applied bug + ready-to-code
Code code (run 35635452135) 13 min $2.66 Correct fix on first attempt — no rework needed
Review ×3 review (runs 35636839359, 35784052080, 36421877915) 14 min each $12.12 1 LOW finding (acceptable — error content assertion would couple to stdlib internals)
Human yvonnedevlinrh — — "LGTM" on Sept 28 (7 days after code agent's fix)

Total agent cost: $15.35 (review was 79% of total).

Code Agent Quality

The code agent produced a well-structured fix addressing all 3 root causes identified by the retro agent:

  1. Missing synchronization — added started channel so cancel() waits for HTTP request arrival
  2. Missing timeout — replaced indefinite <-done with 5-second select timeout
  3. Go 1.24 httptest deadlock — replaced r.Context().Done() with explicit handlerDone channel (Go 1.24's httptest.Server doesn't reliably cancel request context on client disconnect)

The fix required zero rework iterations. The commit message and PR description were both technically accurate and well-documented.

Redundant Review Cost (Existing Tracked Issue)

Two human rebases (by jflowers on Sept 22 and yvonnedevlinrh on Sept 28) triggered full re-reviews on an unchanged diff ($7.78 wasted). All 3 review runs found the identical LOW finding and approved. This is the same rebase-triggered redundant review pattern tracked by:

This PR adds evidence: non-bot rebases (human maintainers rebasing before merge) trigger the same redundant review pattern previously documented for bot/Renovate/Dependabot rebases.

Additional Evidence for Tracked Issues

No New Proposals

All improvement opportunities identified in this retro are already covered by open issues in the upstream repos. The pipeline worked well — the main inefficiency (redundant reviews on rebase) is a known platform-level issue with active tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/low PR risk: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix race condition in TestOllamaAdapter_ContextCancellation causing CI hangs

1 participant