code wiki / _hdl_build / nx_pattern_emit3_demo.nx

nx_pattern_emit3_demo.nx source

↩ module page · 23 lines · 1439 B

1// nx_pattern_emit3_demo.nx -- the TEAM authoring the STATE_FLOW core for the CMS arc (no Claude logic). 2// The table IS the CMS publish lifecycle (ladder step 12, Craft model): states 0=DRAFT 1=PUBLISHED 3// 2=ROLLED-BACK(serving prior revision); events 0=EDIT 1=PUBLISH 2=ROLLBACK. Rollback of a DRAFT is 4// absent from the table -> the authored core refuses it (-1). Engineer verifies the authored test. 5import "nx_pattern_emit3.nx" 6import "nx_syscalls.nx" 7 8func p3d_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 9 10func main() -> i64 { 11 let t: *i64 = sys_mmap(8*15) as *i64 12 t[0]=0; t[1]=0; t[2]=0 // DRAFT --EDIT--> DRAFT (keep editing) 13 t[3]=0; t[4]=1; t[5]=1 // DRAFT --PUBLISH--> PUBLISHED (atomic swap, revision kept) 14 t[6]=1; t[7]=0; t[8]=0 // PUBLISHED --EDIT--> DRAFT (new working copy) 15 t[9]=1; t[10]=2; t[11]=2 // PUBLISHED --ROLLBACK--> ROLLED-BACK (prior revision serves) 16 t[12]=2; t[13]=0; t[14]=0 // ROLLED-BACK --EDIT--> DRAFT 17 let a: i64 = pe3_author_state_flow("_pe_pub" as *u8, 18 "runtime/_hdl_build/_pe_pub.nx" as *u8, 19 "runtime/_hdl_build/_pe_pub_test.nx" as *u8, t, 5) 20 if a == 1 { p3d_w("TEAM AUTHORED CORE: _pe_pub (STATE_FLOW publish lifecycle, 5 transitions + refuse) -- verify with Engineer\n" as *u8); sys_exit(0) } 21 p3d_w("author failed\n" as *u8); sys_exit(1) 22 return 1 23}