code wiki / _hdl_build / nx_worklog_ingest_lib.nx
nx_worklog_ingest_lib.nx
buildroot/runtime/_hdl_build/nx_worklog_ingest_lib.nx
about
nx_worklog_ingest_lib.nx -- the PRESENT-axis workhorse: ingest the session transcript (.jsonl the
harness writes out-of-band as work happens) into the append-only work-journal. A byte-offset
CURSOR makes it idempotent: each run appends one framed line per NEW tool_use since the cursor,
then advances the cursor to the last complete line. Idempotence is the key property -- the SAME
organ can fire on PostToolUse (real-time / mid-turn crash durability), on Stop (turn end), and on a
Cron timer (fully out-of-band redundancy) with ZERO duplicate lines, because the cursor gates them
all. Reading the harness's OWN record means capture can never miss an action.
REUSE: getdents64 + fstatat(mtime@88) directory walk is the proven nx_ws_index_lib/nx_sov_tree_audit
idiom; line-boundary cursor is the standard JSONL tail-follow; atomic cursor write = tmp+renameat.
Sovereign: nx_syscalls + nx_worklog_lib + nx_json_lib only. license_tier: ORIGINAL
dependencies 3 imports · 4 importers
imports: nx_syscalls.nxnx_worklog_lib.nxnx_json_lib.nx
imported by: nx_worklog_ingest.nxnx_worklog_ingest_gate.nxnx_worklog_stop.nxnx_worklog_sweep_gate.nx
structs
| none |
consts
| 15 | const WLI_MAGIC_1024: i64 = 1024 |
| 16 | const WLI_MAGIC_65536: i64 = 65536 |
| 17 | const WLI_MAGIC_2048: i64 = 2048 |
| 18 | const WLI_MAGIC_131072: i64 = 131072 |
| 20 | const WLI_READCAP: i64 = 8388608 // 8MB per ingest pass (process up to last newline within it) |
| 21 | const WLI_TOOLCAP: i64 = 64 |
| 22 | const WLI_TGTCAP: i64 = 256 |
| 23 | const WLI_TGTWIN: i64 = 4096 // bound the first-string-value search inside an input object |
functions
| 25 | func wli_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 31 | func wli_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 44 | func wli_read_cursor(cursor_path: *u8) -> i64 |
| 62 | func wli_write_cursor(cursor_path: *u8, v: i64) -> i64 |
| 81 | func wli_default_cursor(transcript: *u8, out: *u8, outcap: i64) -> i64 |
| 99 | func wli_ingest(transcript: *u8, cursor_path: *u8, worklog: *u8) -> i64 called by 3: mainwli_capturewli_sweep_behind_to calls 12: wli_read_cursorsys_openat_rdsys_lseeksys_mmapsys_readsys_close+6 |
| 157 | func wli_winpath_to_wsl(src: *u8, out: *u8) -> i64 |
| 189 | func wli_is_jsonl(name: *u8) -> i64 |
| 200 | func wli_newest_transcript(dir: *u8, out: *u8, outcap: i64) -> i64 |
| 248 | func wli_capture(argpath: *u8, projdir: *u8, cursors_dir: *u8) -> i64 |
| 284 | func wli_is_cur(name: *u8) -> i64 |
| 301 | func wli_sweep_behind_to(projdir: *u8, cursors_dir: *u8, worklog: *u8) -> i64 called by 2: wli_sweep_behindmain calls 8: sys_openat_rdsys_mmapwli_is_curwli_catsys_fstatatwli_read_cursor+2 |
| 345 | func wli_sweep_behind(projdir: *u8, cursors_dir: *u8) -> i64 |