Publish Kernel Trap Cards

#1
by alphabell-research - opened
Files changed (10) hide show
  1. .gitignore +6 -0
  2. LICENSE +21 -0
  3. README.md +23 -5
  4. app.js +95 -0
  5. cases.mjs +141 -0
  6. index.html +49 -17
  7. make_thumbnail.py +30 -0
  8. styles.css +66 -0
  9. tests/cases.mjs +13 -0
  10. thumbnail.png +0 -0
.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ node_modules/
2
+ *.log
3
+ *-preview.png
4
+ .env
5
+ .env.*
6
+ !*.example
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alphaBell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,10 +1,28 @@
1
  ---
2
  title: Kernel Trap Cards
3
- emoji: 💻
4
- colorFrom: gray
5
- colorTo: pink
6
  sdk: static
7
- pinned: false
 
 
 
 
 
 
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Kernel Trap Cards
3
+ emoji: 🧪
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: static
7
+ app_file: index.html
8
+ thumbnail: https://huggingface.co/spaces/alphabell/Kernel-Trap-Cards/resolve/main/thumbnail.png
9
+ license: mit
10
+ tags:
11
+ - code-evaluation
12
+ - gpu-kernels
13
+ - agents
14
+ - education
15
+ short_description: One green test can lie. Find five hidden correctness traps.
16
  ---
17
 
