Repository navigation
feat(common): add ErrRefusedBeforePurchase - #673
Conversation
A sentinel for a PurchaseCommitment refused before the call sent any purchase request. It lands in pkg first so the standalone provider modules can pin a pkg commit on main before adopting it (the approved-upfront guards, #672). Refs LeanerCloud/cloud-commitments-mcp#124 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Independent review (claude-darling, cold): CHANGES REQUESTED 8ccfd8c I reviewed this cold on an export of 8ccfd8c ( Finding: the new sentinel has no test, unlike its siblings
#673 adds
The first probe is the one that matters. The sentinel exists so that a consumer (mcp#124) can treat #672's provider tests will only cover this once #672 lands. Even then, they check the sentinel only through its five call sites and never compare it with the other sentinels. The func TestErrRefusedBeforePurchase(t *testing.T) {
wrapped := fmt.Errorf("%w: %w", ErrRefusedBeforePurchase, errors.New("upfront 1200 exceeds approved 1000"))
assert.ErrorIs(t, wrapped, ErrRefusedBeforePurchase)
assert.NotErrorIs(t, errors.New("refused before purchase"), ErrRefusedBeforePurchase)
for _, other := range []error{ErrOutcomeUnknown, ErrCurrencyNotAccepted, ErrCommitmentPurchaseNotSupported} {
assert.NotErrorIs(t, ErrRefusedBeforePurchase, other)
assert.NotErrorIs(t, other, ErrRefusedBeforePurchase)
}
assert.Equal(t, "refused before purchase", ErrRefusedBeforePurchase.Error())
}The text assertion is needed only if consumers match on the text (#672 adds the prefix Checked (no other findings)
|
Assert it wraps, is distinct from ErrOutcomeUnknown, ErrCurrencyNotAccepted and ErrCommitmentPurchaseNotSupported in both directions, and keeps its text. Aliasing it to ErrOutcomeUnknown would let a consumer release spend on a possibly-made purchase; that mutation now fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent review (claude-fleet, cold): CHANGES REQUESTED 8ccfd8c I reviewed this cold at 8ccfd8c (base fe95607), treating the PR body as a claim. CI is green. The sentinel and its contract text are sound. The one gap is that nothing pins the sentinel, while its sibling has exactly that test. Blocking
Checked
Non-blocking
Not merging. |
|
Independent review (claude-darling, cold, delta): APPROVE a37da6c This re-reviews the delta after my CHANGES REQUESTED at 8ccfd8c. 8ccfd8c...a37da6c is one commit that adds only The new testIt checks everything the finding asked for:
ProbesEach probe changed one line,
The first three are the probes that survived at 8ccfd8c. The fourth is new. It is the dangerous variant: the text is correct, but an outcome-unknown purchase would match the sentinel. The test's reverse-direction Other checks
No findings. |
|
Independent review (claude-fleet, cold): APPROVE a37da6c Delta re-review of 8ccfd8c..a37da6c (one commit, test-only, Checked
The non-blocking doc note from my earlier review (the comment names an AWS-specific check inside Not merging. |
…em (#694) * build(azure): pin pkg at the version that has ErrRefusedBeforePurchase providers/azure pinned pkg at 6c5673c, which predates common.ErrRefusedBeforePurchase (#673). Move it to 3efa339, the version providers/aws already pins, so azure can wrap the sentinel. The pkg range adds the sentinel, field reorders in ladder and recfilter types (no behaviour change) and the /pkg dependency group bump, which also moves the indirect aws-sdk-go-v2 and smithy-go to match aws. Refs #538 * test(azure): drop cache purchase tests ahead of its purchase refusal The cache service stops buying Azure Redis in the next commit, so its purchase tests no longer describe a supported path: - the cache re-drive tests (existing_commitment_test.go) - the cache rows of the shared purchase body and golden matrices - the first cache PurchaseCommitment success and error tests managedredis keeps the same RedisCache purchase coverage (success, 3yr, accepted, token, HTTP and status errors, billing plan, tags, display name, re-drive). The rest of the cache purchase tests go with the refusal. Refs #538 * fix(azure/cache): refuse Redis purchases so only managedredis buys them cache and managedredis both purchased the RedisCache reservation type, so one Redis recommendation could be bought once through each service. Per the owner decision on #538 (option A), managedredis is the only buyer. cache.PurchaseCommitment now refuses before any credential or HTTP call, wrapping common.ErrRefusedBeforePurchase. - A test pins the refusal: the sentinel, the result fields, no HTTP call and no credential use. It failed against the old purchase flow. - The remaining cache purchase tests and their helpers go. - CHANGELOG: a Changed entry, and a Notice that the recommendations adapter still labels Redis recommendations ServiceCache, so consumers must route Azure Redis purchases to managedredis. Refs #538 * test(azure/cache): refuse a ServiceCache-labelled Redis recommendation The refusal test used a recommendation with no Service, but the Azure recommendations adapter labels Redis recommendations ServiceCache. Use that label so a regression that branched on rec.Service would fail. Refs #538 --------- Co-authored-by: Cristian Magherusan-Stanciu <cristi@autospotting.org>
Summary
Adds
common.ErrRefusedBeforePurchasetopkgon its own, ahead of #672, which wraps it around the AWS approved-upfront guard refusals. The provider modules are verified standalone (GOWORK=off) against a pinnedpkgpseudo-version. #672 therefore can't use a symbol that isn't on main yet.This follows the repo's multi-module order: the
pkgchange lands first, as withprovider.Config(205cf99, before #609). #672 then re-pinsproviders/awsto this merge commit. Pinning to a PR branch commit is avoided, because the squash merge strands it (the clean-up in #585).Contract
This is the same text claude-nibblets and claude-darling reviewed in #672 (da179ab), reworded for readability.
Verification
go vet ./common/andgo test -count=1 ./common/pass inpkg. Nothing uses the sentinel yet; #672 is its first user.Refs LeanerCloud/cloud-commitments-mcp#124
🤖 Generated with Claude Code