Skip to content

fix(#5485): move RepoPool.Release channel send inside mutex#5486

Merged
ifireball merged 1 commit into
mainfrom
agent/5485-fix-repopool-release-window
Jul 23, 2026
Merged

fix(#5485): move RepoPool.Release channel send inside mutex#5486
ifireball merged 1 commit into
mainfrom
agent/5485-fix-repopool-release-window

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Move the p.names <- name channel send inside the mutex-held region in RepoPool.Release, closing the inconsistency window where a released name was in neither the outstanding map nor the names channel. This ensures atomic transition from outstanding to available under concurrent acquire/release at the concurrency levels #5441 will enable.

Related Issue

Closes #5485

Changes

  • pkg/behaviourtest/world/pool.go: Use defer p.mu.Unlock() and move the channel send before the deferred unlock, eliminating the gap between delete(p.outstanding, name) and p.names <- name. The send is non-blocking by invariant (buffer equals pool size, name was removed during Acquire).
  • pkg/behaviourtest/world/pool_test.go: Add TestRepoPool_ConcurrentAcquireRelease_PoolIntegrity — 20 workers cycle through a pool of 4, then the test drains the channel to verify all names survived, no duplicates exist, and the outstanding map is empty.

Testing

  • All existing pool tests pass with -race
  • New integrity test passes with -race
  • go vet clean
  • Secret scan clean

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • Commits are signed off (DCO) — human and human-directed agent sessions only
  • I wrote this contribution myself and can explain all changes in it

Closes #5485

Post-script verification

  • Branch is not main/master (agent/5485-fix-repopool-release-window)
  • Secret scan passed (gitleaks — c9c7540c2995d9a294ede00c2444d2eb600e4852..HEAD)
  • PR body secret scan passed (gitleaks — no-git)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner July 23, 2026 04:18
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Agent PR ready for human review label Jul 23, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 4:20 AM UTC · Completed 4:30 AM UTC
Commit: 922ef90 · View workflow run →

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Site preview

Preview: https://e2842be5-site.fullsend-ai.workers.dev

Commit: ba2eca83f6dd84b2e1adec76005eb90777ea4b38

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [commit-message-type] — PR title uses fix(#5485): prefix. The linked issue fix(behaviour): close RepoPool.Release inconsistency window under concurrent lease churn #5485 carries both type/bug and enhancement labels. While fix is defensible given the type/bug label and the concrete invariant violation (name briefly in neither channel nor outstanding map), refactor could also apply since this is internal test infrastructure not directly visible to end users. The current prefix is a judgment call, not a clear violation.

Labels: PR modifies e2e behaviour test infrastructure (pkg/behaviourtest/world/)

@fullsend-ai-review fullsend-ai-review Bot added ready-for-merge All reviewers approved — ready to merge component/e2e End-to-end tests labels Jul 23, 2026
@ifireball ifireball added ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) and removed ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) labels Jul 23, 2026
@ifireball

Copy link
Copy Markdown
Member

/fs-fix rebase the commit on an up-to-date main please

@fullsend-ai-coder

fullsend-ai-coder Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ✅ Success · Started 1:38 PM UTC · Completed 1:44 PM UTC
Commit: 9d03e50 · View workflow run →

Release previously unlocked the mutex before sending the name back
on the buffered channel. This left a window where the name was in
neither the outstanding map nor the names channel. Under concurrent
acquire/release at high concurrency (e.g. GODOG_CONCURRENCY=12),
this gap could cause lost names or pool corruption.

Move the channel send inside the mutex-held region and use
defer p.mu.Unlock() for clarity. The send is guaranteed
non-blocking because the channel buffer equals pool size and the
name was removed from the channel during Acquire.

Add TestRepoPool_ConcurrentAcquireRelease_PoolIntegrity which
verifies that all names survive concurrent churn: after 20
workers cycle through a pool of 4, every name is back in the
channel, no duplicates exist, and the outstanding map is empty.

Closes #5485
@fullsend-ai-coder

Copy link
Copy Markdown
Contributor Author

🔧 Fix agent — iteration 1 (human-triggered)

Rebased PR branch onto latest origin/main. The single commit was cleanly replayed on top of 42 new commits from main. All tests pass with -race, go vet clean, secret scan clean.

Fixed (1):

  1. rebase the commit on an up-to-date main: Rebased the single PR commit (922ef90 -> ba2eca8) onto origin/main. The branch was 42 commits behind main. Rebase completed cleanly with no conflicts. Tests pass with -race and go vet is clean.

Tests: passed

Updated by fullsend fix agent

@ifireball
ifireball added this pull request to the merge queue Jul 23, 2026
Merged via the queue into main with commit a0d583f Jul 23, 2026
16 checks passed
@ifireball
ifireball deleted the agent/5485-fix-repopool-release-window branch July 23, 2026 19:02
@fullsend-ai-retro

fullsend-ai-retro Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 7:05 PM UTC · Completed 7:14 PM UTC
Commit: ba2eca8 · View workflow run →

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #5486 — move RepoPool.Release channel send inside mutex

Verdict: Clean workflow, no new proposals. All improvement opportunities are already tracked in existing issues.

Timeline

Time (UTC) Event
03:44 Issue #5485 filed by ifireballRepoPool.Release inconsistency window
03:45–03:48 Triage run 1 — correctly identified issue as blocked by PR #5444
04:05 ifireball triggered /fs-triage — blocker PR #5444 has merged
04:06–04:10 Triage run 2 — updated status to "ready-to-code"
04:10–04:18 Code agent run — created PR #5486 (1 commit, $1.38)
04:19–04:30 Review agent run — approved with 1 low-severity finding
13:36 ifireball requested /fs-fix rebase the commit on an up-to-date main please
13:36–13:44 Fix agent run — rebased cleanly ($0.72)
18:52 ifireball approved
19:02 PR merged, issue #5485 closed

Total agent cost: ~$2.10 | Issue-to-merge: ~15h (mostly human review wait) | Issue-to-PR: ~34 min | Rework iterations: 0 (rebase only)

What went well

  1. Code agent quality: First-attempt fix was correct. The agent identified the race condition in RepoPool.Release, moved the channel send inside the mutex-held region, used defer for clarity, and wrote a thorough concurrency test (20 workers, pool of 4, verifies no lost names/duplicates/extras). The triage agent's recommended fix was closely followed.
  2. Review agent orchestration: Dispatched 4 sub-agents (correctness on Opus, 3 others on Sonnet) plus a challenger. The correctness sub-agent verified the fix was sound — channel send cannot block while holding the mutex, defer p.mu.Unlock() correctly replaces both manual unlock paths, and the new test is well-designed.
  3. False positive filtering: The intent-coherence sub-agent incorrectly claimed sync.WaitGroup.Go() does not exist (it was added in Go 1.24). The orchestrator correctly identified this as both factually wrong and out-of-scope for the intent-coherence dimension, and discarded it before sending to the challenger.
  4. Fix agent: Handled the rebase cleanly across 42 new commits on main with no conflicts. Post-script correctly used --force-with-lease for the rebase push.

Evidence for existing issues (no new proposals needed)

Autonomy assessment

This PR is a good example of high agent autonomy readiness: the code agent's fix was correct on the first attempt, the review agent approved correctly, and the human's only intervention was an operational rebase request (not a code quality concern). The human approval added no code-quality findings beyond what the agent already covered. For prescriptive concurrency bug fixes in test infrastructure with comprehensive test coverage, reduced human review wait time could meaningfully improve time-to-merge (14h of the 15h total was human review latency). This pattern is tracked in agents#104.

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

Labels

component/e2e End-to-end tests ok-to-test Allow e2e CI to run after maintainer review (must be re-applied after each push) ready-for-merge All reviewers approved — ready to merge ready-for-review Agent PR ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(behaviour): close RepoPool.Release inconsistency window under concurrent lease churn

1 participant