code wiki / _hdl_build / nx_ws_index_lib.nx

nx_ws_index_lib.nx

buildroot/runtime/_hdl_build/nx_ws_index_lib.nx

11878 B282 linesdepth 2pulls 2 transitivereach 12 importersview sourcekind librarytopic ws
docsdependenciesstructsconstsfunctions

about

nx_ws_index_lib.nx -- WMS durability LIB: derive the LIVE workstream auto-index from the memory dir (the actual live source of workstream state) so the resume manifest + a publish gate can NEVER silently go stale. This is the missing "regenerate-from-source" half the operator named: every project-*.md becomes a manifest entry by construction, so nothing can be dropped -- and the count-on-disk vs count-in-manifest comparison turns "we lost a workstream" into a mechanical RED (the loss-detector), never a silent gap. REUSE / lineage: the getdents64 + newfstatat directory walk is the proven nx_sov_tree_audit idiom (ta_getdents/ta_isdir); atomic publish = sys_openat_wr(tmp) + sys_renameat(tmp,live) (the ss_commit / cst_write_atomic hot-swap discipline). Sovereign: imports only nx_syscalls. license_tier: ORIGINAL

dependencies 1 imports · 7 importers

nx_syscalls.nx nx_ws_index_lib.nx nx_discover_loop.nx nx_work_retro_lib.nx nx_worklog_stop.nx nx_ws_discover_gate.nx nx_ws_ingest.nx nx_ws_manifest_emit.nx nx_ws_manifest_emit_gate.nx

imports: nx_syscalls.nx

imported by: nx_discover_loop.nxnx_work_retro_lib.nxnx_worklog_stop.nxnx_ws_discover_gate.nxnx_ws_ingest.nxnx_ws_manifest_emit.nxnx_ws_manifest_emit_gate.nx

structs

none

consts

13const WME_MAGIC_65536: i64 = 65536
17const WME_BEGIN: *u8 = "<!-- WS-AUTO-INDEX:BEGIN (nx_ws_manifest_emit -- generated, do not hand-edit below) -->"
18const WME_END: *u8 = "<!-- WS-AUTO-INDEX:END -->"
19const WME_MAXF: i64 = 8192 // max workstream records (382 today; headroom)
20const WME_SLOT: i64 = 320 // per-name / per-path byte slot
21const WME_FBUF: i64 = 1048576 // 1MB: read the existing manifest (curated prefix; ~25KB today)
22const WME_OUTBUF: i64 = 1048576 // 1MB: assembled output (bump-mmap is a finite arena -- stay lean)

functions

24func wme_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
27func wme_getdents(fd: i64, buf: *u8, count: i64) -> i64 { return __syscall(217, fd, buf, count, 0, 0, 0) }
30func wme_is_project(name: *u8) -> i64
called by 1: wme_scan calls 1: wme_len
43func wme_join(dst: *u8, dir: *u8, name: *u8) -> i64
55func wme_read(path: *u8, buf: *u8, cap: i64) -> i64
69func wme_find(buf: *u8, n: i64, pat: *u8) -> i64
83func wme_cat(buf: *u8, off: i64, s: *u8) -> i64
90func wme_catn(buf: *u8, off: i64, v: i64) -> i64
called by 2: wme_emitwsi_build_record calls 1: sys_mmap
105func wme_scan(memdir: *u8, names: *i64, mtimes: *i64, cap: i64) -> i64
146func wme_count_disk(memdir: *u8) -> i64
called by 1: wme_is_stale calls 2: sys_mmapwme_scan
153func wme_count_manifest(manifest: *u8) -> i64
177func wme_is_stale(memdir: *u8, manifest: *u8) -> i64
186func wme_write_all(fd: i64, buf: *u8, n: i64) -> i64
called by 1: wme_emit calls 1: sys_write
200func wme_emit(memdir: *u8, manifest: *u8) -> i64