File size: 16,812 Bytes
43b6fc5
b972309
 
 
 
cc4d8e9
 
b972309
 
cc4d8e9
 
 
 
 
 
 
 
b972309
cc4d8e9
 
 
 
 
b972309
 
 
 
cc4d8e9
b972309
cc4d8e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a1469bd
 
 
 
 
cc4d8e9
 
a1469bd
cc4d8e9
 
 
 
 
 
 
 
 
a1469bd
cc4d8e9
 
 
 
 
 
a1469bd
cc4d8e9
 
a1469bd
cc4d8e9
3869bf5
 
 
 
 
 
 
cc4d8e9
 
 
 
 
 
 
b972309
cc4d8e9
 
 
 
 
 
 
 
 
b972309
cc4d8e9
 
 
b972309
 
cc4d8e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b972309
cc4d8e9
 
 
 
 
 
 
 
 
b972309
cc4d8e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b972309
cc4d8e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b972309
cc4d8e9
 
 
 
 
 
 
 
 
 
 
 
 
 
a1469bd
cc4d8e9
 
 
 
b972309
 
 
cc4d8e9
 
 
 
 
 
 
 
b972309
 
 
cc4d8e9
a1469bd
 
 
 
 
 
 
 
 
3869bf5
cc4d8e9
b972309
cc4d8e9
 
 
b972309
 
cc4d8e9
 
 
 
 
 
 
 
 
 
 
 
 
b972309
 
cc4d8e9
 
 
 
 
 
 
 
 
 
b972309
cc4d8e9
 
b972309
cc4d8e9
 
 
b972309
cc4d8e9
 
 
 
b972309
 
 
cc4d8e9
 
 
 
b972309
cc4d8e9
 
 
 
 
b972309
cc4d8e9
 
 
b972309
cc4d8e9
 
 
 
b972309
 
 
 
 
 
 
cc4d8e9
 
 
 
b972309
 
cc4d8e9
b972309
 
 
 
 
 
 
 
 
 
 
 
 
cc4d8e9
 
 
b972309
 
cc4d8e9
b972309
cc4d8e9
 
 
b972309
cc4d8e9
 
 
 
 
 
 
 
 
b972309
cc4d8e9
b972309
 
 
 
 
 
 
cc4d8e9
b972309
 
 
 
 
 
 
 
 
 
cc4d8e9
 
 
 
 
 
b972309
 