18
+ # Kernel Trap Cards
19
+
20
+ Five short puzzles about false confidence in generated code. Each card presents a candidate sketch that passes a fixed input. Choose a second test; the browser runs the candidate and a reference and shows their first different result. The examples cover tail masks, row strides, accumulator overflow, row coverage and aliasing. Share a card with its `?case=` URL.
21
+
22
+ These are original, simplified CPU sketches. They teach the input-regime problem examined in Dipankar Sarkar's [paper on LLM-generated GPU kernel correctness](https://arxiv.org/abs/2606.20128) and [public GPU-kernel corpus](https://huggingface.co/datasets/dipankarsarkar/gpuemu-corpus). The paper's empirical claims belong to its authors; this quiz does not rerun the GPU experiments.
23
+
24
+ The app is static and makes no model calls or runtime network requests. All candidate and reference computations run in the browser.
25
+
26
+ ## Run locally
27
+
28
+ Serve this directory with any static HTTP server. For example, `python3 -m http.server 8000`, then open `http://localhost:8000/`. Run the puzzle-invariant check with `node tests/cases.mjs`.
app.js ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { cases, runTest } from './cases.mjs';
2
+
3
+ const byId = (id) => document.getElementById(id);
4
+ const initialSlug = new URLSearchParams(location.search).get('case');
5
+ let current = Math.max(0, cases.findIndex((item) => item.slug === initialSlug));
6
+ let score = 0;
7
+
8
+ function displayValue(value) {
9
+ if (value === null) return 'unwritten';
10
+ if (value === Infinity) return 'Infinity';
11
+ if (value === -Infinity) return '-Infinity';
12
+ return String(value);
13
+ }
14
+
15
+ function renderCase() {
16
+ const item = cases[current];
17
+ byId('case-card').hidden = false;
18
+ byId('final-card').hidden = true;
19
+ byId('progress').textContent = `Case ${current + 1} of ${cases.length}`;
20
+ byId('score').textContent = `Caught: ${score}`;
21
+ byId('case-number').textContent = `${String(current + 1).padStart(2, '0')} / ${String(cases.length).padStart(2, '0')}`;
22
+ byId('case-title').textContent = item.title;
23
+ byId('case-task').textContent = item.task;
24
+ byId('fixed-test').textContent = item.fixed;
25
+ byId('code').textContent = item.code;
26
+ byId('question').textContent = item.question;
27
+ byId('case-link').href = `?case=${encodeURIComponent(item.slug)}`;
28
+ byId('feedback').hidden = true;
29
+ byId('feedback').textContent = '';
30
+ byId('next').hidden = true;
31
+ byId('choices').replaceChildren();
32
+ history.replaceState({}, '', `?case=${encodeURIComponent(item.slug)}`);
33
+
34
+ item.choices.forEach((choice, index) => {
35
+ const button = document.createElement('button');
36
+ button.type = 'button';
37
+ button.className = 'choice';
38
+ button.innerHTML = `<span class="choice-index">${String.fromCharCode(65 + index)}</span><span></span><span class="choice-arrow" aria-hidden="true">&rarr;</span>`;
39
+ button.children[1].textContent = choice.label;
40
+ button.addEventListener('click', () => choose(item, choice, index));
41
+ byId('choices').append(button);
42
+ });
43
+ }
44
+
45
+ function choose(item, choice, index) {
46
+ if (!byId('next').hidden) return;
47
+ const mismatch = runTest(item, choice);
48
+ if (mismatch) score++;
49
+ const correctIndex = item.choices.findIndex((candidate) => runTest(item, candidate) !== null);
50
+ [...byId('choices').children].forEach((button, i) => {
51
+ button.disabled = true;
52
+ if (i === index) button.classList.add('selected');
53
+ if (i === correctIndex) button.classList.add('correct');
54
+ });
55
+
56
+ const feedback = byId('feedback');
57
+ const detail = mismatch || runTest(item, item.choices[correctIndex]);
58
+ const lead = mismatch ? 'Caught it.' : 'Still green.';
59
+ const evidence = `At index ${detail.index}, the reference returns ${displayValue(detail.expected)}; the candidate returns ${displayValue(detail.observed)}.`;
60
+ const alternative = mismatch ? '' : ` Try ${item.choices[correctIndex].label.toLowerCase()}.`;
61
+ feedback.className = `feedback ${mismatch ? 'caught' : 'missed'}`;
62
+ feedback.innerHTML = '<strong></strong><p></p><p></p>';
63
+ feedback.children[0].textContent = lead;
64
+ feedback.children[1].textContent = evidence + alternative;
65
+ feedback.children[2].textContent = item.lesson;
66
+ feedback.hidden = false;
67
+ byId('score').textContent = `Caught: ${score}`;
68
+ byId('next').textContent = current === cases.length - 1 ? 'See result' : 'Next trap';
69
+ byId('next').hidden = false;
70
+ byId('next').focus();
71
+ }
72
+
73
+ function renderEnd() {
74
+ byId('case-card').hidden = true;
75
+ byId('final-card').hidden = false;
76
+ byId('progress').textContent = 'Complete';
77
+ byId('score').textContent = `Caught: ${score}`;
78
+ byId('case-link').href = '?case=tail-mask';
79
+ byId('final-title').textContent = `You caught ${score} of ${cases.length}.`;
80
+ byId('restart').focus();
81
+ }
82
+
83
+ byId('next').addEventListener('click', () => {
84
+ if (current < cases.length - 1) {
85
+ current++;
86
+ renderCase();
87
+ byId('case-title').focus?.();
88
+ } else renderEnd();
89
+ });
90
+ byId('restart').addEventListener('click', () => {
91
+ current = 0;
92
+ score = 0;
93
+ renderCase();
94
+ });
95
+ renderCase();
cases.mjs ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export const cases = [
2
+ {
3
+ slug: 'tail-mask',
4
+ title: 'The missing tail',
5
+ task: 'Double every element of a vector.',
6
+ fixed: '1,024 elements, all values checked',
7
+ code: `for (start = 0; start + 64 <= n; start += 64) {
8
+ write(out[start : start + 64], 2 * x[start : start + 64]);
9
+ }`,
10
+ question: 'Which second test exposes the bug?',
11
+ choices: [
12
+ { label: 'Another 2,048-element vector', input: { n: 2048 } },
13
+ { label: 'A 1,030-element vector', input: { n: 1030 } },
14
+ { label: 'Different values, still 1,024 elements', input: { n: 1024, offset: 7 } },
15
+ ],
16
+ reference({ n, offset = 0 }) {
17
+ return Array.from({ length: n }, (_, i) => 2 * (i + offset));
18
+ },
19
+ candidate({ n, offset = 0 }) {
20
+ const out = Array(n).fill(null);
21
+ for (let start = 0; start + 64 <= n; start += 64) {
22
+ for (let i = start; i < start + 64; i++) out[i] = 2 * (i + offset);
23
+ }
24
+ return out;
25
+ },
26
+ lesson: 'The loop never launches a partial block. Tests whose lengths are multiples of 64 cannot reveal the unwritten tail.',
27
+ },
28
+ {
29
+ slug: 'row-stride',
30
+ title: 'The wrong row stride',
31
+ task: 'Triple every value in a 2D view.',
32
+ fixed: '4 by 3 contiguous view, all values checked',
33
+ code: `for (row = 0; row < height; row++)
34
+ for (col = 0; col < width; col++)
35
+ out[row, col] = 3 * storage[row * width + col];`,
36
+ question: 'Which input breaks the candidate?',
37
+ choices: [
38
+ { label: 'Contiguous 8 by 3 view', input: { width: 8, height: 3, stride: 8 } },
39
+ { label: 'Contiguous 4 by 3 view with negatives', input: { width: 4, height: 3, stride: 4, offset: -20 } },
40
+ { label: '4 by 3 view with row stride 6', input: { width: 4, height: 3, stride: 6 } },
41
+ ],
42
+ reference({ width, height, stride, offset = 0 }) {
43
+ return Array.from({ length: width * height }, (_, i) => 3 * (Math.floor(i / width) * stride + (i % width) + offset));
44
+ },
45
+ candidate({ width, height, offset = 0 }) {
46
+ return Array.from({ length: width * height }, (_, i) => 3 * (Math.floor(i / width) * width + (i % width) + offset));
47
+ },
48
+ lesson: 'Width is not a memory stride. A sliced or padded view can keep the same visible shape while changing where each row begins.',
49
+ },
50
+ {
51
+ slug: 'half-accumulator',
52
+ title: 'The half-precision accumulator',
53
+ task: 'Sum values and return a 32-bit result.',
54
+ fixed: '32 copies of 0.25, expected result 8',
55
+ code: `half total = 0;
56
+ for (i = 0; i < n; i++) total = half(total + x[i]);
57
+ return float32(total);`,
58
+ question: 'Which values expose the overflow?',
59
+ choices: [
60
+ { label: '64 copies of 0.25', input: { values: Array(64).fill(0.25) } },
61
+ { label: '60,000 and 60,000', input: { values: [60000, 60000] } },
62
+ { label: '1, 2, and 3', input: { values: [1, 2, 3] } },
63
+ ],
64
+ reference({ values }) {
65
+ return [values.reduce((sum, value) => sum + value, 0)];
66
+ },
67
+ candidate({ values }) {
68
+ let total = 0;
69
+ for (const value of values) {
70
+ total += value;
71
+ if (Math.abs(total) > 65504) total = total < 0 ? -Infinity : Infinity;
72
+ }
73
+ return [total];
74
+ },
75
+ lesson: 'The simplified half accumulator overflows above 65,504 even though the requested 32-bit output can represent the correct sum.',
76
+ },
77
+ {
78
+ slug: 'single-row',
79
+ title: 'The one-row illusion',
80
+ task: 'Add a column bias to every matrix row.',
81
+ fixed: '1 by 4 matrix, all values checked',
82
+ code: `out = copy(matrix);
83
+ for (col = 0; col < width; col++)
84
+ out[0, col] += bias[col];`,
85
+ question: 'Which shape exposes the missing work?',
86
+ choices: [
87
+ { label: '1 by 8 matrix', input: { rows: 1, width: 8 } },
88
+ { label: '2 by 4 matrix', input: { rows: 2, width: 4 } },
89
+ { label: '1 by 4 matrix with a different bias', input: { rows: 1, width: 4, biasOffset: 10 } },
90
+ ],
91
+ reference({ rows, width, biasOffset = 0 }) {
92
+ return Array.from({ length: rows * width }, (_, i) => i + 1 + (i % width) + biasOffset);
93
+ },
94
+ candidate({ rows, width, biasOffset = 0 }) {
95
+ const out = Array.from({ length: rows * width }, (_, i) => i + 1);
96
+ for (let col = 0; col < width; col++) out[col] += col + biasOffset;
97
+ return out;
98
+ },
99
+ lesson: 'The candidate only writes row zero. A one-row correctness test can check every value and still miss the missing rows.',
100
+ },
101
+ {
102
+ slug: 'aliasing',
103
+ title: 'The aliasing trap',
104
+ task: 'For each element after the first, add its left neighbor from the original input.',
105
+ fixed: 'Separate input and output buffers',
106
+ code: `for (i = 1; i < n; i++)
107
+ out[i] = x[i] + x[i - 1];`,
108
+ question: 'Which buffer setup changes the result?',
109
+ choices: [
110
+ { label: 'Separate buffers with larger values', input: { values: [10, 20, 30, 40], alias: false } },
111
+ { label: 'Output aliases input', input: { values: [1, 2, 3, 4], alias: true } },
112
+ { label: 'Separate buffers with more elements', input: { values: [1, 2, 3, 4, 5, 6], alias: false } },
113
+ ],
114
+ reference({ values }) {
115
+ const out = values.slice();
116
+ for (let i = 1; i < values.length; i++) out[i] = values[i] + values[i - 1];
117
+ return out;
118
+ },
119
+ candidate({ values, alias }) {
120
+ const input = values.slice();
121
+ const out = alias ? input : input.slice();
122
+ for (let i = 1; i < input.length; i++) out[i] = input[i] + input[i - 1];
123
+ return out;
124
+ },
125
+ lesson: 'When output aliases input, each write changes the left neighbor read by the next step. Separate-buffer tests never exercise that dependency.',
126
+ },
127
+ ];
128
+
129
+ export function compare(reference, candidate) {
130
+ if (reference.length !== candidate.length) return { index: -1, expected: reference.length, observed: candidate.length };
131
+ for (let index = 0; index < reference.length; index++) {
132
+ if (!Object.is(reference[index], candidate[index])) return { index, expected: reference[index], observed: candidate[index] };
133
+ }
134
+ return null;
135
+ }
136
+
137
+ export function runTest(testCase, choice) {
138
+ const expected = testCase.reference(choice.input);
139
+ const observed = testCase.candidate(choice.input);
140
+ return compare(expected, observed);
141
+ }
index.html CHANGED
@@ -1,19 +1,51 @@
1
  <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
  <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="theme-color" content="#0c1725">
