code wiki / _hdl_build / nx_publisher.nx

nx_publisher.nx

buildroot/runtime/_hdl_build/nx_publisher.nx

79632 B1404 linesdepth 5pulls 9 transitivereach 106 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_publisher.nx -- THE NISHI PUBLISHER, R1: the single INTAKE. pub_submit() enqueues a publish REQUEST to a durable, concurrency-safe queue so every workstream DECOUPLES from the live site (workstreams REQUEST; the publisher SHIPS). The queue append reuses nx_framed_append's fa_appendz = O_APPEND + flock(LOCK_EX) + write-until-complete, so N concurrent submitters can NEVER tear or lose a record -- the exact collision class that caused the sites.elf outage. Each request carries a sha256 of the SOURCE CONTENT (honest identity -> later enables idempotent dedup + post-deploy verification). One framed TSV line per request: PENDING<TAB>site<TAB>requester<TAB>sha256<TAB>src<TAB>dest<TAB>policy This is R1 of [[project-nishi-publisher-role-2026-06-20]] (R0 census GREEN). license_tier: ORIGINAL

dependencies 5 imports · 94 importers

nx_syscalls.nx nx_connect.nx nx_framed_append.nx nx_sha256.nx nx_arbiter.nx nx_publisher.nx nx_activities_gate.nx nx_aid_federation_gate.nx nx_aid_gate.nx nx_brand_publish_submit.nx nx_ciq_submit.nx nx_clean_market_gate.nx nx_docpub_publish.nx nx_docpub_ship.nx nx_ecodesign_gate.nx nx_estate_gate.nx

diagram shows first 10 each side; +0 more imports, +84 more importers in the complete lists below.

imports: nx_syscalls.nxnx_connect.nxnx_framed_append.nxnx_sha256.nxnx_arbiter.nx

imported by: nx_activities_gate.nxnx_aid_federation_gate.nxnx_aid_gate.nxnx_brand_publish_submit.nxnx_ciq_submit.nxnx_clean_market_gate.nxnx_docpub_publish.nxnx_docpub_ship.nxnx_ecodesign_gate.nxnx_estate_gate.nxnx_food_menu_gate.nxnx_food_site_gate.nxnx_garden_gate.nxnx_hostop.nxnx_household_gate.nxnx_hub_deploy_bundle.nxnx_hub_publish.nxnx_hub_publish_bin.nxnx_hub_publish_hostctl.nxnx_impact_gate.nxnx_lineage_deep_gate.nxnx_lineage_gate.nxnx_link_auto_gate.nxnx_link_gate.nxnx_meet_publish.nxnx_mgmt_publish_bin.nxnx_ng_publish.nxnx_price_gate.nxnx_price_hist_gate.nxnx_produce_gate.nxnx_pub_approve_outward.nxnx_pub_audit_gate.nxnx_pub_audit_run.nxnx_pub_bluegreen_gate.nxnx_pub_bypass2_gate.nxnx_pub_bypass_gate.nxnx_pub_canary_gate.nxnx_pub_cd2_gate.nxnx_pub_daemon.nxnx_pub_daemon2_gate.nxnx_pub_daemon_gate.nxnx_pub_deploy_gate.nxnx_pub_dns_apply.nxnx_pub_dns_gate.nxnx_pub_drain_diag.nxnx_pub_exceed_gate.nxnx_pub_fin_handoff.nxnx_pub_gallery_handoff.nxnx_pub_game_e2e_gate.nxnx_pub_go_games.nxnx_pub_govern2_gate.nxnx_pub_governed_gate.nxnx_pub_hostop_e2e_gate.nxnx_pub_library_handoff.nxnx_pub_loop_gate.nxnx_pub_metrics_gate.nxnx_pub_nobypass_gate.nxnx_pub_obs_gate.nxnx_pub_pd_exceed_gate.nxnx_pub_policy_gate.nxnx_pub_promote_gate.nxnx_pub_q_gate.nxnx_pub_reader_handoff.nxnx_pub_receipt_loop.nxnx_pub_rel_gate.nxnx_pub_resilient_gate.nxnx_pub_rollout.nxnx_pub_search_handoff.nxnx_pub_selfheal_gate.nxnx_pub_serve.nxnx_pub_serve_gate.nxnx_pub_ship.nxnx_pub_ship_andelin.nxnx_pub_ship_meet.nxnx_pub_ship_meet_gate.nxnx_pub_ship_now.nxnx_pub_smoke_gate.nxnx_pub_submit.nxnx_pub_submit_gate.nxnx_pub_teacher_handoff.nxnx_pub_tls_serve.nxnx_pub_todos.nxnx_pub_vroom_emit_handoff.nxnx_pub_vroom_handoff.nxnx_pub_vroom_ship.nxnx_publish_account_admin.nxnx_publish_banner.nxnx_publish_opaque_login.nxnx_reorder_gate.nxnx_rewards_gate.nxnx_seedlib_gate.nxnx_stackaudit_submit.nxnx_swap_gate.nxnx_swap_reward_gate.nx

