nx_card_adversary_gate.nx source
↩ module page · 94 lines · 5637 B
1// nx_card_adversary_gate.nx -- the CRITIC + ADVERSARY pass on the rewards-vs-interest ruler. Per the sovereign
2// critic-kernel discipline: a ruler is trustworthy (LAW) only if it DISCRIMINATES a genuinely-good sample from
3// an adversary built to game it (good >= 700, adversary <= 300 on a 0-1000 scale). Here the ruler = the honest
4// verdict "is the interest eating the rewards?". The adversaries are the exact pushy-industry tricks:
5// 1. "rewards always win" -- hides the interest so every card looks like a winner.
6// 2. affiliate steering -- push the card that pays a commission, not the one that helps the person.
7// 3. points inflation -- value points at a fantasy redemption to puff up a card.
8// The honest engine must REJECT all three while still PASSING a truly good card (the payer). license_tier: ORIGINAL expect_exit: 0
9import "nx_card_rewards.nx"
10
11func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
12func g_n(v: i64) -> i64 {
13 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
14 var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
15 let d: *u8 = sys_mmap(24); var k: i64 = 0
16 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
17 var i: i64 = k - 1; while i >= 0 { let o: *u8 = sys_mmap(1); o[0] = d[i]; sys_write(1, o, 1); i = i - 1 }
18 return 0
19}
20func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 {
21 if got == want { st[0] = st[0] + 1; g_puts(" PASS " as *u8) }
22 else { st[1] = st[1] + 1; g_puts(" FAIL " as *u8) }
23 g_puts(name); g_puts(" got=" as *u8); g_n(got); g_puts(" want=" as *u8); g_n(want); g_puts("\n" as *u8)
24 return 0
25}
26// Map an honest verdict to a 0-1000 ruler score: REWARDS WIN=1000, MARGINAL=500, INTEREST-EATS=0.
27func score(verdict: i64) -> i64 {
28 if verdict == 2 { return 1000 }
29 if verdict == 1 { return 500 }
30 return 0
31}
32
33func main() -> i64 {
34 let st: *i64 = sys_mmap(32) as *i64
35 st[0] = 0; st[1] = 0
36 g_puts("=== nx_card_adversary_gate: does the rewards-vs-interest RULER survive the red team? ===\n\n" as *u8)
37
38 // The same $480/yr, $95-fee cashback card as the engine gate.
39 let sp: *i64 = sys_mmap(8 * 8) as *i64
40 sp[0] = 600000; sp[1] = 1
41 sp[2] = 240000; sp[3] = 2
42 sp[4] = 360000; sp[5] = 3
43 sp[6] = 1200000; sp[7] = 0
44 let rates: *i64 = sys_mmap(8 * 6) as *i64
45 rates[0] = 100; rates[1] = 300; rates[2] = 300; rates[3] = 300
46 let rewards: i64 = cr_rewards_annual(sp, 4, rates, 4, 100)
47 let fee: i64 = 9500
48
49 // --- CALIBRATION-GOOD: the ruler must PASS a genuinely good case (a payer who carries no balance). ---
50 let net_payer: i64 = cr_net_annual(rewards, 0, fee, cr_interest_annual(0, 2499, 100))
51 let good_score: i64 = score(cr_verdict(net_payer, 5000))
52 var good_ok: i64 = 0
53 if good_score >= 700 { good_ok = 1 }
54 chk("calib-good: ruler PASSES the honest good card (score >= 700)" as *u8, good_ok, 1, st)
55
56 // --- ADVERSARY 1: 'rewards always win' -- hide the interest so the revolver looks like a winner. ---
57 let int_rev: i64 = cr_interest_annual(300000, 2499, 100)
58 let honest_net_rev: i64 = cr_net_annual(rewards, 0, fee, int_rev)
59 let fake_net_rev: i64 = rewards - fee // interest IGNORED -> looks positive
60 var fake_says_win: i64 = 0
61 if fake_net_rev > 0 { fake_says_win = 1 }
62 chk("adversary-1 'rewards always win' WOULD pass the revolver" as *u8, fake_says_win, 1, st)
63 let adv_score: i64 = score(cr_verdict(honest_net_rev, 5000))
64 var adv_rejected: i64 = 0
65 if adv_score <= 300 { adv_rejected = 1 }
66 chk("honest ruler REJECTS it (score <= 300 = INTEREST EATS REWARDS)" as *u8, adv_rejected, 1, st)
67 // the discrimination itself: the two disagree, and the honest side counts real money
68 var discriminates: i64 = 0
69 if good_score >= 700 { if adv_score <= 300 { discriminates = 1 } }
70 chk("RULER DISCRIMINATES good from adversary -> the verdict is LAW" as *u8, discriminates, 1, st)
71
72 // --- ADVERSARY 2: affiliate steering -- push the fee card (pays a commission) over the better option. ---
73 // A plain no-fee 1% card at a lower 12% APR loses the revolver only $120, vs $364.70 on the fee card.
74 let no_fee_net: i64 = 0 - 12000
75 chk("adversary-2: honest pick = the NO-FEE card, not the commission card" as *u8, cr_pick(no_fee_net, honest_net_rev), 0, st)
76
77 // --- ADVERSARY 3: points inflation -- value points at a fantasy 3.0cpp to puff a card. ---
78 let honest_floor: i64 = cr_point_bps(150, 100) // 1.5x at the 1.0cpp cash FLOOR = 150 bps
79 let inflated: i64 = cr_point_bps(150, 300) // fantasy 3.0cpp = 450 bps
80 chk("adversary-3: engine reports the conservative cash floor (150 bps)" as *u8, honest_floor, 150, st)
81 var not_inflated: i64 = 0
82 if honest_floor < inflated { not_inflated = 1 }
83 chk("the honest floor is BELOW the inflated claim (no puffery)" as *u8, not_inflated, 1, st)
84
85 g_puts("\n--- ADVERSARY GATE ---\n PASS=" as *u8); g_n(st[0]); g_puts(" FAIL=" as *u8); g_n(st[1]); g_puts("\n" as *u8)
86 if st[1] == 0 {
87 g_puts("VERDICT GREEN -- RULER = LAW. The rewards-vs-interest verdict discriminates a genuinely good card\n" as *u8)
88 g_puts(" (payer, score 1000) from the 'rewards always win' adversary (revolver, score 0), and refuses\n" as *u8)
89 g_puts(" affiliate steering and points inflation. The judge cannot be gamed in either direction.\n" as *u8)
90 sys_exit(0); return 0
91 }
92 g_puts("VERDICT RED -- the ruler is gameable; do not trust it yet.\n" as *u8)
93 sys_exit(1); return 0
94}