nx_srcreg_lib.nx
buildroot/runtime/nx_srcreg_lib.nx
about
nx_srcreg_lib.nx -- THE ONE READER FOR THE RESEARCH SOURCE REGISTRY (knowledge/research_sources.conf).
Operator 2026-09-06: "we need to measure and make sure we never have any unreachable data whether by search or api
we need to be able to gather it all" and "a regular cadence for all domains without smashing our nas resources".
The registry is the POPULATION every reach and coverage number on /compare/researchreach is measured over, so a
reader that silently drops a row it cannot parse under-reports coverage in the FLATTERING direction. This lib
refuses a bad row BY NAME instead, and its partition must sum to the rows seen.
THE DATA (rows in knowledge/research_sources.conf, pipe-separated, NO pipe inside a field):
src|<key>|<kind>|<protocol>|<base-url>|<pace_ms>|<auth>|<licence>|<note>
kind forge | preprint | index | publisher | government | repository | registry
protocol oai-pmh | atom-api | rest-json | graphql | sitemap | html
pace_ms MINIMUM milliseconds between two requests to THIS host. Per-source and not global, because a shared
budget starves the slow hosts first.
THE STATES, per row:
OK nine fields, a declared kind, a declared protocol, a positive integer pace
BAD-FIELDS fewer than nine fields -- the row cannot be read, and is NOT silently skipped
BAD-KIND a kind outside the declared vocabulary
BAD-PROTO a protocol outside the declared vocabulary
BAD-PACE a pace that is not all digits, or is zero or negative
A row belongs to exactly ONE bucket and rows = ok + bad_fields + bad_kind + bad_proto + bad_pace must SUM.
The vocabularies are CLOSED on purpose: an unknown protocol must REFUSE rather than default to the permissive
value, because a mistyped protocol that falls through to a default is a silent downgrade of a fail-closed row.
COMPOSES, never re-implements: sys_read_file (sizes its buffer from the file and cannot short-read, so there is
no cap to reach in silence here).
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_srcreach.nxnx_srcreach_gate.nx
structs
| none |
consts
| 31 | const SR_PIPE: i64 = 124 |
| 32 | const SR_NL: i64 = 10 |
| 33 | const SR_DIGIT0: i64 = 48 |
| 34 | const SR_DIGIT9: i64 = 57 |
| 35 | const SR_I64: i64 = 8 |
| 36 | const SR_NONE: i64 = 0 - 1 |
| 37 | const SR_ROW_TAG: *u8 = "src|" |
| 38 | const SR_MIN_FIELDS: i64 = 9 |
| 41 | const SR_F_KEY: i64 = 1 |
| 42 | const SR_F_KIND: i64 = 2 |
| 43 | const SR_F_PROTO: i64 = 3 |
| 44 | const SR_F_URL: i64 = 4 |
| 45 | const SR_F_PACE: i64 = 5 |
| 46 | const SR_F_AUTH: i64 = 6 |
| 47 | const SR_F_LICENCE: i64 = 7 |
| 48 | const SR_F_NOTE: i64 = 8 |
| 54 | const SR_F_PROBE_PATH: i64 = 9 |
| 57 | const SR_S_OK: i64 = 0 |
| 58 | const SR_S_BAD_FIELDS: i64 = 1 |
| 59 | const SR_S_BAD_KIND: i64 = 2 |
| 60 | const SR_S_BAD_PROTO: i64 = 3 |
| 61 | const SR_S_BAD_PACE: i64 = 4 |
| 64 | const SR_C_ROWS: i64 = 0 |
| 65 | const SR_C_OK: i64 = 1 |
| 66 | const SR_C_BAD_FIELDS: i64 = 2 |
| 67 | const SR_C_BAD_KIND: i64 = 3 |
| 68 | const SR_C_BAD_PROTO: i64 = 4 |
| 69 | const SR_C_BAD_PACE: i64 = 5 |
| 70 | const SR_C_N: i64 = 6 |
| 73 | const SR_EXIT_OK: i64 = 0 |
| 74 | const SR_EXIT_BAD: i64 = 1 |
| 75 | const SR_EXIT_USAGE: i64 = 2 |
| 76 | const SR_EXIT_NOREG: i64 = 3 |
functions
| 78 | func sr_slen(s: *u8) -> i64 |
| 85 | func sr_line_end(buf: *u8, n: i64, p: i64) -> i64 |
| 96 | func sr_line_starts(buf: *u8, p: i64, e: i64, tag: *u8) -> i64 |
| 107 | func sr_field(buf: *u8, p: i64, e: i64, k: i64, off: *i64) -> i64 |
| 124 | func sr_field_count(buf: *u8, p: i64, e: i64) -> i64 called by 1: sr_classify |
| 135 | func sr_span_eq(buf: *u8, a: i64, len: i64, lit: *u8) -> i64 |
| 146 | func sr_is_digit(b: u8) -> i64 called by 1: sr_atoi_span |
| 153 | func sr_atoi_span(buf: *u8, a: i64, len: i64) -> i64 |
| 166 | func sr_kind_id(buf: *u8, a: i64, len: i64) -> i64 |
| 179 | func sr_proto_id(buf: *u8, a: i64, len: i64) -> i64 |
| 189 | func sr_state_name(s: i64) -> *u8 called by 1: main |
| 198 | func sr_kind_name(k: i64) -> *u8 |
| 211 | func sr_load(path: *u8, out_len: *i64) -> *u8 |
| 217 | func sr_count_rows(buf: *u8, n: i64) -> i64 |
| 230 | func sr_classify(buf: *u8, n: i64, off: *i64, st: *i64, pace: *i64, kind: *i64, c: *i64) -> i64 |
| 277 | func sr_partition_sum(c: *i64) -> i64 |
| 281 | func sr_verdict(c: *i64) -> i64 |
| 288 | func sr_verdict_name(v: i64) -> *u8 called by 1: main |