code wiki / _hdl_build / nx_pub_rollout.nx
nx_pub_rollout.nx source
↩ module page · 53 lines · 3656 B
1// nx_pub_rollout.nx -- Plans a read-only rollout of queued publications over the canonical ledger without live writes.
2import "nx_gate_gn.nx"
3import "nx_gate_base.nx"
4// nx_pub_rollout.nx -- READ-ONLY rollout planner: pub_status + pub_dryrun over the CANONICAL queue/ledger, so the
5// operator sees exactly what the publisher would ship (e.g. the 43 queued docpub requests) WITHOUT any live write.
6// The wet ship is pub_run_governed (outward = operator-approved). license_tier: ORIGINAL expect_exit: 0
7import "nx_syscalls.nx"
8import "nx_publisher.nx"
9
10func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
11" as *u8); return ok }
12
13func main() -> i64 {
14 pub_init()
15 gw("=== NISHI PUBLISHER ROLLOUT PLAN (read-only dry-run over the canonical queue) ===\n" as *u8)
16 let st: *i64 = sys_mmap(64) as *i64
17 pub_status("knowledge/publish/queue.tsv" as *u8, "knowledge/publish/ledger.tsv" as *u8, "knowledge/publish/approvals" as *u8, st)
18 gw(" queue PENDING=" as *u8); gn(st[0]); gw(" ledger PUBLISHED=" as *u8); gn(st[1]); gw(" ready=" as *u8); gn(st[2]); gw(" held(outward-unapproved)=" as *u8); gn(st[3]); gw(" idempotent-skip=" as *u8); gn(st[4]); gw("\n" as *u8)
19 let plan: *i64 = sys_mmap(64) as *i64
20 let would: i64 = pub_dryrun("knowledge/publish/queue.tsv" as *u8, "knowledge/publish/ledger.tsv" as *u8, "knowledge/publish/approvals" as *u8, plan)
21 gw(" DRY-RUN: would publish " as *u8); gn(would); gw(" now (held=" as *u8); gn(plan[2]); gw(", idempotent-skip=" as *u8); gn(plan[3]); gw(")\n" as *u8)
22
23 // SRC-ARTIFACT READINESS: for each READY request, does its src file actually exist on disk? (would the deploy land?)
24 let lenp: *i64 = sys_mmap(8) as *i64
25 let data: *u8 = sys_read_file("knowledge/publish/queue.tsv" as *u8, lenp)
26 var ready_src: i64 = 0; var ready_missing: i64 = 0
27 if (data as i64) != 0 {
28 let n: i64 = lenp[0]
29 let stf: *u8 = sys_mmap(64); let sha: *u8 = sys_mmap(256); let src: *u8 = sys_mmap(512); let dest: *u8 = sys_mmap(256); let pol: *u8 = sys_mmap(64)
30 var i: i64=0; var ls: i64=0
31 while i < n {
32 if data[i]==(10 as u8) {
33 let line: *u8 = ((data as i64)+ls) as *u8; let ll: i64 = i-ls
34 pub_field(line, ll, 0, stf)
35 if pub_streq(stf, "PENDING" as *u8)==1 {
36 pub_field(line, ll, 3, sha); pub_field(line, ll, 4, src); pub_field(line, ll, 5, dest); pub_field(line, ll, 6, pol)
37 if pub_policy_allows(pol, sha, "knowledge/publish/approvals" as *u8)==1 {
38 if pub_led_has("knowledge/publish/ledger.tsv" as *u8, sha, dest)==0 {
39 if pub_exists(src)==1 { ready_src = ready_src + 1 } else { ready_missing = ready_missing + 1 }
40 }
41 }
42 }
43 ls = i + 1
44 }
45 i = i + 1
46 }
47 }
48 gw(" SRC-READINESS of the ready set: artifacts-present=" as *u8); gn(ready_src); gw(" artifacts-MISSING=" as *u8); gn(ready_missing); gw("\n" as *u8)
49 if ready_missing == 0 { if ready_src > 0 { gw(" => SHIPPABLE NOW: all ready artifacts exist -> pub_run_governed would deploy " as *u8); gn(ready_src); gw(" (verify+atomic-promote+ledger, reversible).\n" as *u8) } }
50 if ready_missing > 0 { gw(" => BLOCKED: regenerate missing src artifacts first (docs-arc: nx_docpub_site + nx_docpub_tree).\n" as *u8) }
51 gw(" READ-ONLY: no live writes, ledger untouched. Wet ship = pub_run_governed (internal proceeds; outward needs operator approval).\n" as *u8)
52 return 0
53}