code wiki / (root) / nx_tsv.nx

nx_tsv.nx

buildroot/runtime/nx_tsv.nx

7583 B235 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic tsv
docsdependenciesstructsconstsfunctions

about

tsv.nx -- Tab-separated values reader + writer. The "database format" for sovereign apps that don't yet have a SQLite binding (per ROADMAP P8). Append-only files, one per entity (people.tsv, obligations.tsv, interactions.tsv). Reads are linear scans; writes are fwrite-append at end. Format (RFC 4180 TSV variant, simpler than CSV): - Fields separated by TAB (0x09) - Rows separated by LF (0x0A) - No field-level quoting -- TAB and LF inside fields escaped via \t and \n (our convention; not RFC 4180) - Leading #-comment rows skipped by the reader Not designed for megabyte-scale; linear scans are O(n). Fine at the ~1k-record scale that CLAUDE.md rule #1 (Schema First) implies for a CRM/ops app's first iteration. Invariants: TSV1 Round-trip exact for any row whose fields don't contain raw TAB or LF. Fields with TAB/LF are lossy unless caller pre-escapes via tsv_escape_field. TSV2 Comment rows (# at start-of-line) never contribute fields to row callbacks. TSV3 Trailing newline on the file is tolerated; absence is also fine. TSV4 Reader is streaming: processes byte-by-byte without buffering whole rows. Safe on arbitrarily-long files.

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_fs.nx nx_tsv.nx

imports: nx_syscalls.nxnx_fs.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap tsv_write_field tsv_end_row tsv_scan_field

structs

none

consts

none

functions

57func tsv_scan_field(buf: *u8, len: i64, pos: *i64,
called by 1: main
86func tsv_skip_comment(buf: *u8, len: i64, pos: i64) -> i64
102func tsv_write_field(out: *u8, pos: *i64, cap: i64,
called by 1: main
124func tsv_end_row(out: *u8, pos: *i64, cap: i64) -> i64
called by 1: main
137func tsv_escape_field(in_bytes: *u8, n: i64,
170func tsv_unescape_field(in_bytes: *u8, n: i64,
210func main() -> i64