pace-eval 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. cme/__init__.py +11 -0
  2. cme/__main__.py +5 -0
  3. cme/analysis.py +223 -0
  4. cme/audit.py +145 -0
  5. cme/baseline.py +162 -0
  6. cme/cli.py +279 -0
  7. cme/client.py +165 -0
  8. cme/dynamics.py +212 -0
  9. cme/examples/crewai_integration.py +16 -0
  10. cme/examples/demo_pool.jsonl +360 -0
  11. cme/examples/demo_run.jsonl +480 -0
  12. cme/examples/langgraph_integration.py +27 -0
  13. cme/examples/make_demo.py +37 -0
  14. cme/examples/openai_quickstart.py +18 -0
  15. cme/experiment.py +555 -0
  16. cme/frontier.py +143 -0
  17. cme/hidden_profile.py +135 -0
  18. cme/proxy.py +106 -0
  19. cme/rebuttal.py +76 -0
  20. cme/report.py +197 -0
  21. cme/rollout_card.py +137 -0
  22. cme/tasks.py +266 -0
  23. cme/verified_debate.py +127 -0
  24. cme/verifier.py +92 -0
  25. mae_eval/__init__.py +11 -0
  26. mae_eval/__main__.py +5 -0
  27. mae_eval/auditor.py +112 -0
  28. mae_eval/classifier.py +62 -0
  29. mae_eval/cli.py +210 -0
  30. mae_eval/tracker.py +162 -0
  31. mae_eval/vector.py +91 -0
  32. pace/__init__.py +11 -0
  33. pace/__main__.py +5 -0
  34. pace/analysis.py +129 -0
  35. pace/audit.py +145 -0
  36. pace/baseline.py +162 -0
  37. pace/card.py +205 -0
  38. pace/cli.py +898 -0
  39. pace/client.py +165 -0
  40. pace/dynamics.py +372 -0
  41. pace/escape_benchmarks.py +162 -0
  42. pace/examples/crewai_integration.py +16 -0
  43. pace/examples/demo_pool.jsonl +360 -0
  44. pace/examples/demo_run.jsonl +480 -0
  45. pace/examples/langgraph_integration.py +27 -0
  46. pace/examples/make_demo.py +37 -0
  47. pace/examples/openai_quickstart.py +18 -0
  48. pace/experiment.py +555 -0
  49. pace/frontier.py +114 -0
  50. pace/hidden_profile.py +301 -0
  51. pace/importers.py +219 -0
  52. pace/inflate.py +213 -0
  53. pace/influence.py +231 -0
  54. pace/meta_engine.py +246 -0
  55. pace/middleware.py +230 -0
  56. pace/open_ended.py +114 -0
  57. pace/plotting.py +132 -0
  58. pace/pool_sizer.py +154 -0
  59. pace/protocol_v3.py +414 -0
  60. pace/proxy.py +106 -0
  61. pace/rebuttal.py +219 -0
  62. pace/report.py +197 -0
  63. pace/rollout_card.py +137 -0
  64. pace/schema.py +74 -0
  65. pace/simulator.py +199 -0
  66. pace/studio.html +1040 -0
  67. pace/tasks.py +266 -0
  68. pace/verified_debate.py +127 -0
  69. pace/verifier.py +92 -0
  70. pace/workbench.html +26 -0
  71. pace/workbench.py +119 -0
  72. pace_eval-0.2.2.dist-info/METADATA +205 -0
  73. pace_eval-0.2.2.dist-info/RECORD +83 -0
  74. pace_eval-0.2.2.dist-info/WHEEL +5 -0
  75. pace_eval-0.2.2.dist-info/entry_points.txt +4 -0
  76. pace_eval-0.2.2.dist-info/licenses/LICENSE +202 -0
  77. pace_eval-0.2.2.dist-info/top_level.txt +4 -0
  78. pace_lab/__init__.py +9 -0
  79. pace_lab/clients.py +568 -0
  80. pace_lab/concurrency_test.py +127 -0
  81. pace_lab/data.py +445 -0
  82. pace_lab/graders.py +626 -0
  83. pace_lab/strategies.py +345 -0
