noCV
PPOLICY-103 · Pin down the contract

Add a capped volume contract without editing the existing rules

Practice briefStoryIntermediate

Reseller C needs 20% off from twenty units, capped at 5,000 cents per quote. The current conditional is also used by the other resellers, whose issued quotes must remain reproducible.

Focused work estimate
2h 30m + prerequisites
Priority in the scenario
Medium
Engineering practice
Strategy selection · Pure functions · Compatibility

Estimated field mix

  • Backend70%
  • System design30%

Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.

Pattern topics

  • StrategyApply

    Isolate the capped volume calculation behind the same contract used by existing rules, without adding reseller-specific branches to the caller.

Your next step

Review it, then add it to your workspace.

The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.

Project context

A fictional equipment-rental service supports direct customers and two reseller contracts. Pricing now lives in a long conditional with subclasses left over from a discontinued campaign. Build a local TypeScript quoting module and synthetic fixtures; no starter repository, real charges, tax advice, or payment connection is supplied. Amounts use integer cents and the exercise supports USD only.

Setup prerequisites

  • Pure functions
  • Object composition
  • Integer arithmetic

Preceding work

Complete these dependencies, or supply their agreed outputs before taking this ticket.

Acceptance criteria

  • Select a pricing rule by explicit contract and revision, returning a typed error for an unknown combination.
  • Implement the threshold and cap while preserving every existing baseline result.
  • Return a stable rule identity and a breakdown showing the uncapped discount and applied cap.

Implementation constraints

  • Use composition or a function-valued Strategy; adding a class hierarchy is not required. Keep rule evaluation free of I/O.

Verification to include

  • Exercise quantities 19 and 20 with discounts below, at, and above 5,000 cents.
  • Request a retired or unknown revision and confirm no fallback contract is used.

Deliverables

  • Capped pricing rule, selector, and regression fixtures

Rollout and recovery

Enable reseller C only in the synthetic scenario set; keep the previous selector available for baseline replay.

Value of the work

For the engineer: Practice choosing, testing, and removing object-design abstractions around versioned business rules and tenant isolation.

For the team: Review changes that let a team introduce a contract without silently changing existing quotes, together with the maintenance costs of the chosen design.

Evidence boundaries

Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.

Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.