Keep a cloned contract draft from changing the live tier table
A sales-operations preview shallow-copies a contract and changes a nested tier. The original contract shares the array and immediately starts quoting the draft rate.
- Focused work estimate
- 2h + prerequisites
- Priority in the scenario
- High
- Engineering practice
- Copy semantics · Immutability · Schema validation
Estimated field mix
- Backend70%
- Quality engineering30%
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
- PrototypeRefactor
Replace a shallow contract clone with a schema-aware draft copy that preserves provenance while preventing shared mutable tier arrays.
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
- A draft receives its own identity, source revision reference, and independently editable tier values.
- Editing, reordering, or deleting a draft tier cannot affect the published contract or another draft.
- Reject unsupported values during cloning instead of silently dropping them through JSON serialization.
Implementation constraints
- Limit the prototype to a declared data-only contract schema; do not clone provider handles, functions, or process state.
Verification to include
- Clone two drafts, mutate nested data in one, and compare all three contract snapshots.
- Attempt to clone an invalid tier boundary and confirm no partial draft is returned.
Deliverables
- Schema-aware prototype copy and aliasing regression fixtures
Rollout and recovery
Use the new copy path for synthetic previews; existing published fixture revisions remain immutable.
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.