cc4d8e9
b972309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43b6fc5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Grainulation Sandbox — Grainulator, Irrigator &amp; OVERTURN</title>
  <link rel="icon" href="data:,">
  <style>
    :root {
      color-scheme: dark;
      --page: #181618;
      --surface: #242126;
      --code: #121013;
      --text: #e2e8f0;
      --muted: #a5b7bd;
      --accent: #8df6ff;
      --gold: #fcc830;
      --ok: #6ee7b7;
      --bad: #fca5a5;
      --line: rgba(141, 246, 255, 0.2);
      --line-soft: rgba(226, 232, 240, 0.12);
      --mono: "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace, monospace;
      --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      background: var(--page);
      color: var(--text);
      font-family: var(--mono);
      font-size: 0.875rem;
      line-height: 1.65;
      -webkit-font-smoothing: antialiased;
    }
    a { color: inherit; text-decoration: none; text-underline-offset: 0.3em; }
    a:hover { color: var(--accent); text-decoration: underline; }
    a:focus-visible, button:focus-visible, select:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 3px;
    }
    button, select { font: inherit; color: inherit; }
    .shell { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem 4rem; }

    .site-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem 2rem;
      flex-wrap: wrap;
      padding: 1.25rem 0;
      border-bottom: 1px solid var(--line);
    }
    .brand { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.04em; min-height: 44px; display: inline-flex; align-items: center; }
    .header-nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
    .header-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.78rem; color: var(--muted); }
    .header-nav a:hover { color: var(--accent); }

    .intro {
      display: grid;
      grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
      gap: 1.5rem 2.25rem;
      align-items: center;
      padding: 2rem 0 1.75rem;
      border-bottom: 1px solid var(--line);
    }
    .intro-copy { min-width: 0; }
    .eyebrow {
      margin: 0 0 0.6rem;
      font-size: 0.68rem;
      text-transform: uppercase;
      letter-spacing: 0.09em;
      color: var(--accent);
    }
    .intro h1 {
      margin: 0 0 0.75rem;
      font-size: clamp(1.45rem, 2.8vw, 2.05rem);
      font-weight: 400;
      letter-spacing: -0.04em;
      line-height: 1.18;
    }
    .intro p {
      margin: 0;
      max-width: 58ch;
      color: var(--muted);
      font-family: var(--sans);
      font-size: 0.92rem;
    }
    .hero-visual {
      display: block;
      width: 100%;
      height: auto;
      border: 1px solid var(--line-soft);
      border-radius: 4px;
    }

    .tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 1.5rem;
      border-bottom: 1px solid var(--line);
    }
    .tab-btn {
      background: transparent;
      border: none;
      border-bottom: 2px solid transparent;
      color: var(--muted);
      min-height: 48px;
      padding: 0.75rem 0;
      cursor: pointer;
      font-size: 0.85rem;
      margin-bottom: -1px;
    }
    .tab-btn:hover { color: var(--text); }
    .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

    .panel { display: none; }
    .panel.active { display: block; }

    .section {
      padding: 2rem 0;
      border-bottom: 1px solid var(--line-soft);
    }
    .section:last-child { border-bottom: none; }
    .section-head {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      justify-content: space-between;
      gap: 0.75rem 1.5rem;
      margin-bottom: 1rem;
    }
    .section-head h2 {
      margin: 0;
      font-size: 1.05rem;
      font-weight: 500;
      letter-spacing: -0.02em;
    }
    .section-note {
      margin: 0 0 1rem;
      max-width: 72ch;
      color: var(--muted);
      font-family: var(--sans);
      font-size: 0.88rem;
    }

    .controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
    select {
      width: 100%;
      max-width: 640px;
      min-height: 44px;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 4px;
      padding: 0.5rem 0.75rem;
      font-size: 0.82rem;
    }
    .seg-btn {
      background: var(--surface);
      border: 1px solid var(--line-soft);
      border-radius: 4px;
      min-height: 44px;
      padding: 0.45rem 0.9rem;
      font-size: 0.8rem;
      color: var(--muted);
      cursor: pointer;
    }
    .seg-btn:hover { color: var(--text); border-color: var(--line); }
    .seg-btn.active { color: var(--accent); border-color: var(--accent); }

    .specimen {
      background: var(--surface);
      border: 1px solid var(--line-soft);
      border-radius: 4px;
      padding: 1.25rem;
    }
    .meta-line {
      display: flex;
      flex-wrap: wrap;
      gap: 0.4rem 1.25rem;
      font-size: 0.78rem;
      color: var(--muted);
      margin-bottom: 0.85rem;
    }
    .meta-line strong { color: var(--text); font-weight: 500; }
    .question {
      margin: 0 0 0.75rem;
      font-family: var(--sans);
      font-size: 0.98rem;
      color: var(--text);
    }
    .licenses {
      margin: 0 0 1.25rem;
      font-size: 0.76rem;
      color: var(--gold);
    }

    .two-col {
      display: grid;
      grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
      gap: 1.5rem;
    }
    .two-col > div { min-width: 0; overflow-x: auto; }
    .meta-line span { overflow-wrap: anywhere; }
    h3 {
      margin: 0 0 0.5rem;
      font-size: 0.74rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
      font-weight: 500;
    }
    table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
    th, td {
      padding: 0.45rem 0.5rem 0.45rem 0;
      border-bottom: 1px solid var(--line-soft);
      text-align: left;
      vertical-align: top;
    }
    th { color: var(--muted); font-weight: 500; }
    .status-ok { color: var(--ok); }
    .status-bad { color: var(--bad); }
    .status-na { color: var(--muted); }

    pre {
      margin: 0;
      background: var(--code);
      border: 1px solid var(--line-soft);
      border-radius: 4px;
      padding: 1rem;
      overflow-x: auto;
      font-size: 0.78rem;
      line-height: 1.55;
      white-space: pre-wrap;
      max-height: 360px;
    }

    @media (max-width: 760px) {
      .shell { padding: 0 1rem 3rem; }
      .intro { grid-template-columns: minmax(0, 1fr); }
      .tabs { gap: 1rem; }
      .tab-btn { font-size: 0.78rem; }
      .two-col { grid-template-columns: minmax(0, 1fr); }
    }
  </style>
