code wiki / _hdl_build / nx_costest_gate.nx

nx_costest_gate.nx

buildroot/runtime/_hdl_build/nx_costest_gate.nx

20435 B285 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_costest_gate.nx -- GATE for the cost estimator (nx_costest_lib), driven IN-PROCESS: known-answer teeth on the integer sqrt, the deci-u parser and printers, the three-point aggregate (root-sum-square band beside the correlated sum), the quantile rank rule and the derived distinct-rank floor, the compute-cost rules, and the calibration census over planted plan rows (a rung calibrated from two journal rows, a rung whose last land row wins, a rung with no declared cost EXCLUDED BY NAME, a rung whose only row is its land row EXCLUDED BY NAME, a journal row naming no rung COUNTED, a non-integer epoch IGNORED), then the ledger line written and read back through the one grammar, a malformed ledger REFUSED and an absent one reported absent. Every fixture asserts its own condition first; the neg-controls are named. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_costest_lib.nx nx_gate_verdict.nx nx_costest_gate.nx

imports: nx_syscalls.nxnx_costest_lib.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ sys_mkdir gv_check_eq gv_check gv_puts ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap ces_isqrt g_deciu sys_mmap ↻ g_lit ces_slen ces_parse_deciu sys_mmap ↻ ces_fmt_deci ces_fmt_int sys_mmap ↻ gv_check ↻

structs

none

consts

14const G_I64: i64 = 8
15const G_MODE_755: i64 = 493
16const G_MODE_644: i64 = 420
17const G_DIR: *u8 = "/tmp/nx_costest_gate"
18const G_LEDGER: *u8 = "/tmp/nx_costest_gate/costcal.ledger"
19const G_BADLEDGER: *u8 = "/tmp/nx_costest_gate/bad.ledger"
20const G_ABSENT: *u8 = "/tmp/nx_costest_gate/absent.ledger"
21const G_NUM_CAP: i64 = 32
22const G_ROWCAP: i64 = 4096
23const G_PLAN: *u8 = "rung|R1|a|s1|d|Organ|2|-\nrung|R2|b|s2|d|Organ|1.5|-\nrung|R3|c|s3|d|Organ|-|-\nrung|R4|d|s4|d|Organ|1|-\nlog|1000|R1|queue|q\nlog|8200|R1|land|l\nlog|2000|R2|measure|m\nlog|2000|R2|land|first land\nlog|29000|R2|land|last land\nlog|3000|R3|land|no cost\nlog|4000|R4|land|only row\nlog|5000|R9|land|unmatched\nlog|bad|R1|land|a non-integer epoch\n"
24const G_PLAN_RUNGS: i64 = 4
25const G_PLAN_LOGROWS: i64 = 9
26const G_PLAN_UNMATCHED: i64 = 1
27const G_PLAN_WITHLAND: i64 = 4
28const G_PLAN_CALIBRATED: i64 = 2
29const G_PLAN_EXCL_ZERO: i64 = 1
30const G_PLAN_EXCL_NOCOST: i64 = 1
31const G_R1_RATIO: i64 = 100 // 7200 s over 2 u = 1.00 h per u
32const G_R2_RATIO: i64 = 500 // 27000 s over 1.5 u = 5.00 h per u
33const G_NOPLAN: *u8 = "log|1000|R1|land|no rung rows at all\nlog|2000|R2|land|none\n"
34const G_NOPLAN_LOGROWS: i64 = 2
35const G_BADCAL: *u8 = "cal|1|x|3|4|5|6|7|8|9|10|11|12|13\n"
36const G_AGG_N: i64 = 2
37const G_AGG_P10: i64 = 26 // 40 - isqrt(200)
38const G_AGG_P50: i64 = 40
39const G_AGG_P90: i64 = 68 // 40 + isqrt(800)
40const G_AGG_SUM10: i64 = 20
41const G_AGG_SUM90: i64 = 80
43const G_EVPLAN: *u8 = "rung|A1|a|s|d|Organ|1|-\nlog|100|A1|land|first\nlog|200|A1|retract|withdrawn\nlog|300|A1|land|again\nlog|400|A1|measure|not an event\n"
44const G_EV_FX_LANDS: i64 = 5 // R1 once, R2 twice, R3, R4; R9 is unmatched and the bad epoch writes nothing
45const G_EV_FX_DECIU: i64 = 45 // 20 + 15 + 0 + 10 over the four distinct landed rungs
46const G_EV_LO: i64 = 2500
47const G_EV_HI_INCL: i64 = 8201 // [2500, 8201) holds R3 at 3000, R4 at 4000 and R1 at 8200
48const G_EV_HI_EXCL: i64 = 8200 // hi is exclusive: the same window one second shorter drops R1
49const G_EV_ALL_HI: i64 = 100000
51const G_WIPPLAN: *u8 = "rung|W1|a|s|d|Organ|1|-\nrung|W2|b|s|d|Organ|2|-\nrung|W3|c|s|d|Organ|1|-\nrung|W4|d|s|d|Organ|1|-\nrung|W5|e|s|d|Organ|1|-\nlog|100|W1|measure|m\nlog|900|W1|queue|q\nlog|500|W2|measure|m\nlog|600|W2|land|l\nlog|950|W4|measure|m\nlog|50|W5|measure|m\n"
52const G_WIP_OPEN: i64 = 3
53const G_WIP_NOW_NEAR: i64 = 1000 // W4 touched 50 s ago, W1 100 s ago, W5 950 s ago
54const G_WIP_NOW_FAR: i64 = 5000 // everything is older than the window
55const G_WIP_ACTIVE_S: i64 = 200
56const G_WIP_NEAR_CODE: i64 = 21 // active 2, stale 1, written as active * 10 + stale
57const G_WIP_FAR_CODE: i64 = 3 // active 0, stale 3
58const G_WIP_OLDEST: i64 = 50
59const G_MINN: i64 = 4 // n=3 collides P50 and P90 at rank 1; n=4 gives ranks 0,1,2

functions

61func g_lit(s: *u8, dst: *u8) -> i64
called by 2: g_deciumain calls 1: ces_slen
68func g_streq(a: *u8, b: *u8) -> i64
called by 1: main calls 1: ces_slen
75func g_contains(hay: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: ces_slen
88func g_write(path: *u8, buf: *u8, n: i64) -> i64
95func g_deciu(lit: *u8) -> i64
called by 1: main calls 3: sys_mmapg_litces_parse_deciu
101func main(argc: i64, argv: *i64) -> i64