Prepared demonstration
Expand anything. Nothing is lost.
A fixed example from a fictional repository, with real classifications written by hand for this page. Nothing here runs an analysis, and no code of yours is involved.
Four things are in this example
1 A changed rule. The tenure requirement for a fleet rebate drops from
twelve months to six, and a fleet-size condition is added.
2 Behaviour-preserving cleanup. Imports reordered, the rate table
literal reformatted, commented-out code and a local alias removed. 27 lines across three
blocks.
3 A moved block with its own change. The contract check moves below the
amount calculation and gains an asOf argument.
4 An uncertain block that stays. Inline rounding becomes a helper call
whose definition was not supplied, so it cannot be judged — and is not hidden.
Counts on the right are derived from this example, not from a live analysis. Expanding a block does not move your place in the file.
src/billing/rebate.ts +17 −15 harborline/billing-core · a3f81c2…9b4e7d1 4 visible ·
3 collapsed ·
27 lines hidden
Mechanical Import order and formatting · 8 lines hidden · lines 1–5
Mechanical Import order and formatting Confidence rebate.ts:1–5
@@ -1,4 +1,5 @@
1 − import { ValidationError } from '../errors';
2 − import { Account, RebateTier } from '../types/account';
3 − import { monthsBetween } from '../lib/date';
1 + import { Account, RebateTier } from '../types/account';
2 + import { ValidationError } from '../errors';
3 + import { monthsBetween } from '../lib/date';
4 + import { roundCurrency } from '../lib/currency';
4 5
1 − import { ValidationError } from '../errors';
1 + import { Account, RebateTier } from '../types/account';
2 − import { Account, RebateTier } from '../types/account';
2 + import { ValidationError } from '../errors';
3 − import { monthsBetween } from '../lib/date';
3 + import { monthsBetween } from '../lib/date';
4 + import { roundCurrency } from '../lib/currency';
4
5
Mechanical Rate table literal reformatted · 10 lines hidden · lines 6–13
Mechanical Rate table literal reformatted Confidence rebate.ts:6–13
@@ -5,6 +6,8 @@
5 − const TIER_RATES: Record<RebateTier, number> = { standard: 0.02, fleet: 0.04 };
6 + const TIER_RATES: Record<RebateTier, number> = {
7 + standard: 0.02,
8 + fleet: 0.04,
9 + };
6 10
7 11 /** Rebates are settled monthly against the fleet contract. */
8 − // TODO(2024): move tier rates into the pricing service
9 12
10 13 export interface RebateInput {
5 − const TIER_RATES: Record<RebateTier, number> = { standard: 0.02, fleet: 0.04 };
6 + const TIER_RATES: Record<RebateTier, number> = {
7 + standard: 0.02,
8 + fleet: 0.04,
9 + };
6
10
7 /** Rebates are settled monthly against the fleet contract. */
11 /** Rebates are settled monthly against the fleet contract. */
8 − // TODO(2024): move tier rates into the pricing service
9
12
10 export interface RebateInput {
13 export interface RebateInput {
Business behavior Eligibility rule changed Confidence rebate.ts:24–30
@@ -18,9 +21,13 @@ export function isEligible(input: RebateInput): boolean
18 21 export function isEligible(input: RebateInput): boolean {
19 22 const { account } = input;
20 23 const tenure = monthsBetween(account.contractStart, input.asOf);
21 − if (tenure < 12) {
24 + if (tenure < 6) {
22 25 return false;
23 26 }
27 +
28 + if (account.fleetSize < 5) {
29 + return false;
30 + }
24 31
25 32 return account.tier === 'fleet';
26 33 }
18 export function isEligible(input: RebateInput): boolean {
21 export function isEligible(input: RebateInput): boolean {
19 const { account } = input;
22 const { account } = input;
20 const tenure = monthsBetween(account.contractStart, input.asOf);
23 const tenure = monthsBetween(account.contractStart, input.asOf);
21 − if (tenure < 12) {
24 + if (tenure < 6) {
22 return false;
25 return false;
23 }
26 }
27 +
28 + if (account.fleetSize < 5) {
29 + return false;
30 + }
24
31
25 return account.tier === 'fleet';
32 return account.tier === 'fleet';
26 }
33 }
Business behavior Validation rule removed Confidence rebate.ts:39–40
@@ -30,8 +37,4 @@ export function computeRebate(input: RebateInput): Money
30 37 export function computeRebate(input: RebateInput): Money {
31 38 const { account } = input;
32 39
33 − if (!account.taxIdVerified) {
34 − throw new ValidationError('TAX_ID_UNVERIFIED', account.id);
35 − }
36 −
37 40 const rate = TIER_RATES[account.tier];
30 export function computeRebate(input: RebateInput): Money {
37 export function computeRebate(input: RebateInput): Money {
31 const { account } = input;
38 const { account } = input;
32
39
33 − if (!account.taxIdVerified) {
34 − throw new ValidationError('TAX_ID_UNVERIFIED', account.id);
35 − }
36 −
37 const rate = TIER_RATES[account.tier];
40 const rate = TIER_RATES[account.tier];
Mixed change Block moved and behavior changed Confidence rebate.ts:45 · moved from 40
@@ -40,6 +43,7 @@
40 − assertActiveContract(account);
41 43 const gross = account.monthlySpend * rate;
42 44
45 + assertActiveContract(account, { asOf: input.asOf });
46 +
43 47 if (gross <= 0) {
44 48 return zero(account.currency);
45 49 }
40 − assertActiveContract(account);
41 const gross = account.monthlySpend * rate;
43 const gross = account.monthlySpend * rate;
42
44
45 + assertActiveContract(account, { asOf: input.asOf });
46 +
43 if (gross <= 0) {
47 if (gross <= 0) {
44 return zero(account.currency);
48 return zero(account.currency);
45 }
49 }
Mechanical Comment removal and local rename · 9 lines hidden · lines 56–61
Mechanical Comment removal and local rename Confidence rebate.ts:56–61
@@ -52,8 +56,6 @@
52 56 function formatAudit(account: Account): string {
53 − const acc = account;
54 − // legacy: audit lines were fixed-width before v3
55 − // return pad(acc.id, 12) + acc.tier;
57 +
56 58 return [account.id, account.tier].join(' ');
57 59 }
58 60
59 61 function zero(currency: Currency): Money {
52 function formatAudit(account: Account): string {
56 function formatAudit(account: Account): string {
53 − const acc = account;
57 +
54 − // legacy: audit lines were fixed-width before v3
55 − // return pad(acc.id, 12) + acc.tier;
56 return [account.id, account.tier].join(' ');
58 return [account.id, account.tier].join(' ');
57 }
59 }
58
60
59 function zero(currency: Currency): Money {
61 function zero(currency: Currency): Money {
Uncertain Rounding behavior may change — helper not supplied Confidence rebate.ts:65
@@ -62,5 +64,5 @@
62 64 const net = gross * rate;
63 − return { amount: Math.round(net * 100) / 100, currency: account.currency };
65 + return { amount: roundCurrency(net, account.currency), currency: account.currency };
64 66 }
62 const net = gross * rate;
64 const net = gross * rate;
63 − return { amount: Math.round(net * 100) / 100, currency: account.currency };
65 + return { amount: roundCurrency(net, account.currency), currency: account.currency };
64 }
66 }
This is a prepared demonstration, not a live analysis. Collapsed blocks are hidden from the focused view — they have not been proven irrelevant, and the full diff is one click away.
Focused view — 3 eligible blocks collapsed, as a new review opens.
See this review inside the workspace