7
+ <meta name="description" content="Five tiny correctness tests that pass a faulty kernel. Pick the second test that catches each bug, then compare real browser-run outputs.">
8
+ <title>Kernel Trap Cards | alphaBell</title>
9
+ <link rel="stylesheet" href="./styles.css">
10
+ <script type="module" src="./app.js"></script>
11
+ </head>
12
+ <body>
13
+ <header class="site-header">
14
+ <a class="brand" href="https://alphabell.com/" aria-label="alphaBell homepage"><span class="brand-mark">aB</span><span>alphaBell<span class="brand-sep"> / </span>Kernel Trap Cards</span></a>
15
+ <a class="header-link" href="https://huggingface.co/alphabell">Our lab on Hugging Face <span aria-hidden="true">&nearr;</span></a>
16
+ </header>
17
+
18
+ <main>
19
+ <section class="hero wrap" aria-labelledby="title">
20
+ <div class="eyebrow">Interactive code evaluation</div>
21
+ <h1 id="title">One green test can lie.</h1>
22
+ <p class="lede">A generated kernel passes the fixed test. Choose the next input that exposes what it missed. The browser runs both the candidate and a reference for every choice.</p>
23
+ <div class="hero-note">Five original teaching examples. About three minutes. No model call or upload.</div>
24
+ </section>
25
+
26
+ <section class="game wrap" aria-label="Kernel trap quiz">
27
+ <div class="game-topline"><div><span class="pill" id="progress">Case 1 of 5</span><span class="score" id="score">Caught: 0</span></div><a id="case-link" href="?case=tail-mask">Link to this case <span aria-hidden="true">&nearr;</span></a></div>
28
+
29
+ <article class="case-card" id="case-card">
30
+ <div class="case-head"><span class="case-number" id="case-number">01 / 05</span><h2 id="case-title"></h2><p id="case-task"></p></div>
31
+ <div class="test-badge"><span class="status-dot" aria-hidden="true"></span><div><strong>Fixed test passed</strong><span id="fixed-test"></span></div></div>
32
+ <div class="code-label">Candidate sketch</div><pre><code id="code"></code></pre>
33
+ <h3 id="question"></h3>
34
+ <div class="choices" id="choices" role="group" aria-labelledby="question"></div>
35
+ <div class="feedback" id="feedback" role="status" aria-live="polite" hidden></div>
36
+ <button class="next-button" id="next" type="button" hidden>Next trap <span aria-hidden="true">&rarr;</span></button>
37
+ </article>
38
+
39
+ <article class="final-card" id="final-card" hidden>
40
+ <div class="eyebrow">All five traps tested</div>
41
+ <h2 id="final-title"></h2>
42
+ <p>A passing fixed input says the candidate handled that input. Shape, stride, value range, row count and aliasing each need their own checks.</p>
43
+ <button class="next-button" id="restart" type="button">Try again <span aria-hidden="true">&rarr;</span></button>
44
+ </article>
45
+ </section>
46
+
47
+ <section class="source wrap" aria-labelledby="source-title"><div class="source-inner"><div><div class="eyebrow">Why this matters</div><h2 id="source-title">Correctness needs a wider input regime.</h2><p>These browser-run sketches use original examples, not GPU kernels. They illustrate the fixed-shape testing problem studied in Dipankar Sarkar's work on LLM-generated GPU kernels. His published corpus pairs deliberately faulty variants with correct controls and uses seeded tests across shapes and dtypes.</p></div><div class="source-links"><a href="https://arxiv.org/abs/2606.20128" target="_blank" rel="noopener noreferrer">Read the paper <span aria-hidden="true">&nearr;</span></a><a href="https://huggingface.co/datasets/dipankarsarkar/gpuemu-corpus" target="_blank" rel="noopener noreferrer">Inspect the corpus <span aria-hidden="true">&nearr;</span></a></div></div></section>
48
+ </main>
49
+ <footer class="footer wrap"><span>alphaBell</span><span>Test the boundary, then trust the score.</span></footer>
50
+ </body>
51
  </html>
