Conversation
Co-authored-by: Gemini <gemini@google.com>
Co-authored-by: Claude <noreply@anthropic.com>
Reviewer's GuideThis PR completes the migration from the legacy account-wide advisory_account_data cache to workspace-scoped account_advisory aggregates by centralizing refresh and notification ownership in the aggregator, removing evaluator and job-based legacy workflows, introducing dedicated database permissions and deployment credentials, and updating schema, tests, documentation, and monitoring. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2345 +/- ##
==========================================
+ Coverage 58.95% 60.25% +1.29%
==========================================
Files 150 144 -6
Lines 9605 9077 -528
==========================================
- Hits 5663 5469 -194
+ Misses 3348 3044 -304
+ Partials 594 564 -30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="base/mqueue/platform_event.go" line_range="79" />
<code_context>
- if size <= 0 {
- size = BatchSize
- }
+func batchSize(grouped map[int][]uuid.UUID) int {
+ // compute how many batches we will create
var batches = 0
for _, ev := range grouped {
- batches += (len(ev) + size - 1) / size
+ batches += len(ev)/BatchSize + 1
}
return batches
</code_context>
<issue_to_address>
**nitpick (performance):** `batchSize` returns one extra batch whenever an account has an exact multiple of `BatchSize` systems; for example, 500 systems produces 2 instead of 1. `WriteEvents` still emits only the correct number of events, but it allocates an unnecessarily large `PlatformEvents` backing array for every such account, increasing memory usage during large event batches.
**Triggers:** When an account's inventory count is an exact multiple of `BatchSize`.
**Suggested fix:** Use `(len(ev) + BatchSize - 1) / BatchSize`, matching the previous calculation, and return zero for empty slices.
```suggestion
batches += (len(ev) + BatchSize - 1) / BatchSize
```
</issue_to_address>Sourcery assessment
Needs a human reviewer. The migration drops the production advisory_account_data table and its contents, while the down migration only recreates an empty table, so reverting cannot restore the deleted data. It also changes database roles and permissions, making an incorrect cutover potentially affect both data availability and component access.
| var batches = 0 | ||
| for _, ev := range grouped { | ||
| batches += (len(ev) + size - 1) / size | ||
| batches += len(ev)/BatchSize + 1 |
There was a problem hiding this comment.
nitpick (performance): batchSize returns one extra batch whenever an account has an exact multiple of BatchSize systems; for example, 500 systems produces 2 instead of 1. WriteEvents still emits only the correct number of events, but it allocates an unnecessarily large PlatformEvents backing array for every such account, increasing memory usage during large event batches.
Triggers: When an account's inventory count is an exact multiple of BatchSize.
Suggested fix: Use (len(ev) + BatchSize - 1) / BatchSize, matching the previous calculation, and return zero for empty slices.
| batches += len(ev)/BatchSize + 1 | |
| batches += (len(ev) + BatchSize - 1) / BatchSize |
|
The PR is ok to review, but wait with merging, |
Secure Coding Practices Checklist GitHub Link
Secure Coding Checklist
Summary by Sourcery
Replace the legacy advisory account cache with workspace-scoped account_advisory aggregation throughout the application.
Enhancements:
Deployment:
Documentation:
Tests:
Chores: