code wiki / _hdl_build / nx_costest_gate.nx
nx_costest_gate.nx
buildroot/runtime/_hdl_build/nx_costest_gate.nx
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
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
structs
| none |
consts
| 14 | const G_I64: i64 = 8 |
| 15 | const G_MODE_755: i64 = 493 |
| 16 | const G_MODE_644: i64 = 420 |
| 17 | const G_DIR: *u8 = "/tmp/nx_costest_gate" |
| 18 | const G_LEDGER: *u8 = "/tmp/nx_costest_gate/costcal.ledger" |
| 19 | const G_BADLEDGER: *u8 = "/tmp/nx_costest_gate/bad.ledger" |
| 20 | const G_ABSENT: *u8 = "/tmp/nx_costest_gate/absent.ledger" |
| 21 | const G_NUM_CAP: i64 = 32 |
| 22 | const G_ROWCAP: i64 = 4096 |
| 23 | const 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" |
| 24 | const G_PLAN_RUNGS: i64 = 4 |
| 25 | const G_PLAN_LOGROWS: i64 = 9 |
| 26 | const G_PLAN_UNMATCHED: i64 = 1 |
| 27 | const G_PLAN_WITHLAND: i64 = 4 |
| 28 | const G_PLAN_CALIBRATED: i64 = 2 |
| 29 | const G_PLAN_EXCL_ZERO: i64 = 1 |
| 30 | const G_PLAN_EXCL_NOCOST: i64 = 1 |
| 31 | const G_R1_RATIO: i64 = 100 // 7200 s over 2 u = 1.00 h per u |
| 32 | const G_R2_RATIO: i64 = 500 // 27000 s over 1.5 u = 5.00 h per u |
| 33 | const G_NOPLAN: *u8 = "log|1000|R1|land|no rung rows at all\nlog|2000|R2|land|none\n" |
| 34 | const G_NOPLAN_LOGROWS: i64 = 2 |
| 35 | const G_BADCAL: *u8 = "cal|1|x|3|4|5|6|7|8|9|10|11|12|13\n" |
| 36 | const G_AGG_N: i64 = 2 |
| 37 | const G_AGG_P10: i64 = 26 // 40 - isqrt(200) |
| 38 | const G_AGG_P50: i64 = 40 |
| 39 | const G_AGG_P90: i64 = 68 // 40 + isqrt(800) |
| 40 | const G_AGG_SUM10: i64 = 20 |
| 41 | const G_AGG_SUM90: i64 = 80 |
| 43 | const 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" |
| 44 | const G_EV_FX_LANDS: i64 = 5 // R1 once, R2 twice, R3, R4; R9 is unmatched and the bad epoch writes nothing |
| 45 | const G_EV_FX_DECIU: i64 = 45 // 20 + 15 + 0 + 10 over the four distinct landed rungs |
| 46 | const G_EV_LO: i64 = 2500 |
| 47 | const G_EV_HI_INCL: i64 = 8201 // [2500, 8201) holds R3 at 3000, R4 at 4000 and R1 at 8200 |
| 48 | const G_EV_HI_EXCL: i64 = 8200 // hi is exclusive: the same window one second shorter drops R1 |
| 49 | const G_EV_ALL_HI: i64 = 100000 |
| 51 | const 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" |
| 52 | const G_WIP_OPEN: i64 = 3 |
| 53 | const G_WIP_NOW_NEAR: i64 = 1000 // W4 touched 50 s ago, W1 100 s ago, W5 950 s ago |
| 54 | const G_WIP_NOW_FAR: i64 = 5000 // everything is older than the window |
| 55 | const G_WIP_ACTIVE_S: i64 = 200 |
| 56 | const G_WIP_NEAR_CODE: i64 = 21 // active 2, stale 1, written as active * 10 + stale |
| 57 | const G_WIP_FAR_CODE: i64 = 3 // active 0, stale 3 |
| 58 | const G_WIP_OLDEST: i64 = 50 |
| 59 | const G_MINN: i64 = 4 // n=3 collides P50 and P90 at rank 1; n=4 gives ranks 0,1,2 |
functions
| 61 | func g_lit(s: *u8, dst: *u8) -> i64 |
| 68 | func g_streq(a: *u8, b: *u8) -> i64 |
| 75 | func g_contains(hay: *u8, n: i64, needle: *u8) -> i64 |
| 88 | func g_write(path: *u8, buf: *u8, n: i64) -> i64 |
| 95 | func g_deciu(lit: *u8) -> i64 |
| 101 | func main(argc: i64, argv: *i64) -> i64 |