code wiki / _hdl_build / nx_auction_realtime.nx

nx_auction_realtime.nx source

↩ module page · 105 lines · 6798 B

1// nx_auction_realtime.nx -- MANHEIM-BUILD-L1: LIVE SIMULCAST auction (the real-time auctioneer-driven 2// channel, Manheim's flagship Simulcast lane), COMPOSED on the shared nx_auction_core engine. 3// Sovereign (nx_cc->nxasm, no gcc), pure integer-exact + deterministic. 4// 5// KEY INSIGHT (genuine composition, not a reskin): a live open-outcry lot has NO fixed clock -- it stays 6// open while bids keep coming and the auctioneer's HAMMER falls after a FALLOW gap ("going once, going 7// twice, SOLD" = no new bid for hammer_window ticks). That dynamic close is EXACTLY the core's anti-snipe 8// extension rule GENERALIZED: set the initial close = start + hammer_window and snipe_window = extension = 9// hammer_window, and every live bid pushes the close to bid_time + hammer_window, while a bid arriving 10// after the fallow window finds the lot already hammered (rejected). So rt_resolve is a thin wrapper that 11// configures at_resolve -- one settlement engine, the live channel is a parameterization of it. 12// 13// EXCEED axis (honest, not yet benched): the hammer is a DETERMINISTIC fixed fallow window, removing 14// auctioneer discretion / uneven timing / shill-pause -- a reproducible, auditable close. 15// 16// GATE (self-validating): A live ascending sale where bids keep EXTENDING the close (110->134) then a 17// fallow-gap bid is REJECTED (hammer already fell); neg-control C with hammer_window=0 (no live extension) 18// flips the outcome to NO-SALE. A broken rule diverges a checked value -> verdict=RED. 19// Evidence -> knowledge/status/auction_realtime.log. license_tier: ORIGINAL 20import "nx_syscalls.nx" 21import "nx_auction_core.nx" 22const RT_MAGIC_900000: i64 = 900000 23const RT_MAGIC_925000: i64 = 925000 24const RT_MAGIC_950000: i64 = 950000 25const RT_MAGIC_1000000: i64 = 1000000 26const RT_MAGIC_1010000: i64 = 1010000 27const RT_MAGIC_25000: i64 = 25000 28 29const RT_LOG: *u8 = "knowledge/status/auction_realtime.log" 30 31func rt_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } 32func rt_wn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(fd, bb, k); return 0 } 33 34// LIVE hammer-close auction = the core engine with the close driven by the fallow window. 35// initial close = start + hammer_window; snipe_window = extension = hammer_window (every live bid 36// re-arms the hammer to bid_time + hammer_window). out[] is exactly at_resolve's (out[3]=close_time). 37func rt_resolve(opening: i64, increment: i64, reserve: i64, start: i64, hammer_window: i64, bidder: *i64, amount: *i64, time: *i64, n: i64, out: *i64) -> i64 { 38 at_resolve(opening, increment, reserve, start, start + hammer_window, hammer_window, hammer_window, bidder, amount, time, n, out) 39 return 0 40} 41 42func main() -> i64 { 43 let bidder: *i64 = sys_mmap(8 * 16) as *i64 44 let amount: *i64 = sys_mmap(8 * 16) as *i64 45 let time: *i64 = sys_mmap(8 * 16) as *i64 46 let out: *i64 = sys_mmap(8 * 8) as *i64 47 48 // --- Scenario A: live ascending, hammer_window=10, start=100 (initial close 110) --- 49 bidder[0]=1; amount[0]=RT_MAGIC_900000; time[0]=102 // accept high=RT_MAGIC_900000; close 110->112 50 bidder[1]=2; amount[1]=RT_MAGIC_925000; time[1]=108 // accept high=RT_MAGIC_925000; close ->118 51 bidder[2]=1; amount[2]=RT_MAGIC_950000; time[2]=116 // accept high=RT_MAGIC_950000; close ->126 52 bidder[3]=2; amount[3]=RT_MAGIC_1000000; time[3]=124 // accept high=RT_MAGIC_1000000; close ->134 53 bidder[4]=1; amount[4]=RT_MAGIC_1010000; time[4]=145 // REJECT: fallow gap (last bid 124, hammer fell at 134) 54 rt_resolve(RT_MAGIC_900000, RT_MAGIC_25000, RT_MAGIC_1000000, 100, 10, bidder, amount, time, 5, out) 55 let aw: i64 = out[0]; let ap: i64 = out[1]; let as_: i64 = out[2]; let aclose: i64 = out[3]; let aacc: i64 = out[4]; let arej: i64 = out[5] 56 57 // --- Control C: identical bids, hammer_window=0 -> initial close = start+0 = 100, so EVERY bid (all at 58 // t>100) lands after the instant hammer and is rejected -> nothing sells. Proves the live window is 59 // what enables the whole channel (with it: SOLD; without it: NO-SALE). --- 60 bidder[0]=1; amount[0]=RT_MAGIC_900000; time[0]=102 61 bidder[1]=2; amount[1]=RT_MAGIC_925000; time[1]=108 62 bidder[2]=1; amount[2]=RT_MAGIC_950000; time[2]=116 63 bidder[3]=2; amount[3]=RT_MAGIC_1000000; time[3]=124 64 bidder[4]=1; amount[4]=RT_MAGIC_1010000; time[4]=145 65 rt_resolve(RT_MAGIC_900000, RT_MAGIC_25000, RT_MAGIC_1000000, 100, 0, bidder, amount, time, 5, out) 66 let cw: i64 = out[0]; let cs: i64 = out[2]; let cclose: i64 = out[3]; let cacc: i64 = out[4] 67 68 // --- assertions (tight, hand-computed) --- 69 var ok: i64 = 1 70 // A: live bids ratchet the close 110->134, SOLD to bidder 2 @1000000, fallow-gap bid rejected 71 if aw != 2 { ok = 0 } 72 if ap != RT_MAGIC_1000000 { ok = 0 } 73 if as_ != AT_SOLD { ok = 0 } 74 if aclose != 134 { ok = 0 } 75 if aacc != 4 { ok = 0 } 76 if arej != 1 { ok = 0 } 77 // C: no hammer window -> close=100, all bids land after the instant hammer -> 0 accepted, NO-SALE 78 if cw != 0 { ok = 0 } 79 if cs != AT_NOSALE { ok = 0 } 80 if cclose != 100 { ok = 0 } 81 if cacc != 0 { ok = 0 } 82 if cw == aw { ok = 0 } // control MUST differ from the positive scenario (rule-sensitivity) 83 84 rt_w(1, "REALTIMEGATE engine=nx_auction_realtime A{winner=" as *u8); rt_wn(1, aw) 85 rt_w(1, " price=" as *u8); rt_wn(1, ap); rt_w(1, " status=" as *u8); rt_wn(1, as_) 86 rt_w(1, " close=" as *u8); rt_wn(1, aclose); rt_w(1, " acc=" as *u8); rt_wn(1, aacc) 87 rt_w(1, " rej=" as *u8); rt_wn(1, arej) 88 rt_w(1, "} ctrlC(no-hammer){winner=" as *u8); rt_wn(1, cw); rt_w(1, " status=" as *u8); rt_wn(1, cs) 89 rt_w(1, " close=" as *u8); rt_wn(1, cclose); rt_w(1, "}" as *u8) 90 if ok == 1 { rt_w(1, " verdict=GREEN\n" as *u8) } else { rt_w(1, " verdict=RED\n" as *u8) } 91 92 let lf: i64 = sys_openat_append(RT_LOG, 420) 93 if lf >= 0 { 94 rt_w(lf, "REALTIMEGATE engine=nx_auction_realtime A{winner=" as *u8); rt_wn(lf, aw) 95 rt_w(lf, " price=" as *u8); rt_wn(lf, ap); rt_w(lf, " close=" as *u8); rt_wn(lf, aclose) 96 rt_w(lf, " acc=" as *u8); rt_wn(lf, aacc); rt_w(lf, " rej=" as *u8); rt_wn(lf, arej) 97 rt_w(lf, "} ctrlC{winner=" as *u8); rt_wn(lf, cw); rt_w(lf, " status=" as *u8); rt_wn(lf, cs) 98 rt_w(lf, " close=" as *u8); rt_wn(lf, cclose); rt_w(lf, "}" as *u8) 99 if ok == 1 { rt_w(lf, " verdict=GREEN\n" as *u8) } else { rt_w(lf, " verdict=RED\n" as *u8) } 100 sys_close(lf) 101 } 102 103 if ok == 1 { return 0 } 104 return 1 105}