make_thumbnail.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from PIL import Image, ImageDraw, ImageFont
3
+
4
+ out = Path(__file__).with_name("thumbnail.png")
5
+ im = Image.new("RGB", (1200, 630), (12, 23, 37))
6
+ d = ImageDraw.Draw(im)
7
+ font = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
8
+ bold = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
9
+ small = ImageFont.truetype(font, 25)
10
+ label = ImageFont.truetype(bold, 30)
11
+ title = ImageFont.truetype(bold, 81)
12
+
13
+ d.rounded_rectangle((50, 43, 210, 90), radius=17, fill=(30, 84, 75))
14
+ d.text((68, 52), "alphaBell", font=small, fill=(86, 221, 193))
15
+ d.text((50, 136), "ONE GREEN TEST", font=title, fill=(245, 249, 249))
16
+ d.text((50, 239), "CAN LIE.", font=title, fill=(86, 221, 193))
17
+ d.text((52, 348), "Five hidden correctness traps in generated code.", font=ImageFont.truetype(font, 31), fill=(184, 204, 215))
18
+
19
+ labels = ["TAIL", "STRIDE", "OVERFLOW", "ROWS", "ALIAS"]
20
+ x = 52
21
+ for i, text in enumerate(labels):
22
+ width = d.textbbox((0, 0), text, font=label)[2] + 47
23
+ d.rounded_rectangle((x, 460, x + width, 520), radius=16, fill=(26, 51, 68), outline=(64, 119, 108), width=2)
24
+ d.text((x + 23, 475), text, font=label, fill=(231, 246, 243))
25
+ x += width + 13
26
+
27
+ d.line((52, 563, 1147, 563), fill=(69, 93, 112), width=2)
28
+ d.text((52, 584), "Pick the second test. See the actual mismatch.", font=small, fill=(151, 181, 194))
29
+ im.save(out, optimize=True)
30
+ print(out, out.stat().st_size)
styles.css ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root { color-scheme: dark; --bg:#0c1725; --card:#15263a; --line:#30445a; --text:#f3f7f7; --muted:#b0c2cc; --mint:#56ddc1; --yellow:#f2c46d; }
2
+ * { box-sizing:border-box; }
3
+ html { scroll-behavior:smooth; }
4
+ body { margin:0; background:var(--bg); color:var(--text); font:16px/1.55 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
5
+ button, a { -webkit-tap-highlight-color:transparent; }
6
+ button { font:inherit; }
7
+ a { color:var(--mint); }
8
+ a:focus-visible, button:focus-visible { outline:3px solid var(--yellow); outline-offset:3px; }
9
+ [hidden] { display:none !important; }
10
+ .wrap { width:min(1100px,calc(100% - 48px)); margin-inline:auto; }
11
+ .site-header { min-height:70px; display:flex; align-items:center; justify-content:space-between; gap:20px; padding:12px max(24px,calc((100vw - 1100px)/2)); border-bottom:1px solid var(--line); }
12
+ .brand { display:flex; align-items:center; gap:12px; color:var(--text); text-decoration:none; font-weight:730; letter-spacing:-.015em; }
13
+ .brand-mark { width:36px; height:36px; display:grid; place-items:center; background:var(--mint); color:#09241f; border-radius:10px; font-weight:850; letter-spacing:-.08em; }
14
+ .brand-sep { color:#6c8695; }
15
+ .header-link { color:var(--muted); font-size:.88rem; text-decoration:none; }
16
+ .header-link:hover { color:var(--mint); }
17
+ .hero { padding:72px 0 46px; }
18
+ .eyebrow { color:var(--mint); font-size:.75rem; font-weight:850; letter-spacing:.17em; text-transform:uppercase; }
19
+ h1,h2,h3,p { margin-top:0; }
20
+ h1 { max-width:880px; margin:12px 0 16px; font-size:clamp(2.75rem,7vw,5.5rem); line-height:1.02; letter-spacing:-.055em; }
21
+ .lede { max-width:740px; margin-bottom:18px; color:#d6e3e8; font-size:clamp(1.05rem,2vw,1.3rem); }
22
+ .hero-note { color:var(--muted); font-size:.88rem; }
23
+ .game { padding-bottom:68px; }
24
+ .game-topline { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px; }
25
+ .game-topline>div { display:flex; align-items:center; gap:12px; }
26
+ .pill { display:inline-flex; align-items:center; padding:5px 12px; background:#20483f; color:var(--mint); border-radius:999px; font-size:.82rem; font-weight:800; }
27
+ .score { color:var(--muted); font-size:.85rem; }
28
+ .game-topline a { color:var(--muted); font-size:.85rem; text-decoration:none; }
29
+ .game-topline a:hover { color:var(--mint); }
30
+ .case-card,.final-card { padding:36px; background:var(--card); border:1px solid #2b455a; border-radius:24px; box-shadow:0 18px 55px #050e1880; }
31
+ .case-number { color:var(--mint); font-size:.8rem; font-weight:800; letter-spacing:.13em; }
32
+ .case-head h2,.final-card h2 { margin:9px 0 8px; font-size:clamp(1.75rem,4vw,2.6rem); line-height:1.12; letter-spacing:-.035em; }
33
+ .case-head p { margin-bottom:22px; color:#d4e1e8; }
34
+ .test-badge { display:flex; gap:12px; align-items:center; margin-bottom:28px; padding:15px 18px; border-radius:14px; background:#1a3b3a; border:1px solid #2a6157; }
35
+ .status-dot { flex:none; width:10px; height:10px; background:var(--mint); border-radius:50%; box-shadow:0 0 0 4px #56ddc123; }
36
+ .test-badge strong,.test-badge span:not(.status-dot) { display:block; }
37
+ .test-badge span:not(.status-dot) { color:#bbdbd3; font-size:.87rem; }
38
+ .code-label { margin-bottom:8px; color:#abc3cf; font-size:.77rem; font-weight:750; letter-spacing:.12em; text-transform:uppercase; }
39
+ pre { overflow:auto; margin:0 0 31px; padding:22px; background:#08121d; border:1px solid #2b4458; border-radius:14px; color:#d7f3ee; font:clamp(.79rem,1.4vw,.98rem)/1.65 ui-monospace,SFMono-Regular,Consolas,monospace; }
40
+ h3 { margin-bottom:15px; font-size:1.1rem; }
41
+ .choices { display:grid; gap:10px; }
42
+ .choice { min-height:60px; display:flex; align-items:center; gap:14px; width:100%; padding:11px 16px; border:1px solid #466073; border-radius:13px; background:#1c3044; color:var(--text); text-align:left; cursor:pointer; transition:background .15s,border-color .15s,transform .15s; }
43
+ .choice:not(:disabled):hover { background:#27445b; border-color:var(--mint); transform:translateY(-1px); }
44
+ .choice:disabled { cursor:default; opacity:.72; }
45
+ .choice.selected { border-color:var(--yellow); opacity:1; }
46
+ .choice.correct { border-color:var(--mint); opacity:1; }
47
+ .choice-index { flex:none; width:26px; height:26px; display:grid; place-items:center; border-radius:7px; color:#0b1825; background:#9cc8c6; font-size:.78rem; font-weight:850; }
48
+ .choice-arrow { margin-left:auto; color:var(--mint); }
49
+ .feedback { margin-top:20px; padding:20px; border-radius:14px; border:1px solid #647486; background:#213447; }
50
+ .feedback.caught { border-color:#3c8c77; background:#173c3b; }
51
+ .feedback.missed { border-color:#8e754c; background:#3d342b; }
52
+ .feedback strong { display:block; margin-bottom:4px; font-size:1.18rem; }
53
+ .feedback p { margin:5px 0 0; color:#e2e9e8; }
54
+ .next-button { margin-top:22px; min-height:48px; padding:10px 20px; border:0; border-radius:10px; background:var(--mint); color:#08251e; font-weight:850; cursor:pointer; }
55
+ .next-button:hover { background:#84edd8; }
56
+ .final-card p { max-width:650px; color:#d0dfe5; }
57
+ .source { padding-bottom:75px; }
58
+ .source-inner { display:grid; grid-template-columns:1fr auto; gap:36px; padding:28px 32px; border:1px solid var(--line); border-radius:18px; background:#101f30; }
59
+ .source h2 { margin:7px 0 10px; font-size:1.6rem; }
60
+ .source p { max-width:760px; margin:0; color:var(--muted); }
61
+ .source-links { display:flex; flex-direction:column; justify-content:center; gap:10px; white-space:nowrap; }
62
+ .source-links a { text-decoration:none; font-weight:700; }
63
+ .source-links a:hover { text-decoration:underline; }
64
+ .footer { display:flex; justify-content:space-between; gap:18px; padding:22px 0 32px; border-top:1px solid var(--line); color:#8fa6b2; font-size:.78rem; }
65
+ @media (max-width:720px) { .site-header { padding-inline:20px; } .header-link { display:none; } .hero { padding:54px 0 35px; } .case-card,.final-card { padding:23px; } .source-inner { grid-template-columns:1fr; gap:18px; } .source-links { white-space:normal; } }
66
+ @media (max-width:430px) { .wrap { width:calc(100% - 28px); } .site-header { min-height:64px; padding-inline:14px; } .brand { gap:8px; font-size:.85rem; } .brand-mark { width:31px; height:31px; } .hero { padding-top:43px; } h1 { font-size:2.65rem; } .game-topline { align-items:flex-start; } .game-topline>div { flex-wrap:wrap; gap:6px; } .game-topline a { text-align:right; } .case-card,.final-card { padding:18px; border-radius:17px; } pre { padding:15px; white-space:pre-wrap; overflow-wrap:anywhere; } .source-inner { padding:21px; } .footer { flex-direction:column; gap:2px; } }
tests/cases.mjs ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assert from 'node:assert/strict';
2
+ import { cases, runTest } from '../cases.mjs';
3
+
4
+ assert.equal(cases.length, 5);
5
+ assert.equal(new Set(cases.map((item) => item.slug)).size, cases.length);
6
+ for (const item of cases) {
7
+ assert.equal(item.choices.length, 3, `${item.slug} must have three choices`);
8
+ const outcomes = item.choices.map((choice) => runTest(item, choice));
9
+ assert.equal(outcomes.filter(Boolean).length, 1, `${item.slug} must have exactly one revealing test`);
10
+ const mismatch = outcomes.find(Boolean);
11
+ assert.ok(Number.isInteger(mismatch.index) && mismatch.index >= 0, `${item.slug} needs a concrete mismatch`);
12
+ }
13
+ console.log('Five puzzles have one reproducible revealing test each.');
thumbnail.png ADDED