code wiki / _hdl_build / nx_scribe_query.nx

nx_scribe_query.nx source

↩ module page · 39 lines · 1957 B

1// nx_scribe_query.nx -- the Scribe's M2 upgrade (the growth loop's last pick): the deliverable 2// history stops being write-only and becomes QUERYABLE, turning the parseable CREWMSG log into the 3// clarity + efficiency METRICS the operator wanted ("logging to parse to improve our clarity and 4// efficiency"). Given the structured deliverables (from[], to[], kind[], verdict[]), the Scribe can 5// now answer: how many BAD handoffs? what is the heal rate? who hands to whom? where was the last 6// failure? -- the team reads its own history to improve. license_tier: ORIGINAL 7 8import "nx_crew_scribe.nx" // ORG_*, K_*, V_* deliverable vocabulary 9 10// count deliverables with a given verdict (V_OK / V_BAD / V_HEALED / ...). the clarity metric. 11func scq_count_verdict(n: i64, verdict: *i64, target: i64) -> i64 { 12 var c: i64 = 0; var i: i64 = 0 13 while i < n { if verdict[i] == target { c = c + 1 } i = i + 1 } 14 return c 15} 16 17// count f->t handoffs (who hands to whom, how often) -- the communication graph. 18func scq_count_handoff(n: i64, from: *i64, to: *i64, f: i64, t: i64) -> i64 { 19 var c: i64 = 0; var i: i64 = 0 20 while i < n { if from[i] == f { if to[i] == t { c = c + 1 } } i = i + 1 } 21 return c 22} 23 24// index of the LAST deliverable with a given verdict (triage the most recent failure); -1 if none. 25func scq_last(n: i64, verdict: *i64, target: i64) -> i64 { 26 var idx: i64 = 0 - 1; var i: i64 = 0 27 while i < n { if verdict[i] == target { idx = i } i = i + 1 } 28 return idx 29} 30 31// HEAL EFFICIENCY (per-1000): of the detections/heals, how many resolved HEALED vs ended BAD. 32// high = the crew fixes what it finds. (V_HEALED resolved / (V_HEALED + V_BAD)). 33func scq_heal_efficiency(n: i64, verdict: *i64) -> i64 { 34 let healed: i64 = scq_count_verdict(n, verdict, V_HEALED) 35 let bad: i64 = scq_count_verdict(n, verdict, V_BAD) 36 let tot: i64 = healed + bad 37 if tot <= 0 { return 1000 } 38 return (healed * 1000) / tot 39}