code wiki / (root) / nx_civicmap_lib.nx

nx_civicmap_lib.nx

buildroot/runtime/nx_civicmap_lib.nx

52235 B1069 linesdepth 3pulls 5 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_civicmap_lib.nx -- THE CIVIC QUALITY-OF-LIFE MAP, all of its judgement and none of its plumbing. /compare/civicmap rungs CM1 (cm_layer_admit), CM2 (cm_fips_join), CM3 (cm_choropleth_emit) = milestone M0, "one honest layer on a real map". Admitted 2026-08-27; this is the first organ behind those contracts. THE THESIS, and it is the whole reason this organ exists rather than a spreadsheet and a JS map library: 1. A LAYER IS A DATA ADMISSION, NEVER CODE. Source, url, licence, resolution, cadence and mirror are ROWS. cm_layer_admit REFUSES a row that cannot say its licence or name its mirror, and the refusal NAMES THE RULE THAT FIRED -- a count without a worklist is not actionable. Adding a layer is adding data; a bad layer gets better data, never a deletion (rule 25). 2. ABSENCE IS NOT ZERO. The published record this map is built from is riddled with suppression: county death counts under ten are withheld for confidentiality, and the peer-reviewed finding is that ignoring that censoring SYSTEMATICALLY UNDERSTATES rural mortality. A choropleth that paints a suppressed county with the bottom-bucket colour publishes a lie in the safest-looking direction. ★★★★★★ AN UNOBSERVABLE CELL RENDERED AS A NUMBER IS A FALSE MEASUREMENT WITH AN AUTHORITATIVE COLOUR, AND NOBODY AUDITS THE REASSURING END OF A SCALE. So a county with no observation, or a suppressed one, emits data-state='UNOBSERVABLE' WITH A NAMED REASON AND NO data-value AT ALL -- structurally incapable of being read as a quantity. That is a machine-checkable contract, and nx_civicmap_gate bites it in both directions. 3. COVERAGE PRINTS BESIDE EVERY FIGURE. counties=, present=, unobservable= and their SUM are emitted on the page and on stdout. A partition is a claim: the parts must sum, and the sum is printed. COMPOSES, NEVER RE-IMPLEMENTS: geo_spatial_join (nx_geo_join, integer-exact point-in-polygon -- the PostGIS ST_Contains staple with no float, so boundary points can be neither dropped nor double-counted) and ep_artifact_path (nx_estate_path -- a verdict that changes with the caller's working directory is not a measurement). Numbers go out through nxi_fd (zero-alloc); file reads compose sys_read_file, which sizes its buffer from the file and CANNOT short-read, so there is no cap here to guess wrong. SCOPE, STATED SO IT CANNOT BE OVERREAD: this organ renders whatever counties are ADMITTED. It has no opinion about national coverage and never claims any -- the count it loaded is the count it prints. Banking the full public-domain TIGER county set is CM2's DATA half and is deliberately not smuggled in here as a hardcoded table. LIBRARY ONLY: there is deliberately NO main() here. The verbs and argv live in nx_civicmap.nx, so nx_civicmap_gate.nx can import THIS file and exercise every rule IN-PROCESS -- no fork, no deployed binary, and therefore no gate that measures a stale artifact instead of the source under test. It is also what lets the mutation harness reach the logic: a rule behind a fork boundary has zero mutation coverage, which is a defect this estate has already paid for and filed.// license_tier: ORIGINAL No hardware writes (Rule 26).

dependencies 4 imports · 2 importers

nx_syscalls.nx nx_itoa_lib.nx nx_estate_path.nx nx_geo_join.nx nx_civicmap_lib.nx nx_civicmap.nx nx_civicmap_gate.nx

imports: nx_syscalls.nxnx_itoa_lib.nxnx_estate_path.nxnx_geo_join.nx

imported by: nx_civicmap.nxnx_civicmap_gate.nx

structs

none

consts

43const CM_PIPE: i64 = 124
44const CM_NL: i64 = 10
45const CM_DASH: i64 = 45
46const CM_COMMA: i64 = 44
47const CM_SPACE: i64 = 32
48const CM_PATHCAP: i64 = 1024
49const CM_MODE_644: i64 = 420
50const CM_PROVCAP: i64 = 65536
53const CM_ADMIT: i64 = 0
54const CM_REF_FIELDS: i64 = 1
55const CM_REF_KEY: i64 = 2
56const CM_REF_URL: i64 = 3
57const CM_REF_LICENCE: i64 = 4
58const CM_REF_RES: i64 = 5
59const CM_REF_CADENCE: i64 = 6
60const CM_REF_MIRROR: i64 = 7
63const CM_LF_KEY: i64 = 1
64const CM_LF_TITLE: i64 = 2
65const CM_LF_URL: i64 = 3
66const CM_LF_LICENCE: i64 = 4
67const CM_LF_RES: i64 = 5
68const CM_LF_CADENCE: i64 = 6
69const CM_LF_MIRROR: i64 = 7
70const CM_LF_MIN: i64 = 8
73const CM_CF_FIPS: i64 = 1
74const CM_CF_NAME: i64 = 2
75const CM_CF_STATE: i64 = 3
76const CM_CF_RING: i64 = 4
77const CM_CF_MIN: i64 = 5
80const CM_VF_LAYER: i64 = 1
81const CM_VF_FIPS: i64 = 2
82const CM_VF_VAL: i64 = 3
83const CM_VF_MIN: i64 = 4
88const CM_V_PRESENT: i64 = 0
89const CM_V_SUPPRESSED: i64 = 1
90const CM_V_ABSENT: i64 = 2
94const CM_V_REJECTED: i64 = 3
96const CM_BUCKETS: i64 = 5
99const CM_MIN_BYTES_PER_VERTEX: i64 = 4
100const CM_SCRATCH: i64 = 64
103const CM_CTX_BYTES: i64 = 128
104const CM_CTX_NC: i64 = 4
105const CM_CTX_POOLUSED: i64 = 5
106const CM_CTX_SEEN: i64 = 6
107const CM_CTX_D_SHAPE: i64 = 7
108const CM_CTX_D_FIPS: i64 = 8
109const CM_CTX_D_RING: i64 = 9
110const CM_CTX_D_SHORT: i64 = 10
111const CM_CTX_D_CAP: i64 = 11
112const CM_H: i64 = 900
113const CM_ASPECT_NUM: i64 = 780
114const CM_ASPECT_DEN: i64 = 1000
115const CM_W_MIN: i64 = 200
116const CM_W_MAX: i64 = 2400
664const CM_AX_KEY: i64 = 1
665const CM_AX_TITLE: i64 = 2
666const CM_AX_DIR: i64 = 3
667const CM_AX_WEIGHT: i64 = 4
668const CM_AX_MIN: i64 = 5
669const CM_OB_FIPS: i64 = 1
670const CM_OB_AXIS: i64 = 2
671const CM_OB_VAL: i64 = 3
672const CM_OB_MIN: i64 = 4
673const CM_DIR_HIGHER: i64 = 0
674const CM_DIR_LOWER: i64 = 1
675const CM_PERMIL: i64 = 1000
677const CM_IX_SCORE: i64 = 0
678const CM_IX_OBSERVED: i64 = 1
679const CM_IX_DECLARED: i64 = 2
680const CM_IX_WEIGHT: i64 = 3
681const CM_IX_MEASURED: i64 = 4
682const CM_IX_BADAXIS: i64 = 5
683const CM_IX_SLOTS: i64 = 8
684const CM_IX_BYTES: i64 = 64
860const CM_SL_FIPS: i64 = 1
861const CM_SL_PRICE: i64 = 2
862const CM_SL_ACRES: i64 = 3
863const CM_SL_MIN: i64 = 4
864const CM_MILLI: i64 = 1000
869const CM_AT_INSIDE: i64 = 0
870const CM_AT_ABOVE: i64 = 1
871const CM_AT_BELOW: i64 = 2
872const CM_AT_ND: i64 = 3
873const CM_AT_THIN: i64 = 4
874const CM_AT_BADINPUT: i64 = 5
875const CM_AT_TRUNC: i64 = 6
877const CM_AT_V: i64 = 0
878const CM_AT_PA: i64 = 1
879const CM_AT_LO: i64 = 2
880const CM_AT_HI: i64 = 3
881const CM_AT_MED: i64 = 4
882const CM_AT_N: i64 = 5
883const CM_AT_DROP_NOACRE: i64 = 6
884const CM_AT_DROP_CAP: i64 = 7
885const CM_AT_SLOTS: i64 = 8
886const CM_AT_BYTES: i64 = 64

functions

118func cm_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
119func cm_n(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
120func cm_span(fd: i64, buf: *u8, s: i64, e: i64) -> i64
called by 1: cm_do_admit calls 1: sys_write
128func cm_to(buf: *u8, i: i64, lim: i64, d: i64) -> i64
139func cm_nfields(buf: *u8, s: i64, e: i64) -> i64
151func cm_fld(buf: *u8, s: i64, e: i64, idx: i64, out: *i64) -> i64
167func cm_empty(buf: *u8, s: i64, e: i64) -> i64
180func cm_starts(buf: *u8, s: i64, e: i64, lit: *u8) -> i64
190func cm_eqlit(buf: *u8, s: i64, e: i64, lit: *u8) -> i64
198func cm_int(buf: *u8, s: i64, e: i64) -> i64
217func cm_layer_admit(buf: *u8, s: i64, e: i64, f: *i64) -> i64
236func cm_refuse_name(code: i64) -> *u8
called by 1: cm_do_admit
253func cm_fips_parse(buf: *u8, s: i64, e: i64) -> i64
called by 1: cm_do_emit calls 1: cm_int
264func cm_fips_index(fipstab: *i64, ncounty: i64, fips: i64) -> i64
called by 1: cm_do_emit
273func cm_fips_join(pts: *i64, npts: i64, pool: *i64, off: *i64, cnt: *i64, npolys: i64, fipstab: *i64, out: *i64) -> i64
297func cm_px(lon: i64, lonmin: i64, lonrange: i64, w: i64) -> i64
called by 1: cm_emit_poly
303func cm_py(lat: i64, latmax: i64, latrange: i64, h: i64) -> i64
called by 1: cm_emit_poly
309func cm_bucket(v: i64, lo: i64, hi: i64) -> i64
called by 1: cm_emit_poly
320func cm_color(b: i64) -> *u8
called by 1: cm_emit_poly
328func cm_state_name(st: i64) -> *u8
called by 1: cm_emit_poly
333func cm_state_reason(st: i64) -> *u8
called by 2: maincm_emit_poly
342func cm_emit_poly(fd: i64, pool: *i64, base: i64, npts: i64, pj: *i64, fips: i64, val: i64, st: i64) -> i64
377func cm_choropleth_emit(outpath: *u8, pool: *i64, off: *i64, cnt: *i64, fipstab: *i64, val: *i64, st: *i64, npolys: i64, pj: *i64, title: *u8, prov: *u8, provn: i64) -> i64
432func cm_parse_ring(buf: *u8, s: i64, e: i64, pool: *i64, pooln: *i64, maxpts: i64) -> i64
453func cm_cat(d: *u8, o: i64, s: *u8, cap: i64) -> i64
465func cm_cat_span(d: *u8, o: i64, src: *u8, s: i64, e: i64, cap: i64) -> i64
498func cm_count_lines(buf: *u8, n: i64) -> i64
508func cm_load_counties(path: *u8, ctx: *i64) -> i64
599func cm_load_report(fd: i64, ctx: *i64) -> i64
631func cm_eqspan(a: *u8, a0: i64, a1: i64, b: *u8, b0: i64, b1: i64) -> i64
689func cm_orient(v: i64, dir: i64) -> i64
700func cm_qol_index(abuf: *u8, an: i64, obuf: *u8, on: i64, fips: i64, f: *i64, out: *i64) -> i64
808func cm_index_print(fd: i64, fips: i64, out: *i64) -> i64
891func cm_per_acre(price: i64, acres_milli: i64) -> i64
898func cm_is_nondisclosure(nbuf: *u8, nn: i64, st: *u8, stlen: i64) -> i64
927func cm_acre_samples(sbuf: *u8, sn: i64, fips: i64, f: *i64, out: *i64, cap: i64, drops: *i64) -> i64
978func cm_pctl(sorted: *i64, n: i64, permil: i64) -> i64
988func cm_acre_truth(sbuf: *u8, sn: i64, nbuf: *u8, nn: i64, fips: i64, st: *u8, stlen: i64,
1040func cm_acre_verdict_name(v: i64) -> *u8
1050func cm_acre_print(fd: i64, v: i64, out: *i64) -> i64