-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-diff.html
More file actions
553 lines (533 loc) · 42.6 KB
/
Copy pathbundle-diff.html
File metadata and controls
553 lines (533 loc) · 42.6 KB
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data:; connect-src 'none'; frame-src 'none'; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; form-action 'self'; manifest-src 'none';">
<title>Bundle Diff: Compare Two OCG Artifacts or Evidence Bundles · AINumbers.co</title>
<meta name="description" content="Load two OpenChainGraph artifacts, chains, or §27.6 evidence bundles and get an OCG-semantic diff: which input hashes moved, which kernel/policy versions changed, which §27 approvals/roles/thresholds differ, and whether the verdict changed. Runs entirely in your browser.">
<meta name="robots" content="index, follow">
<meta name="author" content="Post Oak Labs">
<link rel="canonical" href="https://ainumbers.co/bundle-diff.html">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Bundle Diff","url":"https://ainumbers.co/bundle-diff.html","description":"Client-side OCG-semantic diff for OpenChainGraph artifacts, chains, and §27.6 evidence bundles.","isPartOf":{"@id":"https://ainumbers.co/#org"}}</script>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='7' fill='%23080E1A'/><text x='50%25' y='56%25' dominant-baseline='middle' text-anchor='middle' font-family='Sora,sans-serif' font-weight='600' font-size='13' fill='%2314B8A6'>AI</text></svg>">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Sora:wght@300;400;500;600&family=JetBrains+Mono:wght@300;400;500&display=swap" rel="stylesheet">
<style>
:root{--bg:#080E1A;--bg-2:#0D1627;--bg-3:#111E35;--bg-4:#162340;--border:#1E2F4A;--border-2:#263855;--muted:#3A5270;--body:#6888A8;--text:#A8C4DE;--bright:#D4E8F8;--white:#EEF6FD;--teal:#14B8A6;--teal-dim:rgba(20,184,166,.12);--teal-lt:#2DD4BF;--gold:#D4A847;--gold-dim:rgba(212,168,71,.12);--green:#22C55E;--green-dim:rgba(34,197,94,.12);--red:#EF4444;--red-dim:rgba(239,68,68,.12);--warn:#F59E0B;--purple:#9B72F5;--purple-dim:rgba(155,114,245,.12);--purple-lt:#B794F4;--radius:6px;--radius-lg:10px}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{background:var(--bg);color:var(--text);font-family:'Sora',sans-serif;font-weight:300;font-size:14px;line-height:1.7;-webkit-font-smoothing:antialiased}
h1,h2,h3{font-family:'DM Serif Display',serif;font-weight:400;line-height:1.2}
a{color:inherit;text-decoration:none}button{cursor:pointer;font-family:inherit}
.container{max-width:1100px;margin:0 auto;padding:0 1.5rem}
body::before{content:'';position:fixed;inset:0;background-image:linear-gradient(rgba(20,184,166,.014) 1px,transparent 1px),linear-gradient(90deg,rgba(20,184,166,.014) 1px,transparent 1px);background-size:48px 48px;pointer-events:none;z-index:0}
nav{padding:0 1.5rem;height:52px;border-bottom:1px solid var(--border);background:rgba(8,14,26,.92);position:sticky;top:0;z-index:200;backdrop-filter:blur(8px)}
.nav-inner{max-width:1100px;margin:0 auto;height:100%;display:flex;align-items:center;justify-content:space-between}
.logo{display:flex;align-items:center;gap:9px}
.logo-text{display:flex;flex-direction:column;gap:.08rem}
.logo-name{font-family:'JetBrains Mono',monospace;font-size:.88rem;font-weight:600;color:var(--bright);line-height:1}
.logo-ai{color:var(--teal)}.logo-co{color:var(--muted);font-size:.75rem}
.nav-bc{font-family:'JetBrains Mono',monospace;font-size:.52rem;color:var(--muted);display:flex;align-items:center;gap:.5rem;justify-content:center}
.nav-bc a{color:var(--body)}.nav-bc a:hover{color:var(--teal)}
.nav-sep{color:var(--border-2)}
.nav-right{display:flex;align-items:center;gap:.4rem}
.nav-cta{font-family:'JetBrains Mono',monospace;font-size:.55rem;letter-spacing:.1em;text-transform:uppercase;color:var(--bg);background:var(--teal);padding:.28rem .75rem;border-radius:4px}
.nav-cta:hover{background:var(--teal-lt)}
.hero{padding:2.5rem 0 2rem;border-bottom:1px solid var(--border);position:relative;z-index:1}
.hero::before{content:'';position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,var(--purple),transparent)}
.hero-eyebrow{font-family:'JetBrains Mono',monospace;font-size:.52rem;letter-spacing:.2em;text-transform:uppercase;color:var(--purple);margin-bottom:.75rem;display:flex;align-items:center;gap:.6rem}
.hero-eyebrow::before{content:'';display:block;width:24px;height:1px;background:var(--purple)}
.hero h1{font-size:clamp(1.6rem,3vw,2.3rem);color:var(--white);margin-bottom:.6rem}
.hero-desc{font-size:.82rem;color:var(--body);max-width:720px;line-height:1.8;margin-bottom:1rem}
.disclaimer{background:var(--bg-3);border:1px solid var(--border);border-left:3px solid var(--purple);padding:.65rem 1rem;font-size:.72rem;color:var(--muted);line-height:1.6;margin-bottom:1rem}
.hero-badges{display:flex;gap:.5rem;flex-wrap:wrap}
.badge{font-family:'JetBrains Mono',monospace;font-size:.48rem;letter-spacing:.1em;text-transform:uppercase;padding:.22rem .6rem;border:1px solid;border-radius:3px}
.badge-purple{color:var(--purple);border-color:rgba(155,114,245,.3)}.badge-gold{color:var(--gold);border-color:rgba(212,168,71,.3)}.badge-green{color:var(--green);border-color:rgba(34,197,94,.3)}.badge-muted{color:var(--muted);border-color:var(--border)}
.tool-body{position:relative;z-index:1;padding:2rem 0 4rem}
.panel{background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.25rem;margin-bottom:1.5rem}
.panel-label{font-family:'JetBrains Mono',monospace;font-size:.56rem;letter-spacing:.14em;text-transform:uppercase;color:var(--purple);margin-bottom:.75rem;display:block}
.panel-row{display:flex;flex-direction:column;gap:.3rem;margin-bottom:.85rem}
.panel-row label{font-family:'JetBrains Mono',monospace;font-size:.5rem;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
.panel-row textarea,.panel-row input[type=text]{background:var(--bg-3);border:1px solid var(--border);color:var(--bright);font-family:'JetBrains Mono',monospace;font-size:.72rem;padding:.45rem .6rem;border-radius:4px;outline:none;width:100%}
.panel-row textarea:focus,.panel-row input:focus{border-color:var(--purple)}
.two-col{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
@media(max-width:760px){.two-col{grid-template-columns:1fr}}
.drop-zone{border:2px dashed var(--border);border-radius:var(--radius-lg);padding:1.5rem 1rem;text-align:center;font-family:'JetBrains Mono',monospace;font-size:.64rem;color:var(--muted);transition:border-color .2s;cursor:pointer;margin-bottom:.85rem}
.drop-zone.drag{border-color:var(--teal)}
.drop-zone strong{color:var(--text)}
.slot-label{font-family:'JetBrains Mono',monospace;font-size:.6rem;letter-spacing:.1em;text-transform:uppercase;margin-bottom:.6rem;display:flex;align-items:center;gap:.4rem}
.slot-a .slot-label{color:var(--teal-lt)}.slot-b .slot-label{color:var(--gold)}
.slot-tag{border:1px solid;border-radius:3px;padding:.1rem .4rem;font-size:.5rem}
.slot-a .slot-tag{border-color:rgba(20,184,166,.35);color:var(--teal-lt)}
.slot-b .slot-tag{border-color:rgba(212,168,71,.35);color:var(--gold)}
.run-btn{background:var(--purple);color:var(--bg);border:none;padding:.65rem 2rem;border-radius:var(--radius);font-family:'JetBrains Mono',monospace;font-size:.62rem;letter-spacing:.12em;text-transform:uppercase;font-weight:600;transition:background .2s}
.run-btn:hover{background:var(--purple-lt)}
.run-btn:disabled{opacity:.4;cursor:not-allowed}
.run-btn.ghost{background:var(--bg-3);color:var(--text);border:1px solid var(--border)}
.run-btn.ghost:hover{background:var(--bg-4);color:var(--bright)}
.output-section{margin-top:1.5rem;display:flex;flex-direction:column;gap:1rem}
.sec-card{background:var(--bg-2);border:1px solid var(--border);border-radius:var(--radius-lg);overflow:hidden}
.sec-head{padding:.75rem 1.25rem;border-bottom:1px solid var(--border);background:var(--bg-3);display:flex;align-items:center;justify-content:space-between;gap:.75rem;flex-wrap:wrap}
.sec-title{font-family:'JetBrains Mono',monospace;font-size:.6rem;letter-spacing:.1em;text-transform:uppercase;color:var(--purple)}
.sec-body{padding:1.1rem 1.25rem}
.verdict-chip{font-family:'JetBrains Mono',monospace;font-size:.6rem;letter-spacing:.08em;text-transform:uppercase;padding:.28rem .7rem;border-radius:20px;border:1px solid;font-weight:600}
.verdict-chip.pass{color:var(--green);border-color:rgba(34,197,94,.35);background:var(--green-dim)}
.verdict-chip.fail{color:var(--red);border-color:rgba(239,68,68,.35);background:var(--red-dim)}
.verdict-chip.absent{color:var(--muted);border-color:var(--border-2);background:var(--bg-4)}
.verdict-chip.partial{color:var(--warn);border-color:rgba(245,158,11,.35);background:rgba(245,158,11,.1)}
.detail-line{font-size:.74rem;color:var(--body);line-height:1.7;margin-bottom:.4rem}
.hashbox{font-family:'JetBrains Mono',monospace;font-size:.6rem;color:var(--teal-lt);word-break:break-all;background:var(--bg-3);border:1px solid var(--border);border-radius:4px;padding:.55rem .7rem;margin:.35rem 0}
.limit-note{font-size:.68rem;color:var(--muted);line-height:1.6;margin-top:.6rem;padding:.55rem .8rem;background:var(--bg-3);border-left:3px solid var(--warn);border-radius:4px}
.diff-table{width:100%;border-collapse:collapse;font-size:.64rem;margin-top:.5rem}
.diff-table th{font-family:'JetBrains Mono',monospace;font-size:.42rem;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);padding:.5rem .6rem;border-bottom:1px solid var(--border);text-align:left;background:var(--bg-3)}
.diff-table td{padding:.4rem .6rem;border-bottom:1px solid var(--border);font-family:'JetBrains Mono',monospace;word-break:break-all;vertical-align:top}
.diff-table td.path{color:var(--body);word-break:break-word}
.val-from{color:var(--red)}.val-to{color:var(--green)}
.tag-added{color:var(--green)}.tag-removed{color:var(--red)}.tag-changed{color:var(--warn)}
footer{border-top:1px solid var(--border);padding:1.75rem 1.5rem;margin-top:1.5rem}
.footer-inner-ai{display:flex;align-items:center;gap:2rem;flex-wrap:wrap;justify-content:space-between}
.footer-links-ai{display:flex;gap:1.25rem;font-family:'JetBrains Mono',monospace;font-size:.52rem;color:var(--muted)}
.footer-links-ai a{color:var(--muted)}
.footer-links-ai a:hover{color:var(--teal-lt)}
.footer-badge-ai{display:flex;flex-direction:column;gap:.3rem;font-family:'JetBrains Mono',monospace;font-size:.5rem;color:var(--muted)}
.footer-brand-link{display:flex;align-items:center;gap:.5rem;color:var(--text)}
.footer-wordmark{font-family:'JetBrains Mono',monospace;font-size:.9rem;font-weight:500}
@media(max-width:640px){.footer-inner-ai{flex-direction:column;text-align:center}.footer-badge-ai{align-items:center}}
.pii-notice{font-family:'JetBrains Mono',monospace;font-size:.62rem;color:var(--muted);background:var(--bg-3);border:1px solid var(--border);border-left:3px solid var(--teal);border-radius:4px;padding:.5rem .85rem;line-height:1.5;margin-bottom:1rem}
@media print{
nav,.drop-zone,.run-btn,footer,.pii-notice,.disclaimer,.hero-badges{display:none!important}
body{background:#fff;color:#111}
.sec-card,.hashbox,.panel{border-color:#ccc;background:#fff}
.sec-head{background:#f4f4f4}
.verdict-chip.pass{color:#0a0;border-color:#0a0}
.verdict-chip.fail{color:#a00;border-color:#a00}
.verdict-chip.absent{color:#777;border-color:#aaa}
}
</style>
</head>
<body>
<nav><div class="nav-inner">
<a href="index.html" class="logo">
<svg width="28" height="28" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" rx="9" fill="var(--bg-2)"/><rect x="1" y="1" width="46" height="46" rx="8" fill="none" stroke="var(--border)" stroke-width="1"/><rect x="9" y="9" width="8" height="8" rx="1.5" fill="var(--teal)" opacity="1"/><rect x="20" y="9" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".45"/><rect x="31" y="9" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".15"/><rect x="9" y="20" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".6"/><rect x="20" y="20" width="8" height="8" rx="1.5" fill="var(--gold)" opacity=".9"/><rect x="31" y="20" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".3"/><rect x="9" y="31" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".2"/><rect x="20" y="31" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".35"/><rect x="31" y="31" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".7"/></svg>
<div class="logo-text"><div class="logo-name"><span class="logo-ai">AI</span>Numbers<span class="logo-co">.co</span></div></div>
</a>
<div class="nav-bc"><a href="start.html">Start</a><span class="nav-sep">/</span><span>Bundle Diff</span></div>
<div class="nav-right"><a href="verification-desk.html" class="nav-cta">Verification Desk →</a></div>
</div></nav>
<div class="hero"><div class="container">
<div class="hero-eyebrow">Examiner Infrastructure</div>
<h1>Bundle Diff</h1>
<p class="hero-desc">Load two OpenChainGraph artifacts, chains, or §27.6 evidence bundles — before/after, quarter-over-quarter, or two exam cycles apart — and get an OCG-semantic diff, not a generic JSON diff. Every field differs between two artifacts by construction (timestamps, generated hashes); the question that matters is narrower: which input hashes moved, which kernel or policy versions changed, which §27 approvals, roles, or thresholds differ, and whether the verdict changed. Legacy and §27.6 approval-record shapes are both understood, so a shape change alone never reads as a substantive one.</p>
<div class="disclaimer">⚠ This report only reflects the two files you loaded. It does not fetch, verify authenticity of, or attest to either bundle — pair it with the Verification Desk to check each side individually first.</div>
<div class="hero-badges">
<span class="badge badge-purple">Client-Side</span>
<span class="badge badge-gold">Zero PII</span>
<span class="badge badge-green">OCG-Semantic, Not Generic Diff</span>
<span class="badge badge-muted">Print-Ready Report</span>
</div>
</div></div>
<div class="tool-body"><div class="container">
<div class="pii-notice">🔒 All inputs are processed locally in your browser. No data is transmitted. Do not enter real personal data — use synthetic or anonymised inputs only.</div>
<div id="handoffNotice" style="display:none;font-family:'JetBrains Mono',monospace;font-size:.62rem;color:var(--muted);background:var(--bg-3);border:1px solid var(--border);border-left:3px solid var(--teal);border-radius:4px;padding:.5rem .85rem;line-height:1.5;margin-bottom:1rem"></div>
<div class="panel">
<span class="panel-label">Two Bundles To Compare</span>
<div class="two-col">
<div class="slot-a">
<div class="slot-label">Bundle A <span class="slot-tag">before</span></div>
<div class="drop-zone" id="dropA">Drag one JSON file here, or click to choose</div>
<input type="file" id="fileAInput" accept=".json,application/json" style="display:none">
<div class="panel-row"><label for="pasteA">…or paste JSON directly</label><textarea id="pasteA" rows="6" placeholder="Paste an OCG artifact, chain, or §27.6 evidence bundle"></textarea></div>
</div>
<div class="slot-b">
<div class="slot-label">Bundle B <span class="slot-tag">after</span></div>
<div class="drop-zone" id="dropB">Drag one JSON file here, or click to choose</div>
<input type="file" id="fileBInput" accept=".json,application/json" style="display:none">
<div class="panel-row"><label for="pasteB">…or paste JSON directly</label><textarea id="pasteB" rows="6" placeholder="Paste an OCG artifact, chain, or §27.6 evidence bundle"></textarea></div>
</div>
</div>
<div style="display:flex;gap:.75rem;align-items:center;flex-wrap:wrap;margin-top:.5rem">
<button class="run-btn" onclick="runDiffFromPaste()">▶ Run Bundle Diff</button>
<button class="run-btn ghost" onclick="window.print()" id="printBtn" style="display:none">🖨 Print Report</button>
<button class="run-btn ghost" id="sendWpiBtn" onclick="sendLoadedToWorkpaperIndex()" title="Open the Workpaper Index and hand it whichever bundle(s) are loaded above — same-origin message, no file, no network">➡ Send loaded bundle(s) to Workpaper Index</button>
<span id="diffStatus" style="font-family:'JetBrains Mono',monospace;font-size:.62rem;color:var(--muted)"></span>
</div>
</div>
<div class="output-section" id="outputSection"></div>
</div></div>
<footer><div class="container">
<div class="footer-inner-ai">
<a href="index.html" class="footer-brand-link">
<svg width="22" height="22" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" style="flex-shrink:0"><rect width="48" height="48" rx="9" fill="var(--bg-2)"/><rect x="1" y="1" width="46" height="46" rx="8" fill="none" stroke="var(--border)" stroke-width="1"/><rect x="9" y="9" width="8" height="8" rx="1.5" fill="var(--teal)" opacity="1"/><rect x="20" y="9" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".45"/><rect x="31" y="9" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".15"/><rect x="9" y="20" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".6"/><rect x="20" y="20" width="8" height="8" rx="1.5" fill="var(--gold)" opacity=".9"/><rect x="31" y="20" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".3"/><rect x="9" y="31" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".2"/><rect x="20" y="31" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".35"/><rect x="31" y="31" width="8" height="8" rx="1.5" fill="var(--teal)" opacity=".7"/></svg><span class="footer-wordmark"><span style="color:var(--teal)">AI</span>Numbers<span style="color:var(--muted);font-size:.8em">.co</span></span>
</a>
<div class="footer-links-ai">
<a href="tools.html">All Tools</a>
<a href="verification-desk.html">Verification Desk</a>
<a href="chaingraph/verify.html">Verify (hash / §16 / §27)</a>
<a href="sitemap.html">Sitemap</a>
<a href="contact.html">Contact</a>
</div>
<div class="footer-badge-ai">
<span>CC BY 4.0 · Post Oak Labs</span>
<span>🔒 Zero PII 📡 No server calls 💻 Client-side</span>
</div>
</div>
</div>
</footer>
<script>
/* OCG-CANON v1 — RFC 8785/JCS (I-JSON). DO NOT hand-edit. Byte-identical to chaingraph/kernels/_hash.mjs and verification-desk.html. */
function __ocgCanon(v){return Array.isArray(v)?v.map(__ocgCanon):(v&&typeof v==='object')?Object.keys(v).sort().reduce((o,k)=>(o[k]=__ocgCanon(v[k]),o),{}):v;}
async function __ocgSha256Hex(bytesOrStr){var b=typeof bytesOrStr==='string'?new TextEncoder().encode(bytesOrStr):bytesOrStr;var d=await crypto.subtle.digest('SHA-256',b);return Array.from(new Uint8Array(d)).map(function(x){return x.toString(16).padStart(2,'0');}).join('');}
async function executionHash(policy_parameters,output_payload){return __ocgSha256Hex(new TextEncoder().encode(JSON.stringify(__ocgCanon({policy_parameters:policy_parameters,output_payload:output_payload}))));}
</script>
<script>
/* §27 HUMAN ACCOUNTABILITY — gate-precondition evaluator, byte-identical to chaingraph/verify.html / verification-desk.html (ported inline; SSOT chaingraph/kernels/_hagate.mjs). DO NOT hand-edit. Reused here only to detect conformant-signature status on legacy records; the diff logic below is new (SI-5), not a reimplementation of this block. */
function __haIsConformant(record){var proof=record&&record.audit_signature&&record.audit_signature.proof;if(!proof)return false;var vm=proof.verificationMethod||'';return proof.cryptosuite==='eddsa-jcs-2022'&&typeof vm==='string'&&vm.indexOf((record.identity&&record.identity.id)||' ')===0;}
function __haOverrideActive(record,nowISO){if(!record||record.record_type!=='override'||!record.override||!record.override.expiry)return false;return Date.parse(nowISO)<Date.parse(record.override.expiry);}
</script>
<script>
/* ════════════════════════════════════════════════════════════════════
SI-5 — BUNDLE DIFF: OCG-SEMANTIC STRUCTURAL WALK (new code)
Engine choice: HAND-ROLLED, not jsondiffpatch (see START-INFRA-BUILD-SPEC.md
§5 kill-criteria language and PR body for the full reasoning). The row's
own value proposition is the four-category OCG-aware presentation, not a
generic tree diff — a vendored engine would still need this exact amount
of OCG-specific extraction/classification code layered on top of it, so
vendoring buys nothing but a bundle-weight cost and a new dependency to
keep zero-dep-clean. Reuses SI-1's canon/hash/§27-conformance primitives
above rather than reimplementing them.
════════════════════════════════════════════════════════════════════ */
function escHtml(s){return String(s).replace(/[&<>"']/g,function(c){return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c];});}
function chip(status){ // 'pass'(unchanged)|'partial'(changed)|'fail'(verdict regressed)|'absent'(neither side has this layer)
var labels={pass:'✓ UNCHANGED',fail:'⚠ CHANGED',absent:'— NOT PRESENT',partial:'⚠ CHANGED'};
return '<span class="verdict-chip '+status+'">'+labels[status]+'</span>';
}
function card(title,status,bodyHtml){
return '<div class="sec-card"><div class="sec-head"><span class="sec-title">'+escHtml(title)+'</span>'+chip(status)+'</div><div class="sec-body">'+bodyHtml+'</div></div>';
}
function diffTable(rows){ // rows: [{path,kind,from,to}] kind: 'added'|'removed'|'changed'
if(!rows.length)return '';
var body=rows.map(function(r){
var tag=r.kind==='added'?'<span class="tag-added">+ added</span>':r.kind==='removed'?'<span class="tag-removed">− removed</span>':'<span class="tag-changed">~ changed</span>';
var fromCell=r.kind==='added'?'<span style="color:var(--muted)">—</span>':'<span class="val-from">'+escHtml(String(r.from))+'</span>';
var toCell=r.kind==='removed'?'<span style="color:var(--muted)">—</span>':'<span class="val-to">'+escHtml(String(r.to))+'</span>';
return '<tr><td class="path">'+escHtml(r.path)+'</td><td>'+tag+'</td><td>'+fromCell+'</td><td>'+toCell+'</td></tr>';
}).join('');
return '<table class="diff-table"><thead><tr><th>Path</th><th>Change</th><th>Bundle A</th><th>Bundle B</th></tr></thead><tbody>'+body+'</tbody></table>';
}
// ── generic path-keyed field walk (used for hash + version extraction) ──
var __BI_MAX_DEPTH=200; // named cap — a hostile bundle from the counterparty must not crash the tab (SECFIX-STARTINFRA-1 item 4)
function __biWalk(obj,matcher,prefix,out,depth){
depth=depth||0;
if(depth>__BI_MAX_DEPTH) throw new Error('Bundle nesting exceeds '+__BI_MAX_DEPTH+' levels at "'+prefix+'" — refusing to walk further.');
if(obj===null||obj===undefined)return;
if(Array.isArray(obj)){ obj.forEach(function(v,i){ __biWalk(v,matcher,prefix+'['+i+']',out,depth+1); }); return; }
if(typeof obj!=='object')return;
Object.keys(obj).forEach(function(k){
var v=obj[k];
var path=prefix?prefix+'.'+k:k;
if(matcher(k)&&(typeof v==='string'||typeof v==='number')&&String(v).length){ out[path]=String(v); }
if(v&&typeof v==='object'){ __biWalk(v,matcher,path,out,depth+1); }
});
}
function __biExtractHashes(root){ var out={}; __biWalk(root,function(k){ return /(_hash|_digest)$/i.test(k)||/^(hash|digest)$/i.test(k); },'',out); return out; }
function __biExtractVersions(root){ var out={}; __biWalk(root,function(k){ return /(^|_)version$/i.test(k); },'',out); return out; }
function __biExtractThresholds(root){ var out={}; __biWalk(root,function(k){ return /(threshold|gate_policy|policy_applied)/i.test(k); },'',out); return out; }
function __biDiffMaps(a,b){
var rows=[]; var keys=new Set(Object.keys(a).concat(Object.keys(b)));
Array.from(keys).sort().forEach(function(k){
var inA=k in a, inB=k in b;
if(inA&&inB){ if(a[k]!==b[k]) rows.push({path:k,kind:'changed',from:a[k],to:b[k]}); }
else if(inA) rows.push({path:k,kind:'removed',from:a[k],to:null});
else rows.push({path:k,kind:'added',from:null,to:b[k]});
});
return rows;
}
// ── input-classification (same heuristic as verification-desk.html's runReport, reused so a bundle-diff never disagrees with the desk about what it's looking at) ──
function __biClassify(parsed){
if(Array.isArray(parsed)&&parsed.length){
if(parsed[0]&&parsed[0].record_type) return 'records';
if(parsed[0]&&parsed[0].tool_id&&('execution_hash'in parsed[0])) return 'chain';
return 'unknown';
}
if(parsed&&typeof parsed==='object'){
if(parsed.steps&&Array.isArray(parsed.steps)) return 'chain';
if(parsed.subject_hash&&!parsed.execution_hash&&(parsed.reviewers||parsed.approvers||parsed.annotations||parsed.timestamps)) return 'bundle276';
if('execution_hash'in parsed) return 'artifact';
}
return 'unknown';
}
// ── §27 canonicalization: legacy record array, embedded sign_off, and §27.6
// bundle shape all normalize to the SAME {approvals,rejections,overrides,roles}
// triple set, so a shape change alone (HA-CONV-1's legacy → §27.6 migration)
// never surfaces as a diff row — only substantive accountability changes do.
// Bucketing (role==='reviewer' -> "reviewer", every other role -> "approver")
// mirrors chaingraph/kernels/_haevidence.mjs's own assembleEvidenceBundle split
// exactly, so a legacy "engagement_reviewer" approval and its post-convergence
// §27.6 approvers[] entry land on the SAME comparison key. ──
function __biHaBucket(role){ return role==='reviewer' ? 'reviewer' : 'approver'; }
function __biHaCanon(parsed){
var kind=__biClassify(parsed);
var approvals=[],rejections=[],overrides=[],thresholdHints={};
var subjectHash=null, shape='none';
if(kind==='bundle276'){
shape='27.6-bundle';
subjectHash=parsed.subject_hash||null;
(parsed.approvers||[]).forEach(function(id){ approvals.push('approver::'+id); });
(parsed.reviewers||[]).forEach(function(id){ approvals.push('reviewer::'+id); });
if(parsed.exception_rationale) overrides.push('exception::'+parsed.exception_rationale);
} else {
var records = kind==='records' ? parsed
: (parsed && (parsed.human_accountability_records||parsed.records)) || null;
if(records&&records.length){
shape='records-array';
var now=new Date().toISOString();
records.forEach(function(r){
var id=(r.identity&&r.identity.id)||'(unsigned)';
var tag=__biHaBucket(r.role)+'::'+id;
if(r.record_type==='approval') approvals.push(tag);
else if(r.record_type==='rejection') rejections.push(tag);
else if(r.record_type==='override') overrides.push(tag+(__haOverrideActive(r,now)?'(active)':'(expired)'));
if(r.subject_hash) subjectHash=subjectHash||r.subject_hash;
});
} else if(parsed && parsed.output_payload){
// legacy pre-§27.6 ad-hoc sign_off, exactly the shape HA-CONV-1 remaps.
var op=parsed.output_payload;
if(op.sign_off && op.sign_off.reviewer_statement){
shape='legacy-sign_off';
approvals.push(__biHaBucket(op.sign_off.reviewer_role)+'::(legacy sign_off, no signer identity)');
}
if(op.ha_record){
shape='ha_record';
var hr=op.ha_record;
var id2=(hr.identity&&hr.identity.id)||'(unsigned)';
approvals.push(__biHaBucket(hr.role)+'::'+id2);
}
}
}
var thresholds = (parsed&&parsed.policy_parameters) ? __biExtractThresholds(parsed.policy_parameters) : {};
return {shape:shape,subjectHash:subjectHash,approvals:approvals.sort(),rejections:rejections.sort(),overrides:overrides.sort(),thresholds:thresholds};
}
function __biDiffSets(a,b){
var A=new Set(a),B=new Set(b);
var added=b.filter(function(x){return !A.has(x);});
var removed=a.filter(function(x){return !B.has(x);});
return {added:added,removed:removed};
}
// ── verdict extraction: §27.6 verification_result first (NORMATIVE field name,
// SPEC.md §27.6 — "the §16/§18/§20 verdict"), then other explicit fields,
// else derived from a checks[] array ──
var VERDICT_KEYS=['verdict','decision','status','outcome','result'];
function __biExtractVerdict(parsed){
if(!parsed||typeof parsed!=='object')return {value:null,source:null};
if('verification_result' in parsed && parsed.verification_result!==null && parsed.verification_result!==undefined){
var vr=parsed.verification_result;
return {value:(typeof vr==='string')?vr:JSON.stringify(vr),source:'verification_result'};
}
var op=parsed.output_payload||parsed;
for(var i=0;i<VERDICT_KEYS.length;i++){
var k=VERDICT_KEYS[i];
if(op&&typeof op[k]==='string') return {value:op[k],source:'output_payload.'+k};
if(parsed[k]&&typeof parsed[k]==='string') return {value:parsed[k],source:k};
}
if(op&&Array.isArray(op.checks)&&op.checks.length){
var allPass=op.checks.every(function(c){return c&&c.pass===true;});
return {value:allPass?'PASS (all checks)':'FAIL ('+op.checks.filter(function(c){return c&&c.pass!==true;}).length+' check(s) failed)',source:'derived from output_payload.checks[]'};
}
return {value:null,source:null};
}
// ── report sections ──────────────────────────────────────────────────
function sectionHashes(a,b){
var ha=__biExtractHashes(a), hb=__biExtractHashes(b);
var rows=__biDiffMaps(ha,hb);
if(!Object.keys(ha).length && !Object.keys(hb).length){
return card('1. Input Hashes','absent','<div class="detail-line">Neither bundle carries any field ending in <code>_hash</code>/<code>_digest</code> (or named exactly <code>hash</code>/<code>digest</code>).</div>');
}
if(!rows.length){
return card('1. Input Hashes','pass','<div class="detail-line">All '+Object.keys(ha).length+' hash/digest field(s) are byte-identical between A and B.</div>');
}
return card('1. Input Hashes ('+rows.length+' moved)','partial','<div class="detail-line">Hash- and digest-bearing fields (execution_hash, subject_hash, receipt hashes, kernel digests, chained workpaper hashes…) that differ between the two bundles:</div>'+diffTable(rows));
}
function sectionVersions(a,b){
var va=__biExtractVersions(a), vb=__biExtractVersions(b);
var rows=__biDiffMaps(va,vb);
if(!Object.keys(va).length && !Object.keys(vb).length){
return card('2. Kernel / Policy Versions','absent','<div class="detail-line">Neither bundle carries a field ending in <code>_version</code> (e.g. <code>chaingraph_version</code>, <code>tool_version</code>, <code>receipt_tool_version</code>).</div>');
}
if(!rows.length){
return card('2. Kernel / Policy Versions','pass','<div class="detail-line">All '+Object.keys(va).length+' version field(s) match between A and B.</div>');
}
return card('2. Kernel / Policy Versions ('+rows.length+' changed)','partial','<div class="detail-line">Version-bearing fields that moved — a kernel or policy revision landed between the two bundles:</div>'+diffTable(rows));
}
function sectionHa(a,b){
var ca=__biHaCanon(a), cb=__biHaCanon(b);
if(ca.shape==='none' && cb.shape==='none'){
return card('3. §27 Approvals / Roles / Thresholds','absent','<div class="detail-line">Neither bundle carries §27 accountability records, a legacy sign_off, or a §27.6 evidence bundle. Fully conformant — §27 is optional.</div>');
}
var appr=__biDiffSets(ca.approvals,cb.approvals);
var rej=__biDiffSets(ca.rejections,cb.rejections);
var ovr=__biDiffSets(ca.overrides,cb.overrides);
var thrRows=__biDiffMaps(ca.thresholds,cb.thresholds);
var changed = appr.added.length||appr.removed.length||rej.added.length||rej.removed.length||ovr.added.length||ovr.removed.length||thrRows.length;
var shapeNote = ca.shape!==cb.shape
? '<div class="limit-note">Record shape differs (A: '+escHtml(ca.shape)+', B: '+escHtml(cb.shape)+') — e.g. one side pre-dates the §27.6 convergence (HA-CONV-1) and the other post-dates it. That shape difference alone is <strong>not</strong> reported as a change below; only the normalized role+identity approval/rejection/override sets are compared.</div>'
: '';
var rows=[];
appr.removed.forEach(function(x){rows.push({path:'approval: '+x,kind:'removed',from:'present',to:null});});
appr.added.forEach(function(x){rows.push({path:'approval: '+x,kind:'added',from:null,to:'present'});});
rej.removed.forEach(function(x){rows.push({path:'rejection: '+x,kind:'removed',from:'present',to:null});});
rej.added.forEach(function(x){rows.push({path:'rejection: '+x,kind:'added',from:null,to:'present'});});
ovr.removed.forEach(function(x){rows.push({path:'override: '+x,kind:'removed',from:'present',to:null});});
ovr.added.forEach(function(x){rows.push({path:'override: '+x,kind:'added',from:null,to:'present'});});
thrRows.forEach(function(r){rows.push({path:'threshold field: '+r.path,kind:r.kind,from:r.from,to:r.to});});
var body=shapeNote
+'<div class="detail-line">A: '+ca.approvals.length+' approval(s), '+ca.rejections.length+' rejection(s), '+ca.overrides.length+' override(s) — shape: '+escHtml(ca.shape)+'</div>'
+'<div class="detail-line">B: '+cb.approvals.length+' approval(s), '+cb.rejections.length+' rejection(s), '+cb.overrides.length+' override(s) — shape: '+escHtml(cb.shape)+'</div>'
+(rows.length?diffTable(rows):'<div class="detail-line">Normalized approval/rejection/override sets are identical.</div>');
return card('3. §27 Approvals / Roles / Thresholds'+(changed?' ('+rows.length+' changed)':''),changed?'partial':'pass',body);
}
function sectionVerdict(a,b){
var va=__biExtractVerdict(a), vb=__biExtractVerdict(b);
if(va.value===null && vb.value===null){
return card('4. Verdict','absent','<div class="detail-line">Neither bundle carries an explicit verdict/decision/status/outcome/result field, nor a checks[] array to derive one from.</div>');
}
if(va.value===vb.value){
return card('4. Verdict','pass','<div class="detail-line">Unchanged: <strong>'+escHtml(va.value||'(absent)')+'</strong> ('+escHtml(va.source||vb.source||'—')+')</div>');
}
var regressed = /fail|reject|hold/i.test(String(vb.value)) && !/fail|reject|hold/i.test(String(va.value));
return card('4. Verdict — CHANGED',regressed?'fail':'partial',
'<div class="detail-line">A: <strong>'+escHtml(va.value===null?'(absent)':va.value)+'</strong> ('+escHtml(va.source||'—')+')</div>'
+'<div class="detail-line">B: <strong>'+escHtml(vb.value===null?'(absent)':vb.value)+'</strong> ('+escHtml(vb.source||'—')+')</div>'
+(regressed?'<div class="limit-note">The verdict moved toward fail/reject/hold between A and B.</div>':''));
}
async function runDiff(a,b){
var out=document.getElementById('outputSection');
out.innerHTML='<div class="detail-line" style="color:var(--muted)">Comparing…</div>';
document.getElementById('printBtn').style.display='none';
var kindA=__biClassify(a), kindB=__biClassify(b);
if(kindA==='unknown'||kindB==='unknown'){
out.innerHTML='<div class="sec-card"><div class="sec-body"><div class="detail-line">One or both inputs do not look like an OCG artifact (has <code>execution_hash</code>), a chain (array of step artifacts, or <code>{steps:[...]}</code>), a §27.6 evidence bundle (has <code>subject_hash</code>, no <code>execution_hash</code>), or a §27 records array. Check the input.</div></div></div>';
return;
}
var meta='<div class="detail-line" style="color:var(--muted)">Bundle A classified as: <strong>'+escHtml(kindA)+'</strong> · Bundle B classified as: <strong>'+escHtml(kindB)+'</strong>'+(kindA!==kindB?' — different input kinds; the four sections below still compare whatever each side actually carries.':'')+'</div>';
var sections;
try{ sections=[sectionHashes(a,b),sectionVersions(a,b),sectionHa(a,b),sectionVerdict(a,b)]; }
catch(e){ out.innerHTML='<div class="sec-card"><div class="sec-body"><div class="detail-line" style="color:var(--red)">Could not compare: '+escHtml(e.message)+'</div></div></div>'; return; }
out.innerHTML=meta+sections.join('');
document.getElementById('printBtn').style.display='inline-block';
}
function runDiffFromPaste(){
var rawA=document.getElementById('pasteA').value.trim();
var rawB=document.getElementById('pasteB').value.trim();
var statusEl=document.getElementById('diffStatus');
if(!rawA||!rawB){ statusEl.textContent='Load both Bundle A and Bundle B first.'; return; }
var a,b;
try{ a=JSON.parse(rawA); }catch(e){ statusEl.textContent='Bundle A is not valid JSON: '+e.message; return; }
try{ b=JSON.parse(rawB); }catch(e){ statusEl.textContent='Bundle B is not valid JSON: '+e.message; return; }
statusEl.textContent='';
runDiff(a,b);
}
// ── drag/drop + file picking wiring (same pattern as verification-desk.html) ──
function wireDropZone(zoneId,inputId,onFile){
var zone=document.getElementById(zoneId), input=document.getElementById(inputId);
zone.addEventListener('click',function(){input.click();});
input.addEventListener('change',function(){ if(input.files[0]) onFile(input.files[0]); });
zone.addEventListener('dragover',function(e){e.preventDefault();zone.classList.add('drag');});
zone.addEventListener('dragleave',function(){zone.classList.remove('drag');});
zone.addEventListener('drop',function(e){ e.preventDefault(); zone.classList.remove('drag'); if(e.dataTransfer.files[0]) onFile(e.dataTransfer.files[0]); });
}
document.addEventListener('DOMContentLoaded',function(){
wireDropZone('dropA','fileAInput',function(f){
var reader=new FileReader();
reader.onload=function(){ document.getElementById('pasteA').value=reader.result; };
reader.readAsText(f);
});
wireDropZone('dropB','fileBInput',function(f){
var reader=new FileReader();
reader.onload=function(){ document.getElementById('pasteB').value=reader.result; };
reader.readAsText(f);
});
});
/* ─────────────────────────────────────────────────────────────────
§1.5 HOP B RECEIVER — Verify -> Bundle Diff. Same discipline as the hop A
receiver on chaingraph/verify.html: origin checked both ends, discarded
silently otherwise; payload is the artifact JSON + a declared kind + a
routing "slot" (a|b), nothing else; assigned via .value, never innerHTML;
size-capped with a visible reject. Zero network, zero storage.
───────────────────────────────────────────────────────────────── */
var HANDOFF_MAX_CHARS=2000000;
function handoffNotice(msg,ok){
var el=document.getElementById('handoffNotice');
if(!el)return;
if(!msg){ el.style.display='none'; return; }
el.textContent=msg; // never innerHTML
el.style.borderLeftColor= ok ? 'var(--teal)' : 'var(--red)';
el.style.display='block';
}
window.addEventListener('message',function(ev){
if(ev.origin!==window.location.origin)return; // §1.3 — discard silently
var d=ev.data;
if(!d||typeof d!=='object')return;
if(d.type!=='ain-handoff/v1')return;
if(d.kind!=='ocg-artifact')return;
var text=d.artifact;
if(typeof text!=='string'||!text)return;
if(text.length>HANDOFF_MAX_CHARS){ // §1.4 — visible reject, never hang
handoffNotice('Handoff rejected: the artifact is '+text.length+' characters, over the '+HANDOFF_MAX_CHARS+'-character limit. Paste it below instead.',false);
return;
}
var slot = d.slot==='b' ? 'b' : 'a';
document.getElementById(slot==='b' ? 'pasteB' : 'pasteA').value=text; // never innerHTML
handoffNotice('Bundle '+slot.toUpperCase()+' received from the sending page. Nothing was uploaded and nothing was stored.',true);
});
if(window.opener){
try{ window.opener.postMessage({type:'ain-handoff-ready/v1',accepts:['ocg-artifact']},window.location.origin); }
catch(e){ /* no opener we may talk to — paste intake still works */ }
}
/* ─────────────────────────────────────────────────────────────────
§1.5 HOP C SENDER — Bundle Diff -> Workpaper Index. Whichever of the two
loaded bundles is present gets sent as its own handoff message into a
NAMED target window, so a second send (e.g. after loading a new pair)
reuses the same Workpaper Index tab instead of spawning another —
the mechanic that lets N sends accumulate in one index (§1.5 hop C).
───────────────────────────────────────────────────────────────── */
function sendLoadedToWorkpaperIndex(){
var rawA=document.getElementById('pasteA').value.trim();
var rawB=document.getElementById('pasteB').value.trim();
if(!rawA&&!rawB){ handoffNotice('Load Bundle A and/or B above first.',false); return; }
if((rawA&&rawA.length>HANDOFF_MAX_CHARS)||(rawB&&rawB.length>HANDOFF_MAX_CHARS)){
handoffNotice('One of the bundles is over the '+HANDOFF_MAX_CHARS+'-character handoff limit. Use the Workpaper Index page directly and drop the file there instead.',false);
return;
}
var target=new URL('workpaper-index.html',window.location.href).href;
var win=window.open(target,'ainWorkpaperIndexTab');
if(!win){ handoffNotice('The Workpaper Index window was blocked. Allow pop-ups for this site.',false); return; }
var toSend=[rawA,rawB].filter(Boolean);
var sentCount=0, ready=false, timer=null;
function sendNext(){
while(sentCount<toSend.length){
win.postMessage({type:'ain-handoff/v1',kind:'ocg-artifact',artifact:toSend[sentCount]},window.location.origin);
sentCount++;
}
}
function onReady(ev){
if(ev.origin!==window.location.origin)return; /* §1.3 discard silently */
if(ev.source!==win)return;
var d=ev.data;
if(!d||typeof d!=='object'||d.type!=='ain-handoff-ready/v1')return;
ready=true;
window.removeEventListener('message',onReady);
if(timer)clearTimeout(timer);
sendNext();
handoffNotice('Sent '+toSend.length+' bundle(s) to the Workpaper Index.',true);
}
window.addEventListener('message',onReady);
handoffNotice('Opening the Workpaper Index…',true);
timer=setTimeout(function(){
if(ready)return;
window.removeEventListener('message',onReady);
handoffNotice('The Workpaper Index did not answer. Open it directly and drop the file(s) in.',false);
},10000);
}
</script>
</body>
</html>