nx_civicmap_lib.nx
buildroot/runtime/nx_civicmap_lib.nx
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
imports: nx_syscalls.nxnx_itoa_lib.nxnx_estate_path.nxnx_geo_join.nx
imported by: nx_civicmap.nxnx_civicmap_gate.nx
structs
| none |
consts
| 43 | const CM_PIPE: i64 = 124 |
| 44 | const CM_NL: i64 = 10 |
| 45 | const CM_DASH: i64 = 45 |
| 46 | const CM_COMMA: i64 = 44 |
| 47 | const CM_SPACE: i64 = 32 |
| 48 | const CM_PATHCAP: i64 = 1024 |
| 49 | const CM_MODE_644: i64 = 420 |
| 50 | const CM_PROVCAP: i64 = 65536 |
| 53 | const CM_ADMIT: i64 = 0 |
| 54 | const CM_REF_FIELDS: i64 = 1 |
| 55 | const CM_REF_KEY: i64 = 2 |
| 56 | const CM_REF_URL: i64 = 3 |
| 57 | const CM_REF_LICENCE: i64 = 4 |
| 58 | const CM_REF_RES: i64 = 5 |
| 59 | const CM_REF_CADENCE: i64 = 6 |
| 60 | const CM_REF_MIRROR: i64 = 7 |
| 63 | const CM_LF_KEY: i64 = 1 |
| 64 | const CM_LF_TITLE: i64 = 2 |
| 65 | const CM_LF_URL: i64 = 3 |
| 66 | const CM_LF_LICENCE: i64 = 4 |
| 67 | const CM_LF_RES: i64 = 5 |
| 68 | const CM_LF_CADENCE: i64 = 6 |
| 69 | const CM_LF_MIRROR: i64 = 7 |
| 70 | const CM_LF_MIN: i64 = 8 |
| 73 | const CM_CF_FIPS: i64 = 1 |
| 74 | const CM_CF_NAME: i64 = 2 |
| 75 | const CM_CF_STATE: i64 = 3 |
| 76 | const CM_CF_RING: i64 = 4 |
| 77 | const CM_CF_MIN: i64 = 5 |
| 80 | const CM_VF_LAYER: i64 = 1 |
| 81 | const CM_VF_FIPS: i64 = 2 |
| 82 | const CM_VF_VAL: i64 = 3 |
| 83 | const CM_VF_MIN: i64 = 4 |
| 88 | const CM_V_PRESENT: i64 = 0 |
| 89 | const CM_V_SUPPRESSED: i64 = 1 |
| 90 | const CM_V_ABSENT: i64 = 2 |
| 94 | const CM_V_REJECTED: i64 = 3 |
| 96 | const CM_BUCKETS: i64 = 5 |
| 99 | const CM_MIN_BYTES_PER_VERTEX: i64 = 4 |
| 100 | const CM_SCRATCH: i64 = 64 |
| 103 | const CM_CTX_BYTES: i64 = 128 |
| 104 | const CM_CTX_NC: i64 = 4 |
| 105 | const CM_CTX_POOLUSED: i64 = 5 |
| 106 | const CM_CTX_SEEN: i64 = 6 |
| 107 | const CM_CTX_D_SHAPE: i64 = 7 |
| 108 | const CM_CTX_D_FIPS: i64 = 8 |
| 109 | const CM_CTX_D_RING: i64 = 9 |
| 110 | const CM_CTX_D_SHORT: i64 = 10 |
| 111 | const CM_CTX_D_CAP: i64 = 11 |
| 112 | const CM_H: i64 = 900 |
| 113 | const CM_ASPECT_NUM: i64 = 780 |
| 114 | const CM_ASPECT_DEN: i64 = 1000 |
| 115 | const CM_W_MIN: i64 = 200 |
| 116 | const CM_W_MAX: i64 = 2400 |
| 664 | const CM_AX_KEY: i64 = 1 |
| 665 | const CM_AX_TITLE: i64 = 2 |
| 666 | const CM_AX_DIR: i64 = 3 |
| 667 | const CM_AX_WEIGHT: i64 = 4 |
| 668 | const CM_AX_MIN: i64 = 5 |
| 669 | const CM_OB_FIPS: i64 = 1 |
| 670 | const CM_OB_AXIS: i64 = 2 |
| 671 | const CM_OB_VAL: i64 = 3 |
| 672 | const CM_OB_MIN: i64 = 4 |
| 673 | const CM_DIR_HIGHER: i64 = 0 |
| 674 | const CM_DIR_LOWER: i64 = 1 |
| 675 | const CM_PERMIL: i64 = 1000 |
| 677 | const CM_IX_SCORE: i64 = 0 |
| 678 | const CM_IX_OBSERVED: i64 = 1 |
| 679 | const CM_IX_DECLARED: i64 = 2 |
| 680 | const CM_IX_WEIGHT: i64 = 3 |
| 681 | const CM_IX_MEASURED: i64 = 4 |
| 682 | const CM_IX_BADAXIS: i64 = 5 |
| 683 | const CM_IX_SLOTS: i64 = 8 |
| 684 | const CM_IX_BYTES: i64 = 64 |
| 860 | const CM_SL_FIPS: i64 = 1 |
| 861 | const CM_SL_PRICE: i64 = 2 |
| 862 | const CM_SL_ACRES: i64 = 3 |
| 863 | const CM_SL_MIN: i64 = 4 |
| 864 | const CM_MILLI: i64 = 1000 |
| 869 | const CM_AT_INSIDE: i64 = 0 |
| 870 | const CM_AT_ABOVE: i64 = 1 |
| 871 | const CM_AT_BELOW: i64 = 2 |
| 872 | const CM_AT_ND: i64 = 3 |
| 873 | const CM_AT_THIN: i64 = 4 |
| 874 | const CM_AT_BADINPUT: i64 = 5 |
| 875 | const CM_AT_TRUNC: i64 = 6 |
| 877 | const CM_AT_V: i64 = 0 |
| 878 | const CM_AT_PA: i64 = 1 |
| 879 | const CM_AT_LO: i64 = 2 |
| 880 | const CM_AT_HI: i64 = 3 |
| 881 | const CM_AT_MED: i64 = 4 |
| 882 | const CM_AT_N: i64 = 5 |
| 883 | const CM_AT_DROP_NOACRE: i64 = 6 |
| 884 | const CM_AT_DROP_CAP: i64 = 7 |
| 885 | const CM_AT_SLOTS: i64 = 8 |
| 886 | const CM_AT_BYTES: i64 = 64 |
functions
| 118 | func 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 } |
| 119 | func cm_n(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 120 | func cm_span(fd: i64, buf: *u8, s: i64, e: i64) -> i64 |
| 128 | func cm_to(buf: *u8, i: i64, lim: i64, d: i64) -> i64 |
| 139 | func cm_nfields(buf: *u8, s: i64, e: i64) -> i64 |
| 151 | func cm_fld(buf: *u8, s: i64, e: i64, idx: i64, out: *i64) -> i64 |
| 167 | func cm_empty(buf: *u8, s: i64, e: i64) -> i64 |
| 180 | func cm_starts(buf: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 190 | func cm_eqlit(buf: *u8, s: i64, e: i64, lit: *u8) -> i64 |
| 198 | func cm_int(buf: *u8, s: i64, e: i64) -> i64 |
| 217 | func cm_layer_admit(buf: *u8, s: i64, e: i64, f: *i64) -> i64 called by 4: cm_do_admitcm_do_emitcg_admit_litmain calls 5: cm_nfieldscm_fldcm_emptycm_startscm_eqlit |
| 236 | func cm_refuse_name(code: i64) -> *u8 called by 1: cm_do_admit |
| 253 | func cm_fips_parse(buf: *u8, s: i64, e: i64) -> i64 |
| 264 | func cm_fips_index(fipstab: *i64, ncounty: i64, fips: i64) -> i64 called by 1: cm_do_emit |
| 273 | func cm_fips_join(pts: *i64, npts: i64, pool: *i64, off: *i64, cnt: *i64, npolys: i64, fipstab: *i64, out: *i64) -> i64 |
| 297 | func cm_px(lon: i64, lonmin: i64, lonrange: i64, w: i64) -> i64 called by 1: cm_emit_poly |
| 303 | func cm_py(lat: i64, latmax: i64, latrange: i64, h: i64) -> i64 called by 1: cm_emit_poly |
| 309 | func cm_bucket(v: i64, lo: i64, hi: i64) -> i64 called by 1: cm_emit_poly |
| 320 | func cm_color(b: i64) -> *u8 called by 1: cm_emit_poly |
| 328 | func cm_state_name(st: i64) -> *u8 called by 1: cm_emit_poly |
| 333 | func cm_state_reason(st: i64) -> *u8 |
| 342 | func cm_emit_poly(fd: i64, pool: *i64, base: i64, npts: i64, pj: *i64, fips: i64, val: i64, st: i64) -> i64 |
| 377 | func 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 |
| 432 | func cm_parse_ring(buf: *u8, s: i64, e: i64, pool: *i64, pooln: *i64, maxpts: i64) -> i64 |
| 453 | func cm_cat(d: *u8, o: i64, s: *u8, cap: i64) -> i64 |
| 465 | func cm_cat_span(d: *u8, o: i64, src: *u8, s: i64, e: i64, cap: i64) -> i64 |
| 498 | func cm_count_lines(buf: *u8, n: i64) -> i64 |
| 508 | func cm_load_counties(path: *u8, ctx: *i64) -> i64 |
| 599 | func cm_load_report(fd: i64, ctx: *i64) -> i64 |
| 631 | func cm_eqspan(a: *u8, a0: i64, a1: i64, b: *u8, b0: i64, b1: i64) -> i64 |
| 689 | func cm_orient(v: i64, dir: i64) -> i64 |
| 700 | func cm_qol_index(abuf: *u8, an: i64, obuf: *u8, on: i64, fips: i64, f: *i64, out: *i64) -> i64 |
| 808 | func cm_index_print(fd: i64, fips: i64, out: *i64) -> i64 |
| 891 | func cm_per_acre(price: i64, acres_milli: i64) -> i64 |
| 898 | func cm_is_nondisclosure(nbuf: *u8, nn: i64, st: *u8, stlen: i64) -> i64 |
| 927 | func cm_acre_samples(sbuf: *u8, sn: i64, fips: i64, f: *i64, out: *i64, cap: i64, drops: *i64) -> i64 |
| 978 | func cm_pctl(sorted: *i64, n: i64, permil: i64) -> i64 |
| 988 | func cm_acre_truth(sbuf: *u8, sn: i64, nbuf: *u8, nn: i64, fips: i64, st: *u8, stlen: i64, |
| 1040 | func cm_acre_verdict_name(v: i64) -> *u8 |
| 1050 | func cm_acre_print(fd: i64, v: i64, out: *i64) -> i64 |