structs

none

consts

14const PUB_MAGIC_50000: i64 = 50000
15const PUB_MAGIC_4294967296: i64 = 4294967296
16const PUB_MAGIC_100000: i64 = 100000
17const PUB_MAGIC_1000000: i64 = 1000000
18const PUB_MAGIC_262144: i64 = 262144
19const PUB_MAGIC_4096: i64 = 4096
21const PUB_REC_CAP: i64 = 4096

functions

23func pub_queue_default() -> *u8 { return "knowledge/publish/queue.tsv" as *u8 }
26func pub_init() -> i64 { let d: *u8 = "knowledge/publish" as *u8; __syscall(83, d as i64, 493, 0, 0, 0, 0); return 0 }
called by 47: mainmainmainmainmainmain+41
28func pub_hexd(v: i64) -> i64 { if v < 10 { return 48 + v } return 87 + v } // 0-9 then a-f
31func pub_uw(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 }
called by 1: pub_append_unlocked calls 1: sys_write
32func pub_unap() -> i64 { let ts: *i64 = sys_mmap(16) as *i64; ts[0] = 0; ts[1] = PUB_MAGIC_50000; __syscall(35, ts as i64, 0, 0, 0, 0, 0); return 0 }
called by 1: pub_append_unlocked calls 1: sys_mmap
35func pub_sha_file(path: *u8, outhex: *u8) -> i64
54func pub_build_rec(rec: *u8, site: *u8, requester: *u8, hex: *u8, src: *u8, dest: *u8, policy: *u8) -> i64
69func pub_submit_to(qpath: *u8, src: *u8, dest: *u8, site: *u8, requester: *u8, policy: *u8) -> i64
80func pub_submit(src: *u8, dest: *u8, site: *u8, requester: *u8, policy: *u8) -> i64
88func pub_append_unlocked(qpath: *u8, src: *u8, dest: *u8, site: *u8, requester: *u8, policy: *u8) -> i64
106func pub_ledger_default() -> *u8 { return "knowledge/publish/ledger.tsv" as *u8 }
called by 4: mainmainmainmain
107func pub_nap_us(us: i64) -> i64 { let ts: *i64 = sys_mmap(16) as *i64; ts[0]=0; ts[1]=us*1000; __syscall(35, ts as i64, 0, 0, 0, 0, 0); return 0 }
called by 1: pub_run calls 1: sys_mmap
110func pub_streq(a: *u8, b: *u8) -> i64
117func pub_field(line: *u8, linelen: i64, idx: i64, out: *u8) -> i64
132func pub_led_has(ledpath: *u8, sha: *u8, dest: *u8) -> i64
156func pub_record_ledger(ledpath: *u8, sha: *u8, dest: *u8, site: *u8) -> i64
172func pub_run(qpath: *u8, ledpath: *u8, lockres: *u8, locked: i64, racewin_us: i64) -> i64
215func pub_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
218func pub_copy(src: *u8, dst: *u8) -> i64
229func pub_sha_match(path: *u8, expect_hex: *u8) -> i64
237func pub_pcat(base: *u8, suffix: *u8, out: *u8) -> i64
called by 13: mainmainmainmainmainmain+7
243func pub_rename(old: *u8, neu: *u8) -> i64 { return __syscall(82, old as i64, neu as i64, 0, 0, 0, 0) } // x86_64 rename
247func pub_promote_atomic(stage: *u8, live: *u8) -> i64
254func pub_backup_prev(live: *u8) -> i64
261func pub_rollback(live: *u8) -> i64
277func pub_mkdirp(path: *u8) -> i64
285func pub_deploy(expect_sha: *u8, src: *u8, stagepath: *u8, livepath: *u8) -> i64
302func pub_substr(hay: *u8, haylen: i64, needle: *u8) -> i64
314func pub_file_has(path: *u8, needle: *u8) -> i64
321func pub_audit_file(path: *u8, allowlisted: i64) -> i64
called by 1: main calls 1: pub_file_has
331func pub_audit_file_strict(path: *u8, allowlisted: i64) -> i64
349func pub_forbidden_in(code: *u8, n: i64) -> i64
called by 1: pub_audit_src_strict calls 1: pub_substr
364func pub_audit_src_strict(path: *u8, allowlisted: i64) -> i64
391func pub_join(root: *u8, name: *u8, out: *u8) -> i64
399func pub_publish_one(sha: *u8, src: *u8, dest: *u8, site: *u8, stageroot: *u8, liveroot: *u8, ledpath: *u8) -> i64
408func pub_run_full(qpath: *u8, ledpath: *u8, stageroot: *u8, liveroot: *u8, lockres: *u8) -> i64
448func pub_policy_allows(policy: *u8, sha: *u8, approval_dir: *u8) -> i64
455func pub_approve(sha: *u8, approval_dir: *u8) -> i64
464func pub_run_governed(qpath: *u8, ledpath: *u8, stageroot: *u8, liveroot: *u8, lockres: *u8, approval_dir: *u8) -> i64
515func pub_dlcat(rec: *u8, o: i64, s: *u8) -> i64 { var w: i64=o; var i: i64=0; while s[i]!=(0 as u8){rec[w]=s[i];w=w+1;i=i+1} return w }
516func pub_dlnum(rec: *u8, o: i64, v: i64) -> i64 { var w: i64=o; var m: i64=v; if m==0{rec[w]=48 as u8;return w+1} let t:*u8=sys_mmap(24); var k:i64=0; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var j:i64=0; while j<k{rec[w]=t[k-1-j];w=w+1;j=j+1} return w }
called by 1: pub_dl_raw calls 1: sys_mmap
519func pub_dl_raw(dlpath: *u8, reason: *u8, detail: i64, line: *u8, ll: i64) -> i64
534func pub_run_resilient(qpath: *u8, ledpath: *u8, stageroot: *u8, liveroot: *u8, lockres: *u8, approval_dir: *u8, dlpath: *u8, outcounts: *i64) -> i64
600func pub_sh_cause(reason: *u8, sha: *u8, src: *u8, ledpath: *u8, dest: *u8) -> i64
610func pub_sh_cause_name(c: i64) -> *u8 { if c==1 { return "PUBLISHER-BUG" as *u8 } if c==2 { return "SRC-MISSING" as *u8 } if c==3 { return "ARTIFACT-CHANGED" as *u8 } if c==5 { return "ALREADY-LIVE" as *u8 } return "DEPLOY-ERROR" as *u8 }
called by 1: pub_selfheal
611func pub_sh_action(c: i64) -> *u8 { if c==1 { return "FLAG-ENGINEER" as *u8 } if c==2 { return "FLAG-OWNER-RESTAGE" as *u8 } if c==3 { return "FLAG-OWNER-RESUBMIT" as *u8 } if c==5 { return "PRUNE-STALE-DUP" as *u8 } return "RETRY-NEXT-PASS" as *u8 }
called by 1: pub_selfheal
619func pub_selfheal(dlpath: *u8, reportpath: *u8, requeue_path: *u8, resub_led: *u8, ledpath: *u8) -> i64
677func pub_nap_ms(ms: i64) -> i64 { let ts: *i64 = sys_mmap(16) as *i64; ts[0]=0; ts[1]=ms*PUB_MAGIC_1000000; __syscall(35, ts as i64, 0, 0, 0, 0, 0); return 0 }
680func pub_hash_bytes(data: *u8, len: i64, outhex: *u8) -> i64
694func pub_body_off(resp: *u8, n: i64) -> i64
called by 1: pub_smoke
704func pub_http_get(port: i64, path: *u8, resp: *u8, cap: i64) -> i64
737func pub_smoke(port: i64, urlpath: *u8, expect_sha: *u8) -> i64
750func pub_health_gate(expect_sha: *u8, livepath: *u8, port: i64, urlpath: *u8) -> i64
758func pub_deploy_smoke(expect_sha: *u8, src: *u8, stagepath: *u8, livepath: *u8, port: i64, urlpath: *u8) -> i64
called by 1: main calls 2: pub_deploypub_health_gate
770func pub_count_ledger(ledpath: *u8) -> i64
782func pub_plan(qpath: *u8, ledpath: *u8, approval_dir: *u8, out: *i64) -> i64
812func pub_dryrun(qpath: *u8, ledpath: *u8, approval_dir: *u8, out: *i64) -> i64
called by 5: mainmainmainmainmain calls 1: pub_plan
817func pub_status(qpath: *u8, ledpath: *u8, approval_dir: *u8, out: *i64) -> i64
831func pub_audit_query(ledpath: *u8, dest: *u8, out_sha: *u8) -> i64
854func pub_query_count_site(ledpath: *u8, site: *u8) -> i64
873func pub_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v }
877func pub_record_outcome(ledpath: *u8, sha: *u8, dest: *u8, site: *u8, outcome: *u8, ts: i64, lead: i64) -> i64
898func pub_dora(ledpath: *u8, out: *i64) -> i64
960func pub_notify(notifypath: *u8, kind: *u8, dest: *u8, sha: *u8) -> i64
973func pub_changelog(ledpath: *u8, out: *u8, cap: i64) -> i64
1004func pub_approvers_path(approval_dir: *u8, sha: *u8, out: *u8) -> i64
1010func pub_has_line(path: *u8, needle: *u8) -> i64
1030func pub_approve_quorum(approval_dir: *u8, sha: *u8, approver: *u8) -> i64
1038func pub_quorum_met(approval_dir: *u8, sha: *u8, need: i64) -> i64
1050func pub_frozen(freeze_path: *u8) -> i64 { return pub_exists(freeze_path) }
calls 1: pub_exists
1052func pub_schedule_allows(now: i64, win_start: i64, win_end: i64, freeze_path: *u8) -> i64
called by 1: main calls 1: pub_exists
1064func pub_bg_cpath(slotroot: *u8, dest: *u8, color: *u8, out: *u8) -> i64
1072func pub_blue_green_stage(slotroot: *u8, dest: *u8, color: *u8, src: *u8, expect_sha: *u8) -> i64
1081func pub_blue_green_flip(slotroot: *u8, dest: *u8, color: *u8) -> i64
1096func pub_canary_rollout(expect_sha: *u8, src: *u8, slotroot: *u8, dest: *u8, urlbase: *u8, port: i64, cohort: i64) -> i64
1119func pub_promote_chain(expect_sha: *u8, src: *u8, dest: *u8, roots: *i64, nroots: i64, stageroot: *u8) -> i64
called by 2: mainmain calls 3: sys_mmappub_joinpub_deploy
1132func pub_fanout(expect_sha: *u8, src: *u8, dest: *u8, targets: *i64, ntargets: i64, stageroot: *u8) -> i64
1146func pub_flag_set(store: *u8, name: *u8, val: i64) -> i64
1153func pub_flag_get(store: *u8, name: *u8) -> i64
1177func pub_rolling(expect_sha: *u8, src: *u8, dest: *u8, targets: *i64, ntargets: i64, stageroot: *u8) -> i64
called by 2: mainmain calls 3: sys_mmappub_joinpub_deploy
1190func pub_retain(livepath: *u8) -> i64
called by 1: main calls 2: sys_mmappub_pcat
1198func pub_retry(succeed_at: i64, maxtries: i64, base_backoff_ms: i64) -> i64
called by 1: main calls 1: pub_nap_ms
1212func pub_submit_pri(qpath: *u8, src: *u8, dest: *u8, site: *u8, requester: *u8, policy: *u8, pri: i64) -> i64
1222func pub_priority_pick(qpath: *u8, out_dest: *u8) -> i64
1251func pub_lockgroup_res(site: *u8, out: *u8) -> i64
1259func pub_lockgroup_acquire(site: *u8) -> i64
1263func pub_lockgroup_release(fd: i64) -> i64 { return fl_release(fd) }
called by 1: main calls 1: fl_release
1270func pub_dns_config(domain: *u8, host: *u8, port: i64, out: *u8) -> i64
called by 2: mainpub_dns_emit calls 2: fa_catfa_catn
1280func pub_dns_emit(domain: *u8, host: *u8, port: i64, path: *u8) -> i64
1293func pub_run_drain(qpath: *u8, ledpath: *u8, stageroot: *u8, liveroot: *u8, lockres: *u8, approval_dir: *u8, max_cycles: i64, sleep_ms: i64) -> i64
called by 1: main calls 2: pub_run_governedpub_nap_ms
1311func pub_forbidden_call(code: *u8, n: i64) -> i64
called by 1: pub_audit_call_strict calls 1: pub_substr
1323func pub_audit_call_strict(path: *u8, allowlisted: i64) -> i64
1357func pub_daemon_heartbeat(hbpath: *u8) -> i64
1365func pub_daemon_hb_age(hbpath: *u8, now: i64) -> i64
1372func pub_daemon_watch_init(dirpath: *u8) -> i64
1379func pub_daemon_wait(infd: i64, timeout_ms: i64) -> i64
1389func pub_daemon_should_stop(stopflag: *u8) -> i64 { return pub_exists(stopflag) }
called by 2: mainpub_daemon_serve calls 1: pub_exists
1392func pub_daemon_serve(qpath: *u8, ledpath: *u8, stageroot: *u8, liveroot: *u8, lockres: *u8, approval: *u8, watchdir: *u8, hbpath: *u8, stopflag: *u8, max_cycles: i64, poll_ms: i64) -> i64