</head>
<body>
  <div class="shell">
    <header class="site-header">
      <span class="brand">grainulation / sandbox</span>
      <nav class="header-nav" aria-label="Primary links">
        <a href="https://grainulator.dev/" target="_blank" rel="noopener">Grainulator ↗</a>
        <a href="https://github.com/grainulation/irrigator" target="_blank" rel="noopener">Irrigator ↗</a>
        <a href="https://blog.grainulation.org/verify-then-vote/" target="_blank" rel="noopener">Verify, Then Vote ↗</a>
        <a href="https://huggingface.co/datasets/grainulation/overturn-benchmark" target="_blank" rel="noopener">OVERTURN dataset ↗</a>
      </nav>
    </header>

    <section class="intro">
      <div class="intro-copy">
        <p class="eyebrow">Static offline specimen</p>
        <h1>Evidence ledgers, bounded DAGs, and sealed benchmark replay.</h1>
        <p>
          Zero-credential static view of sealed conflict samples from <code>grainulation/overturn-benchmark</code>
          alongside recorded transcripts from <code>grainulator</code> (offline protocol fixtures) and <code>irrigator</code>
          (<code>--backend mock</code>). No live inference runs here.
        </p>
      </div>
      <img class="hero-visual" src="./assets/sandbox-banner.jpg" alt="Grainulator and Irrigator mascots connected across evidence ledger lines and parallel DAG tracks">
    </section>

    <div class="tabs" role="tablist" aria-label="Sandbox views">
      <button class="tab-btn active" role="tab" aria-selected="true" data-tab="tab-grainulator">Grainulator &amp; OVERTURN</button>
      <button class="tab-btn" role="tab" aria-selected="false" data-tab="tab-irrigator">Irrigator DAG &amp; Recovery</button>
    </div>

    <section id="tab-grainulator" class="panel active" role="tabpanel">
      <div class="section">
        <div class="section-head">
          <h2>Sealed OVERTURN decisive conflicts</h2>
        </div>
        <p class="section-note">
          Eight primary (<code>P</code>) confirmatory items from Pool 1 (<code>v5</code>) and Pool 2 (<code>v6</code>), showing plurality vote against passage-checked arbitration (<code>BE-G</code>, <code>BE-G/VDF</code>) and the Sonnet judge reference (<code>J</code>).
        </p>
        <div class="controls">
          <label for="overturn-select" style="position:absolute;left:-9999px;">Select benchmark item</label>
          <select id="overturn-select"></select>
        </div>
        <div class="specimen" id="overturn-detail">Loading sealed samples…</div>
      </div>

      <div class="section">
        <div class="section-head">
          <h2>Claim compiler and conflict surfacing</h2>
        </div>
        <p class="section-note">
          Recorded output of <code>grainulator init</code>, <code>add</code>, and <code>compile</code> with a clean ledger vs. an explicit <code>--conflicts-with c002</code> claim.
        </p>
        <div class="controls">
          <button class="seg-btn active" id="btn-compile-conflict" aria-pressed="true">With conflict (c003 → c002)</button>
          <button class="seg-btn" id="btn-compile-clean" aria-pressed="false">Clean ledger</button>
        </div>
        <pre id="out-grainulator-compile">Loading…</pre>
      </div>

      <div class="section">
        <div class="section-head">
          <h2>Offline verifier protocol fixture</h2>
        </div>
        <p class="section-note">
          Verbatim output of <code>grainulator demo</code> (synthetic offline fixture; does not measure model quality).
        </p>
        <pre id="out-grainulator-demo">Loading…</pre>
      </div>
    </section>

    <section id="tab-irrigator" class="panel" role="tabpanel">
      <div class="section">
        <div class="section-head">
          <h2>Mock swarm scheduling and child graphs</h2>
        </div>
        <p class="section-note">
          Verbatim output of <code>irrigator demo</code>: real graph scheduling and recursive child tasks under mock workers ($0 API spend).
        </p>
        <pre id="out-irrigator-demo">Loading…</pre>
      </div>

      <div class="section">
        <div class="section-head">
          <h2>Init → Plan → Apply (mock) → Status</h2>
        </div>
        <p class="section-note">
          Generated <code>swarm/v1</code> plan, state transitions, and the recovery boundary: in real coding cells (<code>irrigator code --verify</code>), exit 77 or timeout leaves status uncertain instead of silently replaying side effects.
        </p>
        <pre id="out-irrigator-plan">Loading…</pre>
      </div>
    </section>
  </div>

  <script>
    for (const btn of document.querySelectorAll('.tab-btn')) {
      btn.addEventListener('click', () => {
        document.querySelectorAll('.tab-btn').forEach(b => {
          b.classList.remove('active');
          b.setAttribute('aria-selected', 'false');
        });
        document.querySelectorAll('.panel').forEach(p => p.classList.remove('active'));
        btn.classList.add('active');
        btn.setAttribute('aria-selected', 'true');
        document.getElementById(btn.dataset.tab).classList.add('active');
      });
    }

    function esc(s) {
      return String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
    }

    let OVERTURN_SAMPLES = [];
    function renderSample(idx) {
      const s = OVERTURN_SAMPLES[idx];
      if (!s) return;
      const methodRows = Object.entries(s.methods).map(([k, v]) => {
        const cls = v.correct === true ? 'status-ok' : (v.correct === false ? 'status-bad' : 'status-na');
        const label = v.correct === true ? 'correct' : (v.correct === false ? 'wrong' : 'n/a');
        return `<tr><td><code>${esc(k)}</code></td><td>${esc(v.selected)}</td><td class="${cls}">${label}</td></tr>`;
      }).join('');
      const agentRows = s.agents.map(a =>
        `<tr><td><code>${esc(a.model_tag)}</code> (${esc(a.quantization)})</td><td>${esc(a.answer)}</td><td>${esc(a.confidence)}</td><td>${esc((a.citations || []).join(', ') || '—')}</td></tr>`
      ).join('');
      const goldDisplay = (s.gold && typeof s.gold === 'object' && 'answer' in s.gold)
        ? String(s.gold.answer)
        : (Array.isArray(s.gold) ? s.gold.join(', ') : String(s.gold ?? '—'));
      document.getElementById('overturn-detail').innerHTML = `
        <div class="meta-line">
          <span>pool <strong>${esc(s.pool_id)}</strong></span>
          <span>item <strong>${esc(s.item_id)}</strong></span>
          <span>source <strong>${esc(s.source_dataset)}</strong> (${esc(s.analysis_set)})</span>
          <span>gold <strong>${esc(goldDisplay)}</strong></span>
        </div>
        <p class="question">${esc(s.question)}</p>
        <p class="licenses">Component licenses: ${s.license_ids.map(esc).join(' · ')}</p>
        <div class="two-col">
          <div><h3>Decisions</h3><table><tr><th>Method</th><th>Selected</th><th>Outcome</th></tr>${methodRows}</table></div>
          <div><h3>Agent answers</h3><table><tr><th>Model</th><th>Answer</th><th>Conf.</th><th>Citations</th></tr>${agentRows}</table></div>
        </div>`;
    }

    fetch('./sample_overturn.json').then(r => r.json()).then(data => {
      OVERTURN_SAMPLES = data.samples || [];
      const sel = document.getElementById('overturn-select');
      sel.innerHTML = OVERTURN_SAMPLES.map((s, i) =>
        `<option value="${i}">${esc(s.pool_id)} · ${esc(s.item_id)} (${esc(s.source_dataset)}) — MAJ: ${s.methods.MAJ?.correct ? 'correct' : 'wrong'}</option>`
      ).join('');
      sel.addEventListener('change', () => renderSample(Number(sel.value)));
      renderSample(0);
    }).catch(err => {
      document.getElementById('overturn-detail').textContent = 'Failed to load samples: ' + err.message;
    });

    let RECORDED = null;
    function showCompile(withConflict) {
      if (!RECORDED) return;
      const b1 = document.getElementById('btn-compile-conflict');
      const b2 = document.getElementById('btn-compile-clean');
      b1.classList.toggle('active', withConflict);
      b1.setAttribute('aria-pressed', String(withConflict));
      b2.classList.toggle('active', !withConflict);
      b2.setAttribute('aria-pressed', String(!withConflict));
      const d = withConflict ? RECORDED.grainulator_compile_with_conflict : RECORDED.grainulator_compile_clean;
      document.getElementById('out-grainulator-compile').textContent =
        `exit=${d.returncode} · claims=${d.claims_count} · inject_conflict=${d.inject_conflict}\n\n` +
        `${d.compile_stdout || d.compile_stderr}\n\nclaims.json:\n` +
        JSON.stringify(d.claims_preview, null, 2);
    }

    fetch('./recorded_runs.json').then(r => r.json()).then(rec => {
      RECORDED = rec;
      document.getElementById('out-grainulator-demo').textContent =
        `exit=${rec.grainulator_demo.returncode}\n${rec.grainulator_demo.stdout}`;
      showCompile(true);
      document.getElementById('btn-compile-conflict').addEventListener('click', () => showCompile(true));
      document.getElementById('btn-compile-clean').addEventListener('click', () => showCompile(false));

      document.getElementById('out-irrigator-demo').textContent =
        `exit=${rec.irrigator_demo.returncode}\n${rec.irrigator_demo.stdout}`;
      const p = rec.irrigator_mock_plan;
      document.getElementById('out-irrigator-plan').textContent =
        (p.simulate_uncertain_note ? `Note: ${p.simulate_uncertain_note}\n\n` : '') +
        `--- irrigator plan ---\n${p.plan.stdout}\n--- irrigator apply --backend mock ---\n${p.apply.stdout}\n--- irrigator status ---\n${p.status.stdout}\n--- generated swarm/v1 plan.json ---\n` +
        JSON.stringify(p.plan_json, null, 2);
    }).catch(err => {
      document.getElementById('out-grainulator-demo').textContent = 'Failed to load recorded runs: ' + err.message;
    });
  </script>
</body>
</html>