protocolith 0.6.0__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 (57) hide show
  1. protocolith/__init__.py +38 -0
  2. protocolith/baseline_groups.py +294 -0
  3. protocolith/baselines.py +288 -0
  4. protocolith/card_svg_render.py +281 -0
  5. protocolith/card_svg_styles.py +178 -0
  6. protocolith/cli.py +796 -0
  7. protocolith/core/__init__.py +63 -0
  8. protocolith/core/_lock_posix.py +29 -0
  9. protocolith/core/_lock_windows.py +29 -0
  10. protocolith/core/atlas.py +406 -0
  11. protocolith/core/atlas_assets/atlas.css +86 -0
  12. protocolith/core/atlas_assets/atlas.html +84 -0
  13. protocolith/core/atlas_assets/atlas.js +370 -0
  14. protocolith/core/atlas_i18n/en.json +61 -0
  15. protocolith/core/canonical.py +124 -0
  16. protocolith/core/capture.py +68 -0
  17. protocolith/core/clock.py +25 -0
  18. protocolith/core/commands.py +356 -0
  19. protocolith/core/errors.py +116 -0
  20. protocolith/core/issue.py +98 -0
  21. protocolith/core/ledger.py +75 -0
  22. protocolith/core/mcp.py +371 -0
  23. protocolith/core/ops.py +183 -0
  24. protocolith/core/rules.py +352 -0
  25. protocolith/core/schema.py +137 -0
  26. protocolith/core/store.py +101 -0
  27. protocolith/core/views.py +136 -0
  28. protocolith/doctor.py +135 -0
  29. protocolith/evidence_card.py +354 -0
  30. protocolith/family_ledger.py +489 -0
  31. protocolith/generic_ohlcv_batch_pre_registration_meta.py +123 -0
  32. protocolith/inspect.py +48 -0
  33. protocolith/nasa_power.py +266 -0
  34. protocolith/nasa_power_fetch.py +64 -0
  35. protocolith/nasa_power_parser.py +133 -0
  36. protocolith/nasa_power_prereg_runner.py +383 -0
  37. protocolith/noaa_coops_fetch.py +188 -0
  38. protocolith/noaa_coops_parser.py +120 -0
  39. protocolith/noaa_coops_prereg_runner.py +341 -0
  40. protocolith/public_ai_protocol.py +176 -0
  41. protocolith/py.typed +0 -0
  42. protocolith/registry.py +139 -0
  43. protocolith/registry_view.py +302 -0
  44. protocolith/rerun_report.py +111 -0
  45. protocolith/run_root.py +243 -0
  46. protocolith/scaffold.py +565 -0
  47. protocolith/source_probe.py +230 -0
  48. protocolith/svg_a11y.py +100 -0
  49. protocolith/tree_overlay.py +343 -0
  50. protocolith/verify_packs.py +251 -0
  51. protocolith/workflows.py +233 -0
  52. protocolith-0.6.0.dist-info/METADATA +283 -0
  53. protocolith-0.6.0.dist-info/RECORD +57 -0
  54. protocolith-0.6.0.dist-info/WHEEL +4 -0
  55. protocolith-0.6.0.dist-info/entry_points.txt +3 -0
  56. protocolith-0.6.0.dist-info/licenses/LICENSE +201 -0
  57. protocolith-0.6.0.dist-info/licenses/NOTICE +13 -0
