Skip to content

feat(insurance): preserve selected comparison amounts - #435

Merged
cristim merged 1 commit into
mainfrom
feat/434-insurance-selected-amount
Oct 16, 2026
Merged

cristim merged 1 commit into
mainfrom
feat/434-insurance-selected-amount

Conversation

@cristim

@cristim cristim commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

What

Keep the selected comparison amount (the selected_commitment side of an Archera comparison row) instead of dropping it when quotes are decoded.

Why

The Public Archera CommitmentPlanLineItem schema carries account_id, offer.provider_offering_id and selected_commitment. Comparison rows join to line items by line_item_id, so the selected amount must survive decoding for that join to be useful (#434).

Test evidence

Synthetic httptest fixtures only; no live Archera calls.

  • cd pkg && gofmt -l . clean, go vet ./insurance/... clean
  • cd pkg && go test ./insurance/... ok; go test -race -short ./insurance/... ok
  • cd pkg && go build ./... ok
  • Local golangci-lint could not run (built with go1.26, repo needs go1.27); relying on CI lint.

Stack

PR 1 of 3 (base: main). Followed by the line-item decode PR and the pagination PR.

Refs #434

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Insurance offer details now include the selected amount, expressed as a unit count or hourly dollar amount.
  • Bug Fixes
    • Offer data now rejects missing, invalid, or negative selected amounts while preserving precision for decimal values.

@cristim cristim added type/feat New capability priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience effort/m Days triaged Item has been triaged labels Oct 16, 2026
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 8143e698-53ad-4612-a623-0ee34c5d9ec8
📥 Commits

Reviewing files that changed from the base of the PR and between 829ae14 and 7a1704f.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 396b21ff-c640-49c4-924b-c096e6c16da6
📥 Commits

Reviewing files that changed from the base of the PR and between 740dfbd and 829ae14.

📒 Files selected for processing: 4
  • pkg/insurance/amounts.go
  • pkg/insurance/quote.go
  • pkg/insurance/quote_test.go
  • pkg/insurance/types.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

Offer quote decoding now reads selected_amount, validates it as a nonnegative rational, and stores it on OfferEntry. Tests cover invalid values, exact decimal conversion, and decoded amounts for current and candidate offers.

Changes: Offer selected amounts

Layer / File(s) Summary
Decode and validate selected amounts
pkg/insurance/amounts.go, pkg/insurance/quote.go, pkg/insurance/types.go, pkg/insurance/quote_test.go
The wire offer entry now decodes selected_amount. Conversion rejects missing, null, non-numeric, or negative values and stores valid values as *big.Rat on OfferEntry. Tests check error cases and exact decoded values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 829ae

The change adds exact nonnegative selected-amount decoding and validation; no concrete user-facing failure is established, so merge readiness is minimal pending normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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: preserving selected comparison amounts during insurance quote decoding.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ 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
  • 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 16, 2026

Copy link
Copy Markdown
Member Author

Independent review at 829ae14

Verdict: no actionable findings.

Source of truth: the live Public OpenAPI schema (the two local spec files named in the brief were absent, so I fetched the schema from the vendor's unauthenticated openapi endpoint and parsed it).

Checked:

  • OfferComparisonEntry.selected_amount is in required and is type: number (not nullable). quote.go (wireOfferEntry.SelectedAmount wireNum, toOfferEntry) rejects null, absent, quoted and negative values and keeps the amount as *big.Rat (amounts.go:9-17), consistent with the package's money convention. The 19-digit decimal test confirms no float rounding.
  • go test ./insurance/... passes at the stacked tip (366 tests); go vet clean.

Mutation probes (scratch copy, each reverted):

  • drop e.SelectedAmount = amount: killed.
  • allow negative amounts (amounts.go): killed.
  • requiredRat -> ratOrNil (accept null/absent): killed.

Info only: offer_org_id stays undecoded, as before.

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: CLEAN at 829ae14eea8eea5d186924cc8d4817604b2eed34 (claude-go-pr-merge-2; non-author reviewer, cold brief, diff 740dfbd..829ae14e).

  • Comparison selected_amount decodes through the existing wireNum/requiredRat helpers (new nonnegativeRat in amounts.go wraps them) into *big.Rat, so no float loss; 0.1234567890123456789 round-trips exactly (TestDecodeComparisonSelectedAmount). Null, absent, quoted-string and negative are rejected; zero accepted.
  • Mutation: disabling the negative check fails TestDecodeComparisonSelectedAmount and TestDecodeLineItemsContractBreaks.
  • Non-blocking: the field is now required, so a vendor response without selected_amount fails the whole decode (fail-loud; schema required list not verifiable locally). The types.go unit comment (count vs $/hour) is not backed by anything in the repo and the type carries no unit tag.

Local verification (macOS; httptest/JSON fixture evidence only, no live Archera calls): (cd pkg && GOWORK=off go test -race -short ./...) pass at 829ae14, f767908 and b0f66cd; at b0f66cd make build, make vet and go build ./... in all five modules (go.work) pass. No Archera schema or fixture exists in the repo, so field names and pagination parameters were not checked against the vendor schema (gap recorded).

CI green on 829ae14e (14/14); CodeRabbit reviewed exactly 829ae14e with no actionable comments; labels mirror #434. Stack 1/3: merge first, then retarget #436 to main.

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Automated review of 829ae14: no blocking findings and CI is green. Ready to merge.
Small, correct change: selected_amount is decoded as a required nonnegative exact rational, reusing requiredRat. Tests cover null, negative, string, absent and high-precision values, and the golden fixtures assert the mapped value. No bugs found.

  • (optional) pkg/insurance/amounts.go:14: The new file holds a single three-line helper. It could live next to requiredRat in quote.go, but a separate file is harmless.

Posted by a read-only review sweep. It stays silent on this commit and re-reviews only after a new push.

@cristim
cristim force-pushed the feat/434-insurance-selected-amount branch from 829ae14 to 3adf47b Compare October 16, 2026 15:01
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Rebased onto main 551be56 (pure rebase, no conflicts). git range-diff 740dfbd..829ae14e 551be56..3adf47b7 is 1: 829ae14 = 1: 3adf47b, so the CLEAN verdict at 829ae14e stands for 3adf47b7530f8ee85d75d4ae53f7559f0a94a263. Local check (macOS, fixture/mock): (cd pkg && GOWORK=off go build ./... && GOWORK=off go test -race -short ./insurance/...) pass (288 tests). Waiting for CI.

@cristim
cristim force-pushed the feat/434-insurance-selected-amount branch from 3adf47b to 99c7310 Compare October 16, 2026 15:23
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

CI was green on 3adf47b7, but main moved to 9fe0d74 (GCP test-only change) before merge. Rebased: git range-diff 551be56..3adf47b7 9fe0d74..99c73106 is =. Verdict at 829ae14e stands for 99c73106def85f83ae93c94ce4600f63ec0f40a1; local (cd pkg && GOWORK=off go test -race -short ./insurance/...) pass (fixture/mock).

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Main moved to 53dfba9 (#429 merged). Rebased: git range-diff 9fe0d74..99c73106 53dfba9..0a018e8e is =. Verdict at 829ae14e stands for 0a018e8eadd1e2128ba3914d8d53a35224ae4c8d; local (cd pkg && GOWORK=off go test -race -short ./insurance/...) pass (fixture/mock).

@cristim
cristim force-pushed the feat/434-insurance-selected-amount branch from 99c7310 to 0a018e8 Compare October 16, 2026 15:48
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

CI on 0a018e8e failed only in Lint Code (providers/azure) (golangci-lint schema-fetch timeout, fixed on main by #445). Rebased onto 071a496: git range-diff 53dfba9..0a018e8e 071a496..eee7a2ca is =. Verdict at 829ae14e stands for eee7a2ca3f5d3ce8a17a47a6e7cd9705bc944b41; local (cd pkg && GOWORK=off go test -race -short ./insurance/...) pass (fixture/mock).

@cristim
cristim force-pushed the feat/434-insurance-selected-amount branch from 0a018e8 to eee7a2c Compare October 16, 2026 16:11
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

CI green on eee7a2ca (pre-commit 38929927540, Build & Test 38929927757), but main moved to b69a17e (#447) first. Rebased: git range-diff 071a496..eee7a2ca b69a17e..7a1704f5 is =. Verdict at 829ae14e stands for 7a1704f547eb85c8ce09834f335dc536311dc715; local (cd pkg && GOWORK=off go test -race -short ./insurance/...) pass (fixture/mock).

@cristim
cristim force-pushed the feat/434-insurance-selected-amount branch from eee7a2c to 7a1704f Compare October 16, 2026 16:26
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Merge evidence at 7a1704f547eb85c8ce09834f335dc536311dc715 (claude-go-pr-merge-2, owner-authorized): independent review CLEAN at 829ae14e; 7a1704f5 is a pure rebase onto b69a17e (range-diff =). CodeRabbit reviewed 829ae14e with no actionable comments; no open threads. CI green on 7a1704f5 (pre-commit 38932015263, Build & Test 38932015102). Local verification (macOS, fixture/mock, no live Archera) recorded above. Labels mirror #434. Stack 1/3; #436 is retargeted to main next. CR waived: quota, adversarial review + local verification + green CI (for the rebased head).

@cristim
cristim merged commit 4566498 into main Oct 16, 2026
15 checks passed
@cristim
cristim deleted the feat/434-insurance-selected-amount branch October 16, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant