code wiki / (root) / nx_barfresh_lib.nx

nx_barfresh_lib.nx

buildroot/runtime/nx_barfresh_lib.nx

18831 B403 linesdepth 3pulls 4 transitivereach 137 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_barfresh_lib.nx -- THE ONE RULER FOR BAR AGE ON A /compare BOARD: a bar is the CURRENT MONTH'S, or it is refused. Operator 2026-09-06, verbatim: "make sure its a hard fail to use anything less than current month unless there is nothing current month for these what does x month of x year say is sota" and "this needs to become the way that the logic forces you from the /compare domain and nishi estate as youve invested significantly in 12 year old tech". Measured cost the same day: the intelmine ladder (a tagger, a parser, a clusterer, a CRF, an embedding reader) climbed for a day toward the SemEval-2014 winners' F1 because that paper was the one source the domain had mirrored and the bar carried no month. Nothing in the estate asked how old the bar was: nx_capsearch and nx_spendgate guard ORGAN duplication, nx_sota_status guards CLAIM binding, and bar AGE had no ruler. This lib is that ruler. It is composed by nx_compare_rank, so a stale bar refuses the board's work queue instead of being remembered by a seat. THE DATA (rows in <domain>.plan, pipe-separated, NO pipe inside a field): bar|<id>|<YYYY-MM>|<subject>|<what that month says is the state of the art>|<ref key>|<note> the source MONTH of the bar and the .refs key of the listing it was read from (a mirror of the bytes read) barscan|<YYYY-MM-DD>|<ref key>|newest=<YYYY-MM>|<note> an ATTESTATION: on that date the listing at <ref key> was fetched and read, and its newest entry was in <newest>. This is the only way a bar older than the current month survives: the current month was LOOKED FOR and had nothing. THE STATES, per bar, against the current month (derived from the clock, or handed in by a gate): FRESH the bar's month IS the current month ATTESTED older, and a barscan dated THIS month for the SAME ref reports newest == the bar's month: the fallback is named, "what does <that month> say is sota" is exactly what the row carries STALE older, and a barscan dated this month for the same ref reports a NEWER month than the bar cites: the bar ignores evidence the board already holds UNATTESTED older, and no barscan dated this month for its ref: nobody looked this month. "Nothing newer" is a claim that must be re-earned every month, so this is the hard fail the operator asked for MALFORMED a month that does not parse, or a month after the current one DUPLICATE a sotabar row whose id an EARLIER sotabar row on the same plan already carries: one declaration made twice. MEASURED 2026-09-14 on search.plan: a whole intake landed twice across a transport drop (two bars, two scans, two targets, one rung id reused) and only the rung id was refused, by the plan-graph rule; two rows for one id hand every reader a coin flip, so this ruler refuses them the same way. AND PER ATTESTATION: a barscan row repeating an earlier row's date AND ref is a DUPLICATE SCAN, counted (scans_dup) and refused like a duplicate bar; two scans of one listing on DIFFERENT days are two attestations, not duplicates. THE VERDICT: FRESH (exit 0) when every bar is FRESH or ATTESTED; STALE (exit 1) when any bar is STALE, UNATTESTED, MALFORMED or DUPLICATE or any scan is a duplicate (bf_refusal_rule names WHICH, so a consumer prints the rule from this lib instead of paraphrasing it); NO-BAR (exit 3) when the plan declares no bar rows. A domain opts in by declaring its first bar; a domain that has not is LABELED by its consumers, never acquitted and never refused (a fleet-wide refusal on day one would be the permanently-red detector everyone learns to ignore). The partition bars = fresh + attested + stale + unattested + malformed is printed by every consumer and must sum. COMPOSES, never re-implements: sys_read_file (whole file, cannot short-read), sys_clock_gettime_real (the clock), civil_from_days (nx_timefmt, Hinnant) for the month of an epoch, nx_comparetree_lib for the two-tree plan path.

dependencies 3 imports · 26 importers

nx_syscalls.nx nx_timefmt.nx nx_comparetree_lib.nx nx_barfresh_lib.nx nx_barfresh.nx nx_barfresh_gate.nx nx_compare_rank.nx nx_compare_rank_artifact_20260910. nx_compare_rank_refresh_test_20260 nx_compare_shared_fit_lib_20260910 nx_costcal.nx nx_frontier_scan.nx nx_frontier_scan_review_candidate_ nx_incumbents.nx

diagram shows first 10 each side; +0 more imports, +16 more importers in the complete lists below.

imports: nx_syscalls.nxnx_timefmt.nxnx_comparetree_lib.nx

imported by: nx_barfresh.nxnx_barfresh_gate.nxnx_compare_rank.nxnx_compare_rank_artifact_20260910.nxnx_compare_rank_refresh_test_20260907.nxnx_compare_shared_fit_lib_20260910.nxnx_costcal.nxnx_frontier_scan.nxnx_frontier_scan_review_candidate_t346.nxnx_incumbents.nxnx_ladder.nxnx_ladder_gate.nxnx_ladder_lib.nxnx_lbclimb.nxnx_lbclimb_gate.nxnx_lbclimb_lib.nxnx_rungclose.nxnx_swcompare_evidence_lib_t138.nxnx_swcompare_growth_candidate_20260910.nxnx_swcompare_heading_lib_20260907.nxnx_swcompare_ladder_candidate.nxnx_swcompare_lib.nxnx_swcompare_preview_lib_t56.nxnx_swcompare_production_lib_20260907.nxnx_swcompare_release_candidate.nxnx_treatment.nx

