code wiki / (root) / nx_build_firsttry_lib.nx

nx_build_firsttry_lib.nx

buildroot/runtime/nx_build_firsttry_lib.nx

17444 B281 linesdepth 2pulls 2 transitivereach 8 importersview sourcekind librarytopic build
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_build_firsttry_lib.nx nx_build_firsttry_gate.nx nx_organ_ship.nx nx_organ_ship_loss_candidate_t370. nx_organ_ship_review_candidate_t37

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

18const BFT_DAY_S: i64 = 86400
19const BFT_DEFAULT_WINDOW_DAYS: i64 = 14 // the rung's 14-day build-rework window (GitClear's two-week churn horizon)
20const 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
21const BFT_FIELDS: i64 = 5
22const BFT_WORD: i64 = 8
23const BFT_PATH: i64 = 1024
24const BFT_LINE: i64 = 512
25const BFT_NUMBUF: i64 = 32
26const BFT_MODE644: i64 = 420
27const BFT_PERMIL: i64 = 1000
28const BFT_TAB: i64 = 9
29const BFT_NL: i64 = 10
30const BFT_ZERO: i64 = 48
31const BFT_NINE: i64 = 57
32const BFT_MINUS: i64 = 45
33const BFT_PROD_JRNL: *u8 = "knowledge/status/organ_ship.jrnl"
34const BFT_SPINE_PROD: *u8 = "knowledge/status/build_firsttry.spine"
35const BFT_SPINE_SIDECAR: *u8 = ".firsttry.spine"
36const BFT_BYTES_KEY: *u8 = "bytes="
37const BFT_UNOBSERVABLE: i64 = 0 - 1
38const BFT_VERDICT_MEASURED: i64 = 0
39const BFT_VERDICT_UNOBSERVABLE: i64 = 1
40const BFT_VERDICT_UNREADABLE: i64 = 2
41const BFT_VERDICT_LEAK: i64 = 3
43const BFT_T_OFF: i64 = 0
44const BFT_T_LEN: i64 = 1
45const BFT_T_OPEN: i64 = 2
46const BFT_T_LASTSHIP: i64 = 3
47const BFT_T_LASTBYTES: i64 = 4
48const BFT_T_SLOTS: i64 = 5
50const BFT_R_ROWS: i64 = 0
51const BFT_R_ROWS_IN: i64 = 1
52const BFT_R_EPISODES: i64 = 2
53const BFT_R_FIRST_PASS: i64 = 3
54const BFT_R_CODE_FAIL: i64 = 4
55const BFT_R_BOX_REFUSED: i64 = 5
56const BFT_R_RETRIES: i64 = 6
57const BFT_R_SHIPPED: i64 = 7
58const BFT_R_REWORK: i64 = 8
59const BFT_R_REVERT: i64 = 9
60const BFT_R_NON_REVERT: i64 = 10
61const BFT_R_REVERT_UNOBS: i64 = 11
62const BFT_R_FIRST_PERMIL: i64 = 12
63const BFT_R_REWORK_PERMIL: i64 = 13
64const BFT_R_TARGETS: i64 = 14
65const BFT_R_NEG_CLASS_ABSENT: i64 = 15
66const BFT_R_SLOTS: i64 = 16

functions

68func bft_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
69func 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 }
70func bft_catn(dst: *u8, off: i64, v: i64) -> i64
82func bft_puts(s: *u8) -> i64 { return sys_write(1, s, bft_slen(s)) }
83func 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) }
called by 1: bft_kv calls 3: sys_mmapbft_catnsys_write
84func 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
86func bft_atoi(s: *u8) -> i64
96func bft_span_eq(buf: *u8, off: i64, len: i64, s: *u8) -> i64
called by 1: bft_compute calls 1: bft_slen
102func bft_span_starts(buf: *u8, off: i64, len: i64, s: *u8) -> i64
called by 1: bft_compute calls 1: bft_slen
109func bft_span_eq_span(buf: *u8, aoff: i64, alen: i64, boff: i64, blen: i64) -> i64
called by 1: bft_compute
115func bft_span_atoi(buf: *u8, off: i64, len: i64) -> i64
called by 1: bft_compute
124func bft_span_find(buf: *u8, off: i64, len: i64, needle: *u8) -> i64
called by 1: bft_compute calls 1: bft_slen
133func bft_compute(buf: *u8, n: i64, now: i64, window_days: i64, r: *i64) -> i64
216func bft_measure(jrnl: *u8, window_days: i64, now: i64, r: *i64) -> i64
222func bft_spine_path(jrnl: *u8, out: *u8) -> i64
called by 1: bft_spine_append calls 2: bft_streqbft_cat
227func bft_verdict_name(code: i64) -> *u8
called by 1: bft_report
233func bft_kv(k: *u8, v: i64) -> i64 { bft_puts(k); bft_num(v); return 0 }
234func bft_state_name(permil: i64) -> *u8 { if permil == BFT_UNOBSERVABLE { return "UNOBSERVABLE" as *u8 } return "MEASURED" as *u8 }
called by 1: bft_report
236func bft_spine_append(jrnl: *u8, now: i64, window_days: i64, r: *i64) -> i64
262func bft_report(jrnl: *u8, window_days: i64, now: i64) -> i64