code wiki / (root) / nx_readcap_lib.nx

nx_readcap_lib.nx

buildroot/runtime/nx_readcap_lib.nx

4187 B84 linesdepth 2pulls 2 transitivereach 212 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_readcap_lib.nx -- THE ONE read-into-a-caller's-cap helper (dataio DI16, first cause, 2026-09-06). MEASURED before this lib existed: the io-envelope census worklist held 1,082 silent readers in 803 files, and its SHAPES table showed the top of the population was ONE helper family copied by hand -- `sys_read(fd, buf+n, cap-n)` in a loop that stops when the cap fills and never says so (x28, x22, x20, x19, x15, x13 ...). Every copy is a silent-truncation cap: the caller cannot tell "the file was exactly cap bytes" from "the cap filled and the tail is gone". This lib is the bus stop: ONE loop, ONE named state per outcome, so a consumer that adopts it has no sys_read( site of its own and the census counts it CONVERTED. States (rc_fill): RC_EOF the source ended before the cap (buf holds all of it) / RC_CAPPED the cap filled and the source was NOT probed further (a socket must not be probed: the next byte may never come) / RC_ERR a read failed (st[1] = the rc). rc_read_file_into adds the file-only refinement: after a CAPPED fill it reads ONE more byte, so RC_FULL means "TRUNCATED, more remains" and RC_EXACT means "the file was exactly cap bytes" -- the distinction the hand-rolled loops could never make. rc_state_name spells the TRUNCATED state so any consumer that prints it announces its envelope in the census's own vocabulary. Whole-file reads with no cap at all belong to sys_read_file (nx_syscalls), which sizes from the file; this lib is for the case where the BUFFER is the caller's and the cap is real (a fixed header, a bounded request line, a window). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 76 importers

nx_syscalls.nx nx_readcap_lib.nx nx_craft_affine_fit_t342.nx nx_craft_body_affine_alpha_fit_t36 nx_craft_body_fit_t138.nx nx_craft_body_semantic_alpha_fit_t nx_craft_body_winding_alpha_fit_t3 nx_craft_canonical_fit_t135.nx nx_craft_eye_fit_t138.nx nx_craft_gait_fit_t139.nx nx_craft_garment_fit_t132.nx nx_craft_hair_attachment_fit_t263.

diagram shows first 10 each side; +0 more imports, +66 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: nx_craft_affine_fit_t342.nxnx_craft_body_affine_alpha_fit_t361.nxnx_craft_body_fit_t138.nxnx_craft_body_semantic_alpha_fit_t345.nxnx_craft_body_winding_alpha_fit_t365.nxnx_craft_canonical_fit_t135.nxnx_craft_eye_fit_t138.nxnx_craft_gait_fit_t139.nxnx_craft_garment_fit_t132.nxnx_craft_hair_attachment_fit_t263.nxnx_craft_hair_attachment_fit_t283.nxnx_craft_hair_probe_fit_t280.nxnx_craft_imported_fit_t262.nxnx_craft_inspection_alpha_fit_t342.nxnx_craft_inspection_canonical_fit_t142.nxnx_craft_inspection_distance_fit_t235.nxnx_craft_inspection_fit_t142.nxnx_craft_integrated_fit_t73.nxnx_craft_length_fit_t140.nxnx_craft_material_body_fit_t61.nxnx_craft_material_fit_t55.nxnx_craft_mip_fit_t241.nxnx_craft_motion_fit_t328.nxnx_craft_move_fit_t72.nxnx_craft_person_alpha_fit_t343.nxnx_craft_pipeline_fit_t64.nxnx_craft_private_combined_fit_t28.nxnx_craft_private_combined_fit_t29.nxnx_craft_private_feedback_fit_t28.nxnx_craft_private_history_fit_t25.nxnx_craft_private_knight_fit_t25.nxnx_craft_private_page_fit_gate.nxnx_craft_private_pinned_fit_t24.nxnx_craft_private_recovery_fit_t23.nxnx_craft_private_support_fit_t31.nxnx_craft_private_water_fit_t31.nxnx_craft_procedural_review_fit_candidate_t333.nxnx_craft_rig_comparison_fit_t332.nxnx_craft_rig_inspection_fit_t230.nxnx_craft_rig_observation_fit_t331.nxnx_craft_rigview_host_fit_t341.nxnx_craft_rigview_workbench_fit_t342.nxnx_craft_scene_light_alpha_fit_t364.nxnx_craft_search_fit_t53.nxnx_craft_skin_canonical_diag_t140.nxnx_craft_skin_canonical_fit_t140.nxnx_craft_skin_fit_t138.nxnx_craft_skin_wrap_fit_t261.nxnx_craft_static_fit_t338.nxnx_craft_toon_region_fit_t143.nxnx_craft_visitors_canonical_fit_t142.nxnx_craft_visitors_fit_t140.nxnx_craft_visitors_inspection_fit_t142.nxnx_craft_visitors_lit_fit_t181.nxnx_craft_visitors_material_fit_t181.nxnx_craft_visitors_owned_fit_t219.nxnx_craft_workspace_fit_t48.nxnx_knight_bind_t24.nxnx_measurement_binding_lib.nxnx_nxa_anim_selection_gate_t30.nxnx_nxa_anim_selection_gate_t33.nxnx_nxa_bind.nxnx_nxa_bind_gate_t29.nxnx_nxa_bind_second_gate_t29.nxnx_nxa_bind_t29.nxnx_readcap_gate.nxnx_rigbench.nxnx_rigbench_motion_gate.nxnx_rigbench_motion_gate_t21.nxnx_rigbench_t21.nxnx_swarm_job.nxnx_swarm_job_evidence_t67.nxnx_swarm_pack.nxnx_swarm_pack_measured_t68.nxnx_swarm_pack_units_t70.nxnx_wasm_memory_inspect_gate.nx

structs

none

consts

22const RC_EOF: i64 = 0
23const RC_CAPPED: i64 = 1
24const RC_FULL: i64 = 2
25const RC_EXACT: i64 = 3
26const RC_ERR: i64 = 4
27const RC_PROBE_BYTES: i64 = 1 // one byte decides EXACT vs FULL; a bigger probe would only cost more and prove no more

functions

31func rc_fill(fd: i64, buf: *u8, cap: i64, st: *i64) -> i64
called by 3: pbm_readmainrc_fill_file calls 1: sys_read
49func rc_fill_file(fd: i64, buf: *u8, cap: i64, st: *i64) -> i64
62func rc_read_file_into(path: *u8, buf: *u8, cap: i64, st: *i64) -> i64
72func rc_complete(st: *i64) -> i64
78func rc_state_name(s: i64) -> *u8