Skip to content

Conversation

@daveshanley
Copy link
Member

smashing out non-deterministic issues once and for all, ordering maps and using singleflight and RWMutex.

smashing out non-deterministic issues once and for all, ordering maps and using singleflight and RWMutex.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses non-deterministic behavior in reference extraction and resolution by introducing deterministic ordering through map key sorting, using singleflight for deduplication of concurrent lookups, and upgrading to RWMutex for better concurrency control.

  • Implements deterministic ordering by sorting map keys before iteration across multiple index operations
  • Adds singleflight pattern to deduplicate concurrent reference lookups and reduce contention
  • Changes refLock from sync.Mutex to sync.RWMutex to allow concurrent reads

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
go.mod Adds golang.org/x/sync v0.19.0 dependency for singleflight support
go.sum Updates checksums for new golang.org/x/sync dependency
index/index_model.go Changes refLock from sync.Mutex to sync.RWMutex for improved concurrency
index/spec_index.go Sorts polymorphic reference map keys before iteration for deterministic ordering
index/resolver.go Sorts component schemas and security schemes keys before iteration for deterministic ordering
index/extract_refs.go Major refactoring: introduces singleflight for deduplication, channel-based collection for reduced mutex contention, position-based sorting for deterministic ordering, and adds locateRef helper function
index/determinism_benchmark_test.go Adds regression tests and benchmarks to verify consistent deterministic ordering across multiple runs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Dec 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.59%. Comparing base (b4e5820) to head (94dfb0d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
+ Coverage   99.58%   99.59%   +0.01%     
==========================================
  Files         175      175              
  Lines       21641    21700      +59     
==========================================
+ Hits        21552    21613      +61     
+ Misses         56       55       -1     
+ Partials       33       32       -1     
Flag Coverage Δ
unittests 99.59% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

added some better docs too.
Reported on discord. params were being dropped on render because the skip flag was bugging things out.
@daveshanley daveshanley merged commit 3bb251f into main Dec 20, 2025
4 checks passed
@daveshanley daveshanley deleted the v0.30.4 branch December 20, 2025 01:50
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.

2 participants