code wiki / (root) / nx_id_help_gate_t190.nx

nx_id_help_gate_t190.nx source

↩ module page · 27 lines · 1623 B

1import "nx_syscalls.nx" 2import "nx_gate_verdict.nx" 3func ih_has(b:*u8,n:i64,s:*u8)->i64{ 4 var sn:i64=0;while s[sn]!=0 as u8{sn=sn+1} 5 var i:i64=0;while i+sn<=n{var j:i64=0;var ok:i64=1;while j<sn{if b[i+j]!=s[j]{ok=0};j=j+1};if ok==1{return 1};i=i+1};return 0 6} 7func main()->i64{ 8 let c:*i64=gv_ctr() 9 let path:*u8="knowledge/gates/idempotency-help-t190.out" 10 let fd:i64=__syscall(257,AT_FDCWD,path,193,0x180,0,0) 11 if fd<0{return 2} 12 let av:*i64=sys_mmap(16) as *i64 13 av[0]="/volume1/homes/elderwesto/nishihost/buildroot/_build/nx_fsops_write_candidate_t190.sov.elf" as i64;av[1]=0 14 let env:*i64=sys_mmap(8) as *i64;env[0]=0 15 let st:*i64=sys_mmap(8) as *i64 16 let pid:i64=sys_fork() 17 if pid==0{if sys_dup3(fd,1,0)<0{sys_exit(125)};sys_execve(av[0] as *u8,av,env);sys_exit(127)} 18 var waited:i64=0-1;if pid>0{waited=sys_wait4(pid,st,0)};sys_close(fd) 19 gv_check("actual help child exits usage not signal",pid>0&&waited==pid&&wait_status_rc(st[0])==2,c) 20 let n:*i64=sys_mmap(8) as *i64;let b:*u8=sys_read_file(path,n) 21 if (b as i64)<=0{return 3} 22 gv_check("help requires retained matching receipt",ih_has(b,n[0],"replay requires a retained matching receipt")==1,c) 23 gv_check("help explains missing receipt reconciliation",ih_has(b,n[0],"reconcile the destination before retrying")==1,c) 24 gv_check("help states mutation journal crash window",ih_has(b,n[0],"a key alone does not close the mutation-to-journal crash window")==1,c) 25 gv_check("old unconditional safe retry claim removed",ih_has(b,n[0],"the only safe retry")==0,c) 26 return gv_verdict("idempotency-help",c,"Actual rebuilt executable stdout; no production mutation") 27}