nx_build_firsttry_lib.nx
buildroot/runtime/nx_build_firsttry_lib.nx
about
nx_build_firsttry_lib.nx -- CE2 (codeeffectiveness ce_build_firsttry): THE BUILD PILLAR'S TWO RATES, READ FROM THE
SHIP JOURNAL (knowledge/status/organ_ship.jrnl, rows epoch<TAB>target<TAB>stage<TAB>verdict<TAB>detail).
FIRST-TRY: an EPISODE is a target's run of BUILD rows up to its next SHIPPED row (retries inside it are the same
episode). An episode is classified by its FIRST BUILD row: BUILT = first_pass, REFUSED-ADMIT = box_refused (the
box, not the code -- its own bucket, outside the rate's denominator), anything else = code_fail. The partition
first_pass + code_fail + box_refused = episodes is checked and printed.
REWORK: a SHIPPED row whose same-target previous SHIPPED lies within the window is a REWORK event; one carrying
bytes= smaller than its predecessor's is a REVERT (a byte decrease after an addition); a pair lacking bytes= on
either side is REVERT-UNOBSERVABLE, counted, never guessed. Rows before the window feed STATE (a predecessor ship)
but never COUNT. A window with no episode reads first_try UNOBSERVABLE and one with no ship reads rework
UNOBSERVABLE -- never 0 permil -- and a run with neither writes NO spine row (an unobservable run must not
fabricate a point on the trend). One spine row per MEASURED run, path derived from the journal (the production
spine iff the journal is the production one, else a <jrnl>.firsttry.spine sidecar), announced fd= wrote= of=.
ONE place holds the counts (the r[] slots below): the emitter, the spine and the gate read the same array.
license_tier: ORIGINAL No hw writes.
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_build_firsttry_gate.nxnx_organ_ship.nxnx_organ_ship_loss_candidate_t370.nxnx_organ_ship_review_candidate_t371.nx
structs
| none |
consts
| 18 | const BFT_DAY_S: i64 = 86400 |
| 19 | const BFT_DEFAULT_WINDOW_DAYS: i64 = 14 // the rung's 14-day build-rework window (GitClear's two-week churn horizon) |
| 20 | const BFT_MIN_ROW_B: i64 = 16 // 1<TAB>x<TAB>BUILD<TAB>BUILT<TAB>\n -- the shortest well-formed row bounds the row count from the byte count |
| 21 | const BFT_FIELDS: i64 = 5 |
| 22 | const BFT_WORD: i64 = 8 |
| 23 | const BFT_PATH: i64 = 1024 |
| 24 | const BFT_LINE: i64 = 512 |
| 25 | const BFT_NUMBUF: i64 = 32 |
| 26 | const BFT_MODE644: i64 = 420 |
| 27 | const BFT_PERMIL: i64 = 1000 |
| 28 | const BFT_TAB: i64 = 9 |
| 29 | const BFT_NL: i64 = 10 |
| 30 | const BFT_ZERO: i64 = 48 |
| 31 | const BFT_NINE: i64 = 57 |
| 32 | const BFT_MINUS: i64 = 45 |
| 33 | const BFT_PROD_JRNL: *u8 = "knowledge/status/organ_ship.jrnl" |
| 34 | const BFT_SPINE_PROD: *u8 = "knowledge/status/build_firsttry.spine" |
| 35 | const BFT_SPINE_SIDECAR: *u8 = ".firsttry.spine" |
| 36 | const BFT_BYTES_KEY: *u8 = "bytes=" |
| 37 | const BFT_UNOBSERVABLE: i64 = 0 - 1 |
| 38 | const BFT_VERDICT_MEASURED: i64 = 0 |
| 39 | const BFT_VERDICT_UNOBSERVABLE: i64 = 1 |
| 40 | const BFT_VERDICT_UNREADABLE: i64 = 2 |
| 41 | const BFT_VERDICT_LEAK: i64 = 3 |
| 43 | const BFT_T_OFF: i64 = 0 |
| 44 | const BFT_T_LEN: i64 = 1 |
| 45 | const BFT_T_OPEN: i64 = 2 |
| 46 | const BFT_T_LASTSHIP: i64 = 3 |
| 47 | const BFT_T_LASTBYTES: i64 = 4 |
| 48 | const BFT_T_SLOTS: i64 = 5 |
| 50 | const BFT_R_ROWS: i64 = 0 |
| 51 | const BFT_R_ROWS_IN: i64 = 1 |
| 52 | const BFT_R_EPISODES: i64 = 2 |
| 53 | const BFT_R_FIRST_PASS: i64 = 3 |
| 54 | const BFT_R_CODE_FAIL: i64 = 4 |
| 55 | const BFT_R_BOX_REFUSED: i64 = 5 |
| 56 | const BFT_R_RETRIES: i64 = 6 |
| 57 | const BFT_R_SHIPPED: i64 = 7 |
| 58 | const BFT_R_REWORK: i64 = 8 |
| 59 | const BFT_R_REVERT: i64 = 9 |
| 60 | const BFT_R_NON_REVERT: i64 = 10 |
| 61 | const BFT_R_REVERT_UNOBS: i64 = 11 |
| 62 | const BFT_R_FIRST_PERMIL: i64 = 12 |
| 63 | const BFT_R_REWORK_PERMIL: i64 = 13 |
| 64 | const BFT_R_TARGETS: i64 = 14 |
| 65 | const BFT_R_NEG_CLASS_ABSENT: i64 = 15 |
| 66 | const BFT_R_SLOTS: i64 = 16 |
functions
| 68 | func bft_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 69 | func bft_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } dst[o] = 0 as u8; return o } |
| 70 | func bft_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 82 | func bft_puts(s: *u8) -> i64 { return sys_write(1, s, bft_slen(s)) } |
| 83 | func bft_num(v: i64) -> i64 { let b: *u8 = sys_mmap(BFT_NUMBUF); let o: i64 = bft_catn(b, 0, v); return sys_write(1, b, o) } |
| 84 | func bft_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] == b[i] { if a[i] == (0 as u8) { return 1 } i = i + 1 } return 0 } called by 1: bft_spine_path |
| 86 | func bft_atoi(s: *u8) -> i64 |
| 96 | func bft_span_eq(buf: *u8, off: i64, len: i64, s: *u8) -> i64 |
| 102 | func bft_span_starts(buf: *u8, off: i64, len: i64, s: *u8) -> i64 |
| 109 | func bft_span_eq_span(buf: *u8, aoff: i64, alen: i64, boff: i64, blen: i64) -> i64 called by 1: bft_compute |
| 115 | func bft_span_atoi(buf: *u8, off: i64, len: i64) -> i64 called by 1: bft_compute |
| 124 | func bft_span_find(buf: *u8, off: i64, len: i64, needle: *u8) -> i64 |
| 133 | func bft_compute(buf: *u8, n: i64, now: i64, window_days: i64, r: *i64) -> i64 called by 1: bft_measure calls 7: sys_mmapbft_slenbft_span_atoibft_span_eq_spanbft_span_eqbft_span_starts+1 |
| 216 | func bft_measure(jrnl: *u8, window_days: i64, now: i64, r: *i64) -> i64 |
| 222 | func bft_spine_path(jrnl: *u8, out: *u8) -> i64 |
| 227 | func bft_verdict_name(code: i64) -> *u8 called by 1: bft_report |
| 233 | func bft_kv(k: *u8, v: i64) -> i64 { bft_puts(k); bft_num(v); return 0 } |
| 234 | func bft_state_name(permil: i64) -> *u8 { if permil == BFT_UNOBSERVABLE { return "UNOBSERVABLE" as *u8 } return "MEASURED" as *u8 } called by 1: bft_report |
| 236 | func bft_spine_append(jrnl: *u8, now: i64, window_days: i64, r: *i64) -> i64 |
| 262 | func bft_report(jrnl: *u8, window_days: i64, now: i64) -> i64 |