ROX-33766: Use UUIDv7 for VM scan, component, and CVE IDs#19757
ROX-33766: Use UUIDv7 for VM scan, component, and CVE IDs#19757dashrews78 merged 1 commit intomasterfrom
Conversation
Switch from UUIDv4 (random) to UUIDv7 (time-ordered, RFC 9562) for virtual machine scan, component, and CVE ID generation. UUIDv7 embeds a millisecond timestamp in the high bits, producing monotonically increasing values that improve PostgreSQL B-tree index performance (sequential inserts, better page fill, reduced WAL amplification). This aligns the implementation with the existing proto comment on VirtualMachineScanV2.id that specifies UUIDv7 intent. Partially generated by AI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
This change is part of the following stack: Change managed by git-spice. |
|
Images are ready for the commit at 0ddadea. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19757 +/- ##
==========================================
- Coverage 49.59% 49.59% -0.01%
==========================================
Files 2756 2756
Lines 208036 208040 +4
==========================================
- Hits 103183 103179 -4
- Misses 97192 97199 +7
- Partials 7661 7662 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdded a new V7 UUID constructor to the UUID package and updated scan conversion logic to use V7 UUIDs instead of V4. The new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/uuid/uuid_test.go (1)
86-93: Monotonic test relies on implementation-specific behavior.The lexicographic string comparison works because
google/uuid'sNewV7()uses an internal counter for sub-millisecond ordering. However, this isn't guaranteed by RFC 9562 itself—it only mandates millisecond-precision timestamps. If the underlying library changes its sub-millisecond strategy, this test could become flaky.Consider adding a brief comment noting this relies on
google/uuid's counter-based implementation, or relax to testing non-decreasing order (allowing equality within the same millisecond).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/uuid/uuid_test.go` around lines 86 - 93, The test "monotonically increasing" relies on google/uuid's sub-millisecond counter behavior (NewV7()) which is implementation-specific; either add a clarifying comment above the t.Run noting this dependency on google/uuid's counter-based ordering, or change the assertion to allow non-decreasing order (assert.GreaterOrEqual or assert.NotLess) so equality within the same millisecond is permitted while still checking ordering semantics of NewV7().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/uuid/uuid_test.go`:
- Around line 86-93: The test "monotonically increasing" relies on google/uuid's
sub-millisecond counter behavior (NewV7()) which is implementation-specific;
either add a clarifying comment above the t.Run noting this dependency on
google/uuid's counter-based ordering, or change the assertion to allow
non-decreasing order (assert.GreaterOrEqual or assert.NotLess) so equality
within the same millisecond is permitted while still checking ordering semantics
of NewV7().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 4839782f-fab2-4137-bb3c-a29d5c1b1dd1
📒 Files selected for processing (3)
central/convert/v1tov2storage/vm_scan_parts.gopkg/uuid/uuid.gopkg/uuid/uuid_test.go
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Description
Switch from UUIDv4 (random) to UUIDv7 (time-ordered, RFC 9562) for
virtual machine scan, component, and CVE ID generation. UUIDv7 embeds
a millisecond timestamp in the high bits, producing monotonically
increasing values that improve PostgreSQL B-tree index performance
(sequential inserts, better page fill, reduced WAL amplification).
This aligns the implementation with the existing proto comment on
VirtualMachineScanV2.id that specifies UUIDv7 intent.
Partially generated by AI.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
User-facing documentation
Testing and quality
Automated testing
How I validated my change
existing unit tests sufficient here as APIs and datastores are not wired up to this yet.