structs

none

consts

47const BF_SECS_PER_DAY: i64 = 86400
48const BF_MONTHS_PER_YEAR: i64 = 12
49const BF_PIPE: i64 = 124
50const BF_NL: i64 = 10
51const BF_DASH: i64 = 45
52const BF_DIGIT0: i64 = 48
53const BF_DIGIT9: i64 = 57
54const BF_YM_LEN: i64 = 7 // "YYYY-MM"
55const BF_YM_YEAR_DIGITS: i64 = 4
56const BF_YM_MONTH_AT: i64 = 5
57const BF_YM_MONTH_DIGITS: i64 = 2
58const BF_YM_DASH_AT: i64 = 4
62const BF_BAR_TAG: *u8 = "sotabar|"
63const BF_SCAN_TAG: *u8 = "barscan|"
64const BF_NEWEST_TAG: *u8 = "newest="
65const BF_NEWEST_TAG_LEN: i64 = 7
66const BF_PLAN_SUFFIX: *u8 = ".plan"
67const BF_I64: i64 = 8
68const BF_CLOCK_WORDS: i64 = 2 // sys_clock_gettime_real fills seconds and nanoseconds
70const BF_F_BAR_ID: i64 = 1
71const BF_F_BAR_YM: i64 = 2
72const BF_F_BAR_SUBJECT: i64 = 3
73const BF_F_BAR_SAYS: i64 = 4
74const BF_F_BAR_REF: i64 = 5
75const BF_F_SCAN_DATE: i64 = 1
76const BF_F_SCAN_REF: i64 = 2
77const BF_F_SCAN_NEWEST: i64 = 3
79const BF_S_FRESH: i64 = 0
80const BF_S_ATTESTED: i64 = 1
81const BF_S_STALE: i64 = 2
82const BF_S_UNATTESTED: i64 = 3
83const BF_S_MALFORMED: i64 = 4
84const BF_S_DUPLICATE: i64 = 5
86const BF_EXIT_FRESH: i64 = 0
87const BF_EXIT_STALE: i64 = 1
88const BF_EXIT_NOBAR: i64 = 3
90const BF_C_BARS: i64 = 0
91const BF_C_FRESH: i64 = 1
92const BF_C_ATTESTED: i64 = 2
93const BF_C_STALE: i64 = 3
94const BF_C_UNATTESTED: i64 = 4
95const BF_C_MALFORMED: i64 = 5
96const BF_C_SCANS: i64 = 6
97const BF_C_SCANS_CUR: i64 = 7
98const BF_C_DUPLICATE: i64 = 8 // sotabar rows whose id an earlier row already carries (state DUPLICATE)
99const BF_C_SCANS_DUP: i64 = 9 // barscan rows repeating an earlier row's date AND ref
100const BF_C_N: i64 = 10
101const BF_NONE: i64 = 0 - 1

functions

103func bf_slen(s: *u8) -> i64
110func bf_line_end(buf: *u8, n: i64, p: i64) -> i64
122func bf_line_starts(buf: *u8, p: i64, e: i64, tag: *u8) -> i64
133func bf_field(buf: *u8, p: i64, e: i64, k: i64, off: *i64) -> i64
149func bf_is_digit(b: u8) -> i64
called by 1: bf_parse_ym
155func bf_ym_index(y: i64, m: i64) -> i64
158func bf_ym_year(ix: i64) -> i64
called by 2: mainbf_ym_write
161func bf_ym_month(ix: i64) -> i64
called by 2: mainbf_ym_write
166func bf_parse_ym(s: *u8, len: i64) -> i64
186func bf_parse_newest(s: *u8, len: i64) -> i64
called by 2: mainbf_classify calls 1: bf_parse_ym
194func bf_ym_of_epoch(secs: i64) -> i64
202func bf_now_ym() -> i64
210func bf_ym_write(dst: *u8, off: i64, ix: i64) -> i64
224func bf_count_rows(buf: *u8, n: i64, tag: *u8) -> i64
236func bf_span_eq(buf: *u8, o1: i64, l1: i64, o2: i64, l2: i64) -> i64
246func bf_classify(buf: *u8, n: i64, cur: i64, off: *i64, ym: *i64, st: *i64, seen: *i64, c: *i64) -> i64
349func bf_verdict(c: *i64) -> i64
362func bf_refusal_rule(c: *i64) -> *u8
called by 3: mainmainmain
371func bf_partition_sum(c: *i64) -> i64
375func bf_state_name(s: i64) -> *u8
384func bf_verdict_name(v: i64) -> *u8
393func bf_read_plan(d1: *u8, d2: *u8, dom: *u8, lenp: *i64, which: *i64) -> *u8