code wiki / _hdl_build / nx_hr_autoraci.nx
nx_hr_autoraci.nx source
↩ module page · 46 lines · 2458 B
1// nx_hr_autoraci.nx -- NISHI HR, rung B: AUTO-KEEP the RACI from the LIVE WORK. Sweeps the active work-areas
2// (one per line; field0 = area name -- fed from the WMS workstream registry / board) against the RACI and flags
3// every area that is NOT covered (no single Accountable + >=1 Responsible) as a real STAFFING GAP -- proactively,
4// so HR catches "work is happening with nobody accountable" without anyone asking. Composes nx_hr_team's
5// hrt_staffing_gap (the proven invariant). Emits a report `<area> <TAB> COVERED|GAP` per area + returns the gap
6// count. The LIVE FEED = the areas file (the WMS emits its active stream/area names there). license_tier: ORIGINAL
7import "nx_hr_team.nx" // hrt_staffing_gap (the RACI invariant)
8import "nx_hr.nx" // hr_read / hr_line_end / hr_field_end
9import "nx_syscalls.nx"
10const K_MAGIC_262144: i64 = 262144
11
12// sweep `areas_path` against `raci_path`; write a per-area report to `report_path`; return the staffing-gap count.
13func hra_emit_report(areas_path: *u8, raci_path: *u8, report_path: *u8) -> i64 {
14 let buf: *u8 = sys_mmap(K_MAGIC_262144); let n: i64 = hr_read(areas_path, buf, K_MAGIC_262144)
15 let rfd: i64 = sys_openat_wr(report_path, 0x1a4) // O_CREAT|O_TRUNC
16 var gaps: i64 = 0; var i: i64 = 0
17 while i < n {
18 let le: i64 = hr_line_end(buf, i, n)
19 let f0e: i64 = hr_field_end(buf, i, le)
20 let alen: i64 = f0e - i
21 if alen > 0 {
22 let area: *u8 = ((buf as i64) + i) as *u8
23 let gap: i64 = hrt_staffing_gap(raci_path, area, alen)
24 if rfd >= 0 {
25 sys_write(rfd, area, alen)
26 if gap == 1 { sys_write(rfd, "\tGAP\n" as *u8, 5); gaps = gaps + 1 } else { sys_write(rfd, "\tCOVERED\n" as *u8, 9) }
27 } else { if gap == 1 { gaps = gaps + 1 } }
28 }
29 i = le + 1
30 }
31 if rfd >= 0 { sys_close(rfd) }
32 return gaps
33}
34// just the gap count (no report).
35func hra_gap_count(areas_path: *u8, raci_path: *u8) -> i64 {
36 let buf: *u8 = sys_mmap(K_MAGIC_262144); let n: i64 = hr_read(areas_path, buf, K_MAGIC_262144)
37 var gaps: i64 = 0; var i: i64 = 0
38 while i < n {
39 let le: i64 = hr_line_end(buf, i, n)
40 let f0e: i64 = hr_field_end(buf, i, le)
41 let alen: i64 = f0e - i
42 if alen > 0 { let area: *u8 = ((buf as i64) + i) as *u8; if hrt_staffing_gap(raci_path, area, alen) == 1 { gaps = gaps + 1 } }
43 i = le + 1
44 }
45 return gaps
46}