Skip to content

Fix race detector CI failures#9

Merged
matdev83 merged 6 commits into
mainfrom
codex/fix-stream-race-ci
Apr 28, 2026
Merged

Fix race detector CI failures#9
matdev83 merged 6 commits into
mainfrom
codex/fix-stream-race-ci

Conversation

@matdev83

@matdev83 matdev83 commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • serialize auth event dispatcher sink delivery for concurrent request paths
  • guard secure session test initialization in executor
  • synchronize the stream recv test helper so Close and Recv do not race under -race

Validation

  • go test -tags=precommit,integration ./internal/core/stream
  • go test -tags=precommit,integration ./internal/core/auth ./internal/stdhttp/auth ./internal/core/runtime
  • go test -tags=precommit ./internal/qa

CI

Opening this draft PR triggers the pull_request QA workflow.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced reliability of concurrent event handling in authentication flows
    • Improved robustness of streaming context operations
  • Tests

    • Added comprehensive concurrency testing for event systems
  • Chores

    • Streamlined CI/CD workflow configuration
    • Updated development tooling and linting settings

@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@matdev83 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 26 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 046fa699-0161-4684-a8c6-c029cf1b0201

📥 Commits

Reviewing files that changed from the base of the PR and between d112be8 and c1a94d3.

📒 Files selected for processing (1)
  • internal/core/runtime/executor.go
📝 Walkthrough

Walkthrough

The PR adds thread-safety synchronization to core event dispatch and executor components via mutexes, updates JSON marshaling behavior in model catalog eligibility decisions, refactors the mountModelCatalogDiagnostics function signature, removes linter configuration overrides, and disables CI workflow execution on push events.

Changes

Cohort / File(s) Summary
CI & Linting Configuration
.github/workflows/qa.yml, .golangci.yml
Removes push event trigger from QA workflow and eliminates explicit issues.exclude-use-default: false linter config.
EventDispatcher Thread Safety
internal/core/auth/events.go, internal/core/auth/events_test.go, internal/core/auth/ports.go
Adds mutex synchronization to EventDispatcher for concurrent sink access. Introduces concurrent dispatch test with 64 goroutines. Updates EventSink interface documentation to reflect serialization guarantees.
JSON Serialization Behavior
internal/core/modelcatalog/eligibility.go
Changes EligibilityDecision struct JSON tags from omitempty to omitzero for Facts and Estimate fields.
Executor Thread Safety
internal/core/runtime/executor.go
Adds mutex synchronization around lazy SecureSession initialization path in Execute method.
Stream Contract Test Safety
internal/core/stream/recv_context_contract_test.go
Refactors sdkLikeRecvBlocker to use sync.Once for startup signaling and mutex-protected channel access to prevent race conditions.
Function Signature Refactor
internal/stdhttp/server.go, internal/stdhttp/modelcatalog_diag_test.go
Reorders mountModelCatalogDiagnostics parameters, moving logCtx to first position, and updates call sites accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Mutexes guard the shared domains,
Where goroutines once raced through plains,
JSON tags shift their omit ways,
Thread-safe events brighten our days!
One context reorders its place, 🔒

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Fix race detector CI failures' directly and accurately describes the primary objective of the changeset—addressing race conditions detected by Go's race detector in CI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-stream-race-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@matdev83 matdev83 marked this pull request as ready for review April 28, 2026 12:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/core/runtime/executor.go`:
- Around line 37-38: The package global mutex secureSessionMu causes
cross-Executor contention and unsafe unlock-on-panic; move locking into the
Executor instance by adding a mutex field (e.g., Executor.secureSessionMu) and
use that inside Execute when calling secureSessionTestPrepare(e), replacing
global secureSessionMu references; ensure you acquire the per-Executor mutex and
release it with defer to guarantee unlock on panic, and update all usages
(secureSessionTestPrepare, Executor.SecureSession init paths) to reference the
new Executor.secureSessionMu.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ac0909d-9dcb-4453-aae0-cbbf07f33b1f

📥 Commits

Reviewing files that changed from the base of the PR and between c307d5f and d112be8.

📒 Files selected for processing (10)
  • .github/workflows/qa.yml
  • .golangci.yml
  • internal/core/auth/events.go
  • internal/core/auth/events_test.go
  • internal/core/auth/ports.go
  • internal/core/modelcatalog/eligibility.go
  • internal/core/runtime/executor.go
  • internal/core/stream/recv_context_contract_test.go
  • internal/stdhttp/modelcatalog_diag_test.go
  • internal/stdhttp/server.go
💤 Files with no reviewable changes (2)
  • .golangci.yml
  • .github/workflows/qa.yml

Comment thread internal/core/runtime/executor.go Outdated
@matdev83 matdev83 merged commit 7f19a60 into main Apr 28, 2026
2 checks passed
@matdev83 matdev83 deleted the codex/fix-stream-race-ci branch April 28, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant