code wiki / (root) / nx_pushback_publish_gate.nx

nx_pushback_publish_gate.nx source

↩ module page · 296 lines · 22754 B

1// nx_pushback_publish_gate.nx -- THE COMMUNITY PUSH-BACK GATE (/compare/modding MD23, 2026-09-06). A three-member house package 2// (an OBJ, a PNG under a subdirectory, a VMD) is written under /tmp/nx_pushback_publish_gate/pkg/ at runtime with one cc0 row 3// on a SCRATCH journal, a scratch community table (two dist targets, one api-desc target, one target demanding YES) and a 4// referee grade file. The rung's done-rule is the spine: one house character publishes to two communities with IDENTICAL 5// manifests (the written copies hash equal to each other and to the source), the archive is a real 7z the estate's own reader 6// counts, the content id is the sha256 of the written archive, the index row and the publish row carry the licence and the 7// grade; and every refusal the rung names is REFUSED BY NAME: a rip whose journal row carries a licence class the rights table 8// lacks (PROVENANCE UNKNOWN-LICENCE, cleared by a superseding journal row without re-emitting), a non-redistributable 9// package licence below the community floor, a tampered member and a forged head (MANIFEST-REFUSED), a missing or 10// out-of-range grade (UNGRADED), an unknown community, an unreadable table or manifest. The command is the second witness 11// through the ladder on the PRODUCTION community table (usage, the default grade path, the communities verb). 12// usage: nx_pushback_publish_gate (no args) 13// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 14import "nx_syscalls.nx" 15import "nx_gate_verdict.nx" 16import "nx_gatekit_lib.nx" 17import "nx_pushback_lib.nx" 18 19const PG_DIR: *u8 = "/tmp/nx_pushback_publish_gate" 20const PG_PKG: *u8 = "/tmp/nx_pushback_publish_gate/pkg" 21const PG_TEX: *u8 = "/tmp/nx_pushback_publish_gate/pkg/textures" 22const PG_A_REL: *u8 = "a.obj" 23const PG_B_REL: *u8 = "textures/b.png" 24const PG_C_REL: *u8 = "c.vmd" 25const PG_A: *u8 = "/tmp/nx_pushback_publish_gate/pkg/a.obj" 26const PG_B: *u8 = "/tmp/nx_pushback_publish_gate/pkg/textures/b.png" 27const PG_C: *u8 = "/tmp/nx_pushback_publish_gate/pkg/c.vmd" 28const PG_JRNL: *u8 = "/tmp/nx_pushback_publish_gate/assets.jrnl" 29const PG_CONF: *u8 = "/tmp/nx_pushback_publish_gate/communities.conf" 30const PG_CONF_ABSENT: *u8 = "/tmp/nx_pushback_publish_gate/absent.conf" 31const PG_GRADE: *u8 = "/tmp/nx_pushback_publish_gate/referee.grade" 32const PG_GRADE_BAD: *u8 = "/tmp/nx_pushback_publish_gate/bad.grade" 33const PG_GRADE_ABSENT: *u8 = "/tmp/nx_pushback_publish_gate/absent.grade" 34const PG_GRADE_IN_PKG: *u8 = "/tmp/nx_pushback_publish_gate/pkg/referee.grade" 35const PG_OUT1: *u8 = "/tmp/nx_pushback_publish_gate/out1" 36const PG_OUT2: *u8 = "/tmp/nx_pushback_publish_gate/out2" 37const PG_OUT3: *u8 = "/tmp/nx_pushback_publish_gate/out3" 38const PG_CLI_ARCHIVE: *u8 = "/tmp/nx_pushback_publish_gate/pkg/pushback/nishi-dist/house-cape-1.2.0.7z" 39const PG_M1: *u8 = "/tmp/nx_pushback_publish_gate/one.nxmod" 40const PG_M_NC: *u8 = "/tmp/nx_pushback_publish_gate/nc.nxmod" 41const PG_M_RIP: *u8 = "/tmp/nx_pushback_publish_gate/rip.nxmod" 42const PG_M_FORGED: *u8 = "/tmp/nx_pushback_publish_gate/forged.nxmod" 43const PG_M_ABSENT: *u8 = "/tmp/nx_pushback_publish_gate/absent.nxmod" 44const PG_ELF_LIVE: *u8 = "./nx_pushback_publish.elf" 45const PG_ELF_STAGE: *u8 = "./nx_pushback_publish.sov.elf.new" 46const PG_ELF_BUILD: *u8 = "buildroot/_build/nx_pushback_publish.sov.elf" 47const PG_NAME: *u8 = "house-cape" 48const PG_VER: *u8 = "1.2.0" 49const PG_GAMES: *u8 = "skyrimse,palworld" 50const PG_DEPS: *u8 = "nx_base@1.0" 51const PG_LIC: *u8 = "cc0-1.0" 52const PG_LIC_NC: *u8 = "cc-by-nc-4.0" 53const PG_LIC_RIP: *u8 = "rip-licence-unknown-zz" 54const PG_SRC_URL: *u8 = "https://example.invalid/house-cape" 55const PG_RIP_URL: *u8 = "https://ripsite.invalid/dark-elf-blader" 56const PG_ORIGIN: *u8 = "nx_pushback_publish_gate" 57const PG_EPOCH: i64 = 1788713000 58const PG_EPOCH2: i64 = 1788713001 59const PG_PERMIL: i64 = 812 60const PG_CAP: i64 = 65536 61const PG_DIR_MODE: i64 = 493 62const PG_FILE_MODE: i64 = 420 63const PG_A_LEN: i64 = 40 64const PG_B_LEN: i64 = 40 65const PG_C_LEN: i64 = 30 66const PG_VMD_MAGIC_LEN: i64 = 25 67const PG_MEMBERS: i64 = 3 68const PG_ARCHIVE_MEMBERS: i64 = 4 69const PG_CONF_ROWS: i64 = 4 70const PG_ARCH_NAME: *u8 = "house-cape-1.2.0.7z" 71const PG_MAN_NAME: *u8 = "house-cape-1.2.0.nxmod" 72const PG_COMM_2: *u8 = "nishi-dist,nishi-swarm" 73const PG_COMM_3: *u8 = "nishi-dist,nishi-swarm,nexus-desc" 74const PG_COMM_DIST: *u8 = "nishi-dist" 75const PG_COMM_STRICT: *u8 = "strict-only" 76const PG_COMM_NOBODY: *u8 = "nobody" 77const PG_CONF_TEXT: *u8 = "community|nishi-dist|dist|https://nishifamily.com/dist|1|scratch dist target\ncommunity|nishi-swarm|dist|magnet|1|scratch swarm target\ncommunity|nexus-desc|api-desc|https://api.nexusmods.com/v1|2|scratch descriptor target\ncommunity|strict-only|dist|magnet|2|demands an outright YES\n" 78const PG_GRADE_TEXT: *u8 = "grade|812|cjc_panel|2026-09-06\n" 79const PG_GRADE_BAD_TEXT: *u8 = "grade|1500|cjc_panel|2026-09-06\n" 80 81func pg_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 82func pg_write_file(path: *u8, b: *u8, n: i64) -> i64 { 83 let fd: i64 = sys_openat_wr(path, PG_FILE_MODE) 84 if fd < 0 { return 0 - 1 } 85 var done: i64 = 0 86 while done < n { let k: i64 = sys_write(fd, b + done, n - done); if k <= 0 { break } done = done + k } 87 sys_close(fd) 88 return done 89} 90func pg_write_text(path: *u8, s: *u8) -> i64 { return pg_write_file(path, s, mm_len(s)) } 91func pg_same_file(a: *u8, b: *u8) -> i64 { 92 let la: *i64 = sys_mmap(16) as *i64 93 let lb: *i64 = sys_mmap(16) as *i64 94 let ba: *u8 = sys_read_file(a, la) 95 let bb: *u8 = sys_read_file(b, lb) 96 if (ba as i64) == 0 { return 0 } 97 if (bb as i64) == 0 { return 0 } 98 if la[0] != lb[0] { return 0 } 99 var i: i64 = 0 100 while i < la[0] { if ba[i] != bb[i] { return 0 } i = i + 1 } 101 return 1 102} 103func pg_join(dir: *u8, name: *u8) -> *u8 { let o: *u8 = sys_mmap(PB_PATH_CAP); mm_join_path(dir, name, o); return o } 104func pg_join3(dir: *u8, sub: *u8, name: *u8) -> *u8 { return pg_join(pg_join(dir, sub), name) } 105func pg_write_a() -> i64 { return pg_write_file(PG_A, "v 0 0 0\nv 1 0 0\nv 0 1 0\nf 1 2 3\n# cape\n" as *u8, PG_A_LEN) } 106func pg_write_b(flip: i64) -> i64 { 107 let png: *u8 = sys_mmap(64) 108 png[0] = 137 as u8; png[1] = 80 as u8; png[2] = 78 as u8; png[3] = 71 as u8; png[4] = 13 as u8; png[5] = 10 as u8; png[6] = 26 as u8; png[7] = 10 as u8 109 var k: i64 = 8 110 while k < PG_B_LEN { png[k] = (k * 11 % 251) as u8; k = k + 1 } 111 if flip == 1 { png[20] = (((png[20] & 0xff) as i64) ^ 255) as u8 } 112 return pg_write_file(PG_B, png, PG_B_LEN) 113} 114func pg_write_c() -> i64 { 115 let v: *u8 = sys_mmap(64) 116 let src: *u8 = "Vocaloid Motion Data 0002" as *u8 117 var i: i64 = 0 118 while i < PG_VMD_MAGIC_LEN { v[i] = src[i]; i = i + 1 } 119 return pg_write_file(PG_C, v, PG_C_LEN) 120} 121func pg_emit(out: *u8, lic: *u8, head65: *u8, info: *i64) -> i64 { 122 let paths: *i64 = sys_mmap(8 * 4) as *i64 123 paths[0] = PG_A_REL as i64; paths[1] = PG_B_REL as i64; paths[2] = PG_C_REL as i64 124 return mm_emit(out, PG_NAME, PG_VER, PG_GAMES, PG_DEPS, lic, PG_JRNL, PG_PKG, paths, PG_MEMBERS, head65, info) 125} 126func pg_contains(path: *u8, needle: *u8) -> i64 { 127 let lp: *i64 = sys_mmap(16) as *i64 128 let b: *u8 = sys_read_file(path, lp) 129 if (b as i64) == 0 { return 0 } 130 return gk_out_has(b, lp[0], needle) 131} 132 133func main(argc: i64, argv: *i64) -> i64 { 134 let ctr: *i64 = gv_ctr() 135 sys_mkdir(PG_DIR, PG_DIR_MODE) 136 sys_mkdir(PG_PKG, PG_DIR_MODE) 137 sys_mkdir(PG_TEX, PG_DIR_MODE) 138 sys_unlinkat(PG_JRNL) 139 sys_unlinkat(PG_GRADE_IN_PKG) 140 sys_unlinkat(PG_CLI_ARCHIVE) 141 gv_check_eq("fixture-a-written" as *u8, pg_write_a(), PG_A_LEN, ctr) 142 gv_check_eq("fixture-b-written" as *u8, pg_write_b(0), PG_B_LEN, ctr) 143 gv_check_eq("fixture-c-written" as *u8, pg_write_c(), PG_C_LEN, ctr) 144 let sha_a: *u8 = sys_mmap(PV_SHA_HEX + 1) 145 gv_check_eq("fixture-a-hashed" as *u8, pv_hash_file(PG_A, sha_a), PG_A_LEN, ctr) 146 gv_check("scratch-journal-row-cc0-for-a" as *u8, (pv_row_write(PG_JRNL, sha_a, PG_SRC_URL, PG_LIC, PG_ORIGIN, PG_EPOCH) > 0) as i64, ctr) 147 gv_check("scratch-community-table-written" as *u8, (pg_write_text(PG_CONF, PG_CONF_TEXT) > 0) as i64, ctr) 148 gv_check("scratch-grade-written" as *u8, (pg_write_text(PG_GRADE, PG_GRADE_TEXT) > 0) as i64, ctr) 149 gv_check("scratch-bad-grade-written" as *u8, (pg_write_text(PG_GRADE_BAD, PG_GRADE_BAD_TEXT) > 0) as i64, ctr) 150 // ---- 1. the table and the grade ---- 151 let tbl: *i64 = sys_mmap(8 * PB_C_SLOTS * PB_MAX_COMMUNITIES) as *i64 152 gv_check_eq("conf-loads-every-community-row" as *u8, pb_conf_load(PG_CONF, tbl, PB_MAX_COMMUNITIES), PG_CONF_ROWS, ctr) 153 gv_check_eq("conf-find-nishi-swarm-is-row-1" as *u8, pb_find(tbl, PG_CONF_ROWS, "nishi-swarm" as *u8), 1, ctr) 154 gv_check_eq("conf-find-unknown-id-is-minus-1" as *u8, pb_find(tbl, PG_CONF_ROWS, PG_COMM_NOBODY), 0 - 1, ctr) 155 gv_check_eq("conf-row-2-kind-api-desc" as *u8, pb_kind_code(tbl[2 * PB_C_SLOTS + PB_C_KIND] as *u8), PB_KIND_APIDESC, ctr) 156 gv_check_eq("conf-strict-row-floor-YES (2)" as *u8, tbl[3 * PB_C_SLOTS + PB_C_MINREDIST], LG_YES, ctr) 157 gv_check_eq("conf-absent-file-CONF-UNREADABLE" as *u8, pb_conf_load(PG_CONF_ABSENT, tbl, PB_MAX_COMMUNITIES), PB_ERR_CONF_UNREADABLE, ctr) 158 let g: *i64 = sys_mmap(8 * PB_G_N) as *i64 159 gv_check_eq("grade-file-reads-OK" as *u8, pb_grade_read(PG_GRADE, g), PB_OK, ctr) 160 gv_check_eq("grade-permil-812" as *u8, g[PB_G_PERMIL], PG_PERMIL, ctr) 161 gv_check("grade-judge-cjc_panel" as *u8, mm_streq(g[PB_G_JUDGE] as *u8, "cjc_panel" as *u8), ctr) 162 gv_check_eq("neg-control-grade-over-1000-permil-UNGRADED" as *u8, pb_grade_read(PG_GRADE_BAD, g), PB_ERR_UNGRADED, ctr) 163 gv_check_eq("neg-control-grade-absent-file-UNGRADED" as *u8, pb_grade_read(PG_GRADE_ABSENT, g), PB_ERR_UNGRADED, ctr) 164 // ---- 2. the house package publishes to three communities with identical manifests ---- 165 let head1: *u8 = sys_mmap(MM_SHA_HEX + 1) 166 let info: *i64 = sys_mmap(8 * 8) as *i64 167 let n1: i64 = pg_emit(PG_M1, PG_LIC, head1, info) 168 gv_check("manifest-emits (cc0-1.0)" as *u8, (n1 > 0) as i64, ctr) 169 let sum: *i64 = sys_mmap(8 * PB_S_N) as *i64 170 let rows: *i64 = sys_mmap(8 * PB_R_N * PB_MAX_IDS) as *i64 171 let got: i64 = pushback_publish(PG_PKG, PG_M1, PG_COMM_3, PG_OUT1, PG_GRADE, PG_CONF, PG_JRNL, sum, rows) 172 gv_check_eq("publish-three-communities-returns-3" as *u8, got, 3, ctr) 173 gv_check_eq("summary-published-3" as *u8, sum[PB_S_PUBLISHED], 3, ctr) 174 gv_check_eq("summary-refused-0" as *u8, sum[PB_S_REFUSED], 0, ctr) 175 gv_check_eq("summary-partition-requested-equals-published-plus-refused" as *u8, sum[PB_S_REQUESTED], sum[PB_S_PUBLISHED] + sum[PB_S_REFUSED], ctr) 176 gv_check_eq("summary-identical-manifests-1" as *u8, sum[PB_S_IDENTICAL], 1, ctr) 177 gv_check_eq("summary-members-3" as *u8, sum[PB_S_MEMBERS], PG_MEMBERS, ctr) 178 gv_check_eq("summary-referee-permil-812" as *u8, sum[PB_S_PERMIL], PG_PERMIL, ctr) 179 gv_check_eq("row-0-kind-dist" as *u8, rows[PB_R_KIND], PB_KIND_DIST, ctr) 180 gv_check_eq("row-2-kind-api-desc" as *u8, rows[2 * PB_R_N + PB_R_KIND], PB_KIND_APIDESC, ctr) 181 let m_dist: *u8 = pg_join3(PG_OUT1, "nishi-dist" as *u8, PG_MAN_NAME) 182 let m_swarm: *u8 = pg_join3(PG_OUT1, "nishi-swarm" as *u8, PG_MAN_NAME) 183 let m_desc: *u8 = pg_join3(PG_OUT1, "nexus-desc" as *u8, PG_MAN_NAME) 184 gv_check("bundle-manifest-copy-exists (nishi-dist)" as *u8, pg_exists(m_dist), ctr) 185 gv_check("bundle-manifest-copy-byte-identical-to-the-source" as *u8, pg_same_file(m_dist, PG_M1), ctr) 186 gv_check("two-communities-carry-identical-manifests (the rung's done-rule)" as *u8, pg_same_file(m_dist, m_swarm), ctr) 187 gv_check("descriptor-community-carries-the-same-manifest" as *u8, pg_same_file(m_dist, m_desc), ctr) 188 let sha_src: *u8 = sys_mmap(PV_SHA_HEX + 1) 189 pv_hash_file(PG_M1, sha_src) 190 gv_check("row-manifest-sha-is-the-hash-of-the-written-copy" as *u8, mm_streq(rows[PB_R_MANIFEST_SHA] as *u8, sha_src), ctr) 191 let a_dist: *u8 = pg_join3(PG_OUT1, "nishi-dist" as *u8, PG_ARCH_NAME) 192 let a_swarm: *u8 = pg_join3(PG_OUT1, "nishi-swarm" as *u8, PG_ARCH_NAME) 193 gv_check("bundle-archive-exists" as *u8, pg_exists(a_dist), ctr) 194 gv_check("bundle-archives-byte-identical-across-communities (deterministic writer)" as *u8, pg_same_file(a_dist, a_swarm), ctr) 195 let la: *i64 = sys_mmap(16) as *i64 196 let ab: *u8 = sys_read_file(a_dist, la) 197 gv_check("archive-readable" as *u8, ((ab as i64) != 0) as i64, ctr) 198 gv_check_eq("archive-bytes-equal-the-row" as *u8, la[0], rows[PB_R_ARCHIVE_BYTES], ctr) 199 gv_kv("archive_bytes" as *u8, la[0]) 200 gv_check_eq("archive-is-a-7z-by-signature" as *u8, sz_is_7z(ab, la[0]), 1, ctr) 201 gv_check_eq("archive-counts-manifest-plus-every-member (the estate's own reader)" as *u8, sz_count(ab, la[0]), PG_ARCHIVE_MEMBERS, ctr) 202 let sha_arch: *u8 = sys_mmap(PV_SHA_HEX + 1) 203 pv_hash_file(a_dist, sha_arch) 204 gv_check("cid-is-the-sha256-of-the-written-archive" as *u8, mm_streq(rows[PB_R_CID] as *u8, sha_arch), ctr) 205 let i_dist: *u8 = pg_join3(PG_OUT1, "nishi-dist" as *u8, PB_INDEX_FILE) 206 gv_check("index-row-carries-the-cid" as *u8, pg_contains(i_dist, sha_arch), ctr) 207 gv_check("index-row-carries-the-btmh-magnet" as *u8, pg_contains(i_dist, "magnet:?xt=urn:btmh:1220" as *u8), ctr) 208 gv_check("index-row-carries-the-dist-url" as *u8, pg_contains(i_dist, "https://nishifamily.com/dist/" as *u8), ctr) 209 let p_dist: *u8 = pg_join3(PG_OUT1, "nishi-dist" as *u8, PB_ROW_FILE) 210 let p_desc: *u8 = pg_join3(PG_OUT1, "nexus-desc" as *u8, PB_ROW_FILE) 211 gv_check("publish-row-carries-licence-redist-and-member-count" as *u8, pg_contains(p_dist, "|cc0-1.0|2|3|" as *u8), ctr) 212 gv_check("publish-row-carries-the-referee-grade-and-the-dist-transport" as *u8, pg_contains(p_dist, "|812|cjc_panel|2026-09-06|dist-index" as *u8), ctr) 213 gv_check("descriptor-publish-row-names-the-endpoint" as *u8, pg_contains(p_desc, "|api-desc|https://api.nexusmods.com/v1|" as *u8), ctr) 214 gv_check("descriptor-publish-row-names-the-keyed-door-as-owed" as *u8, pg_contains(p_desc, "descriptor-awaiting-keyed-door" as *u8), ctr) 215 // a community demanding YES takes a cc0 package (the floor test passes at the boundary) 216 let got_s: i64 = pushback_publish(PG_PKG, PG_M1, PG_COMM_STRICT, PG_OUT3, PG_GRADE, PG_CONF, PG_JRNL, sum, rows) 217 gv_check_eq("strict-community-takes-a-cc0-package (redist 2 meets floor 2)" as *u8, got_s, 1, ctr) 218 // ---- 3. refusals, each by name ---- 219 let hx: *u8 = sys_mmap(MM_SHA_HEX + 1) 220 let n_nc: i64 = pg_emit(PG_M_NC, PG_LIC_NC, hx, info) 221 gv_check("fixture-reached-the-condition: cc-by-nc manifest emitted (redist 0)" as *u8, (n_nc > 0) as i64, ctr) 222 gv_check_eq("neg-control-non-redistributable-licence-refused-by-name" as *u8, pushback_publish(PG_PKG, PG_M_NC, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 223 gv_check_eq("non-redistributable-rc-NON-REDISTRIBUTABLE" as *u8, rows[PB_R_RC], PB_ERR_NON_REDISTRIBUTABLE, ctr) 224 gv_check_eq("non-redistributable-reason-is-the-redist-level (0)" as *u8, rows[PB_R_REASON], LG_NO, ctr) 225 gv_check_eq("non-redistributable-writes-no-archive" as *u8, pg_exists(pg_join3(PG_OUT2, "nishi-dist" as *u8, PG_ARCH_NAME)), 0, ctr) 226 // a rip: c.vmd gets a journal row whose licence class the rights table lacks 227 let sha_c: *u8 = sys_mmap(PV_SHA_HEX + 1) 228 gv_check_eq("fixture-c-hashed" as *u8, pv_hash_file(PG_C, sha_c), PG_C_LEN, ctr) 229 gv_check("rip-journal-row-with-unknown-licence-class-written" as *u8, (pv_row_write(PG_JRNL, sha_c, PG_RIP_URL, PG_LIC_RIP, PG_ORIGIN, PG_EPOCH) > 0) as i64, ctr) 230 let n_rip: i64 = pg_emit(PG_M_RIP, PG_LIC, hx, info) 231 gv_check("rip-manifest-emits" as *u8, (n_rip > 0) as i64, ctr) 232 gv_check("fixture-reached-the-condition: manifest prov row reads UNKNOWN-LICENCE" as *u8, pg_contains(PG_M_RIP, "|REFUSE|UNKNOWN-LICENCE" as *u8), ctr) 233 gv_check_eq("neg-control-rip-with-unknown-class-refused (the rung's own words)" as *u8, pushback_publish(PG_PKG, PG_M_RIP, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 234 gv_check_eq("rip-rc-PROVENANCE" as *u8, rows[PB_R_RC], PB_ERR_PROVENANCE, ctr) 235 gv_check_eq("rip-refusing-member-is-c (index 2)" as *u8, rows[PB_R_MEMBER_IDX], 2, ctr) 236 gv_check_eq("rip-reason-UNKNOWN-LICENCE" as *u8, rows[PB_R_REASON], PV_R_UNKNOWN_LIC, ctr) 237 gv_check("rip-journal-superseding-cc0-row-written (append-only, last row wins)" as *u8, (pv_row_write(PG_JRNL, sha_c, PG_RIP_URL, PG_LIC, PG_ORIGIN, PG_EPOCH2) > 0) as i64, ctr) 238 gv_check_eq("superseding-row-clears-the-refusal-without-re-emitting (the journal is the authority at publish time)" as *u8, pushback_publish(PG_PKG, PG_M_RIP, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 1, ctr) 239 // a tampered member 240 gv_check_eq("fixture-reached-the-condition: b.png rewritten with one byte flipped" as *u8, pg_write_b(1), PG_B_LEN, ctr) 241 gv_check_eq("neg-control-tampered-member-refused" as *u8, pushback_publish(PG_PKG, PG_M1, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 242 gv_check_eq("tampered-rc-MANIFEST-REFUSED" as *u8, rows[PB_R_RC], PB_ERR_MANIFEST_REFUSED, ctr) 243 gv_check_eq("tampered-reason-TAMPERED" as *u8, rows[PB_R_REASON], MM_V_TAMPERED, ctr) 244 gv_check_eq("restore-b" as *u8, pg_write_b(0), PG_B_LEN, ctr) 245 gv_check_eq("publishes-again-after-restore (the refusal tracked the bytes)" as *u8, pushback_publish(PG_PKG, PG_M1, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 1, ctr) 246 // a forged head 247 let lp1: *i64 = sys_mmap(16) as *i64 248 let mb1: *u8 = sys_read_file(PG_M1, lp1) 249 let fb: *u8 = sys_mmap(lp1[0] + 16) 250 var i: i64 = 0 251 while i < lp1[0] { fb[i] = mb1[i]; i = i + 1 } 252 let hp: i64 = lp1[0] - 2 253 if (fb[hp] as i64) == 48 { fb[hp] = 49 as u8 } else { fb[hp] = 48 as u8 } 254 pg_write_file(PG_M_FORGED, fb, lp1[0]) 255 gv_check_eq("neg-control-forged-head-refused" as *u8, pushback_publish(PG_PKG, PG_M_FORGED, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 256 gv_check_eq("forged-head-reason-HEAD" as *u8, rows[PB_R_REASON], MM_V_HEAD, ctr) 257 // no grade, a bad grade, an unknown community, an unreadable table, an unreadable manifest 258 gv_check_eq("neg-control-absent-grade-refused" as *u8, pushback_publish(PG_PKG, PG_M1, PG_COMM_DIST, PG_OUT2, PG_GRADE_ABSENT, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 259 gv_check_eq("absent-grade-rc-UNGRADED" as *u8, rows[PB_R_RC], PB_ERR_UNGRADED, ctr) 260 gv_check_eq("absent-grade-summary-permil-minus-1" as *u8, sum[PB_S_PERMIL], 0 - 1, ctr) 261 gv_check_eq("neg-control-out-of-range-grade-refused-UNGRADED" as *u8, pushback_publish(PG_PKG, PG_M1, PG_COMM_DIST, PG_OUT2, PG_GRADE_BAD, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 262 gv_check_eq("neg-control-unknown-community-refused" as *u8, pushback_publish(PG_PKG, PG_M1, PG_COMM_NOBODY, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), 0, ctr) 263 gv_check_eq("unknown-community-rc-NO-SUCH-COMMUNITY" as *u8, rows[PB_R_RC], PB_ERR_NO_SUCH_COMMUNITY, ctr) 264 gv_check_eq("unknown-community-partition-sums (1 = 0 + 1)" as *u8, sum[PB_S_REQUESTED], sum[PB_S_PUBLISHED] + sum[PB_S_REFUSED], ctr) 265 gv_check_eq("neg-control-unreadable-table-refuses-the-request" as *u8, pushback_publish(PG_PKG, PG_M1, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF_ABSENT, PG_JRNL, sum, rows), PB_ERR_CONF_UNREADABLE, ctr) 266 gv_check_eq("neg-control-unreadable-manifest-refuses-the-request" as *u8, pushback_publish(PG_PKG, PG_M_ABSENT, PG_COMM_DIST, PG_OUT2, PG_GRADE, PG_CONF, PG_JRNL, sum, rows), PB_ERR_MANIFEST_UNREADABLE, ctr) 267 gv_check("err-names-are-readable (PROVENANCE)" as *u8, mm_streq(pb_err_name(PB_ERR_PROVENANCE), "PROVENANCE" as *u8), ctr) 268 // ---- 4. the command as a second witness, on the PRODUCTION community table and the default paths ---- 269 var elf: *u8 = 0 as *u8 270 if pg_exists(PG_ELF_LIVE) == 1 { elf = PG_ELF_LIVE } 271 else { if pg_exists(PG_ELF_STAGE) == 1 { elf = PG_ELF_STAGE } else { if pg_exists(PG_ELF_BUILD) == 1 { elf = PG_ELF_BUILD } } } 272 gv_need("cli-witness-present (live, staged or build fossil of nx_pushback_publish)" as *u8, ((elf as i64) != 0) as i64, ctr) 273 if (elf as i64) != 0 { 274 let out: *u8 = sys_mmap(PG_CAP) 275 let bl: *i64 = sys_mmap(16) as *i64 276 let rc0: i64 = gk_run_capture(elf, "publish" as *u8, 0 as *u8, 0 as *u8, 0 as *u8, out, PG_CAP, bl) 277 gv_check_eq("cli-publish-without-args-is-usage-exit-2" as *u8, rc0, 2, ctr) 278 gv_check("cli-grade-in-package-written (the default grade path)" as *u8, (pg_write_text(PG_GRADE_IN_PKG, PG_GRADE_TEXT) > 0) as i64, ctr) 279 let rc1: i64 = gk_run_capture(elf, "publish" as *u8, PG_PKG, PG_M1, PG_COMM_2, out, PG_CAP, bl) 280 gv_check_eq("cli-publish-two-production-communities-exits-0" as *u8, rc1, 0, ctr) 281 gv_check("cli-publish-reads-GREEN" as *u8, gk_out_has(out, bl[0], "verdict=GREEN" as *u8), ctr) 282 gv_check("cli-publish-reads-published-2" as *u8, gk_out_has(out, bl[0], "published=2" as *u8), ctr) 283 gv_check("cli-publish-names-the-dist-transport" as *u8, gk_out_has(out, bl[0], "transport=dist-index" as *u8), ctr) 284 gv_check("cli-default-outdir-under-the-package-carries-the-archive" as *u8, pg_exists(PG_CLI_ARCHIVE), ctr) 285 sys_unlinkat(PG_GRADE_IN_PKG) 286 let rc2: i64 = gk_run_capture(elf, "publish" as *u8, PG_PKG, PG_M1, PG_COMM_2, out, PG_CAP, bl) 287 gv_check_eq("cli-publish-without-a-grade-exits-3" as *u8, rc2, 3, ctr) 288 gv_check("cli-publish-without-a-grade-names-UNGRADED" as *u8, gk_out_has(out, bl[0], "rule=UNGRADED" as *u8), ctr) 289 gv_check("cli-publish-without-a-grade-reads-RED" as *u8, gk_out_has(out, bl[0], "verdict=RED" as *u8), ctr) 290 let rc3: i64 = gk_run_capture(elf, "communities" as *u8, 0 as *u8, 0 as *u8, 0 as *u8, out, PG_CAP, bl) 291 gv_check_eq("cli-communities-exits-0" as *u8, rc3, 0, ctr) 292 gv_check("cli-communities-lists-the-production-dist-target" as *u8, gk_out_has(out, bl[0], "id=nishi-dist kind=dist" as *u8), ctr) 293 } 294 gv_kv("published_in_process" as *u8, got) 295 return gv_verdict("NX-PUSHBACK-PUBLISH" as *u8, ctr, "a graded house package publishes to every requested community with byte-identical manifests, an estate-written 7z the estate's own reader counts, the content id of the written archive and rows carrying the licence and the referee grade; a rip with an unknown licence class, a non-redistributable licence, a tampered member, a forged head, an ungraded package, an unknown community and unreadable inputs each refuse by name; the command agrees on the production table" as *u8) 296}