nx_intelmine_propose_gate.nx source
↩ module page · 147 lines · 9462 B
1// nx_intelmine_propose_gate.nx -- GATE for the proposer (/compare/intelmine IM3 im_propose_rows, IM24 ic_propose): a
2// planted four-review journal, planted lexicons, a planted census row and a planted capability map under
3// /tmp/nx_intelmine_propose_gate; proposals land in per-domain files there, deduped on a second run. No network.
4// license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_reviewmine_lib.nx"
7import "nx_intelmine_lib.nx"
8import "nx_gate_verdict.nx"
9
10const G_DIR: *u8 = "/tmp/nx_intelmine_propose_gate"
11const G_OUT: *u8 = "/tmp/nx_intelmine_propose_gate/out"
12const G_JRNL: *u8 = "/tmp/nx_intelmine_propose_gate/777.jrnl"
13const G_CENSUS: *u8 = "/tmp/nx_intelmine_propose_gate/steam.census"
14const G_MAP: *u8 = "/tmp/nx_intelmine_propose_gate/capability_map.conf"
15const G_STOP: *u8 = "/tmp/nx_intelmine_propose_gate/stop.conf"
16const G_LD: *u8 = "/tmp/nx_intelmine_propose_gate/lex_defect.conf"
17const G_LF: *u8 = "/tmp/nx_intelmine_propose_gate/lex_feature.conf"
18const G_LE: *u8 = "/tmp/nx_intelmine_propose_gate/lex_exceed.conf"
19const G_LN: *u8 = "/tmp/nx_intelmine_propose_gate/lex_notmeet.conf"
20const G_LV: *u8 = "/tmp/nx_intelmine_propose_gate/lex_value.conf"
21const G_LM: *u8 = "/tmp/nx_intelmine_propose_gate/lex_demand.conf"
22const G_P_PERF: *u8 = "/tmp/nx_intelmine_propose_gate/out/performance.proposed"
23const G_P_GE: *u8 = "/tmp/nx_intelmine_propose_gate/out/gameengine.proposed"
24const G_P_CHAR: *u8 = "/tmp/nx_intelmine_propose_gate/out/charsim.proposed"
25const G_P_HAPT: *u8 = "/tmp/nx_intelmine_propose_gate/out/hapticcare.proposed"
26const G_APPID: i64 = 777
27const G_EPOCH: i64 = 1788623900
28
29func g_put(path: *u8, s: *u8) -> i64 { return rm_file_put(path, s, rm_slen(s)) }
30func g_row(recid: i64, up: i64, text: *u8) -> i64 {
31 let rec: *i64 = sys_mmap(RM_REC_BYTES) as *i64
32 var k: i64 = 0
33 while k < RM_F_N { rec[k] = 0; k = k + 1 }
34 rec[RM_F_RECID] = recid; rec[RM_F_UP] = up; rec[RM_F_PT_REVIEW] = 600; rec[RM_F_TEXTLEN] = rm_slen(text)
35 let row: *u8 = sys_mmap(RM_ROW_CAP)
36 let n: i64 = rm_row_emit(rec, "english" as *u8, text, row, RM_ROW_CAP)
37 return rm_file_append(G_JRNL, row, n)
38}
39func g_lines(path: *u8) -> i64 {
40 let lp: *i64 = sys_mmap(16) as *i64
41 lp[0] = 0
42 let b: *u8 = sys_read_file(path, lp)
43 if (b as i64) == 0 { return 0 }
44 var n: i64 = 0
45 var i: i64 = 0
46 while i < lp[0] { if (b[i] as i64) == RM_LF { n = n + 1 } i = i + 1 }
47 return n
48}
49func g_has(path: *u8, lit: *u8) -> i64 {
50 let lp: *i64 = sys_mmap(16) as *i64
51 lp[0] = 0
52 let b: *u8 = sys_read_file(path, lp)
53 if (b as i64) == 0 { return 0 }
54 if rm_find(b, lp[0], lit, 0) >= 0 { return 1 }
55 return 0
56}
57func g_load_all() -> i64 {
58 rm_vocab_reset()
59 rm_stopwords_load(G_STOP)
60 var lex: i64 = 0
61 lex = lex + rm_lexicon_load(G_LD, RM_LEX_DEFECT)
62 lex = lex + rm_lexicon_load(G_LF, RM_LEX_FEATURE)
63 lex = lex + rm_lexicon_load(G_LE, RM_LEX_EXCEED)
64 lex = lex + rm_lexicon_load(G_LN, RM_LEX_NOTMEET)
65 lex = lex + rm_lexicon_load(G_LV, RM_LEX_VALUE)
66 lex = lex + rm_lexicon_load(G_LM, RM_LEX_DEMAND)
67 return lex
68}
69
70func main() -> i64 {
71 gv_head("=== nx_intelmine_propose_gate -- mined signals to board proposals (intelmine IM3/IM24) ===" as *u8)
72 let c: *i64 = gv_ctr()
73 rm_mkdirp(G_OUT)
74 let empty: *u8 = sys_mmap(8)
75 rm_file_put(G_JRNL, empty, 0)
76 rm_file_put(G_P_PERF, empty, 0); rm_file_put(G_P_GE, empty, 0); rm_file_put(G_P_CHAR, empty, 0); rm_file_put(G_P_HAPT, empty, 0)
77 g_row(1, 0, "the controls are clunky and it will stutter" as *u8)
78 g_row(2, 1, "great character customization" as *u8)
79 g_row(3, 1, "customization is amazing but needs more" as *u8)
80 g_row(4, 0, "crash on start" as *u8)
81 g_put(G_STOP, "the\nand\nit\nis\nbut\n" as *u8)
82 g_put(G_LD, "stutter\ncrash\n" as *u8)
83 g_put(G_LF, "controls\ncustomization\n" as *u8)
84 g_put(G_LE, "amazing\n" as *u8)
85 g_put(G_LN, "refund\n" as *u8)
86 g_put(G_LV, "price\n" as *u8)
87 g_put(G_LM, "needs\n" as *u8)
88 g_put(G_MAP, "; planted\ndefect|stutter|performance|Frame pacing: {title} reviewers flag stutter\ndefect|crash|gameengine|Crash-free class: {title}\nfeature|controls|gameengine|Control mapping: {title}\nfeature|customization|charsim|Character customization: {title}\nengine|Unity|gameengine|Engine parity: {title} ships Unity\nvr|OpenXR|hapticcare|OpenXR door: {title}\n" as *u8)
89 g_put(G_CENSUS, "# header\ni|777|Planted Title|Planted|1000|1|1|1|english|0|1|Unity|-|OpenXR|FMOD|-|-|-|-|-|-|10|2|0|4|5|2|2|1000|dll:2:2\n" as *u8)
90 ip_init()
91 let maps: i64 = ip_map_load(G_MAP)
92 gv_check_eq("map-loaded-six-rows" as *u8, maps, 6, c)
93 gv_check("map-find-is-case-insensitive-on-the-term" as *u8, (ip_map_find("engine" as *u8, "unity" as *u8) >= 0) as i64, c)
94 gv_check_eq("neg-control-map-find-unknown-term-minus-one" as *u8, ip_map_find("feature" as *u8, "teapot" as *u8), 0 - 1, c)
95 let tb: *u8 = sys_mmap(512)
96 ip_map_title(ip_map_find("defect" as *u8, "stutter" as *u8), "Game X" as *u8, tb, 512)
97 gv_check("title-template-substitutes-the-name" as *u8, rm_streq(tb, "Frame pacing: Game X reviewers flag stutter" as *u8), c)
98 let lex: i64 = g_load_all()
99 gv_check_eq("lexicons-loaded-eight-terms" as *u8, lex, 8, c)
100 let docs: i64 = rm_rubric(G_JRNL, "english" as *u8)
101 gv_check_eq("rubric-docs-four" as *u8, docs, 4, c)
102 gv_check_eq("rubric-does-not-meet-two" as *u8, rm_rubric_tier(RM_TIER_DNM), 2, c)
103 gv_check_eq("rubric-exceeds-one" as *u8, rm_rubric_tier(RM_TIER_EXCEEDS), 1, c)
104 gv_check_eq("neg-control-census-unknown-appid-not-found" as *u8, ip_census_load(G_CENSUS, 778), 0, c)
105 gv_check("neg-control-miss-clears-the-name" as *u8, (ip_census_name_get()[0] == (0 as u8)) as i64, c)
106 let cen: i64 = ip_census_load(G_CENSUS, G_APPID)
107 gv_check("census-row-found" as *u8, cen, c)
108 gv_check("census-name-read" as *u8, rm_streq(ip_census_name_get(), "Planted Title" as *u8), c)
109 gv_check("census-engine-class-read" as *u8, rm_streq(ip_census_class_get(0), "Unity" as *u8), c)
110 gv_check("census-vr-class-read" as *u8, rm_streq(ip_census_class_get(2), "OpenXR" as *u8), c)
111 ip_counters_reset()
112 let nd: i64 = ip_propose_defects(G_OUT, G_EPOCH, G_APPID, ip_census_name_get(), 10, 1)
113 gv_check_eq("defects-proposed-two" as *u8, nd, 2, c)
114 let nf: i64 = ip_propose_features(G_OUT, G_EPOCH, G_APPID, ip_census_name_get(), 10, 1)
115 gv_check_eq("features-proposed-two" as *u8, nf, 2, c)
116 let ni: i64 = ip_propose_installed(G_OUT, G_EPOCH, G_APPID, ip_census_name_get())
117 gv_check_eq("installed-proposed-two-unity-openxr-fmod-unmapped" as *u8, ni, 2, c)
118 gv_check_eq("unmapped-counted-fmod" as *u8, ip_rows_unmapped_get(), 1, c)
119 gv_check_eq("rows-written-six" as *u8, ip_rows_written_get(), 6, c)
120 gv_check_eq("performance-file-one-row" as *u8, g_lines(G_P_PERF), 1, c)
121 gv_check_eq("gameengine-file-three-rows-crash-controls-unity" as *u8, g_lines(G_P_GE), 3, c)
122 gv_check_eq("charsim-file-one-row" as *u8, g_lines(G_P_CHAR), 1, c)
123 gv_check_eq("hapticcare-file-one-row" as *u8, g_lines(G_P_HAPT), 1, c)
124 gv_check("stutter-row-is-DEFECT-with-evidence" as *u8, g_has(G_P_PERF, "|DEFECT|defect|stutter|performance|Frame pacing: Planted Title reviewers flag stutter|does_not_meet=1" as *u8), c)
125 gv_check("controls-row-is-WE-DO-BETTER-complained-not-praised" as *u8, g_has(G_P_GE, "|WE-DO-BETTER|feature|controls|gameengine|" as *u8), c)
126 gv_check("customization-row-is-DEMANDED-praised-twice-asked-once" as *u8, g_has(G_P_CHAR, "|DEMANDED|feature|customization|charsim|" as *u8), c)
127 gv_check("customization-evidence-praised-two-demanded-one" as *u8, g_has(G_P_CHAR, "praised=2 complained=0 mixed=0 demanded=1" as *u8), c)
128 gv_check("unity-row-is-SHIPS" as *u8, g_has(G_P_GE, "|SHIPS|engine|Unity|gameengine|Engine parity: Planted Title ships Unity|fingerprint=installed-tree" as *u8), c)
129 gv_check("openxr-row-is-SHIPS-on-hapticcare" as *u8, g_has(G_P_HAPT, "|SHIPS|vr|OpenXR|hapticcare|" as *u8), c)
130 // idempotency: the same run again writes nothing and counts every row as already present
131 ip_counters_reset()
132 ip_propose_defects(G_OUT, G_EPOCH + 1, G_APPID, ip_census_name_get(), 10, 1)
133 ip_propose_features(G_OUT, G_EPOCH + 1, G_APPID, ip_census_name_get(), 10, 1)
134 ip_propose_installed(G_OUT, G_EPOCH + 1, G_APPID, ip_census_name_get())
135 gv_check_eq("rerun-writes-zero" as *u8, ip_rows_written_get(), 0, c)
136 gv_check_eq("rerun-already-present-six" as *u8, ip_rows_dup_get(), 6, c)
137 gv_check_eq("rerun-gameengine-file-still-three" as *u8, g_lines(G_P_GE), 3, c)
138 // a different title with the same terms is NOT a duplicate (dedupe is per appid)
139 ip_counters_reset()
140 ip_propose_installed(G_OUT, G_EPOCH + 2, 778, "Other Title" as *u8)
141 gv_check_eq("neg-control-another-appid-same-terms-writes-two" as *u8, ip_rows_written_get(), 2, c)
142 gv_values_head()
143 gv_kv("map_rows" as *u8, maps)
144 gv_kv("rubric_docs" as *u8, docs)
145 gv_kv("rows_first_run" as *u8, 6)
146 return gv_verdict("nx_intelmine_propose_gate" as *u8, c, "the map loader, the census row reader, the title template and the three proposers are proven on a planted four-review journal, a planted census row and a six-row map, with an unknown term, an unknown appid, an unmapped label and a same-terms-different-title run as the controls; a second identical run writes nothing; no network, all scratch under /tmp" as *u8)
147}