code wiki / (root) / nx_race_telemetry.nx

nx_race_telemetry.nx

buildroot/runtime/nx_race_telemetry.nx

30302 B775 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic race
docsdependenciesstructsconstsfunctions

about

nx_race_telemetry.nx -- SEED: substrate-native lap recorder. Replaces the bash bootstrap at bench/race_telemetry.sh for the hot path (lap recording). The bash script also handles patch/perspective/competition/tail/stats/clear -- those remain in bash until substrate-native CLI dispatch + tail/stats land. Per user directive 2026-05-15: "if we need to build our own shell and tools from the bits up lets do it" "i want nishi stack to do the work with you just initially mapping what needs to be done till it can be self sufficient" SEED scope (one responsibility, per cardinal 9): 1. Format one lap row matching the existing schema 2. Append to .race_telemetry.tsv via sys_openat_append + sys_write 3. Return bytes-written or -errno (no exceptions, no NULL) Existing bash schema (column-tab-separated): timestamp event_type bench_name lap_n duration_ms verdict thermal_c notes Substrate seed emits the same row layout but uses Unix-milliseconds for timestamp (sortable, monotonic in single-run; bash version uses ISO 8601). race_analysis.sh accepts either since it parses by column index, not by timestamp content. Sealed-enum verdict codes (caller passes one of these as i64): NX_RT_WIN = 0 NX_RT_TIE = 1 NX_RT_LOSE = 2 NX_RT_RECORD_ONLY = 3 NX_RT_UNDECIDED = 4 Out-of-range verdict falls back to RECORD_ONLY (defensive at boundary, per cardinal 12). license_tier: ORIGINAL genealogy_id: substrate-native -- no external derivation lineage_id: nx_race_telemetry_seed_q10

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_fs.nx nx_race_telemetry.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 _u64_to_ascii sys_mmap ↻ _i64_to_ascii _u64_to_ascii ↻ _verdict_emit nx_race_telemetry_clear nx_race_telemetry_lap sys_mmap ↻ _emit_prelude sys_now_ms sys_mmap ↻ sys_clock_gettime_mono _u64_to_ascii ↻ _emit_byte _copy_bytes _copy_bytes ↻ _emit_byte ↻ _i64_to_ascii ↻ _verdict_emit ↻ _u64_to_ascii ↻ _append_row sys_openat_append sys_write sys_close nx_race_telemetry_patch sys_mmap ↻ _emit_prelude ↻ _copy_bytes ↻ _emit_byte ↻ _emit_dash_tab _append_row ↻ nx_race_telemetry_perspect sys_mmap ↻ _emit_prelude ↻ _emit_dash_tab ↻ _copy_bytes ↻ _emit_byte ↻ _append_row ↻

structs

none

consts

75const NX_RT_WIN: i64 = 0
76const NX_RT_TIE: i64 = 1
77const NX_RT_LOSE: i64 = 2
78const NX_RT_RECORD_ONLY: i64 = 3
79const NX_RT_UNDECIDED: i64 = 4

functions

83func _copy_bytes(src: *u8, dst: *u8, n: i64) -> i64
95func _u64_to_ascii(n: i64, out: *u8) -> i64
117func _i64_to_ascii(n: i64, out: *u8) -> i64
127func _emit_byte(out: *u8, off: i64, b: i64) -> i64
134func _verdict_emit(code: i64, out: *u8) -> i64
165func _emit_prelude(buf: *u8, event_str: *u8, event_len: i64) -> i64
179func _append_row(path: *u8, buf: *u8, off: i64) -> i64
190func _emit_dash_tab(buf: *u8, off: i64) -> i64
216func nx_race_telemetry_lap(path: *u8, bench: *u8, bench_len: i64, lap_n: i64, duration_ms: i64, verdict: i64, thermal_c10: i64) -> i64
262func nx_race_telemetry_patch(path: *u8, bench: *u8, bench_len: i64, commit: *u8, commit_len: i64, notes: *u8, notes_len: i64) -> i64
309func nx_race_telemetry_corner(path: *u8, bench: *u8, bench_len: i64, region: *u8, region_len: i64, duration_ns: i64, notes: *u8, notes_len: i64) -> i64
359func nx_race_telemetry_competition(path: *u8, arena: *u8, arena_len: i64, problem: *u8, problem_len: i64, result_ms: i64, verdict: i64, notes: *u8, notes_len: i64) -> i64
413func nx_race_telemetry_perspective(path: *u8, category: *u8, cat_len: i64, observation: *u8, obs_len: i64) -> i64
465func nx_race_telemetry_tail(path: *u8, n_lines: i64, out_buf: *u8, out_cap: i64) -> i64
called by 1: main
477func nx_race_telemetry_clear(path: *u8) -> i64
called by 1: main
487func _matches_at(buf: *u8, off: i64, target: *u8, target_len: i64) -> i64
512func nx_race_telemetry_stats(path: *u8, counts: *i64) -> i64
608func main() -> i64