nx_race_telemetry.nx
buildroot/runtime/nx_race_telemetry.nx
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
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
structs
| none |
consts
| 75 | const NX_RT_WIN: i64 = 0 |
| 76 | const NX_RT_TIE: i64 = 1 |
| 77 | const NX_RT_LOSE: i64 = 2 |
| 78 | const NX_RT_RECORD_ONLY: i64 = 3 |
| 79 | const NX_RT_UNDECIDED: i64 = 4 |
functions
| 83 | func _copy_bytes(src: *u8, dst: *u8, n: i64) -> i64 |
| 95 | func _u64_to_ascii(n: i64, out: *u8) -> i64 called by 5: _i64_to_ascii_emit_preludenx_race_telemetry_lapnx_race_telemetry_competitionmain calls 1: sys_mmap |
| 117 | func _i64_to_ascii(n: i64, out: *u8) -> i64 |
| 127 | func _emit_byte(out: *u8, off: i64, b: i64) -> i64 |
| 134 | func _verdict_emit(code: i64, out: *u8) -> i64 |
| 165 | func _emit_prelude(buf: *u8, event_str: *u8, event_len: i64) -> i64 |
| 179 | func _append_row(path: *u8, buf: *u8, off: i64) -> i64 |
| 190 | func _emit_dash_tab(buf: *u8, off: i64) -> i64 |
| 216 | func nx_race_telemetry_lap(path: *u8, bench: *u8, bench_len: i64, lap_n: i64, duration_ms: i64, verdict: i64, thermal_c10: i64) -> i64 |
| 262 | func nx_race_telemetry_patch(path: *u8, bench: *u8, bench_len: i64, commit: *u8, commit_len: i64, notes: *u8, notes_len: i64) -> i64 |
| 309 | func 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 |
| 359 | func 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 |
| 413 | func nx_race_telemetry_perspective(path: *u8, category: *u8, cat_len: i64, observation: *u8, obs_len: i64) -> i64 |
| 465 | func nx_race_telemetry_tail(path: *u8, n_lines: i64, out_buf: *u8, out_cap: i64) -> i64 called by 1: main |
| 477 | func nx_race_telemetry_clear(path: *u8) -> i64 called by 1: main |
| 487 | func _matches_at(buf: *u8, off: i64, target: *u8, target_len: i64) -> i64 called by 1: nx_race_telemetry_stats |
| 512 | func nx_race_telemetry_stats(path: *u8, counts: *i64) -> i64 |
| 608 | func main() -> i64 |