@@ -0,0 +1,84 @@
1
+ <!doctype html>
2
+ <html lang="{{LANG}}">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <meta name="color-scheme" content="light dark">
7
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data:">
8
+ <title>{{TITLE}}</title>
9
+ <style>
10
+ {{CSS}}
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <a class="skip" href="#table-wrap" data-i18n="skip_link"></a>
15
+ <header class="top">
16
+ <h1 id="atlas-title"></h1>
17
+ <div class="tools">
18
+ <label id="lang-wrap" class="lang" hidden><span data-i18n="lang_label"></span>
19
+ <select id="lang"></select></label>
20
+ <button type="button" id="theme" data-i18n-attr="aria-label:theme_toggle,title:theme_toggle">&#9680;</button>
21
+ </div>
22
+ </header>
23
+ <noscript><p class="banner bad">{{T:noscript}}</p></noscript>
24
+ <p id="fatal" class="banner bad" role="alert" hidden>{{T:load_error}}</p>
25
+ <main id="app" hidden>
26
+ <section id="integrity" aria-live="polite"></section>
27
+ <section id="tiles" class="tiles" aria-label="summary" data-i18n-attr="aria-label:tiles_label"></section>
28
+ <section class="charts">
29
+ <figure><figcaption data-i18n="chart_status"></figcaption><div id="chart-status" class="bars"></div></figure>
30
+ <figure><figcaption data-i18n="chart_timeline"></figcaption><div id="chart-time"></div></figure>
31
+ </section>
32
+ <section class="filters" role="search">
33
+ <label class="grow"><span data-i18n="search_label"></span>
34
+ <input id="q" type="search" autocomplete="off" data-i18n-attr="placeholder:search_placeholder"></label>
35
+ <label><span data-i18n="filter_status"></span><select id="f-status"></select></label>
36
+ <label><span data-i18n="filter_domain"></span><select id="f-domain"></select></label>
37
+ <label><span data-i18n="filter_level"></span><select id="f-level"></select></label>
38
+ <label><span data-i18n="filter_from"></span><input id="f-from" type="date"></label>
39
+ <label><span data-i18n="filter_to"></span><input id="f-to" type="date"></label>
40
+ <button type="button" id="reset" data-i18n="filter_reset"></button>
41
+ </section>
42
+ <p id="count" class="muted" role="status"></p>
43
+ <div id="table-wrap" class="wrap" tabindex="-1">
44
+ <table id="table">
45
+ <caption class="sr" data-i18n="table_caption"></caption>
46
+ <thead><tr id="head"></tr></thead>
47
+ <tbody id="body"></tbody>
48
+ </table>
49
+ <p id="empty" class="muted" hidden data-i18n="no_results"></p>
50
+ </div>
51
+ <nav class="pager" aria-label="pagination" data-i18n-attr="aria-label:pager_label">
52
+ <button type="button" id="prev" data-i18n="page_prev"></button>
53
+ <span id="page-info" class="muted"></span>
54
+ <button type="button" id="next" data-i18n="page_next"></button>
55
+ </nav>
56
+ <p class="muted keys" data-i18n="shortcuts"></p>
57
+ </main>
58
+ <aside id="drawer" role="dialog" aria-modal="false" aria-labelledby="drawer-title" hidden>
59
+ <div class="drawer-head">
60
+ <h2 id="drawer-title" data-i18n="drawer_title"></h2>
61
+ <button type="button" id="close" data-i18n="drawer_close"></button>
62
+ </div>
63
+ <div class="drawer-actions">
64
+ <button type="button" id="copy-id" data-i18n="copy_id"></button>
65
+ <button type="button" id="copy-hash" data-i18n="copy_hash"></button>
66
+ <button type="button" id="copy-link" data-i18n="copy_link"></button>
67
+ <span id="live" class="muted" role="status"></span>
68
+ </div>
69
+ <p id="drawer-id" class="mono wrapany"></p>
70
+ <p id="drawer-hash" class="mono wrapany muted"></p>
71
+ <p id="drawer-note" class="muted" role="status"></p>
72
+ <h3 data-i18n="fields_heading"></h3>
73
+ <dl id="fields"></dl>
74
+ <p class="muted" data-i18n="clipped_note"></p>
75
+ <h3 data-i18n="raw_heading"></h3>
76
+ <pre id="raw"></pre>
77
+ </aside>
78
+ <footer class="foot muted" data-i18n="footer_honest"></footer>
79
+ <script type="application/json" id="atlas-data">{{DATA}}</script>
80
+ <script>
81
+ {{JS}}
82
+ </script>
83
+ </body>
84
+ </html>
@@ -0,0 +1,370 @@
1
+ (function () {
2
+ "use strict";
3
+ var $ = function (id) { return document.getElementById(id); };
4
+ var D = null;
5
+ try { D = JSON.parse($("atlas-data").textContent); } catch (e) { D = null; }
6
+ if (!D) { $("fatal").hidden = false; return; }
7
+ $("app").hidden = false;
8
+
9
+ var ID = 0, PR = 1, ST = 2, DO = 3, LV = 4, DT = 5, CL = 6, SH = 7, SRC = 8;
10
+ var RAWKEYS = { 0: "evidence_id", 1: "protocol_id", 2: "result_status", 3: "domain", 4: "reproduction_level", 6: "claim_boundary" };
11
+ var GLYPH = {
12
+ PASSED_UNDER_PROTOCOL: ["\u2713", "P"], NEGATIVE_RESULT_UNDER_PROTOCOL: ["\u2717", "N"],
13
+ BLOCKED_SOURCE: ["\u25A0", "B"], INSUFFICIENT_COVERAGE: ["\u25D0", "I"],
14
+ SOURCE_DRIFT: ["\u21AF", "D"], REPRODUCED_OUTCOME: ["\u21BB", "R"]
15
+ };
16
+ var ORDER = Object.keys(GLYPH);
17
+ var PAGE = 50;
18
+ var R = D.rows, N = R.length;
19
+ var langs = D.i18n.langs, L = langs.en, lang = D.i18n["default"];
20
+ var st = { q: "", status: "", domain: "", level: "", from: "", to: "", sort: -1, dir: 1, page: 0, cur: -1, open: -1 };
21
+ var view = [], H = [], byId = Object.create(null), lastFocus = null;
22
+
23
+ function store(k, v) { try { if (v === undefined) { return window.localStorage.getItem(k); } window.localStorage.setItem(k, v); } catch (e) { } return null; }
24
+ function t(key, vars) {
25
+ var s = L[key];
26
+ if (typeof s !== "string") { s = langs.en[key]; }
27
+ if (typeof s !== "string") { s = key; }
28
+ if (vars) { s = s.replace(/\{(\w+)\}/g, function (m, k) { return Object.prototype.hasOwnProperty.call(vars, k) ? String(vars[k]) : m; }); }
29
+ return s;
30
+ }
31
+ function el(tag, props, kids) {
32
+ var n = document.createElement(tag), k;
33
+ if (props) { for (k in props) { if (k === "text") { n.textContent = props[k]; } else if (k === "class") { n.className = props[k]; } else { n.setAttribute(k, props[k]); } } }
34
+ (kids || []).forEach(function (c) { n.appendChild(typeof c === "string" ? document.createTextNode(c) : c); });
35
+ return n;
36
+ }
37
+ function clear(n) { while (n.firstChild) { n.removeChild(n.firstChild); } }
38
+ function known(s) { return Object.prototype.hasOwnProperty.call(GLYPH, s) ? s : "unknown"; }
39
+ function badge(s) {
40
+ var g = GLYPH[s] || ["?", "?"];
41
+ return el("span", { "class": "badge s-" + known(s), title: GLYPH[s] ? s : t("unknown_status") }, [el("span", { "aria-hidden": "true", text: g[0] }), el("span", { text: g[1] + " " + (s === null ? "" : s) })]);
42
+ }
43
+ function show(v) { return v === null || v === undefined ? "" : String(v); }
44
+
45
+ function setStatic() {
46
+ document.documentElement.lang = lang;
47
+ document.title = D.title;
48
+ $("atlas-title").textContent = D.title;
49
+ Array.prototype.forEach.call(document.querySelectorAll("[data-i18n]"), function (n) { n.textContent = t(n.getAttribute("data-i18n")); });
50
+ Array.prototype.forEach.call(document.querySelectorAll("[data-i18n-attr]"), function (n) {
51
+ n.getAttribute("data-i18n-attr").split(",").forEach(function (pair) { var p = pair.split(":"); n.setAttribute(p[0], t(p[1])); });
52
+ });
53
+ }
54
+
55
+ function buildHaystack() {
56
+ var i, r;
57
+ for (i = 0; i < N; i++) {
58
+ r = R[i];
59
+ H.push([r[ID], r[PR], r[ST], r[DO], r[LV], r[CL], r[SRC]].join("\n").toLowerCase());
60
+ if (!(r[ID] in byId)) { byId[r[ID]] = i; }
61
+ }
62
+ }
63
+
64
+ function uniq(col) {
65
+ var seen = Object.create(null), out = [];
66
+ R.forEach(function (r) { var v = show(r[col]); if (v !== "" && !seen[v]) { seen[v] = 1; out.push(v); } });
67
+ return out.sort();
68
+ }
69
+ var OPT = { status: ST, domain: DO, level: LV };
70
+ var SEL = { status: "f-status", domain: "f-domain", level: "f-level" };
71
+ function fillSelect(key) {
72
+ var s = $(SEL[key]), vals = key === "status" ? ORDER.filter(function (x) { return D.statuses[x]; }).concat(Object.keys(D.statuses).filter(function (x) { return !GLYPH[x]; }).sort()) : uniq(OPT[key]);
73
+ clear(s);
74
+ s.appendChild(el("option", { value: "", text: t("filter_all") }));
75
+ vals.forEach(function (v) { s.appendChild(el("option", { value: v, text: v })); });
76
+ s.value = st[key];
77
+ }
78
+
79
+ function matches(i) {
80
+ var r = R[i];
81
+ if (st.q && H[i].indexOf(st.q) < 0) { return false; }
82
+ if (st.status && show(r[ST]) !== st.status) { return false; }
83
+ if (st.domain && show(r[DO]) !== st.domain) { return false; }
84
+ if (st.level && show(r[LV]) !== st.level) { return false; }
85
+ if (st.from || st.to) {
86
+ if (!r[DT]) { return false; }
87
+ if (st.from && r[DT] < st.from) { return false; }
88
+ if (st.to && r[DT] > st.to) { return false; }
89
+ }
90
+ return true;
91
+ }
92
+ function refilter(keepPage) {
93
+ var i, out = [];
94
+ for (i = 0; i < N; i++) { if (matches(i)) { out.push(i); } }
95
+ if (st.sort >= 0) {
96
+ var c = st.sort, d = st.dir;
97
+ out.sort(function (a, b) { var x = show(R[a][c]), y = show(R[b][c]); return x < y ? -d : x > y ? d : a - b; });
98
+ }
99
+ view = out;
100
+ if (!keepPage) { st.page = 0; st.cur = -1; }
101
+ renderResults();
102
+ }
103
+
104
+ function renderIntegrity() {
105
+ var box = $("integrity");
106
+ clear(box);
107
+ D.integrity.forEach(function (g) {
108
+ var b;
109
+ if (g.kind === "ledger" && g.ok) {
110
+ b = el("p", { "class": "banner ok", role: "status", text: t("integrity_ledger_ok", { count: g.count, seq: g.head_seq === null ? "-" : g.head_seq, hash: g.head_hash === null ? "-" : g.head_hash }) });
111
+ } else if (g.kind === "ledger") {
112
+ var ul = el("ul");
113
+ g.problems.forEach(function (p) { ul.appendChild(el("li", { text: t("problem_item", { code: p.code, seq: p.seq, message: p.message }) })); });
114
+ b = el("div", { "class": "banner bad", role: "alert" }, [el("span", { text: t("integrity_ledger_failed", { count: g.problem_count }) }), ul]);
115
+ } else {
116
+ b = el("p", { "class": "banner", text: t("integrity_cards", { count: g.count }) });
117
+ }
118
+ box.appendChild(b);
119
+ });
120
+ if (D.issues.count) {
121
+ var il = el("ul");
122
+ D.issues.items.forEach(function (x) { il.appendChild(el("li", { text: t("issue_item", { path: x.path, reason: x.reason }) })); });
123
+ var more = D.issues.count > D.issues.items.length ? [el("li", { text: t("issues_more", { n: D.issues.count - D.issues.items.length }) })] : [];
124
+ more.forEach(function (m) { il.appendChild(m); });
125
+ box.appendChild(el("details", { "class": "banner" }, [el("summary", { text: t("integrity_issues", { count: D.issues.count }) }), il]));
126
+ }
127
+ if (D.shown < D.total) { box.appendChild(el("p", { "class": "banner", text: t("truncated", { shown: D.shown, total: D.total }) })); }
128
+ }
129
+
130
+ function renderTiles() {
131
+ var box = $("tiles");
132
+ clear(box);
133
+ function tile(label, n, status) {
134
+ var nodes = [el("b", { text: String(n) })];
135
+ nodes.push(status ? badge(status) : el("span", { text: label }));
136
+ box.appendChild(el("div", { "class": "tile" }, nodes));
137
+ }
138
+ tile(t("tile_total"), D.total);
139
+ ORDER.concat(Object.keys(D.statuses).filter(function (x) { return !GLYPH[x]; }).sort()).forEach(function (s) { if (D.statuses[s]) { tile("", D.statuses[s], s); } });
140
+ tile(t("tile_skipped"), D.issues.count);
141
+ }
142
+
143
+ function statusCounts() {
144
+ var c = Object.create(null);
145
+ view.forEach(function (i) { var s = show(R[i][ST]); c[s] = (c[s] || 0) + 1; });
146
+ return c;
147
+ }
148
+ function renderBars() {
149
+ var box = $("chart-status"), c = statusCounts(), keys = ORDER.concat(Object.keys(c).filter(function (x) { return !GLYPH[x]; }).sort()).filter(function (x) { return c[x]; });
150
+ var max = 1;
151
+ clear(box);
152
+ keys.forEach(function (k) { if (c[k] > max) { max = c[k]; } });
153
+ if (!keys.length) { box.appendChild(el("p", { "class": "muted", text: t("chart_empty") })); }
154
+ keys.forEach(function (k) {
155
+ var g = GLYPH[k] || ["?", "?"], b = el("button", { type: "button", "class": "bar badge s-" + known(k), "aria-pressed": st.status === k ? "true" : "false", title: k }, [
156
+ el("span", { "class": "lbl", text: g[0] + " " + g[1] + " " + k }), el("i", { style: "width:" + Math.max(1, Math.round(100 * c[k] / max)) + "%" }), el("span", { text: String(c[k]) })]);
157
+ b.addEventListener("click", function () { st.status = st.status === k ? "" : k; $("f-status").value = st.status; refilter(); });
158
+ box.appendChild(b);
159
+ });
160
+ }
161
+ function svg(tag, attrs) {
162
+ var n = document.createElementNS("http://www.w3.org/2000/svg", tag), k;
163
+ for (k in attrs) { n.setAttribute(k, attrs[k]); }
164
+ return n;
165
+ }
166
+ function renderTimeline() {
167
+ var box = $("chart-time"), c = Object.create(null), months = [], max = 1;
168
+ clear(box);
169
+ view.forEach(function (i) { var d = R[i][DT]; if (d) { var m = d.slice(0, 7); c[m] = (c[m] || 0) + 1; } });
170
+ months = Object.keys(c).sort();
171
+ if (!months.length) { box.appendChild(el("p", { "class": "muted", text: t("chart_empty") })); return; }
172
+ months.forEach(function (m) { if (c[m] > max) { max = c[m]; } });
173
+ var w = Math.max(240, months.length * 14), h = 110, bw = w / months.length;
174
+ var s = svg("svg", { viewBox: "0 0 " + w + " " + (h + 16), width: "100%", role: "img", preserveAspectRatio: "none", "aria-label": t("chart_timeline_desc", { first: months[0], last: months[months.length - 1], max: max }) });
175
+ months.forEach(function (m, k) {
176
+ var bh = Math.max(1, Math.round(h * c[m] / max)), r = svg("rect", { "class": "col", x: String(k * bw + 1), y: String(h - bh), width: String(Math.max(1, bw - 2)), height: String(bh) });
177
+ var ti = svg("title", {}); ti.textContent = m + ": " + c[m]; r.appendChild(ti); s.appendChild(r);
178
+ });
179
+ var a = svg("text", { x: "0", y: String(h + 12) }); a.textContent = months[0]; s.appendChild(a);
180
+ var z = svg("text", { x: String(w), y: String(h + 12), "text-anchor": "end" }); z.textContent = months[months.length - 1] + " (max " + max + ")"; s.appendChild(z);
181
+ box.appendChild(s);
182
+ }
183
+
184
+ var COLS = [[ID, "col_id", ""], [ST, "col_status", ""], [PR, "col_protocol", ""], [DO, "col_domain", "hide-s"], [LV, "col_level", "hide-s"], [DT, "col_date", ""]];
185
+ function renderHead() {
186
+ var tr = $("head");
187
+ clear(tr);
188
+ COLS.forEach(function (c) {
189
+ var b = el("button", { type: "button", text: t(c[1]) + (st.sort === c[0] ? (st.dir > 0 ? " \u25B2" : " \u25BC") : "") });
190
+ b.addEventListener("click", function () {
191
+ if (st.sort === c[0]) { st.dir = -st.dir; } else { st.sort = c[0]; st.dir = 1; }
192
+ renderHead(); refilter();
193
+ });
194
+ tr.appendChild(el("th", { scope: "col", "class": c[2], "aria-sort": st.sort === c[0] ? (st.dir > 0 ? "ascending" : "descending") : "none" }, [b]));
195
+ });
196
+ }
197
+ function renderTable() {
198
+ var body = $("body"), pages = Math.max(1, Math.ceil(view.length / PAGE)), from = st.page * PAGE;
199
+ clear(body);
200
+ view.slice(from, from + PAGE).forEach(function (i, k) {
201
+ var r = R[i], idb = el("button", { type: "button", "class": "idb", text: r[ID] });
202
+ idb.addEventListener("click", function (ev) { ev.stopPropagation(); openRecord(i); });
203
+ var tr = el("tr", { "class": (from + k === st.cur ? "cur " : "") + (i === st.open ? "sel" : ""), "data-i": String(i) }, [
204
+ el("td", { "class": "id" }, [idb]), el("td", {}, [badge(show(r[ST]))]), el("td", { text: show(r[PR]) }),
205
+ el("td", { "class": "hide-s", text: show(r[DO]) }), el("td", { "class": "hide-s", text: show(r[LV]) }), el("td", { text: r[DT] })]);
206
+ tr.addEventListener("click", function () { st.cur = from + k; openRecord(i); });
207
+ body.appendChild(tr);
208
+ });
209
+ $("empty").hidden = view.length > 0;
210
+ $("prev").disabled = st.page <= 0;
211
+ $("next").disabled = st.page >= pages - 1;
212
+ $("page-info").textContent = t("page_info", { page: st.page + 1, pages: pages });
213
+ }
214
+ function renderResults() {
215
+ $("count").textContent = t("result_count", { n: view.length, total: N });
216
+ renderBars(); renderTimeline(); renderTable();
217
+ }
218
+
219
+ function rawOf(i, extra) {
220
+ var r = R[i], o = {}, k;
221
+ for (k in extra) { o[k] = extra[k]; }
222
+ for (k in RAWKEYS) { if (r[k] !== null) { o[RAWKEYS[k]] = r[k]; } }
223
+ var keys = Object.keys(o).sort(), s = {};
224
+ keys.forEach(function (x) { s[x] = o[x]; });
225
+ return s;
226
+ }
227
+ var blocks = {};
228
+ function decodeBlock(b64) {
229
+ if (typeof DecompressionStream === "undefined" || typeof Response === "undefined") { return Promise.reject(new Error("unsupported")); }
230
+ var bin = atob(b64), bytes = new Uint8Array(bin.length), k;
231
+ for (k = 0; k < bin.length; k++) { bytes[k] = bin.charCodeAt(k); }
232
+ return new Response(new Blob([bytes]).stream().pipeThrough(new DecompressionStream("deflate"))).text().then(JSON.parse);
233
+ }
234
+ function detail(i) {
235
+ var b = Math.floor(i / D.block);
236
+ if (!blocks[b]) { blocks[b] = decodeBlock(D.blocks[b]); }
237
+ return blocks[b].then(function (list) { return list[i % D.block]; });
238
+ }
239
+ function flash(msg) { $("live").textContent = msg; }
240
+ function copy(text) {
241
+ function fallback() {
242
+ var ta = el("textarea", { "aria-hidden": "true", style: "position:fixed;left:-999px" });
243
+ ta.value = text; document.body.appendChild(ta); ta.select();
244
+ var ok = false;
245
+ try { ok = document.execCommand("copy"); } catch (e) { ok = false; }
246
+ document.body.removeChild(ta); flash(t(ok ? "copied" : "copy_failed"));
247
+ }
248
+ try {
249
+ if (!navigator.clipboard) { fallback(); return; }
250
+ navigator.clipboard.writeText(text).then(function () { flash(t("copied")); }, fallback);
251
+ } catch (e) { fallback(); }
252
+ }
253
+ function fillDrawer(extra, note) {
254
+ var r = R[st.open], dl = $("fields"), raw = rawOf(st.open, extra);
255
+ clear(dl);
256
+ Object.keys(raw).forEach(function (k) {
257
+ var v = raw[k];
258
+ dl.appendChild(el("dt", { text: k }));
259
+ dl.appendChild(el("dd", { text: typeof v === "string" ? v : JSON.stringify(v, null, 1) }));
260
+ });
261
+ $("raw").textContent = JSON.stringify(raw, null, 2);
262
+ $("drawer-note").textContent = note ? t(note) : "";
263
+ return r;
264
+ }
265
+ function renderDrawer() {
266
+ var d = $("drawer"), i = st.open;
267
+ if (i < 0) { d.hidden = true; return; }
268
+ $("drawer-id").textContent = R[i][ID];
269
+ $("drawer-hash").textContent = t("hash_label") + ": " + R[i][SH];
270
+ fillDrawer(null, "detail_loading");
271
+ flash("");
272
+ d.hidden = false;
273
+ detail(i).then(function (extra) { if (st.open === i) { fillDrawer(extra, ""); } },
274
+ function () { if (st.open === i) { fillDrawer(null, "detail_unavailable"); } });
275
+ }
276
+ function setHash(id) {
277
+ var h = id === null ? location.pathname + location.search : "#" + encodeURIComponent(id);
278
+ try { history.replaceState(null, "", h); } catch (e) { if (id !== null) { location.hash = encodeURIComponent(id); } }
279
+ }
280
+ function openRecord(i) {
281
+ if (st.open < 0) { lastFocus = document.activeElement; }
282
+ st.open = i; renderDrawer(); renderTable(); setHash(R[i][ID]);
283
+ $("close").focus();
284
+ }
285
+ function closeDrawer() {
286
+ if (st.open < 0) { return; }
287
+ st.open = -1; renderDrawer(); renderTable(); setHash(null);
288
+ if (lastFocus && lastFocus.focus) { lastFocus.focus(); }
289
+ }
290
+ function fromHash() {
291
+ var h = location.hash.slice(1), id;
292
+ if (!h) { return; }
293
+ try { id = decodeURIComponent(h); } catch (e) { return; }
294
+ if (id in byId) { st.open = byId[id]; renderDrawer(); renderTable(); }
295
+ }
296
+
297
+ function move(delta) {
298
+ if (!view.length) { return; }
299
+ st.cur = Math.min(view.length - 1, Math.max(0, st.cur < 0 ? (delta > 0 ? 0 : view.length - 1) : st.cur + delta));
300
+ st.page = Math.floor(st.cur / PAGE);
301
+ renderTable();
302
+ var row = $("body").querySelector("tr.cur");
303
+ if (row && row.scrollIntoView) { row.scrollIntoView({ block: "nearest" }); }
304
+ }
305
+ function onKey(ev) {
306
+ if (ev.ctrlKey || ev.metaKey || ev.altKey) { return; }
307
+ var tag = ev.target && ev.target.tagName, typing = tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA";
308
+ if (ev.key === "Escape") {
309
+ if (st.open >= 0) { closeDrawer(); } else if (typing) { ev.target.blur(); }
310
+ return;
311
+ }
312
+ if (typing) { return; }
313
+ if (ev.key === "/") { ev.preventDefault(); $("q").focus(); }
314
+ else if (ev.key === "j") { move(1); }
315
+ else if (ev.key === "k") { move(-1); }
316
+ else if (ev.key === "Enter" && tag !== "BUTTON" && st.cur >= 0 && st.cur < view.length) { openRecord(view[st.cur]); }
317
+ }
318
+
319
+ function applyTheme(v) {
320
+ if (v === "light" || v === "dark") { document.documentElement.setAttribute("data-theme", v); }
321
+ }
322
+ function setLang(code) {
323
+ if (!langs[code]) { return; }
324
+ lang = code; L = langs[code]; store("atlas-lang", code);
325
+ setStatic(); ["status", "domain", "level"].forEach(fillSelect);
326
+ renderIntegrity(); renderTiles(); renderHead(); renderResults(); renderDrawer();
327
+ }
328
+
329
+ function init() {
330
+ var saved = store("atlas-theme"), codes = Object.keys(langs).sort(), sel = $("lang");
331
+ applyTheme(saved);
332
+ var chosen = store("atlas-lang");
333
+ if (chosen && langs[chosen]) { lang = chosen; }
334
+ L = langs[lang];
335
+ if (codes.length > 1) {
336
+ $("lang-wrap").hidden = false;
337
+ codes.forEach(function (c) { sel.appendChild(el("option", { value: c, text: langs[c]._name || c })); });
338
+ sel.value = lang;
339
+ sel.addEventListener("change", function () { setLang(sel.value); });
340
+ }
341
+ $("theme").addEventListener("click", function () {
342
+ var dark = document.documentElement.getAttribute("data-theme") === "dark" || (!document.documentElement.getAttribute("data-theme") && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
343
+ var next = dark ? "light" : "dark";
344
+ applyTheme(next); store("atlas-theme", next);
345
+ });
346
+ buildHaystack();
347
+ setStatic(); ["status", "domain", "level"].forEach(fillSelect);
348
+ $("q").addEventListener("input", function () { st.q = this.value.trim().toLowerCase(); refilter(); });
349
+ [["f-status", "status"], ["f-domain", "domain"], ["f-level", "level"], ["f-from", "from"], ["f-to", "to"]].forEach(function (p) {
350
+ $(p[0]).addEventListener("change", function () { st[p[1]] = this.value; refilter(); });
351
+ });
352
+ $("reset").addEventListener("click", function () {
353
+ st.q = st.status = st.domain = st.level = st.from = st.to = "";
354
+ $("q").value = ""; $("f-from").value = ""; $("f-to").value = "";
355
+ ["status", "domain", "level"].forEach(fillSelect); refilter();
356
+ });
357
+ $("prev").addEventListener("click", function () { if (st.page > 0) { st.page--; renderTable(); } });
358
+ $("next").addEventListener("click", function () { st.page++; renderTable(); });
359
+ $("close").addEventListener("click", closeDrawer);
360
+ $("copy-id").addEventListener("click", function () { if (st.open >= 0) { copy(R[st.open][ID]); } });
361
+ $("copy-hash").addEventListener("click", function () { if (st.open >= 0) { copy(R[st.open][SH]); } });
362
+ $("copy-link").addEventListener("click", function () { if (st.open >= 0) { copy(location.href.split("#")[0] + "#" + encodeURIComponent(R[st.open][ID])); } });
363
+ document.addEventListener("keydown", onKey);
364
+ window.addEventListener("hashchange", fromHash);
365
+ renderIntegrity(); renderTiles(); renderHead();
366
+ refilter();
367
+ fromHash();
368
+ }
369
+ init();
370
+ })();
@@ -0,0 +1,61 @@
1
+ {
2
+ "_name": "English",
3
+ "skip_link": "Skip to the table",
4
+ "lang_label": "Language",
5
+ "theme_toggle": "Switch between light and dark theme",
6
+ "noscript": "This atlas needs JavaScript to display the records.",
7
+ "load_error": "The embedded atlas data could not be read.",
8
+ "integrity_ledger_ok": "Ledger verified: {count} entries, head seq {seq}, hash {hash}",
9
+ "integrity_ledger_failed": "LEDGER FAILED VERIFICATION ({count} problems). Do not rely on the data below.",
10
+ "problem_item": "{code} at line {seq}: {message}",
11
+ "integrity_cards": "{count} evidence cards read from files. They are shown as found and are not verified against a ledger.",
12
+ "integrity_issues": "{count} files were skipped (malformed or not an evidence card)",
13
+ "issue_item": "{path}: {reason}",
14
+ "issues_more": "and {n} more",
15
+ "truncated": "Showing the first {shown} of {total} records (row limit).",
16
+ "tiles_label": "Summary",
17
+ "tile_total": "Total records",
18
+ "tile_skipped": "Skipped files",
19
+ "unknown_status": "Unknown status (shown as found)",
20
+ "chart_status": "Records by status",
21
+ "chart_timeline": "Records by month",
22
+ "chart_timeline_desc": "Bar chart of records per month, first month {first}, last month {last}, highest count {max}",
23
+ "chart_empty": "No data",
24
+ "search_label": "Search",
25
+ "search_placeholder": "Search id, protocol, domain, status, claim boundary, sources",
26
+ "filter_status": "Status",
27
+ "filter_domain": "Domain",
28
+ "filter_level": "Reproduction level",
29
+ "filter_from": "From date",
30
+ "filter_to": "To date",
31
+ "filter_all": "All",
32
+ "filter_reset": "Reset filters",
33
+ "result_count": "{n} of {total} records match",
34
+ "table_caption": "Evidence records",
35
+ "col_id": "Evidence id",
36
+ "col_status": "Status",
37
+ "col_protocol": "Protocol",
38
+ "col_domain": "Domain",
39
+ "col_level": "Level",
40
+ "col_date": "Date",
41
+ "no_results": "No records match the current filters.",
42
+ "pager_label": "Pagination",
43
+ "page_prev": "Previous",
44
+ "page_next": "Next",
45
+ "page_info": "Page {page} of {pages}",
46
+ "shortcuts": "Keyboard: / search, j and k move, Enter opens, Esc closes.",
47
+ "drawer_title": "Record details",
48
+ "drawer_close": "Close",
49
+ "copy_id": "Copy id",
50
+ "copy_hash": "Copy hash",
51
+ "copy_link": "Copy link",
52
+ "copied": "Copied",
53
+ "copy_failed": "Copy failed",
54
+ "hash_label": "Hash",
55
+ "fields_heading": "Fields",
56
+ "raw_heading": "Raw JSON",
57
+ "clipped_note": "Very long values are clipped here; the source file is authoritative.",
58
+ "footer_honest": "Counts are shown exactly as recorded in the source. Nothing is hidden or reclassified, and unknown statuses are displayed as found.",
59
+ "detail_loading": "Loading the other fields...",
60
+ "detail_unavailable": "The other fields could not be decoded in this browser; the source file has them."
61
+ }
@@ -0,0 +1,124 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """PCJ-1 canonical JSON: encode, strict decode and sha256."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import hashlib
7
+ import json
8
+ import re
9
+ from typing import Any
10
+
11
+ from .errors import InputError
12
+
13
+ MAX_DEPTH = 64
14
+ MAX_INT = 2**53 - 1
15
+ _MAX_INT_CHARS = 32
16
+
17
+ _ESCAPES = {'"': '\\"', "\\": "\\\\", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", "\t": "\\t"}
18
+ _NEEDS_ESCAPE = re.compile('[\x00-\x1f"\\\\]')
19
+
20
+
21
+ class CanonError(InputError):
22
+ """Input that is not valid PCJ-1 data."""
23
+
24
+
25
+ def _escape(match: re.Match[str]) -> str:
26
+ char = match.group()
27
+ return _ESCAPES.get(char) or f"\\u{ord(char):04x}"
28
+
29
+
30
+ def _enc_string(text: str) -> str:
31
+ try:
32
+ text.encode("utf-8")
33
+ except UnicodeEncodeError:
34
+ raise CanonError("LONE_SURROGATE", "string contains a lone surrogate") from None
35
+ return '"' + _NEEDS_ESCAPE.sub(_escape, text) + '"'
36
+
37
+
38
+ def _enc_int(value: int) -> str:
39
+ if abs(value) > MAX_INT:
40
+ raise CanonError("INT_RANGE", f"integer outside +-(2^53-1): {value}")
41
+ return str(value)
42
+
43
+
44
+ def _encode(value: object, depth: int) -> str:
45
+ if value is None:
46
+ return "null"
47
+ if value is True:
48
+ return "true"
49
+ if value is False:
50
+ return "false"
51
+ if isinstance(value, int):
52
+ return _enc_int(value)
53
+ if isinstance(value, str):
54
+ return _enc_string(value)
55
+ if isinstance(value, float):
56
+ raise CanonError("FLOAT_NOT_ALLOWED", "floats are not allowed; write decimals as strings")
57
+ if isinstance(value, (list, dict)):
58
+ if depth + 1 > MAX_DEPTH:
59
+ raise CanonError("TOO_DEEP", f"nesting deeper than {MAX_DEPTH}")
60
+ return _encode_container(value, depth + 1)
61
+ raise CanonError("BAD_TYPE", f"unsupported type: {type(value).__name__}")
62
+
63
+
64
+ def _encode_container(value: list[Any] | dict[Any, Any], depth: int) -> str:
65
+ if isinstance(value, list):
66
+ return "[" + ",".join(_encode(item, depth) for item in value) + "]"
67
+ if not all(isinstance(key, str) for key in value):
68
+ raise CanonError("BAD_TYPE", "object keys must be strings")
69
+ return "{" + ",".join(f"{_enc_string(key)}:{_encode(value[key], depth)}" for key in sorted(value)) + "}"
70
+
71
+
72
+ def encode(value: object) -> bytes:
73
+ """Return the PCJ-1 bytes of ``value``."""
74
+ return _encode(value, 0).encode("utf-8")
75
+
76
+
77
+ def sha256_hex(value: object) -> str:
78
+ return hashlib.sha256(encode(value)).hexdigest()
79
+
80
+
81
+ def _pairs(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
82
+ seen: dict[str, Any] = {}
83
+ for key, item in pairs:
84
+ if key in seen:
85
+ raise CanonError("DUPLICATE_KEY", f"duplicate key {key!r}")
86
+ seen[key] = item
87
+ return seen
88
+
89
+
90
+ def _no_float(text: str) -> Any:
91
+ raise CanonError("FLOAT_NOT_ALLOWED", f"floats are not allowed: {text}; write decimals as strings")
92
+
93
+
94
+ def _no_constant(text: str) -> Any:
95
+ raise CanonError("NON_FINITE", f"{text} is not allowed")
96
+
97
+
98
+ def _parse_int(text: str) -> int:
99
+ if len(text) > _MAX_INT_CHARS:
100
+ raise CanonError("INT_RANGE", "integer outside +-(2^53-1)")
101
+ return int(text)
102
+
103
+
104
+ def decode(data: bytes | str) -> Any:
105
+ """Strictly parse JSON: no duplicate keys, no floats, no BOM, depth and range limits."""
106
+ if isinstance(data, bytes):
107
+ try:
108
+ data = data.decode("utf-8")
109
+ except UnicodeDecodeError:
110
+ raise CanonError("BAD_UTF8", "input is not valid UTF-8") from None
111
+ try:
112
+ value = json.loads(
113
+ data,
114
+ object_pairs_hook=_pairs,
115
+ parse_float=_no_float,
116
+ parse_constant=_no_constant,
117
+ parse_int=_parse_int,
118
+ )
119
+ except json.JSONDecodeError as exc:
120
+ raise CanonError("BAD_JSON", f"invalid JSON: {exc.msg} at char {exc.pos}") from None
121
+ except RecursionError:
122
+ raise CanonError("TOO_DEEP", f"nesting deeper than {MAX_DEPTH}") from None
123
+ encode(value) # validates ranges, surrogates and depth
124
+ return value