code wiki / (root) / nx_arxiv_census_lib.nx

nx_arxiv_census_lib.nx source

↩ module page · 52 lines · 2834 B

1// nx_arxiv_census_lib.nx -- THE DECISION CORE for the arXiv population census, extracted so that the CLI and 2// its gate drive the SAME arithmetic in-process and cannot disagree by discipline. The estate has measured 3// what happens when two organs must agree and coordinate by hand, so there is exactly one of this function. 4// 5// The question: does opensearch:totalResults reconcile against the entries actually delivered? 6// The REASON is computed first and the VERDICT is derived FROM the reason, and the human text is derived from 7// the reason too, so a verdict cannot drift away from the sentence printed beside it (message fidelity). 8// license_tier: ORIGINAL 9 10const ACV_COMPLETE: i64 = 0 11const ACV_CAPPED: i64 = 1 12const ACV_USAGE: i64 = 2 13const ACV_UNREADABLE: i64 = 3 14 15const ACR_OK: i64 = 0 // delivered == totalResults: the window is a POPULATION 16const ACR_NO_TOTAL: i64 = 1 // totalResults absent from the body 17const ACR_OVER: i64 = 2 // delivered > totalResults: the two counters disagree 18const ACR_LOCAL_CAP: i64 = 3 // delivered hit THIS organ's slot cap, so the count is a floor 19const ACR_REMOTE_CAP: i64 = 4 // max_results delivered fewer entries than the population 20 21// total: opensearch:totalResults, or negative when absent. nd: entries delivered. maxd: this organ's slot cap. 22func ac_reason(total: i64, nd: i64, maxd: i64) -> i64 { 23 if total<0 { return ACR_NO_TOTAL } 24 if nd>total { return ACR_OVER } 25 if nd>=maxd { return ACR_LOCAL_CAP } 26 if nd<total { return ACR_REMOTE_CAP } 27 return ACR_OK 28} 29 30func ac_verdict_of_reason(r: i64) -> i64 { 31 if r==ACR_OK { return ACV_COMPLETE } 32 if r==ACR_LOCAL_CAP { return ACV_CAPPED } 33 if r==ACR_REMOTE_CAP { return ACV_CAPPED } 34 return ACV_UNREADABLE 35} 36 37func ac_verdict(total: i64, nd: i64, maxd: i64) -> i64 { return ac_verdict_of_reason(ac_reason(total, nd, maxd)) } 38 39func ac_reason_text(r: i64) -> *u8 { 40 if r==ACR_OK { return "delivered reconciles exactly against totalResults, so this window is a POPULATION and an absence claim over it is sound" as *u8 } 41 if r==ACR_NO_TOTAL { return "totalResults absent from the body -- the feed shape changed or this is not an arXiv Atom listing" as *u8 } 42 if r==ACR_OVER { return "delivered EXCEEDS totalResults -- the two counters disagree, so neither is trustworthy here" as *u8 } 43 if r==ACR_LOCAL_CAP { return "delivered hit this organ's OWN slot cap, so the count is a FLOOR and not a census" as *u8 } 44 return "max_results delivered fewer entries than the population -- raise max_results and re-run; ABSENCE OVER THIS WINDOW IS UNPROVEN" as *u8 45} 46 47func ac_verdict_text(v: i64) -> *u8 { 48 if v==ACV_COMPLETE { return "COMPLETE" as *u8 } 49 if v==ACV_CAPPED { return "CAPPED" as *u8 } 50 if v==ACV_USAGE { return "USAGE" as *u8 } 51 return "UNREADABLE" as *u8 52}