code wiki / (root) / nx_srcreg_lib.nx

nx_srcreg_lib.nx

buildroot/runtime/nx_srcreg_lib.nx

11347 B293 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_srcreg_lib.nx nx_srcreach.nx nx_srcreach_gate.nx

imports: nx_syscalls.nx

imported by: nx_srcreach.nxnx_srcreach_gate.nx

structs

none

consts

31const SR_PIPE: i64 = 124
32const SR_NL: i64 = 10
33const SR_DIGIT0: i64 = 48
34const SR_DIGIT9: i64 = 57
35const SR_I64: i64 = 8
36const SR_NONE: i64 = 0 - 1
37const SR_ROW_TAG: *u8 = "src|"
38const SR_MIN_FIELDS: i64 = 9
41const SR_F_KEY: i64 = 1
42const SR_F_KIND: i64 = 2
43const SR_F_PROTO: i64 = 3
44const SR_F_URL: i64 = 4
45const SR_F_PACE: i64 = 5
46const SR_F_AUTH: i64 = 6
47const SR_F_LICENCE: i64 = 7
48const SR_F_NOTE: i64 = 8
54const SR_F_PROBE_PATH: i64 = 9
57const SR_S_OK: i64 = 0
58const SR_S_BAD_FIELDS: i64 = 1
59const SR_S_BAD_KIND: i64 = 2
60const SR_S_BAD_PROTO: i64 = 3
61const SR_S_BAD_PACE: i64 = 4
64const SR_C_ROWS: i64 = 0
65const SR_C_OK: i64 = 1
66const SR_C_BAD_FIELDS: i64 = 2
67const SR_C_BAD_KIND: i64 = 3
68const SR_C_BAD_PROTO: i64 = 4
69const SR_C_BAD_PACE: i64 = 5
70const SR_C_N: i64 = 6
73const SR_EXIT_OK: i64 = 0
74const SR_EXIT_BAD: i64 = 1
75const SR_EXIT_USAGE: i64 = 2
76const SR_EXIT_NOREG: i64 = 3

functions

78func sr_slen(s: *u8) -> i64
called by 3: src_wmainsr_span_eq
85func sr_line_end(buf: *u8, n: i64, p: i64) -> i64
96func sr_line_starts(buf: *u8, p: i64, e: i64, tag: *u8) -> i64
107func sr_field(buf: *u8, p: i64, e: i64, k: i64, off: *i64) -> i64
124func sr_field_count(buf: *u8, p: i64, e: i64) -> i64
called by 1: sr_classify
135func sr_span_eq(buf: *u8, a: i64, len: i64, lit: *u8) -> i64
called by 3: mainsr_kind_idsr_proto_id calls 1: sr_slen
146func sr_is_digit(b: u8) -> i64
called by 1: sr_atoi_span
153func sr_atoi_span(buf: *u8, a: i64, len: i64) -> i64
called by 2: mainsr_classify calls 1: sr_is_digit
166func sr_kind_id(buf: *u8, a: i64, len: i64) -> i64
called by 2: mainsr_classify calls 1: sr_span_eq
179func sr_proto_id(buf: *u8, a: i64, len: i64) -> i64
called by 2: mainsr_classify calls 1: sr_span_eq
189func sr_state_name(s: i64) -> *u8
called by 1: main
198func sr_kind_name(k: i64) -> *u8
211func sr_load(path: *u8, out_len: *i64) -> *u8
called by 2: mainmain calls 1: sys_read_file
217func sr_count_rows(buf: *u8, n: i64) -> i64
called by 2: mainmain calls 2: sr_line_endsr_line_starts
230func sr_classify(buf: *u8, n: i64, off: *i64, st: *i64, pace: *i64, kind: *i64, c: *i64) -> i64
277func sr_partition_sum(c: *i64) -> i64
called by 3: mainmainsr_verdict
281func sr_verdict(c: *i64) -> i64
called by 2: mainmain calls 1: sr_partition_sum
288func sr_verdict_name(v: i64) -> *u8
called by 1: main