Skip to content

fix(frontend): keep zonal EC2 AZ in purchase variant identity and cell key - #809

Merged
cristim merged 1 commit into
mainfrom
fix/792-frontend-az-identity
Oct 12, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/792-frontend-az-identity

Conversation

@cristim

@cristim cristim commented Oct 12, 2026

Copy link
Copy Markdown
Member

Part of #792 (PR3). Backend identity landed in #807; this keeps the frontend consistent with it.

What

  • samePurchaseVariantIdentity now compares details.availability_zone for EC2/compute, so the purchase modal can no longer switch term/payment to a variant in a different AZ (the backend returns 409 for such a purchase). Regional recs have no AZ on either side and still match.
  • cellKey appends the AZ only when a rec has one, so zonal recs in different AZs are separate cells (and separate radio-selection groups) and every other cell key is unchanged.
  • availability_zone? added to LocalRecommendation and the API Recommendation type.

Ordering

Must merge with or before PR2b (the store change that lets AZ-only variants coexist); until then the backend can still hold only one row per 8-tuple.

Verification

  • jest (maxWorkers=2): full suite 3216 passed; tsc, lint (0 errors) and webpack build clean.
  • New tests: two zonal recs differing only by AZ are excluded from each other's variants (ec2 and compute), a regional rec keeps matching its own variants, groupRecsByCell splits per AZ and leaves the regional key unchanged.
  • Mutations: removing availability_zone from the identity fields fails 2 tests; removing the cellKey suffix fails 1 test.

🤖 Generated with Claude Code

…l key

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/m Days type/bug Defect triaged Item has been triaged labels Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 5 billable files and costs up to $1.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 6 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 62 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: fc46c631-b3f2-4dff-b70b-c4aebe573076

📥 Commits

Reviewing files that changed from the base of the PR and between 3fde4ef and e1f5924.


📒 Files selected for processing (5)
  • frontend/src/__tests__/purchase-modal-submit.test.ts
  • frontend/src/__tests__/recommendations.test.ts
  • frontend/src/api/types.ts
  • frontend/src/recommendations.ts
  • frontend/src/types.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim

cristim commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Independent gate review (Opus 5.5): APPROVE at e1f592440599be9939247364619c5b0cb184cceb

Scope reviewed: full diff (5 files, +34/-2) against origin/main; head contains main.

Findings: none blocking.

  • samePurchaseVariantIdentity (ec2/compute) now compares details.availability_zone; key matches the lib ComputeDetails.AvailabilityZone json tag (availability_zone, pkg@9dae64b216d4 common/types.go:560). Regional recs: both sides undefined -> still equal, so regional variant narrowing is unchanged.
  • cellKey appends the top-level availability_zone only when non-empty; field name matches RecommendationRecord.AvailabilityZone json tag on main (internal/config/types.go:539). Recs reach state via object spread (app.ts:447/595), so the field survives. All cellKey consumers (grouping, radio enforcement, pickBestVariantPerCell, loadedCellVariants, expand set) get per-AZ cells; non-zonal keys are byte-identical. Other composite keys (sp-group, bulk bucket at recommendations.ts:4151) are not per-resource identity and need no AZ.
  • Tests: two zonal recs differing only by AZ (ec2 + compute) in the modal, zonal cell split, and a regional EC2 rec regression case.

Local verification (macOS, git archive of the exact SHA, under cc-heavy-run lock, nice 15):

  • npx jest --maxWorkers=2: 102/102 suites, 3216 passed, 1 skipped, exit 0
  • npm run lint 0, npx tsc --noEmit 0, npm run build 0
  • Fails-before: with main's recommendations.ts and the PR tests, 3 of the 4 new tests fail (2 AZ modal cases, cell split); the regional regression case passes before and after, as intended.
    Evidence type: jest/jsdom fixtures exercising the real modal and grouping code; no real-account verification (frontend-only, backend 409 guard from fix(purchase): make zonal EC2 AZ part of the guard, identity key, idempotency key and rec ID #807 is the server-side backstop).

CI at this SHA: all required checks green (CI Success, Run pre-commit hooks) plus Unit/Integration/E2E/Lint/Build/Security. Only failure is Playwright ladder-config.spec.ts (Dismiss-notification strict-mode), the known main failure #802, not required; this is why mergeStateStatus is UNSTABLE rather than CLEAN.
Mutation sweep: not applicable (frontend change, per owner policy 2026-10-12).

@cristim
cristim merged commit b197104 into main Oct 12, 2026
26 of 27 checks passed
@cristim
cristim deleted the fix/792-frontend-az-identity branch October 16, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/many Affects most users priority/p2 Backlog-worthy 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.

1 participant