{ "description": "Review of return #159: independent direct gcd histogram oracle, streamed-versus-resident boundary checks, and an explicit periodic-padding fix. These are reviewer-created artifacts. Fetch the original C source blocks from return #159, put review-driver.c and review-oracle.py next to src/, and build as in commands.", "commands": [ "clang -O1 -g -fsanitize=address,undefined -pthread -o review-driver src/tile.c src/analyze.c review-driver.c", "mkdir -p rerun", "./review-driver > rerun/review-driver.log", "python3 review-oracle.py" ], "files": { "reproduction/review-driver.c": "#include \n#include \n#include \n#include \"src/tct.h\"\n\nstatic uint64_t gcd64(uint64_t a, uint64_t b) {\n while (b) { uint64_t c = a % b; a = b; b = c; }\n return a;\n}\n\n/* Direct gcd sieve, independent of the submitted tile generator. */\nstatic Tile direct_tile(int x, uint64_t W) {\n uint64_t *slots = malloc(W * sizeof(uint64_t));\n uint64_t D = 0;\n for (uint64_t n = 0; n < W; n++)\n if (gcd64(n, W) == 1 && gcd64(n + 2, W) == 1) slots[D++] = n;\n Tile t = {.x=x, .D=D, .W=W, .s0=slots[0], .gmax=0};\n t.g6 = malloc(D + LOOK + 1);\n for (uint64_t i = 0; i < D; i++) {\n uint64_t g = (i + 1 == D ? slots[0] + W : slots[i+1]) - slots[i];\n if (g % 6 || g / 6 > 255) exit(2);\n t.g6[i] = g / 6;\n if (g > t.gmax) t.gmax = g;\n }\n for (uint64_t j = 0; j <= LOOK; j++) t.g6[D+j] = t.g6[j % D];\n free(slots);\n return t;\n}\n\nstatic int equal_acc(const Acc *a, const Acc *b) {\n return !memcmp(a->histN,b->histN,sizeof a->histN)\n && !memcmp(a->histQl,b->histQl,sizeof a->histQl)\n && !memcmp(a->histQa,b->histQa,sizeof a->histQa)\n && !memcmp(a->histNew,b->histNew,sizeof a->histNew)\n && a->nIdx == b->nIdx && a->winLoose == b->winLoose\n && a->winAlt == b->winAlt && a->runsGE1 == b->runsGE1\n && a->maxL == b->maxL && a->maxQrun == b->maxQrun\n && a->ovf == 0 && b->ovf == 0;\n}\n\nint main(void) {\n const int xs[] = {7,11,13};\n const uint64_t ws[] = {210,2310,30030};\n const int qs[] = {11,13,17,19};\n for (int i=0;i<3;i++) {\n Tile t = direct_tile(xs[i],ws[i]);\n for (int j=0;j<4;j++) if (qs[j] > xs[i]) {\n Acc a; analyze_array(&t,qs[j],1,&a);\n if (a.ovf) return 2;\n printf(\"CASE %d %d %llu\\n\",xs[i],qs[j],(unsigned long long)t.W);\n for (int b=0;b1: interior.append(6*gaps[(i+L-1)%len(gaps)])\n if any(g%q not in (0,2,q-2) for g in interior): break\n total+=gaps[(i+L)%len(gaps)]\n loose[total]+=1\n legal=False\n for start in (0,q-2):\n r=start\n for g in interior:\n r=(r+g)%q\n if r not in (0,q-2): break\n else: legal=True\n if legal: alt[total]+=1\n else: raise AssertionError('Oracle window cap reached')\n old=collections.Counter(gaps)\n return {b:[old[b],loose[b],alt[b],new[b]] for b in sorted(old.keys()|loose.keys()|alt.keys()|new.keys())}\n\ncases=[]\nstream=[]\nfor line in (ROOT/'rerun/review-driver.log').read_text().splitlines():\n parts=line.split()\n if parts[0]=='CASE':\n cases.append({'x':int(parts[1]),'q':int(parts[2]),'W':int(parts[3]),'bins':{}})\n elif parts[0]=='BIN': cases[-1]['bins'][int(parts[1])]=list(map(int,parts[2:]))\n elif parts[0]=='STREAM': stream.append(line)\n\nresults=[]\nfor case in cases:\n expected=reference(case['x'],case['q'],case['W'])\n assert expected==case['bins'], (case['x'],case['q'])\n # Test every jump of the four integer-valued tail functions.\n for theta in range(0,max(expected)+2):\n N,Q,A,Nnew=[sum(row[k] for b,row in expected.items() if b>=theta) for k in range(4)]\n assert Nnew <= (case['q']-2)*N+2*A <= (case['q']-2)*N+2*Q\n altered={b:list(v) for b,v in case['bins'].items()}\n altered[min(altered)][3]+=1\n assert altered!=expected\n results.append({'old_prime':case['x'],'fold_prime':case['q'],'all_four_histograms_match':True,'bins':len(expected),'single_count_negative_control_detected':True})\nassert len(stream)==15 and all(s.endswith('PASS') for s in stream)\nout={'direct_gcd_cases':results,'stream_array_comparisons':stream,'status':'PASS'}\n(ROOT.parent/'independent-check.json').write_text(json.dumps(out,indent=2)+'\\n')\nprint(json.dumps(out,indent=2))\n", "independent-check.json": "{\n \"direct_gcd_cases\": [\n {\n \"old_prime\": 7,\n \"fold_prime\": 11,\n \"all_four_histograms_match\": true,\n \"bins\": 7,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 7,\n \"fold_prime\": 13,\n \"all_four_histograms_match\": true,\n \"bins\": 7,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 7,\n \"fold_prime\": 17,\n \"all_four_histograms_match\": true,\n \"bins\": 7,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 7,\n \"fold_prime\": 19,\n \"all_four_histograms_match\": true,\n \"bins\": 7,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 11,\n \"fold_prime\": 13,\n \"all_four_histograms_match\": true,\n \"bins\": 10,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 11,\n \"fold_prime\": 17,\n \"all_four_histograms_match\": true,\n \"bins\": 12,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 11,\n \"fold_prime\": 19,\n \"all_four_histograms_match\": true,\n \"bins\": 12,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 13,\n \"fold_prime\": 17,\n \"all_four_histograms_match\": true,\n \"bins\": 17,\n \"single_count_negative_control_detected\": true\n },\n {\n \"old_prime\": 13,\n \"fold_prime\": 19,\n \"all_four_histograms_match\": true,\n \"bins\": 17,\n \"single_count_negative_control_detected\": true\n }\n ],\n \"stream_array_comparisons\": [\n \"STREAM 7 11 13 threads=1 PASS\",\n \"STREAM 7 11 13 threads=2 PASS\",\n \"STREAM 7 11 13 threads=3 PASS\",\n \"STREAM 7 11 13 threads=7 PASS\",\n \"STREAM 7 11 13 threads=9 PASS\",\n \"STREAM 11 13 17 threads=1 PASS\",\n \"STREAM 11 13 17 threads=2 PASS\",\n \"STREAM 11 13 17 threads=3 PASS\",\n \"STREAM 11 13 17 threads=7 PASS\",\n \"STREAM 11 13 17 threads=9 PASS\",\n \"STREAM 13 17 19 threads=1 PASS\",\n \"STREAM 13 17 19 threads=2 PASS\",\n \"STREAM 13 17 19 threads=3 PASS\",\n \"STREAM 13 17 19 threads=7 PASS\",\n \"STREAM 13 17 19 threads=9 PASS\"\n ],\n \"status\": \"PASS\"\n}\n", "periodic-padding.patch": "--- a/src/tile.c\n+++ b/src/tile.c\n@@ -78,7 +78,7 @@\n N.g6[n++] = (uint8_t)(g / 6);\n if ((int)g > gm) gm = (int)g;\n if (n != Dn) die(\"fold produced the wrong slot count\");\n- memcpy(N.g6 + Dn, N.g6, LOOK + 1);\n+ for (uint64_t j = 0; j <= LOOK; j++) N.g6[Dn + j] = N.g6[j % Dn];\n N.s0 = first; N.gmax = gm;\n return N;\n }\n" } }