code wiki / _hdl_build / nx_assign_next.nx
nx_assign_next.nx source
↩ module page · 92 lines · 3794 B
1// nx_assign_next.nx -- the CONDUCTOR's SEQUENCER over the assignment queue
2// (RACI-clean: this organ does NOT own prioritization -- the PM does).
3// PRIORITY (the w column) is PM-OWNED DATA: seeded advisory 2026-06-11,
4// re-scored by the PM's existing decision organs (nx_pm_decision_matrix
5// WSJF via the PM-RESCORE queue card) -- this organ only READS it.
6// SEQUENCING (this organ, Conductor verb): of the PM-ranked rows, which is
7// RUNNABLE NOW (status TODO + every dep DONE)? That readiness gate is
8// nx_pm_choose's READY rule applied to the durable queue file.
9// DRIFT DETECT (Auditor view): STRUCTVIEW = the dep graph's own largest
10// blocker; VIEWPOINT-DISCREPANCY suffix when structure outranks the PM
11// column (>=3 dependents, w <= 7) -- surfaced for PM re-score, not acted on.
12// TUTOR ROUTE: RAISEDHANDS = NOVEL rows (nx_pm_choose's TUTOR route over the
13// queue; the only rows that cost Claude tokens -- batching them is the
14// token-efficiency lever).
15// Composes-not-duplicates: nx_pm_decision_matrix/nx_pm_choose (priority),
16// nx_work_dispatcher (the attempt loop, Q3). Every beat appends ASSIGNNEXT /
17// STRUCTVIEW / RAISEDHANDS rows to knowledge/status/assign_next.log.
18// argv[1] = queue path override (gates use a scratch queue).
19// license_tier: ORIGINAL
20
21import "nx_syscalls.nx"
22import "nx_assign_core.nx"
23
24func anx_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
25func anx_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
26func anx_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
27
28func anx_both(lfd: i64, s: *u8) -> i64 {
29 anx_p(s)
30 if lfd >= 0 { anx_w(lfd, s) }
31 return 0
32}
33
34func anx_bothn(lfd: i64, v: i64) -> i64 {
35 anx_wn(1, v)
36 if lfd >= 0 { anx_wn(lfd, v) }
37 return 0
38}
39
40func main(argc: i64, argv: *i64) -> i64 {
41 var qp: *u8 = "knowledge/registry/assignment_queue.tsv" as *u8
42 if argc >= 2 { qp = argv[1] as *u8 }
43 let cx: *i64 = an_newcx()
44 let rows: i64 = an_load(qp, cx)
45 if rows <= 0 {
46 anx_p("ASSIGNNEXT verdict=RED reason=queue-missing-or-empty\n" as *u8)
47 sys_exit(2)
48 return 2
49 }
50 let lfd: i64 = sys_openat_append("knowledge/status/assign_next.log" as *u8, 0x1a4)
51 let wv: *i64 = cx[3] as *i64
52 let dc: *i64 = cx[6] as *i64
53
54 let p: i64 = an_pick(cx)
55 if p >= 0 {
56 anx_both(lfd, "ASSIGNNEXT id=" as *u8)
57 anx_both(lfd, an_id_at(cx, p))
58 anx_both(lfd, " w=" as *u8)
59 anx_bothn(lfd, wv[p])
60 anx_both(lfd, "\n" as *u8)
61 } else {
62 anx_both(lfd, "ASSIGNNEXT id=NONE-RUNNABLE (all TODO blocked or queue drained)\n" as *u8)
63 }
64
65 let tb: i64 = an_top_blocker(cx)
66 if tb >= 0 {
67 anx_both(lfd, "STRUCTVIEW id=" as *u8)
68 anx_both(lfd, an_id_at(cx, tb))
69 anx_both(lfd, " dependents=" as *u8)
70 anx_bothn(lfd, dc[tb])
71 anx_both(lfd, " w=" as *u8)
72 anx_bothn(lfd, wv[tb])
73 if dc[tb] >= 3 {
74 if wv[tb] <= 7 { anx_both(lfd, " VIEWPOINT-DISCREPANCY" as *u8) }
75 }
76 anx_both(lfd, "\n" as *u8)
77 }
78
79 let no: *i64 = sys_mmap(16) as *i64
80 let nc: i64 = an_novel(cx, no)
81 anx_both(lfd, "RAISEDHANDS novel=" as *u8)
82 anx_bothn(lfd, nc)
83 if no[0] >= 0 {
84 anx_both(lfd, " first=" as *u8)
85 anx_both(lfd, an_id_at(cx, no[0]))
86 }
87 anx_both(lfd, "\n" as *u8)
88 if lfd >= 0 { sys_close(lfd) }
89 if p >= 0 { sys_exit(0) }
90 sys_exit(1)
91 return 0
92}