pace/studio.html ADDED
@@ -0,0 +1,1040 @@
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 property="og:title" content="PACE Studio · Parity-Aware Compute Evaluation">
7
+ <meta property="og:description" content="Audit multi-agent LLM traces against compute-matched single-agent baselines, inspect debate transition dynamics, and size self-consistency pools (arXiv:2611.17610).">
8
+ <meta property="og:type" content="website">
9
+ <meta property="og:url" content="https://huggingface.co/spaces/sajjadi/pace-studio">
10
+ <meta property="og:image" content="https://raw.githubusercontent.com/mahmoudsajjadi/pace/main/docs/assets/pace_cheatsheet.png">
11
+ <meta name="twitter:card" content="summary_large_image">
12
+ <meta name="twitter:image" content="https://raw.githubusercontent.com/mahmoudsajjadi/pace/main/docs/assets/pace_cheatsheet.png">
13
+ <meta name="twitter:title" content="PACE Studio · Parity-Aware Compute Evaluation">
14
+ <meta name="twitter:description" content="Audit multi-agent LLM traces against compute-matched single-agent baselines (arXiv:2611.17610).">
15
+ <title>PACE Studio · Parity-Aware Compute Evaluation</title>
16
+ <style>
17
+ :root{
18
+ --ink:#17212b;
19
+ --muted:#52606d;
20
+ --paper:#f6f3ed;
21
+ --panel:#ffffff;
22
+ --line:#dfd8cc;
23
+ --accent:#bb4d2e;
24
+ --accent2:#1d6b68;
25
+ --ok:#1b6e42;
26
+ --warn:#9a5b13;
27
+ --bad:#a62b2b;
28
+ --radius:10px;
29
+ }
30
+ *{box-sizing:border-box}
31
+ body{
32
+ margin:0;
33
+ color:var(--ink);
34
+ font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
35
+ background:radial-gradient(circle at 88% 0,#ebd7c3 0,transparent 36%),var(--paper);
36
+ }
37
+ header{
38
+ padding:30px max(24px,calc((100vw - 1140px)/2)) 24px;
39
+ border-bottom:1px solid var(--line);
40
+ background:linear-gradient(180deg,#fffcf7 0%,transparent 100%);
41
+ }
42
+ .header-top{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:18px}
43
+ .badge{
44
+ display:inline-block;
45
+ font-size:12px;
46
+ font-weight:700;
47
+ letter-spacing:.03em;
48
+ color:var(--accent2);
49
+ background:#e6f2f1;
50
+ padding:4px 10px;
51
+ border-radius:999px;
52
+ margin-bottom:8px;
53
+ }
54
+ h1{
55
+ font-family:Georgia,"Times New Roman",serif;
56
+ font-size:clamp(1.9rem,4vw,3rem);
57
+ line-height:1.06;
58
+ margin:0 0 8px;
59
+ letter-spacing:-.01em;
60
+ }
61
+ header p{max-width:700px;color:var(--muted);font-size:.98rem;margin:0}
62
+ .link-pills{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
63
+ .link-pill{
64
+ display:inline-flex;
65
+ align-items:center;
66
+ gap:5px;
67
+ padding:6px 12px;
68
+ border-radius:999px;
69
+ border:1px solid var(--line);
70
+ background:var(--panel);
71
+ color:var(--ink);
72
+ font-size:13px;
73
+ font-weight:600;
74
+ text-decoration:none;
75
+ transition:border-color .15s,background .15s;
76
+ }
77
+ .link-pill:hover{border-color:var(--accent2);background:#f2f8f7}
78
+ .link-pill.primary{background:var(--accent2);border-color:var(--accent2);color:#fff}
79
+ .link-pill.primary:hover{opacity:.9;background:var(--accent2)}
80
+ .cite-box{
81
+ background:var(--panel);
82
+ border:1px solid var(--line);
83
+ border-left:4px solid var(--accent);
84
+ border-radius:var(--radius);
85
+ padding:14px 16px;
86
+ max-width:420px;
87
+ font-size:13px;
88
+ box-shadow:0 4px 14px rgba(23,33,43,.04);
89
+ }
90
+ .cite-box strong{display:block;margin-bottom:4px;font-size:13.5px}
91
+ .cite-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px;align-items:center}
92
+ main{max-width:1140px;margin:22px auto 44px;padding:0 24px}
93
+ .tabs{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}
94
+ .tab{
95
+ border:1px solid var(--line);
96
+ border-radius:8px;
97
+ background:var(--panel);
98
+ padding:9px 15px;
99
+ font:600 13.5px/1.2 inherit;
100
+ cursor:pointer;
101
+ color:var(--ink);
102
+ transition:all .15s;
103
+ }
104
+ .tab:hover{border-color:var(--accent2)}
105
+ .tab.active{background:var(--accent2);border-color:var(--accent2);color:#fff}
106
+ .tab-panel{display:none}
107
+ .tab-panel.active{display:block}
108
+ .actions{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0;align-items:center}
109
+ button,.btn{
110
+ border:1px solid var(--ink);
111
+ border-radius:8px;
112
+ background:var(--ink);
113
+ color:#fff;
114
+ padding:8px 14px;
115
+ font:600 13.5px/1.2 inherit;
116
+ cursor:pointer;
117
+ text-decoration:none;
118
+ display:inline-flex;
119
+ align-items:center;
120
+ gap:6px;
121
+ transition:opacity .15s,background .15s;
122
+ }
123
+ button:hover,.btn:hover{opacity:.88}
124
+ button.secondary,.btn.secondary{background:var(--panel);color:var(--ink);border-color:var(--line)}
125
+ button.teal{background:var(--accent2);border-color:var(--accent2);color:#fff}
126
+ button.accent{background:var(--accent);border-color:var(--accent);color:#fff}
127
+ .actions label{display:inline-flex;align-items:center;gap:6px;font-size:13.5px;font-weight:500}
128
+ .actions input,.actions select{
129
+ padding:7px 10px;
130
+ border:1px solid var(--line);
131
+ border-radius:6px;
132
+ background:var(--panel);
133
+ font:inherit;
134
+ }
135
+ .demo-bar{
136
+ border-bottom:1px solid var(--line);
137
+ padding-bottom:14px;
138
+ margin-bottom:14px;
139
+ }
140
+ .demo-label{font-size:12.5px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin-right:4px}
141
+ .drop{
142
+ display:block;
143
+ width:100%;
144
+ margin:14px 0;
145
+ padding:20px;
146
+ border:2px dashed var(--accent);
147
+ border-radius:var(--radius);
148
+ background:var(--panel);
149
+ text-align:center;
150
+ cursor:pointer;
151
+ font-weight:500;
152
+ transition:background .15s,border-color .15s;
153
+ }
154
+ .drop:hover,.drop.drag{background:#fdf3ee;border-color:#9e3c20}
155
+ .drop input{display:none}
156
+ .drop small{display:block;color:var(--muted);font-weight:400;margin-top:4px}
157
+ .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px}
158
+ .kpi-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:12px 0}
159
+ .kpi{
160
+ background:#faf8f4;
161
+ border:1px solid var(--line);
162
+ border-radius:8px;
163
+ padding:12px 14px;
164
+ }
165
+ .kpi .k-label{font-size:12px;color:var(--muted);font-weight:600;text-transform:uppercase;letter-spacing:.03em}
166
+ .kpi .k-val{font-family:Georgia,serif;font-size:1.5rem;color:var(--ink);margin-top:2px}
167
+ .kpi .k-sub{font-size:12px;color:var(--muted);margin-top:2px}
168
+ .panel{
169
+ background:var(--panel);
170
+ border:1px solid var(--line);
171
+ border-top:4px solid var(--accent2);
172
+ border-radius:var(--radius);
173
+ padding:20px;
174
+ box-shadow:0 6px 20px rgba(23,33,43,.05);
175
+ }
176
+ .panel.accent-top{border-top-color:var(--accent)}
177
+ .panel h2{font-size:1.05rem;font-weight:700;margin:0 0 10px}
178
+ .panel-sub{font-size:13.5px;color:var(--muted);margin:-4px 0 12px}
179
+ .value{font-family:Georgia,serif;font-size:1.85rem;color:var(--accent);margin-bottom:6px}
180
+ .axis{
181
+ display:flex;
182
+ justify-content:space-between;
183
+ align-items:center;
184
+ padding:8px 0;
185
+ border-bottom:1px solid var(--line);
186
+ font-size:13.5px;
187
+ gap:10px;
188
+ }
189
+ .axis:last-child{border-bottom:none}
190
+ .axis-name{display:flex;flex-direction:column}
191
+ .axis-desc{font-size:11.5px;color:var(--muted)}
192
+ table{width:100%;border-collapse:collapse;font-size:.88rem}
193
+ th,td{text-align:left;padding:8px 10px;border-bottom:1px solid var(--line)}
194
+ th{font-size:12px;text-transform:uppercase;letter-spacing:.03em;color:var(--muted);background:#faf8f4}
195
+ .bar-wrap{width:90px;height:8px;background:#ece6dc;border-radius:999px;overflow:hidden;display:inline-block;vertical-align:middle;margin-right:6px}
196
+ .bar-fill{height:100%;background:var(--accent2);border-radius:999px}
197
+ .pill{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11.5px;font-weight:600}
198
+ .pill.ok{background:#e3f3ea;color:var(--ok)}
199
+ .pill.warn{background:#fbf0df;color:var(--warn)}
200
+ .pill.bad{background:#fae5e5;color:var(--bad)}
201
+ .banner{
202
+ padding:10px 14px;
203
+ border-radius:8px;
204
+ font-size:13.5px;
205
+ margin-bottom:12px;
206
+ border:1px solid var(--line);
207
+ background:#faf8f4;
208
+ }
209
+ .banner.ok{background:#edf8f2;border-color:#b8e1c8;color:var(--ok)}
210
+ .banner.warn{background:#fdf6ea;border-color:#ecd2a6;color:var(--warn)}
211
+ .banner.bad{background:#fdf0f0;border-color:#ebc0c0;color:var(--bad)}
212
+ .empty{color:var(--muted);font-size:14px}
213
+ .forest-wrap{
214
+ margin:14px 0 18px;
215
+ padding:14px;
216
+ border:1px solid var(--line);
217
+ border-radius:8px;
218
+ background:#fffcf8;
219
+ overflow-x:auto;
220
+ }
221
+ .forest-title{font-size:12.5px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin-bottom:8px}
222
+ .cli-strip{
223
+ display:flex;
224
+ flex-wrap:wrap;
225
+ justify-content:space-between;
226
+ align-items:center;
227
+ gap:10px;
228
+ background:#1b242b;
229
+ color:#f5ede3;
230
+ padding:12px 16px;
231
+ border-radius:var(--radius);
232
+ margin-top:16px;
233
+ font-size:13px;
234
+ }
235
+ .cli-strip code{color:#9ee0db;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
236
+ pre{
237
+ white-space:pre-wrap;
238
+ overflow:auto;
239
+ background:#1b242b;
240
+ color:#f5ede3;
241
+ padding:16px;
242
+ border-radius:8px;
243
+ min-height:80px;
244
+ font-size:13px;
245
+ line-height:1.5;
246
+ margin:0;
247
+ }
248
+ .ladder{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-top:10px}
249
+ .rung{padding:6px 8px;border-radius:6px;border:1px solid var(--line);font-size:11.5px;text-align:center;color:var(--muted);background:#faf8f4}
250
+ .rung.on{border-color:var(--accent);background:#fdf3ee;color:var(--accent);font-weight:700}
251
+ .toast{font-size:12.5px;color:var(--ok);font-weight:600;margin-left:6px}
252
+ .toast.err{color:var(--bad)}
253
+ footer{
254
+ max-width:1140px;
255
+ margin:0 auto 40px;
256
+ padding:18px 24px 0;
257
+ border-top:1px solid var(--line);
258
+ color:var(--muted);
259
+ font-size:13px;
260
+ display:flex;
261
+ flex-wrap:wrap;
262
+ justify-content:space-between;
263
+ gap:12px;
264
+ }
265
+ footer a{color:var(--accent2);text-decoration:none;font-weight:600}
266
+ footer a:hover{text-decoration:underline}
267
+ @media(max-width:720px){
268
+ header{padding:24px 16px 18px}
269
+ main,footer{padding-left:16px;padding-right:16px}
270
+ .ladder{grid-template-columns:repeat(2,1fr)}
271
+ .actions button{flex:1 1 44%}
272
+ }
273
+ </style>
274
+ </head>
275
+ <body>
276
+ <header>
277
+ <div class="header-top">
278
+ <div>
279
+ <span class="badge">arXiv:2611.17610 · Parity-Aware Compute Evaluation (PACE)</span>
280
+ <h1>PACE Studio</h1>
281
+ <p>Audit multi-agent LLM traces against compute-matched single-agent baselines, inspect debate peer-influence dynamics, explore the 9-study corpus noise band, and size self-consistency pools locally in your browser.</p>
282
+ <div class="link-pills">
283
+ <a class="link-pill primary" href="https://arxiv.org/abs/2611.17610" target="_blank" rel="noopener">Paper (arXiv:2611.17610)</a>
284
+ <a class="link-pill" href="https://arxiv.org/html/2611.17610v1" target="_blank" rel="noopener">HTML Preprint</a>
285
+ <a class="link-pill" href="https://github.com/mahmoudsajjadi/pace" target="_blank" rel="noopener">GitHub (pace CLI)</a>
286
+ <a class="link-pill" href="https://huggingface.co/datasets/sajjadi/pace-contrasts" target="_blank" rel="noopener">HF Dataset (9 Studies)</a>
287
+ <a class="link-pill" href="https://doi.org/10.5281/zenodo.24286397" target="_blank" rel="noopener">Zenodo DOI</a>
288
+ </div>
289
+ </div>
290
+ <div class="cite-box">
291
+ <strong>Cite PACE in Your Paper</strong>
292
+ <div>Sajjadi Mohammadabadi (2026). <em>More Agents, More Samples, or More Thinking? Untangling Coordination, Ensembling, and Test-Time Compute in Multi-Agent LLMs.</em></div>
293
+ <div class="cite-actions">
294
+ <button id="copyBib" class="accent" type="button">Copy BibTeX</button>
295
+ <a class="btn secondary" href="https://github.com/mahmoudsajjadi/pace" target="_blank" rel="noopener">Get Python Toolkit</a>
296
+ <span id="citeToast" class="toast"></span>
297
+ </div>
298
+ </div>
299
+ </div>
300
+ </header>
301
+
302
+ <main>
303
+ <nav class="tabs" aria-label="PACE Studio tabs">
304
+ <button class="tab active" data-tab="trace" type="button">Trace &amp; Resource Auditor</button>
305
+ <button class="tab" data-tab="dynamics" type="button">Debate Dynamics</button>
306
+ <button class="tab" data-tab="corpus" type="button">Corpus &amp; Noise-Band Explorer</button>
307
+ <button class="tab" data-tab="planner" type="button">Experiment Planner</button>
308
+ </nav>
309
+
310
+ <div class="actions demo-bar">
311
+ <span class="demo-label">Quick Demos:</span>
312
+ <button id="demoDebate" class="teal" type="button">Load Demo: Debate JSONL</button>
313
+ <button id="demoHidden" class="secondary" type="button">Load Demo: Hidden-Profile Split vs Shared</button>
314
+ <button id="demoContrasts" class="secondary" type="button">Load Demo: 9-Study Contrasts CSV</button>
315
+ <span id="loadStatus" class="toast"></span>
316
+ </div>
317
+
318
+ <label class="drop" id="drop">
319
+ Drop a PACE JSONL/JSON log or contrast/trace CSV here, or click to choose a file
320
+ <small>Your file never leaves this browser tab · Supports JSONL/JSON traces (<code>item, agent, round, correct, prompt_tokens, completion_tokens</code>) and contrast CSVs (<code>study, p_mas, p_base, n</code>)</small>
321
+ <input id="file" type="file" accept=".jsonl,.json,.csv">
322
+ </label>
323
+
324
+ <section class="tab-panel active" data-panel="trace">
325
+ <section class="grid">
326
+ <article class="panel accent-top">
327
+ <h2>Baseline Classification</h2>
328
+ <div id="baseline" class="value">Waiting</div>
329
+ <p id="status" class="empty">Load a scored trace to calculate its resource vector.</p>
330
+ <div class="ladder" aria-label="Baseline Ladder">
331
+ <div class="rung" id="rungA">A · Single Pass</div>
332
+ <div class="rung" id="rungB">B · Sampled</div>
333
+ <div class="rung" id="rungC">C · Resource-Matched</div>
334
+ <div class="rung" id="rungD">D · Pareto Frontier</div>
335
+ </div>
336
+ </article>
337
+ <article class="panel">
338
+ <h2>Resource Vector R</h2>
339
+ <div id="vector" class="empty">No data</div>
340
+ </article>
341
+ <article class="panel">
342
+ <h2>Directional Feasibility</h2>
343
+ <div id="feasible" class="empty">No data</div>
344
+ </article>
345
+ </section>
346
+ </section>
347
+
348
+ <section class="tab-panel" data-panel="dynamics">
349
+ <section class="panel">
350
+ <h2>Debate Dynamics, Flow Identity &amp; Peer-Influence Lab</h2>
351
+ <p class="panel-sub">Tracks accuracy from first to final round, wrong-to-right (&tau;<sub>ic</sub>) vs. right-to-wrong (&tau;<sub>ci</sub>) flip rates, and the flow identity for the plug-in &#x0302;p* (which restates the net change in accuracy and is not an independent test).</p>
352
+ <div id="dynamicsLab" class="empty">Load a debate log to inspect round-by-round dynamics.</div>
353
+ </section>
354
+ </section>
355
+
356
+ <section class="tab-panel" data-panel="corpus">
357
+ <section class="panel">
358
+ <h2>Corpus &amp; Noise-Band Explorer</h2>
359
+ <p class="panel-sub">Test whether reported MAS-vs-baseline accuracy differences exceed the paired binomial noise band &plusmn;1.96&thinsp;SE(&phi;) under assumed paired correlation &phi;.</p>
360
+ <div class="actions">
361
+ <label>Paired correlation &phi; = <strong id="phiVal">0.50</strong>
362
+ <input id="phiSlider" type="range" min="0" max="0.9" step="0.01" value="0.5">
363
+ </label>
364
+ </div>
365
+ <div id="corpusLab" class="empty">Load a contrast CSV or click "Load Demo: 9-Study Contrasts CSV".</div>
366
+ </section>
367
+ </section>
368
+
369
+ <section class="tab-panel" data-panel="planner">
370
+ <section class="panel">
371
+ <h2>Prospective Experiment Planner (k<sub>tok</sub> &amp; Pool Sizer)</h2>
372
+ <p class="panel-sub">Compute the token-equivalent single-agent sample count k<sub>tok</sub> for a K-agent, T-round multi-agent protocol and size your benchmark sample count n before running.</p>
373
+ <div class="actions">
374
+ <label>Agents K <input id="pk" type="number" value="5" min="1" style="width:72px"></label>
375
+ <label>Rounds T <input id="pt" type="number" value="3" min="1" style="width:72px"></label>
376
+ <label>Prompt c<sub>0</sub> <input id="pc" type="number" value="400" min="0" style="width:84px"></label>
377
+ <label>Message l <input id="pl" type="number" value="120" min="0" style="width:84px"></label>
378
+ <label>Topology
379
+ <select id="topology">
380
+ <option value="last_round_peers">last_round_peers</option>
381
+ <option value="last_round_all">last_round_all</option>
382
+ <option value="full_history_echo">full_history_echo</option>
383
+ </select>
384
+ </label>
385
+ <label>Items n <input id="pn" type="number" value="200" min="10" style="width:80px"></label>
386
+ <label>Base acc p<sub>0</sub> <input id="pp0" type="number" value="0.50" min="0.01" max="0.99" step="0.05" style="width:78px"></label>
387
+ <button id="calcPool" class="teal" type="button">Calculate k_tok</button>
388
+ </div>
389
+ <div id="theory" class="empty">Configure a budget.</div>
390
+ <div id="powerLab" class="empty" style="margin-top:12px">Power calculator available through pace power.</div>
391
+ </section>
392
+ </section>
393
+
394
+ <section class="panel" style="margin-top:16px">
395
+ <h2>Active Trace: Round Transitions &amp; Peer Correctness</h2>
396
+ <p class="panel-sub">Empirical probability P(correct at t+1) conditioned on own correctness and number of correct peers at round t.</p>
397
+ <div id="transitions" class="empty">No data</div>
398
+ </section>
399
+
400
+ <section class="panel" style="margin-top:16px">
401
+ <div style="display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;margin-bottom:10px">
402
+ <h2 style="margin:0">PACE Card Preview &amp; Export</h2>
403
+ <div class="actions" style="margin:0">
404
+ <span id="exportToast" class="toast"></span>
405
+ <button id="copyMd" class="secondary" type="button">Copy Markdown</button>
406
+ <button id="copyTex" class="secondary" type="button">Copy LaTeX</button>
407
+ <button id="md" type="button">Export Markdown</button>
408
+ <button id="tex" type="button">Export LaTeX</button>
409
+ <button id="json" class="secondary" type="button">Export JSON</button>
410
+ </div>
411
+ </div>
412
+ <pre id="preview">Load a file to render the card.</pre>
413
+ </section>
414
+
415
+ <div class="cli-strip">
416
+ <div><strong>Run PACE on AutoGen / LangGraph / CrewAI / Inspect AI logs:</strong> <code>pip install pace-eval &amp;&amp; pace import-logs --format inspect --input trace.json --output trace.jsonl &amp;&amp; pace card trace.jsonl</code></div>
417
+ <div style="display:flex;align-items:center;gap:8px">
418
+ <button id="copyCli" class="teal" type="button">Copy CLI</button>
419
+ <span id="cliToast" class="toast"></span>
420
+ </div>
421
+ </div>
422
+
423
+ <div class="cli-strip" style="margin-top:10px;background:#faf8f4;border-left:4px solid var(--accent)">
424
+ <div><strong>Feedback &amp; Community Ledger:</strong> Found a bug, want a new importer, or have Category B/C/D results to add? (Your traces never leave this browser tab.)</div>
425
+ <div style="display:flex;flex-wrap:wrap;gap:8px">
426
+ <a class="btn secondary" href="https://github.com/mahmoudsajjadi/pace/issues/new?template=add_study_contrast.yml" target="_blank" rel="noopener">Submit Study Contrast</a>
427
+ <a class="btn secondary" href="https://github.com/mahmoudsajjadi/pace/issues/new" target="_blank" rel="noopener">Report Bug / Feedback</a>
428
+ <a class="btn secondary" href="mailto:mahmoud.sajjadi@unr.edu?subject=PACE%20Studio%20Feedback">Email Author</a>
429
+ </div>
430
+ </div>
431
+ </main>
432
+
433
+ <footer>
434
+ <div><strong>PACE Studio</strong> · Apache-2.0 Code · CC-BY-4.0 Data · Zero-dependency browser workbench</div>
435
+ <div>
436
+ <a href="https://arxiv.org/abs/2611.17610" target="_blank" rel="noopener">arXiv:2611.17610</a> ·
437
+ <a href="https://github.com/mahmoudsajjadi/pace" target="_blank" rel="noopener">GitHub</a> ·
438
+ <a href="https://huggingface.co/datasets/sajjadi/pace-contrasts" target="_blank" rel="noopener">Contrasts Dataset</a> ·
439
+ <a href="https://doi.org/10.5281/zenodo.24286397" target="_blank" rel="noopener">Zenodo 10.5281/zenodo.24286397</a>
440
+ </div>
441
+ </footer>
442
+
443
+ <script>
444
+ let card=null;
445
+ let currentRows=[];
446
+ let currentContrasts=[];
447
+ const $=id=>document.getElementById(id);
448
+
449
+ const BIBTEX=`@article{sajjadi2026more,
450
+ title = {More Agents, More Samples, or More Thinking? Untangling Coordination, Ensembling, and Test-Time Compute in Multi-Agent LLMs},
451
+ author = {Sajjadi Mohammadabadi, Seyed Mahmoud},
452
+ journal = {arXiv preprint arXiv:2611.17610},
453
+ note = {Preprint},
454
+ year = {2026},
455
+ eprint = {2611.17610},
456
+ archivePrefix = {arXiv},
457
+ primaryClass = {cs.AI},
458
+ doi = {10.48550/arXiv.2611.17610},
459
+ url = {https://arxiv.org/abs/2611.17610}
460
+ }`;
461
+
462
+ const CLI_CMD='pip install pace-eval && pace import-logs --format inspect --input trace.json --output trace.jsonl && pace card trace.jsonl';
463
+
464
+ function esc(s){
465
+ return String(s??'').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
466
+ }
467
+
468
+ function copyText(text,toastEl,msg){
469
+ if(navigator.clipboard&&navigator.clipboard.writeText){
470
+ navigator.clipboard.writeText(text).then(()=>flash(toastEl,msg)).catch(()=>fallbackCopy(text,toastEl,msg));
471
+ }else{
472
+ fallbackCopy(text,toastEl,msg);
473
+ }
474
+ }
475
+ function fallbackCopy(text,toastEl,msg){
476
+ const ta=document.createElement('textarea');
477
+ ta.value=text;
478
+ document.body.appendChild(ta);
479
+ ta.select();
480
+ try{document.execCommand('copy');flash(toastEl,msg)}catch(e){}
481
+ document.body.removeChild(ta);
482
+ }
483
+ function flash(el,msg,isErr){
484
+ if(!el)return;
485
+ el.classList.toggle('err',!!isErr);
486
+ el.textContent=msg;
487
+ setTimeout(()=>{if(el.textContent===msg){el.textContent='';el.classList.remove('err')}},2600);
488
+ }
489
+
490
+ function parseCsvLine(line){
491
+ const out=[];
492
+ let cur='',inQ=false;
493
+ for(let i=0;i<line.length;i++){
494
+ const ch=line[i];
495
+ if(inQ){
496
+ if(ch==='"'&&line[i+1]==='"'){cur+='"';i++}
497
+ else if(ch==='"'){inQ=false}
498
+ else{cur+=ch}
499
+ }else{
500
+ if(ch==='"'){inQ=true}
501
+ else if(ch===','){out.push(cur.trim());cur=''}
502
+ else{cur+=ch}
503
+ }
504
+ }
505
+ out.push(cur.trim());
506
+ return out;
507
+ }
508
+
509
+ function csv(text){
510
+ const lines=text.trim().split(/\r?\n/).filter(Boolean);
511
+ if(!lines.length)return [];
512
+ const head=parseCsvLine(lines.shift());
513
+ return lines.map(line=>{
514
+ const cells=parseCsvLine(line);
515
+ return Object.fromEntries(head.map((key,i)=>[key.trim(),cells[i]===undefined?'':cells[i]]));
516
+ });
517
+ }
518
+ function bool(v){return v===true||v===1||v==='1'||String(v).toLowerCase()==='true'||String(v).toLowerCase()==='correct'}
519
+
520
+ function normalizeJsonObj(obj){
521
+ if(Array.isArray(obj))return obj;
522
+ if(obj&&Array.isArray(obj.messages)){
523
+ const item=obj.item??obj.item_id??obj.id??'item_0';
524
+ return obj.messages.map((m,i)=>({item,agent:m.name||m.agent||('agent_'+i),round:m.round??0,correct:m.correct,prompt_tokens:m.prompt_tokens,completion_tokens:m.completion_tokens}));
525
+ }
526
+ if(obj&&obj.state&&Array.isArray(obj.state.messages)){
527
+ const item=obj.item??obj.item_id??obj.id??'item_0';
528
+ return obj.state.messages.map((m,i)=>({item,agent:m.name||m.agent||('agent_'+i),round:m.round??0,correct:m.correct,prompt_tokens:m.prompt_tokens,completion_tokens:m.completion_tokens}));
529
+ }
530
+ if(obj&&Array.isArray(obj.tasks)){
531
+ const item=obj.item??obj.item_id??obj.id??'item_0';
532
+ return obj.tasks.map((t,i)=>({item,agent:t.agent||('agent_'+i),round:t.round??i,correct:t.correct,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens}));
533
+ }
534
+ return obj?[obj]:[];
535
+ }
536
+
537
+ function parseRows(text,name){
538
+ const trimmed=text.trim();
539
+ if(!trimmed)return [];
540
+ if(name.toLowerCase().endsWith('.csv'))return csv(trimmed);
541
+ try{
542
+ const parsed=JSON.parse(trimmed);
543
+ if(Array.isArray(parsed)){
544
+ return parsed.flatMap(el=>(el&&(el.messages||el.state||el.tasks)&&el.correct===undefined)?normalizeJsonObj(el):[el]);
545
+ }
546
+ return normalizeJsonObj(parsed);
547
+ }catch(_){
548
+ return trimmed.split(/\r?\n/).filter(Boolean).flatMap(line=>{
549
+ const obj=JSON.parse(line);
550
+ return (obj&&(obj.messages||obj.state||obj.tasks)&&obj.correct===undefined)?normalizeJsonObj(obj):[obj];
551
+ });
552
+ }
553
+ }
554
+
555
+ function numOrNull(v){
556
+ if(v===undefined||v===null||v==='')return null;
557
+ const n=Number(v);
558
+ return Number.isFinite(n)?n:null;
559
+ }
560
+
561
+ function compute(rows){
562
+ if(!rows||!rows.length){
563
+ return {
564
+ schema:'pace-card/v1',
565
+ n_records:0,
566
+ n_items:0,
567
+ resource_vector:{r_token:null,r_call:null,r_round:null,r_sample:null,r_context:null,r_scaff:null},
568
+ baseline:'insufficient_data',
569
+ feasibility:{status:'insufficient_data',active_axes:[],direction:'empty trace'},
570
+ transition_matrix:{}
571
+ };
572
+ }
573
+ const items=new Set(rows.map(r=>String(r.item??r.item_id??'item_0')));
574
+ const firstRound={};
575
+ rows.forEach(r=>{const k=String(r.item??r.item_id??'item_0'),rd=numOrNull(r.round)??0;if(!(k in firstRound)||rd<firstRound[k])firstRound[k]=rd;});
576
+ let trajectories=0,laterCalls=0;
577
+ rows.forEach(r=>{const k=String(r.item??r.item_id??'item_0');if((numOrNull(r.round)??0)===firstRound[k])trajectories++;else laterCalls++;});
578
+ const rounds=rows.map(r=>numOrNull(r.round)??0);
579
+ const tokens=rows.map(r=>{
580
+ const p=numOrNull(r.prompt_tokens),c=numOrNull(r.completion_tokens);
581
+ return (p!==null&&c!==null)?p+c:null;
582
+ }).filter(v=>v!==null);
583
+ const reasons=rows.map(r=>numOrNull(r.reasoning_tokens)).filter(v=>v!==null);
584
+ const R={
585
+ r_token:tokens.length?tokens.reduce((a,b)=>a+b,0)/Math.max(1,items.size):null,
586
+ r_call:rows.length/Math.max(1,items.size),
587
+ r_round:Math.max(...rounds)-Math.min(...rounds)+1,
588
+ r_sample:trajectories/Math.max(1,items.size),
589
+ r_context:laterCalls/Math.max(1,items.size),
590
+ r_scaff:rows.filter(r=>r.scaffold||r.tool_calls).length
591
+ };
592
+ if(reasons.length)R.r_reason=reasons.reduce((a,b)=>a+b,0)/Math.max(1,items.size);
593
+ let baseline=R.r_round<=1&&R.r_sample<=1&&R.r_context<=0?'A':R.r_round<=1&&R.r_context<=0?'B':R.r_sample<=1?'C':'n/a';
594
+ const by={};
595
+ rows.forEach(r=>{
596
+ const k=String(r.item??r.item_id??'item_0')+'\u0000'+String(r.agent??r.agent_id??'agent_0');
597
+ (by[k]??={})[numOrNull(r.round)??0]=bool(r.correct);
598
+ });
599
+ const counts={};
600
+ Object.keys(by).forEach(k=>{
601
+ const rs=Object.keys(by[k]).map(Number).sort((a,b)=>a-b);
602
+ const itemPrefix=k.split('\u0000')[0]+'\u0000';
603
+ for(let i=0;i<rs.length-1;i++){
604
+ const own=by[k][rs[i]]?1:0;
605
+ const next=by[k][rs[i+1]]?1:0;
606
+ const peers=Object.keys(by).filter(x=>x.startsWith(itemPrefix)).map(x=>by[x][rs[i]]).filter(x=>x!==undefined).reduce((a,b)=>a+(b?1:0),0)-own;
607
+ const key='own='+own+',peers_right='+peers;
608
+ (counts[key]??={good:0,n:0});
609
+ counts[key].good+=next;
610
+ counts[key].n++;
611
+ }
612
+ });
613
+ const T=Object.fromEntries(Object.entries(counts).map(([k,v])=>[k,{p_next:v.good/v.n,n:v.n}]));
614
+ return {
615
+ schema:'pace-card/v1',
616
+ n_records:rows.length,
617
+ n_items:items.size,
618
+ resource_vector:R,
619
+ baseline,
620
+ feasibility:{
621
+ status:tokens.length?'measured_only':'insufficient_data',
622
+ active_axes:Object.keys(R).filter(k=>R[k]>0),
623
+ direction:tokens.length?'requires compute-matched baseline comparison':'missing token logs'
624
+ },
625
+ transition_matrix:T
626
+ };
627
+ }
628
+
629
+ function fmtAxis(v,d){return (v===null||v===undefined||Number.isNaN(Number(v)))?'n/a':Number(v).toFixed(d);}
630
+
631
+ function markdown(c){
632
+ return '<!-- Generated by PACE Studio (https://arxiv.org/abs/2611.17610) -->\n# PACE Card\n\nBaseline: **'+c.baseline+'** ('+c.n_items+' items, '+c.n_records+' calls)\n\n| Axis | Value |\n|---|---:|\n'+
633
+ Object.entries(c.resource_vector).map(([k,v])=>'| '+k+' | '+fmtAxis(v,3)+' |').join('\n')+
634
+ '\n\n## Transition Matrix\n\n| State | P(correct at t+1) | n |\n|---|---:|---:|\n'+
635
+ Object.entries(c.transition_matrix).map(([k,v])=>'| '+k+' | '+v.p_next.toFixed(3)+' | '+v.n+' |').join('\n')+'\n';
636
+ }
637
+
638
+ function latex(c){
639
+ return '% Generated by PACE Studio (https://arxiv.org/abs/2611.17610) — \\cite{sajjadi2026more}\n\\begin{table}[t]\n\\centering\n\\caption{PACE Evaluation Card (Baseline: '+c.baseline.replaceAll('_','\\_')+', '+c.n_items+' items).}\n\\begin{tabular}{lr}\n\\toprule\nAxis & Value\\\\\n\\midrule\n'+
640
+ Object.entries(c.resource_vector).map(([k,v])=>k.replaceAll('_','\\_')+' & '+fmtAxis(v,3)+'\\\\').join('\n')+
641
+ '\n\\bottomrule\n\\end{tabular}\n\\end{table}\n';
642
+ }
643
+
644
+ function download(text,ext){
645
+ const a=document.createElement('a');
646
+ a.href=URL.createObjectURL(new Blob([text],{type:'text/plain'}));
647
+ a.download='pace-card.'+ext;
648
+ a.click();
649
+ URL.revokeObjectURL(a.href);
650
+ }
651
+
652
+ function poolSize(){
653
+ const K=Math.max(1,Number($('pk').value||1));
654
+ const T=Math.max(1,Number($('pt').value||1));
655
+ const c=Math.max(0,Number($('pc').value||0));
656
+ const l=Math.max(0,Number($('pl').value||0));
657
+ const nTarget=Math.max(10,Number($('pn')?$('pn').value:200)||200);
658
+ const p0=Math.min(0.99,Math.max(0.01,Number($('pp0')?$('pp0').value:0.5)||0.5));
659
+ const r=l/(c+l||1);
660
+ const top=$('topology').value;
661
+ const coefficient=top==='last_round_peers'?(T-1)*K*(K-1):top==='last_round_all'?(T-1)*K*K:.5*K*K*T*(T-1);
662
+ const kMin=K*T;
663
+ const kMax=kMin+coefficient;
664
+ const tok=kMin+coefficient*r;
665
+ let recommended=8;
666
+ while(recommended<Math.ceil(tok))recommended*=2;
667
+
668
+ $('theory').innerHTML=
669
+ '<div class="kpi-grid">'+
670
+ '<div class="kpi"><div class="k-label">Effective Samples k<sub>tok</sub></div><div class="k-val">'+tok.toFixed(2)+'</div><div class="k-sub">Range ['+kMin.toFixed(0)+', '+kMax.toFixed(0)+']</div></div>'+
671
+ '<div class="kpi"><div class="k-label">Recommended SC Pool</div><div class="k-val">k = '+recommended+'</div><div class="k-sub">Power-of-2 ceiling &ge; &lceil;k<sub>tok</sub>&rceil;</div></div>'+
672
+ '<div class="kpi"><div class="k-label">Message Ratio r</div><div class="k-val">'+r.toFixed(3)+'</div><div class="k-sub">l / (c<sub>0</sub> + l)</div></div>'+
673
+ '<div class="kpi"><div class="k-label">Context Multiplier</div><div class="k-val">'+coefficient.toFixed(0)+'</div><div class="k-sub">'+esc(top)+'</div></div>'+
674
+ '</div>';
675
+
676
+ const phi=Number($('phiSlider')?$('phiSlider').value:0.5);
677
+ const seTarget=Math.sqrt(2*p0*(1-p0)*(1-phi)/nTarget);
678
+ const mdeTarget=2.8*seTarget*100;
679
+ const se500=Math.sqrt(2*p0*(1-p0)*(1-phi)/500);
680
+ $('powerLab').innerHTML=
681
+ '<div class="banner"><strong>Protocol Checklist:</strong> To claim a Category C gain over single-agent compute for K='+K+', T='+T+' ('+esc(top)+'), evaluate a single-agent self-consistency baseline with <strong>k = '+recommended+' samples</strong> on <strong>n = '+nTarget+' items</strong> (detectable difference &ge; &plusmn;'+mdeTarget.toFixed(1)+' pp at 80% power).</div>'+
682
+ '<div class="kpi-grid">'+
683
+ '<div class="kpi"><div class="k-label">MDE (80% power, n='+nTarget+')</div><div class="k-val">&plusmn;'+mdeTarget.toFixed(1)+' pp</div><div class="k-sub">at p<sub>0</sub>='+p0.toFixed(2)+', &phi;='+phi.toFixed(2)+'</div></div>'+
684
+ '<div class="kpi"><div class="k-label">MDE Reference (n=500)</div><div class="k-val">&plusmn;'+(2.8*se500*100).toFixed(1)+' pp</div><div class="k-sub">CLI: <code>pace power --p-base '+p0.toFixed(2)+' --delta 0.05 --n-items '+nTarget+' --phi '+phi.toFixed(2)+'</code></div></div>'+
685
+ '</div>';
686
+
687
+ return 'k_tok = '+tok.toFixed(3)+'; recommended pool = '+recommended+'; r = '+r.toFixed(3);
688
+ }
689
+
690
+ function renderForestSvg(items){
691
+ if(!items.length)return '';
692
+ let plotRows=items;
693
+ let subtitle='Paired Noise-Band Forest Plot (&Delta; = p<sub>MAS</sub> &minus; p<sub>base</sub> with &plusmn;1.96 SE(&phi;))';
694
+ if(items.length>40){
695
+ const byStudy={};
696
+ items.forEach(it=>{
697
+ const s=it.study||'study';
698
+ (byStudy[s]??=[]).push(it);
699
+ });
700
+ plotRows=Object.entries(byStudy).map(([study,arr])=>({
701
+ study:study+' (k='+arr.length+')',
702
+ d:arr.reduce((a,b)=>a+b.d,0)/arr.length,
703
+ se:arr.reduce((a,b)=>a+b.se,0)/arr.length
704
+ }));
705
+ subtitle='Study-Level Summary Forest Plot (mean &Delta; and mean &plusmn;1.96 SE(&phi;) across '+items.length+' contrasts)';
706
+ }
707
+ const rowH=24,topPad=22,leftPad=185,rightPad=75,width=760;
708
+ const plotW=width-leftPad-rightPad;
709
+ const height=topPad+plotRows.length*rowH+26;
710
+ const maxAbs=Math.max(0.15,...plotRows.map(it=>Math.abs(it.d)+1.96*it.se));
711
+ const xOf=v=>leftPad+((v+maxAbs)/(2*maxAbs))*plotW;
712
+ const x0=xOf(0);
713
+ const lines=plotRows.map((it,idx)=>{
714
+ const y=topPad+idx*rowH+rowH/2;
715
+ const xL=xOf(it.d-1.96*it.se),xR=xOf(it.d+1.96*it.se),xC=xOf(it.d);
716
+ const col=Math.abs(it.d)<=1.96*it.se?'#9a5b13':(it.d>0?'#1b6e42':'#a62b2b');
717
+ const label=esc((it.study||'study').slice(0,25));
718
+ return '<text x="'+(leftPad-8)+'" y="'+(y+4)+'" text-anchor="end" font-size="11.5" fill="#17212b">'+label+'</text>'+
719
+ '<line x1="'+xL.toFixed(1)+'" y1="'+y+'" x2="'+xR.toFixed(1)+'" y2="'+y+'" stroke="'+col+'" stroke-width="2.2"/>'+
720
+ '<circle cx="'+xC.toFixed(1)+'" cy="'+y+'" r="4" fill="'+col+'"/>'+
721
+ '<text x="'+(width-6)+'" y="'+(y+4)+'" text-anchor="end" font-size="11" fill="'+col+'">'+(it.d>=0?'+':'')+(it.d*100).toFixed(1)+' pp</text>';
722
+ }).join('');
723
+ const axisY=topPad+plotRows.length*rowH+4;
724
+ return '<div class="forest-wrap"><div class="forest-title">'+subtitle+'</div>'+
725
+ '<svg viewBox="0 0 '+width+' '+height+'" style="width:100%;max-width:860px;height:auto;display:block">'+
726
+ '<line x1="'+x0.toFixed(1)+'" y1="'+topPad+'" x2="'+x0.toFixed(1)+'" y2="'+axisY+'" stroke="#52606d" stroke-dasharray="4 3" stroke-width="1.2"/>'+
727
+ lines+
728
+ '<text x="'+x0.toFixed(1)+'" y="'+(axisY+14)+'" text-anchor="middle" font-size="11" fill="#52606d">0.0 pp (Parity)</text>'+
729
+ '<text x="'+xOf(-maxAbs).toFixed(1)+'" y="'+(axisY+14)+'" text-anchor="start" font-size="11" fill="#52606d">&minus;'+(maxAbs*100).toFixed(0)+' pp</text>'+
730
+ '<text x="'+xOf(maxAbs).toFixed(1)+'" y="'+(axisY+14)+'" text-anchor="end" font-size="11" fill="#52606d">+'+(maxAbs*100).toFixed(0)+' pp</text>'+
731
+ '</svg></div>';
732
+ }
733
+
734
+ function noise(rows,phi){
735
+ const pCorr=(phi===undefined)?Number($('phiSlider')?$('phiSlider').value:0.5):Number(phi);
736
+ const valid=rows.filter(r=>r.p_mas!==undefined&&r.p_base!==undefined&&r.p_mas!==''&&r.p_base!=='');
737
+ if(!valid.length)return '';
738
+ let band96=0,band1=0,clamp=0;
739
+ const hs=[];
740
+ const plotItems=[];
741
+ const tableRows=[];
742
+ valid.forEach(r=>{
743
+ const m=Number(r.p_mas),b=Number(r.p_base),n=Math.max(1,Number(r.n||1));
744
+ const se=Math.sqrt(Math.max(0,(m*(1-m)+b*(1-b)-2*pCorr*Math.sqrt(Math.max(0,m*(1-m)*b*(1-b))))/n));
745
+ const d=m-b;
746
+ if(Math.abs(d)>1.96*se)band96++;
747
+ if(Math.abs(d)>se)band1++;
748
+ hs.push(2*Math.asin(Math.sqrt(Math.max(0,m)))-2*Math.asin(Math.sqrt(Math.max(0,b))));
749
+ const denom=b*(1-m);
750
+ const o=denom>0?(m*(1-b))/denom:Infinity;
751
+ const phiMax=(o>0&&isFinite(o))?Math.min(Math.sqrt(o),Math.sqrt(1/o)):0;
752
+ const clamped=pCorr>phiMax;
753
+ if(clamped)clamp++;
754
+ plotItems.push({study:r.study||'study',d,se});
755
+ const status=Math.abs(d)<=1.96*se?'<span class="pill warn">Within Noise Band</span>':(d>0?'<span class="pill ok">Above +1.96 SE</span>':'<span class="pill bad">Below -1.96 SE</span>');
756
+ tableRows.push('<tr><td>'+esc(r.study||'study')+'</td><td>'+esc(r.benchmark||'—')+'</td><td>'+esc(r.category||'B/C')+'</td><td>'+m.toFixed(3)+'</td><td>'+b.toFixed(3)+'</td><td>'+(d>=0?'+':'')+d.toFixed(3)+'</td><td>'+n+'</td><td>'+se.toFixed(3)+'</td><td>'+status+'</td></tr>');
757
+ });
758
+ const meanH=hs.reduce((a,b)=>a+b,0)/hs.length;
759
+ const summary='Noise band (&phi;='+pCorr.toFixed(2)+'): '+band96+'/'+valid.length+' outside +-1.96 SE; '+band1+'/'+valid.length+' outside +-1.0 SE; mean Cohen h = '+meanH.toFixed(3)+'; Frechet clamp count = '+clamp;
760
+
761
+ const isSyntheticDemo=rows===demoContrastRows;
762
+ const isLoadedCorpus=loadedCorpusRows!==null&&rows===loadedCorpusRows;
763
+ $('corpusLab').innerHTML=
764
+ (isSyntheticDemo?'<div class="banner warn"><strong>Synthetic Illustrative Demo:</strong> Placeholder rows (Studies A&ndash;I) for UI demonstration only. Upload <code>baseline_tier_contrasts.csv</code> to audit the extracted 9-study corpus.</div>':'')+
765
+ (isLoadedCorpus?'<div class="banner"><strong>Extracted Corpus Loaded:</strong> '+rows.length+' contrast records across '+new Set(rows.map(r=>r.study)).size+' studies (<code>corpus_contrasts.json</code>).</div>':'')+
766
+ '<div class="kpi-grid">'+
767
+ '<div class="kpi"><div class="k-label">Outside &plusmn;1.96 SE</div><div class="k-val">'+band96+' / '+valid.length+'</div><div class="k-sub">Paired 95% noise band</div></div>'+
768
+ '<div class="kpi"><div class="k-label">Outside &plusmn;1.0 SE</div><div class="k-val">'+band1+' / '+valid.length+'</div><div class="k-sub">At &phi; = '+pCorr.toFixed(2)+'</div></div>'+
769
+ '<div class="kpi"><div class="k-label">Mean Cohen&rsquo;s h</div><div class="k-val">'+(meanH>=0?'+':'')+meanH.toFixed(3)+'</div><div class="k-sub">Arcsine effect size</div></div>'+
770
+ '<div class="kpi"><div class="k-label">Fr&eacute;chet Clamps</div><div class="k-val">'+clamp+'</div><div class="k-sub">Rows hitting correlation bound</div></div>'+
771
+ '</div>'+
772
+ renderForestSvg(plotItems)+
773
+ '<div style="overflow:auto"><table><tr><th>Study</th><th>Benchmark</th><th>Cat.</th><th>p<sub>MAS</sub></th><th>p<sub>base</sub></th><th>&Delta;</th><th>n</th><th>SE(&phi;)</th><th>Noise Band</th></tr>'+tableRows.join('')+'</table></div>';
774
+
775
+ return summary;
776
+ }
777
+
778
+ function influence(rows){
779
+ if(!rows.length||rows[0].correct===undefined)return '';
780
+ const rounds=[...new Set(rows.map(r=>numOrNull(r.round)??0))].sort((a,b)=>a-b);
781
+ const first=rounds[0],last=rounds[rounds.length-1];
782
+ const by={};
783
+ rows.forEach(r=>{
784
+ const k=String(r.item??r.item_id??'item_0')+'\u0000'+String(r.agent??r.agent_id??'agent_0');
785
+ (by[k]??={})[numOrNull(r.round)??0]=bool(r.correct);
786
+ });
787
+ let w=0,r=0,fic=0,fci=0,rLast=0,nLast=0;
788
+ Object.values(by).forEach(s=>{
789
+ if(s[first]!==undefined){if(s[first])r++;else w++}
790
+ if(s[last]!==undefined){nLast++;if(s[last])rLast++}
791
+ if(s[first]!==undefined&&s[last]!==undefined){
792
+ if(!s[first]&&s[last])fic++;
793
+ if(s[first]&&!s[last])fci++;
794
+ }
795
+ });
796
+ const p1=(r+w)?r/(r+w):0;
797
+ const pT=nLast?rLast/nLast:0;
798
+ const ti=w?fic/w:0;
799
+ const tc=r?fci/r:0;
800
+ const ps=(ti+tc)?ti/(ti+tc):0;
801
+ const gap=Math.abs((ps-p1)-((r*w*(fic-fci))/((fic*r+fci*w)*(r+w)||1)));
802
+
803
+ const diagCls=rounds.length<=1?'warn':(fic>fci?'ok':'bad');
804
+ const diagText=rounds.length<=1
805
+ ?'Single-round trace: no multi-round peer influence transitions observed.'
806
+ :(fic>fci
807
+ ?'<strong>Net Positive Correction (f<sub>ic</sub> &gt; f<sub>ci</sub>):</strong> Wrong-to-right flips ('+fic+') exceed right-to-wrong flips ('+fci+'): accuracy rises over these transitions (plug-in p* = '+(ps*100).toFixed(1)+'%, a restatement of the net change).'
808
+ :'<strong>Accuracy Fell or Stalled Across Rounds (f<sub>ci</sub> &ge; f<sub>ic</sub>):</strong> Right-to-wrong flips ('+fci+') equal or exceed wrong-to-right flips ('+fic+'); attribution requires a no-communication control.');
809
+
810
+ const perRound=rounds.map(rd=>{
811
+ const sub=rows.filter(x=>(numOrNull(x.round)??0)===rd);
812
+ const acc=sub.filter(x=>bool(x.correct)).length/Math.max(1,sub.length);
813
+ const toks=sub.map(x=>{
814
+ const p=numOrNull(x.prompt_tokens),c=numOrNull(x.completion_tokens);
815
+ return (p!==null&&c!==null)?p+c:null;
816
+ }).filter(v=>v!==null);
817
+ const meanTok=toks.length?toks.reduce((a,b)=>a+b,0)/toks.length:0;
818
+ return '<tr><td>Round '+rd+'</td><td>'+sub.length+'</td><td><span class="bar-wrap"><span class="bar-fill" style="width:'+Math.round(acc*100)+'%"></span></span>'+(acc*100).toFixed(1)+'%</td><td>'+meanTok.toFixed(0)+' tok</td></tr>';
819
+ }).join('');
820
+
821
+ $('dynamicsLab').innerHTML=
822
+ '<div class="banner '+diagCls+'">'+diagText+'</div>'+
823
+ '<div class="kpi-grid">'+
824
+ '<div class="kpi"><div class="k-label">Round '+first+' Accuracy</div><div class="k-val">'+(p1*100).toFixed(1)+'%</div><div class="k-sub">n = '+(r+w)+' agent-items</div></div>'+
825
+ '<div class="kpi"><div class="k-label">Round '+last+' Accuracy</div><div class="k-val">'+(pT*100).toFixed(1)+'%</div><div class="k-sub">&Delta; = '+((pT-p1)>=0?'+':'')+((pT-p1)*100).toFixed(1)+' pp</div></div>'+
826
+ '<div class="kpi"><div class="k-label">Wrong &rarr; Right (&tau;<sub>ic</sub>)</div><div class="k-val">'+ti.toFixed(3)+'</div><div class="k-sub">'+fic+' / '+w+' flips</div></div>'+
827
+ '<div class="kpi"><div class="k-label">Right &rarr; Wrong (&tau;<sub>ci</sub>)</div><div class="k-val">'+tc.toFixed(3)+'</div><div class="k-sub">'+fci+' / '+r+' flips</div></div>'+
828
+ '<div class="kpi"><div class="k-label">Plug-in p* (restates net change)</div><div class="k-val">'+(ps*100).toFixed(1)+'%</div><div class="k-sub">Flow gap: '+gap.toExponential(1)+'</div></div>'+
829
+ '</div>'+
830
+ '<table><tr><th>Round</th><th>Calls</th><th>Agent Accuracy</th><th>Mean Tokens / Call</th></tr>'+perRound+'</table>';
831
+
832
+ return 'Flow identity: gap = '+gap.toExponential(2)+'; p1 = '+p1.toFixed(3)+', p* = '+ps.toFixed(3);
833
+ }
834
+
835
+ const AXIS_DESC={
836
+ r_token:'Mean total tokens per item',
837
+ r_call:'Mean LLM calls per item',
838
+ r_round:'Debate / interaction rounds',
839
+ r_sample:'Independent first-round trajectories per item',
840
+ r_context:'Later-round calls per item (see earlier context)',
841
+ r_scaff:'Tool / scaffolded calls',
842
+ r_reason:'Mean reasoning tokens per item'
843
+ };
844
+
845
+ function render(rows){
846
+ if(!card)return;
847
+ $('baseline').textContent=card.baseline;
848
+ $('status').textContent=card.feasibility.status+' · '+card.n_items+' items · '+card.n_records+' calls';
849
+ ['rungA','rungB','rungC','rungD'].forEach(id=>$(id).classList.remove('on'));
850
+ if(card.baseline==='A')$('rungA').classList.add('on');
851
+ else if(card.baseline==='B')$('rungB').classList.add('on');
852
+ else if(card.baseline==='C')$('rungC').classList.add('on');
853
+
854
+ $('vector').innerHTML=Object.entries(card.resource_vector).map(([k,v])=>
855
+ '<div class="axis"><span class="axis-name"><strong>'+esc(k)+'</strong><span class="axis-desc">'+(AXIS_DESC[k]||'')+'</span></span><strong>'+fmtAxis(v,2)+'</strong></div>'
856
+ ).join('');
857
+
858
+ $('feasible').innerHTML=
859
+ '<p style="margin:0 0 8px"><strong>Status:</strong> '+esc(card.feasibility.status)+'</p>'+
860
+ '<p style="margin:0 0 8px"><strong>Guidance:</strong> '+esc(card.feasibility.direction)+'</p>'+
861
+ (card.baseline==='n/a'?'<p style="margin:0 0 8px"><span class="pill warn">Unmatched MAS</span> Compare against Category B (Sampled) or Category C (Resource-Matched) baseline.</p>':'')+
862
+ '<p style="margin:0;color:var(--muted);font-size:13px">Active axes ('+card.feasibility.active_axes.length+'): '+esc(card.feasibility.active_axes.join(', '))+'</p>';
863
+
864
+ const tEntries=Object.entries(card.transition_matrix);
865
+ $('transitions').innerHTML=tEntries.length
866
+ ?'<table><tr><th>State at Round t</th><th>P(correct at t+1)</th><th>n</th></tr>'+
867
+ tEntries.map(([k,v])=>'<tr><td><code>'+esc(k)+'</code></td><td><span class="bar-wrap"><span class="bar-fill" style="width:'+Math.round(v.p_next*100)+'%"></span></span>'+v.p_next.toFixed(3)+'</td><td>'+v.n+'</td></tr>').join('')+'</table>'
868
+ :'<p class="empty">Single-round trace: no round-to-round transitions.</p>';
869
+
870
+ influence(rows);
871
+ poolSize();
872
+ $('preview').textContent=markdown(card);
873
+ }
874
+
875
+ function showTab(name){
876
+ document.querySelectorAll('.tab').forEach(button=>button.classList.toggle('active',button.dataset.tab===name));
877
+ document.querySelectorAll('.tab-panel').forEach(panel=>panel.classList.toggle('active',panel.dataset.panel===name));
878
+ if(history.replaceState&&['trace','dynamics','corpus','planner'].includes(name)){
879
+ history.replaceState(null,'','#'+name);
880
+ }
881
+ }
882
+
883
+ const demoDebateRows=[];
884
+ for(let item=0;item<6;item++){
885
+ for(let round=1;round<=3;round++){
886
+ for(let agent=0;agent<5;agent++){
887
+ const baseOk=(item+agent)%2===0;
888
+ const ok=round===1?baseOk:(round===2?(item<4?((agent+item)%3!==0):baseOk):(item<4?true:(agent%2===0)));
889
+ demoDebateRows.push({
890
+ item:'mmlu_pro_'+String(item+1).padStart(2,'0'),
891
+ agent:'agent_'+(agent+1),
892
+ round,
893
+ correct:ok,
894
+ answer:ok?'C':'A',
895
+ prompt_tokens:380+(round-1)*240,
896
+ completion_tokens:115
897
+ });
898
+ }
899
+ }
900
+ }
901
+
902
+ const demoHiddenRows=[];
903
+ for(let item=0;item<8;item++){
904
+ for(let round=1;round<=3;round++){
905
+ for(let agent=0;agent<5;agent++){
906
+ const ok=round===1?(agent===0):(round===2?(agent<3):(item<7||agent<4));
907
+ demoHiddenRows.push({
908
+ item:'hp_split_'+String(item+1).padStart(2,'0'),
909
+ agent:'view_'+(agent+1),
910
+ round,
911
+ correct:ok,
912
+ answer:ok?'Target':'Decoy',
913
+ prompt_tokens:420+(round-1)*260,
914
+ completion_tokens:95
915
+ });
916
+ }
917
+ }
918
+ }
919
+
920
+ let loadedCorpusRows=null;
921
+ const demoContrastRows=[
922
+ {study:'Synthetic Study A',benchmark:'Math / MMLU',category:'B',p_mas:0.780,p_base:0.810,n:200},
923
+ {study:'Synthetic Study B',benchmark:'Commonsense / Math',category:'B',p_mas:0.640,p_base:0.690,n:150},
924
+ {study:'Synthetic Study C',benchmark:'Reasoning',category:'C',p_mas:0.715,p_base:0.730,n:180},
925
+ {study:'Synthetic Study D',benchmark:'QA / Math',category:'B',p_mas:0.742,p_base:0.768,n:220},
926
+ {study:'Synthetic Study E',benchmark:'MATH / BBH',category:'B',p_mas:0.590,p_base:0.645,n:300},
927
+ {study:'Synthetic Study F',benchmark:'MMLU-Pro',category:'D',p_mas:0.620,p_base:0.600,n:250},
928
+ {study:'Synthetic Study G',benchmark:'MMLU',category:'B',p_mas:0.695,p_base:0.735,n:200},
929
+ {study:'Synthetic Study H',benchmark:'MMLU / ARC',category:'B',p_mas:0.660,p_base:0.705,n:180},
930
+ {study:'Synthetic Study I',benchmark:'Multi-step',category:'C',p_mas:0.540,p_base:0.555,n:160}
931
+ ];
932
+
933
+ function loadDemo(kind,silent){
934
+ if(kind==='contrasts'){
935
+ currentContrasts=loadedCorpusRows||demoContrastRows;
936
+ noise(currentContrasts);
937
+ if(!silent){
938
+ showTab('corpus');
939
+ flash($('loadStatus'),loadedCorpusRows?'Loaded '+loadedCorpusRows.length+' corpus contrasts':'Loaded 9-study contrast demo');
940
+ }
941
+ return;
942
+ }
943
+ const rows=kind==='hidden'?demoHiddenRows:demoDebateRows;
944
+ currentRows=rows;
945
+ card=compute(rows);
946
+ render(rows);
947
+ if(!silent){
948
+ showTab(kind==='hidden'?'dynamics':'trace');
949
+ flash($('loadStatus'),kind==='hidden'?'Loaded Hidden-Profile demo':'Loaded Debate JSONL demo');
950
+ }
951
+ }
952
+
953
+ function load(file){
954
+ const reader=new FileReader();
955
+ reader.onload=()=>{
956
+ try{
957
+ const rows=parseRows(reader.result,file.name);
958
+ if(!rows.length){
959
+ flash($('loadStatus'),'Empty file: no records found',true);
960
+ return;
961
+ }
962
+ if(rows[0].p_mas!==undefined&&rows[0].p_base!==undefined){
963
+ currentContrasts=rows;
964
+ noise(currentContrasts);
965
+ showTab('corpus');
966
+ flash($('loadStatus'),'Loaded contrast table: '+file.name);
967
+ return;
968
+ }
969
+ if(rows[0].item===undefined&&rows[0].item_id===undefined){
970
+ flash($('loadStatus'),'Unrecognized schema (need item/correct or p_mas/p_base)',true);
971
+ return;
972
+ }
973
+ currentRows=rows;
974
+ card=compute(rows);
975
+ render(rows);
976
+ showTab('trace');
977
+ flash($('loadStatus'),'Loaded trace: '+file.name);
978
+ }catch(e){
979
+ flash($('loadStatus'),'Parse error: '+e.message,true);
980
+ $('preview').textContent='Could not parse file: '+e.message;
981
+ }
982
+ };
983
+ reader.readAsText(file);
984
+ }
985
+
986
+ $('file').onchange=e=>e.target.files[0]&&load(e.target.files[0]);
987
+ $('drop').ondragover=e=>{e.preventDefault();$('drop').classList.add('drag')};
988
+ $('drop').ondragleave=()=>$('drop').classList.remove('drag');
989
+ $('drop').ondrop=e=>{e.preventDefault();$('drop').classList.remove('drag');if(e.dataTransfer.files[0])load(e.dataTransfer.files[0])};
990
+
991
+ $('md').onclick=()=>card&&download(markdown(card),'md');
992
+ $('tex').onclick=()=>card&&download(latex(card),'tex');
993
+ $('json').onclick=()=>card&&download(JSON.stringify(card,null,2),'json');
994
+ $('copyMd').onclick=()=>card&&copyText(markdown(card),$('exportToast'),'Copied Markdown!');
995
+ $('copyTex').onclick=()=>card&&copyText(latex(card),$('exportToast'),'Copied LaTeX!');
996
+ $('copyBib').onclick=()=>copyText(BIBTEX,$('citeToast'),'BibTeX copied!');
997
+ $('copyCli').onclick=()=>copyText(CLI_CMD,$('cliToast'),'CLI copied!');
998
+
999
+ $('calcPool').onclick=()=>poolSize();
1000
+ ['pk','pt','pc','pl','topology','pn','pp0'].forEach(id=>{
1001
+ $(id).addEventListener('input',()=>poolSize());
1002
+ $(id).addEventListener('change',()=>poolSize());
1003
+ });
1004
+
1005
+ document.querySelectorAll('.tab').forEach(button=>{
1006
+ button.onclick=()=>showTab(button.dataset.tab);
1007
+ });
1008
+
1009
+ $('demoDebate').onclick=()=>loadDemo('debate');
1010
+ $('demoHidden').onclick=()=>loadDemo('hidden');
1011
+ $('demoContrasts').onclick=()=>loadDemo('contrasts');
1012
+
1013
+ $('phiSlider').oninput=()=>{
1014
+ $('phiVal').textContent=Number($('phiSlider').value).toFixed(2);
1015
+ if(currentContrasts.length)noise(currentContrasts);
1016
+ poolSize();
1017
+ };
1018
+
1019
+ async function loadDefaultCorpus(){
1020
+ try{
1021
+ const resp=await fetch('./corpus_contrasts.json');
1022
+ if(!resp.ok)throw new Error('HTTP '+resp.status);
1023
+ const rows=await resp.json();
1024
+ if(Array.isArray(rows)&&rows.length){
1025
+ loadedCorpusRows=rows;
1026
+ currentContrasts=rows;
1027
+ noise(currentContrasts);
1028
+ return;
1029
+ }
1030
+ }catch(_e){}
1031
+ currentContrasts=demoContrastRows;
1032
+ noise(currentContrasts);
1033
+ }
1034
+ loadDefaultCorpus();
1035
+ loadDemo('debate',true);
1036
+ const initHash=(window.location.hash||'').replace('#','');
1037
+ if(['trace','dynamics','corpus','planner'].includes(initHash))showTab(initHash);
1038
+ </script>
1039
+ </body>
1040
+ </html>