code wiki / _hdl_build / nx_vroom_gitea_push.nx
nx_vroom_gitea_push.nx source
↩ module page · 94 lines · 5504 B
1// nx_vroom_gitea_push.nx -- the FINAL deploy rung: commit JUST the /video/ camera-fix (the 2
2// Gitea-source files, NOT -A) + push to Gitea (192.168.8.227:3003, branch agents/invention-engine)
3// via the team's git lane (operator 2026-06-23: "do it with the nishi team's capabilities ... so we
4// don't crash with direct touches"). git's ATOMIC ref update -> the NAS checkout serves the new bytes;
5// no hand-overwrite of a live file = the no-crash guarantee. Every failure mode is a safe no-op:
6// hook-fail -> no commit; behind-origin -> push rejected; wrong served branch -> just not live (honest).
7// Focused add (per CONTRIBUTING: never `git add -A`) so the uncommitted session organs are NOT swept in.
8// After GREEN, nx_live_verify must find scaleX(-1) in the SERVED bytes before this is 'done'.
9// BORROWED RUNG (inherited from nx_ark_push): /usr/bin/git binary, pending the sovereign pack/push lane.
10// license_tier: ORIGINAL
11import "nx_syscalls.nx"
12
13const C_GIT: *u8 = "/usr/bin/git"
14const C_REPO: *u8 = "/mnt/c/Users/elder/nishi-core"
15const C_BRANCH: *u8 = "agents/invention-engine"
16const F_IDX: *u8 = "nxc2/sites/nishifamily/video/index.html"
17const F_APP: *u8 = "nxc2/sites/nishifamily/video/app.js"
18const C_MSG: *u8 = "video: self-view camera-mirror fix (organ-emitted SSOT, publisher-verified)"
19const C_LOG: *u8 = "knowledge/status/vroom_gitea_push.log"
20const C_MODE_FILE: i64 = 420
21
22func pw(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 }
23func pn(fd: i64, n: i64) -> i64 { if n==0 { sys_write(fd,"0" as *u8,1); return 0 } var m: i64=n; if m<0 { sys_write(fd,"-" as *u8,1); m=0-m } let d: *u8=sys_mmap(24); var k: i64=0; while m>0 { d[k]=(0x30+(m%10)) as u8; m=m/10; k=k+1 } var i: i64=k-1; while i>=0 { let o: *u8=sys_mmap(1); o[0]=d[i]; sys_write(fd,o,1); i=i-1 } return 0 }
24
25// child env: the EMPTY-env bug hung `git commit` -- the #!/usr/bin/env bash pre-commit hook needs
26// PATH to find bash, and git needs HOME. GIT_TERMINAL_PROMPT=0 = never prompt (fail fast, no hang).
27func mk_env() -> *i64 {
28 let e: *i64 = sys_mmap(64) as *i64
29 e[0] = "PATH=/usr/bin:/bin:/usr/local/bin" as i64
30 e[1] = "HOME=/home/elderwesto" as i64
31 e[2] = "GIT_TERMINAL_PROMPT=0" as i64
32 e[3] = 0
33 return e
34}
35// run argv[] (NULL-terminated) with a REAL env + stdin<-/dev/null (no prompt can hang). stdout/stderr
36// are INHERITED so git's result + any error is visible. returns wait4 status (0 = clean exit).
37func pr_run(argv: *i64) -> i64 {
38 let pid: i64 = sys_fork()
39 if pid == 0 {
40 let dnr: i64 = sys_openat_rd("/dev/null" as *u8)
41 if dnr >= 0 { sys_dup3(dnr, 0, 0) }
42 sys_execve(argv[0] as *u8, argv, mk_env())
43 sys_exit(127)
44 }
45 let st: *i64 = sys_mmap(16) as *i64
46 sys_wait4(pid, st, 0)
47 return st[0]
48}
49
50// git -C <repo> add <idx> <app> (focused, NOT -A)
51func g_add() -> i64 {
52 let argv: *i64 = sys_mmap(80) as *i64
53 let a1: *u8 = "-C" as *u8; let a3: *u8 = "add" as *u8
54 argv[0]=C_GIT as i64; argv[1]=a1 as i64; argv[2]=C_REPO as i64
55 argv[3]=a3 as i64; argv[4]=F_IDX as i64; argv[5]=F_APP as i64; argv[6]=0
56 return pr_run(argv)
57}
58// git -C <repo> commit -q -m <msg>
59func g_commit() -> i64 {
60 let argv: *i64 = sys_mmap(80) as *i64
61 let a1: *u8 = "-C" as *u8; let a3: *u8 = "commit" as *u8; let a4: *u8 = "-q" as *u8; let a5: *u8 = "-m" as *u8
62 argv[0]=C_GIT as i64; argv[1]=a1 as i64; argv[2]=C_REPO as i64
63 argv[3]=a3 as i64; argv[4]=a4 as i64; argv[5]=a5 as i64; argv[6]=C_MSG as i64; argv[7]=0
64 return pr_run(argv)
65}
66// git -C <repo> push -q origin <branch>
67func g_push() -> i64 {
68 let argv: *i64 = sys_mmap(80) as *i64
69 let a1: *u8 = "-C" as *u8; let a3: *u8 = "push" as *u8; let a4: *u8 = "-q" as *u8; let a5: *u8 = "origin" as *u8
70 argv[0]=C_GIT as i64; argv[1]=a1 as i64; argv[2]=C_REPO as i64
71 argv[3]=a3 as i64; argv[4]=a4 as i64; argv[5]=a5 as i64; argv[6]=C_BRANCH as i64; argv[7]=0
72 return pr_run(argv)
73}
74
75func main() -> i64 {
76 pw(1, "=== nx_vroom_gitea_push -- commit JUST the /video/ camera-fix + push to Gitea (team git lane) ===\n")
77 let add_rc: i64 = g_add()
78 pw(1, " git add (2 files, focused) rc="); pn(1, add_rc); pw(1, "\n")
79 let commit_rc: i64 = g_commit()
80 pw(1, " git commit rc="); pn(1, commit_rc); if commit_rc!=0 { pw(1, " (nonzero = nothing-to-commit / already committed -- FINE)") } pw(1, "\n")
81 let push_rc: i64 = g_push()
82 pw(1, " git push origin agents/invention-engine rc="); pn(1, push_rc); pw(1, "\n")
83
84 let lfd: i64 = sys_openat_append(C_LOG, C_MODE_FILE)
85 if lfd>=0 { pw(lfd,"VROOMPUSH epoch="); pn(lfd,sys_now_realtime_sec()); pw(lfd," add_rc="); pn(lfd,add_rc); pw(lfd," commit_rc="); pn(lfd,commit_rc); pw(lfd," push_rc="); pn(lfd,push_rc); if push_rc==0 { pw(lfd," verdict=GREEN\n") } else { pw(lfd," verdict=RED\n") } sys_close(lfd) }
86
87 if push_rc==0 {
88 pw(1, " GREEN: pushed to Gitea. The NAS checkout of agents/invention-engine now carries the camera-fix in sites/nishifamily/video/.\n")
89 pw(1, " FINAL GATE: run nx_live_verify -- it must find scaleX(-1) in the SERVED /video/ bytes. If the NAS serves a different branch or hasn't pulled, it will say NOT LIVE (honest -- no crash, just not deployed yet).\n")
90 sys_exit(0); return 0
91 }
92 pw(1, " RED: push failed (Gitea unreachable or rejected) -- NOT deployed. Per CONTRIBUTING the cycle is NOT complete; the commit may be local-only.\n")
93 sys_exit(1); return 1
94}