Skip to content

fix(scheduler): isolate recommendation IDs by cloud account - #463

Open
cristim wants to merge 1 commit into
mainfrom
fix/platform-account-recommendation-ids
Open

cristim wants to merge 1 commit into
mainfrom
fix/platform-account-recommendation-ids

Conversation

@cristim

@cristim cristim commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Recommendations from two registered AWS accounts can share the provider-reported account value, producing identical IDs and returning the wrong account's recommendation. IDs now use the CUDly cloud-account UUID and the same dimensions as the database's natural key. Tagging recomputes the ID, keeping recollection stable and ambient accounts supported.

Closes #235.

Independent adversarial Astra review approved exact commit 835f6ecac7ed2a29450ed37f79acb86f03697cb3 with no actionable findings, under the owner's authorized local-review alternative. The reviewer read the full committed diff and independently reproduced the original failure with the final regression against the parent source.

Verification used synthetic provider inputs with the real scheduler, PostgreSQL migrations through 101, store, scoped HTTP detail handler and pricing consumers. The exact-commit connected race test passed, including six persisted recommendations across two accounts, account-specific lookups, cross-account denial, compatible variants, tenancy mismatch, stale-ID 409 and successful stable recollection. Full scheduler/API race suites and backend build passed. A negative control confirmed that a failed second collection cannot be mistaken for successful recollection. The committed PostgreSQL 16 container path also passed; separate exact-commit evidence used native PostgreSQL 17 on macOS. Author checks included pinned lint, normal commit hooks and frontend recommendation tests.

No live cloud collection or purchases were performed. Existing recommendation links can return 404 after refresh; failed-account rows retain old IDs until a successful refresh. Same-platform-account subscription collisions in the SQL key remain outside this issue's scope.

Summary by CodeRabbit

  • Bug Fixes
    • Recommendation IDs are now based on the recommendation’s saved details, including its account. This helps keep IDs distinct across accounts and consistent when recommendations are collected again.
    • Recommendations from different providers, services, regions, or pricing terms remain distinguishable, reducing the chance of incorrect lookups or conflicts.

Align generated IDs with persisted recommendation identity and recompute
them after account tagging. Verify account-scoped detail and pricing
through collection, PostgreSQL, and the real consumers.

Closes #235
@cristim cristim added severity/medium Moderate harm urgency/this-sprint Within the current sprint triaged Item has been triaged priority/p1 Next up; this sprint impact/many Affects most users effort/s Hours type/bug Defect labels Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: f3454dc4-6927-464e-b053-d7d74c212632

📥 Commits

Reviewing files that changed from the base of the PR and between 6d9a70f and 835f6ec.

📒 Files selected for processing (4)
  • internal/api/recommendation_identity_integration_test.go
  • internal/scheduler/recommendation_identity_test.go
  • internal/scheduler/scheduler.go
  • internal/scheduler/scheduler_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

Recommendation IDs are now derived from persisted recommendation fields, including the registered cloud account ID when present. Scheduler tests cover account tagging and ID dimensions. An integration test checks collection, persistence, account-scoped details and pricing, error cases, and ID stability.

Changes

Recommendation identity

Layer / File(s) Summary
Account-scoped recommendation IDs
internal/scheduler/scheduler.go, internal/scheduler/recommendation_identity_test.go, internal/scheduler/scheduler_test.go
The scheduler derives IDs from persisted fields, including the account ID when present. Tests check account tagging, ID stability across collection, natural-key dimensions, and expected IDs for AWS, Azure, and GCP tagging.
API and persistence verification
internal/api/recommendation_identity_integration_test.go
The integration test checks collection and persistence across two AWS accounts, account-scoped detail access, stored-record pricing, tenancy and stale-record errors, and ID stability after recollection.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 835f6

Recommendation IDs now distinguish registered cloud accounts while preserving stable recollection and ambient-account behavior. No actionable merge-blocking risk remains after normal checks; existing links may change after refresh as documented.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. 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 title clearly and concisely describes the main change: isolating recommendation IDs by cloud account in the scheduler.
Linked Issues check ✅ Passed Issue [#235] requires distinct IDs for otherwise identical recommendations from different registered AWS accounts and alignment with the stored CUDly account UUID. recommendationID builds the ID fro…
Out of Scope Changes check ✅ Passed The production change is limited to recommendation-ID construction and recomputation after account tagging. The added unit and integration tests verify cross-account uniqueness, natural-key dimensions…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

This branch has not been deployed

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

Labels

effort/s Hours impact/many Affects most users priority/p1 Next up; this sprint severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scheduler): AWS recommendation IDs omit the account, so IDs collide across accounts

1 participant