truthtableai 0.0.0-stage → 0.2.2
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.
- package/README.md +108 -3
- package/dist/THIRD-PARTY-NOTICES.txt +7742 -0
- package/dist/cli.js +3523 -0
- package/dist/panel-ui/assets/app.css +433 -0
- package/dist/panel-ui/assets/app.js +936 -0
- package/dist/panel-ui/assets/favicon.svg +1 -0
- package/dist/panel-ui/assets/lockup-horizontal-on-dark.svg +3 -0
- package/dist/panel-ui/assets/lockup-horizontal.svg +3 -0
- package/dist/panel-ui/assets/mark-on-dark.svg +3 -0
- package/dist/panel-ui/assets/mark.svg +3 -0
- package/dist/panel-ui/index.html +40 -0
- package/dist/rules/banking.ttpack +0 -0
- package/dist/rules/generic/rules.json +76 -0
- package/dist/rules/generic/rules.md +65 -0
- package/dist/rules/paid.json +1 -0
- package/dist/skill/manifest.json +37 -0
- package/dist/skill/truthtable/SKILL.md +193 -0
- package/dist/skill/truthtable/references/answer-kinds.md +118 -0
- package/dist/skill/truthtable/references/bring-your-own-set.md +76 -0
- package/dist/skill/truthtable/references/flow.md +214 -0
- package/dist/skill/truthtable/references/question-types.md +104 -0
- package/dist/skill/truthtable/references/security-questions.md +90 -0
- package/dist/sql-wasm.cjs +213 -0
- package/dist/sql-wasm.wasm +0 -0
- package/package.json +29 -6
|
@@ -0,0 +1,936 @@
|
|
|
1
|
+
// TruthTable AI local panel. No build, no dependencies, no external requests.
|
|
2
|
+
// Every number comes from the engine through the read-only /api endpoints; the panel does not
|
|
3
|
+
// re-judge or re-summarise anything. Text that comes from a workspace (names, questions, cells, SQL)
|
|
4
|
+
// is only ever placed with textContent: this file never assigns innerHTML.
|
|
5
|
+
|
|
6
|
+
const app = document.getElementById("app");
|
|
7
|
+
|
|
8
|
+
// ---- small DOM helpers ---------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
/** Builds an element. Strings and numbers among the children become text nodes. */
|
|
11
|
+
function h(tag, attrs, ...children) {
|
|
12
|
+
const el = document.createElement(tag);
|
|
13
|
+
for (const [k, v] of Object.entries(attrs ?? {})) {
|
|
14
|
+
if (v === undefined || v === null || v === false) continue;
|
|
15
|
+
if (k === "class") el.className = v;
|
|
16
|
+
else if (k === "text") el.textContent = v;
|
|
17
|
+
else if (k.startsWith("on")) el.addEventListener(k.slice(2), v);
|
|
18
|
+
else el.setAttribute(k, v === true ? "" : String(v));
|
|
19
|
+
}
|
|
20
|
+
append(el, children);
|
|
21
|
+
return el;
|
|
22
|
+
}
|
|
23
|
+
function append(el, children) {
|
|
24
|
+
for (const c of children.flat(Infinity)) {
|
|
25
|
+
if (c === undefined || c === null || c === false) continue;
|
|
26
|
+
el.append(c instanceof Node ? c : document.createTextNode(String(c)));
|
|
27
|
+
}
|
|
28
|
+
return el;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const enc = encodeURIComponent;
|
|
32
|
+
const runHref = (name) => `#run/${enc(name)}`;
|
|
33
|
+
const setHref = (name) => `#set/${enc(name)}`;
|
|
34
|
+
|
|
35
|
+
async function api(path) {
|
|
36
|
+
const res = await fetch(path, { headers: { Accept: "application/json" } });
|
|
37
|
+
let body;
|
|
38
|
+
try {
|
|
39
|
+
body = await res.json();
|
|
40
|
+
} catch {
|
|
41
|
+
body = {};
|
|
42
|
+
}
|
|
43
|
+
if (!res.ok) throw new Error(body && body.error ? body.error : `HTTP ${res.status}`);
|
|
44
|
+
return body;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ---- formatting ------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
const dateFmt = new Intl.DateTimeFormat("tr-TR", { day: "numeric", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit" });
|
|
50
|
+
function fmtDate(iso) {
|
|
51
|
+
if (!iso) return "—";
|
|
52
|
+
const d = new Date(iso);
|
|
53
|
+
return Number.isNaN(d.getTime()) ? String(iso) : dateFmt.format(d);
|
|
54
|
+
}
|
|
55
|
+
const intFmt = new Intl.NumberFormat("tr-TR");
|
|
56
|
+
const fmtInt = (n) => intFmt.format(n);
|
|
57
|
+
/** Same as the Markdown report: one decimal, "%" after. */
|
|
58
|
+
const pct = (n, d) => `${d === 0 ? "0.0" : ((n / d) * 100).toFixed(1)}%`;
|
|
59
|
+
const cellText = (v) => (v === null || v === undefined ? "" : typeof v === "object" ? JSON.stringify(v) : String(v));
|
|
60
|
+
|
|
61
|
+
const CLASSES = ["correct", "partial", "clarified", "refused", "wrong", "error"];
|
|
62
|
+
const CLASS_TR = { correct: "doğru", partial: "kısmen doğru", clarified: "netleştirdi", refused: "reddetti", wrong: "yanlış", error: "hata" };
|
|
63
|
+
const KEY_STATUS = [
|
|
64
|
+
["draft", "taslak"],
|
|
65
|
+
["flagged", "işaretli"],
|
|
66
|
+
["approved", "onaylı"],
|
|
67
|
+
];
|
|
68
|
+
const SUBSET_TR = { dev: "geliştirme", holdout: "holdout", ctx: "bağlam" };
|
|
69
|
+
|
|
70
|
+
// ---- shared pieces ---------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
/** "n / N" as two spans; textContent is exactly `${n} / ${N}`. */
|
|
73
|
+
function fraction(key, n, d, { alarm = true } = {}) {
|
|
74
|
+
const hot = alarm && n > 0;
|
|
75
|
+
return h(
|
|
76
|
+
"span",
|
|
77
|
+
{ class: `frac${hot ? " hot" : ""}`, "data-num": key },
|
|
78
|
+
h("span", { class: "frac-n" }, fmtInt(n)),
|
|
79
|
+
h("span", { class: "frac-d" }, ` / ${fmtInt(d)}`),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A row of N cells, n of them marked: the logo's table, one cell per judged question. */
|
|
84
|
+
function cellStrip(n, d, label) {
|
|
85
|
+
if (d <= 0 || d > 240) return null;
|
|
86
|
+
const strip = h("div", { class: "cells", role: "img", "aria-label": `${label}: ${n} / ${d}` });
|
|
87
|
+
for (let i = 0; i < d; i++) strip.append(h("span", { class: i < n ? "cell on" : "cell" }));
|
|
88
|
+
return strip;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function stamp(text, kind = "") {
|
|
92
|
+
return h("span", { class: `stamp ${kind}`.trim() }, text);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function section(title, ...body) {
|
|
96
|
+
return h("section", { class: "block" }, h("h2", { class: "block-title" }, title), ...body);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function errorCard(message) {
|
|
100
|
+
return h(
|
|
101
|
+
"div",
|
|
102
|
+
{ class: "notice error-card", role: "alert" },
|
|
103
|
+
h("strong", {}, "Okunamadı. "),
|
|
104
|
+
h("span", {}, message),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function bar(value, max) {
|
|
109
|
+
const b = h("span", { class: "bar", "aria-hidden": "true" }, h("span", { class: "bar-fill" }));
|
|
110
|
+
const w = max > 0 ? Math.max(0, Math.min(1, value / max)) : 0;
|
|
111
|
+
b.firstChild.style.setProperty("--w", `${(w * 100).toFixed(2)}%`);
|
|
112
|
+
return b;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function classChips(classes) {
|
|
116
|
+
return h(
|
|
117
|
+
"span",
|
|
118
|
+
{ class: "rounds", "aria-label": `Turlar: ${classes.join(", ")}` },
|
|
119
|
+
classes.map((c, i) => h("span", { class: `round c-${c}`, title: `Tur ${i + 1}: ${c} (${CLASS_TR[c] ?? c})` })),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function pageHead(eyebrow, title, ...rest) {
|
|
124
|
+
return h("header", { class: "page-head" }, h("p", { class: "eyebrow" }, eyebrow), h("h1", {}, title), ...rest);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function metaLine(pairs) {
|
|
128
|
+
return h(
|
|
129
|
+
"dl",
|
|
130
|
+
{ class: "meta" },
|
|
131
|
+
pairs
|
|
132
|
+
.filter(([, v]) => v !== undefined && v !== "")
|
|
133
|
+
.map(([k, v]) => h("div", {}, h("dt", {}, k), h("dd", {}, v))),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ---- runs ------------------------------------------------------------------------
|
|
138
|
+
|
|
139
|
+
const byNewest = (a, b) => (b.startedAt || "").localeCompare(a.startedAt || "") || a.name.localeCompare(b.name);
|
|
140
|
+
|
|
141
|
+
function runStamps(r) {
|
|
142
|
+
const out = [];
|
|
143
|
+
if (r.error) out.push(stamp("Okunamadı"));
|
|
144
|
+
else {
|
|
145
|
+
if (!r.ended) out.push(stamp("Sürüyor ya da yarım"));
|
|
146
|
+
else if (r.answers < r.total) out.push(stamp("Eksik koşu"));
|
|
147
|
+
if (!r.headline) out.push(stamp("Yargılanmadı"));
|
|
148
|
+
else if (r.headline.unjudged > 0) out.push(stamp(`Yargılanamayan: ${r.headline.unjudged}`));
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** The change in one headline number between two runs, as an arrow; lower is better for both. */
|
|
154
|
+
function delta(now, before, key, dKey) {
|
|
155
|
+
if (!now || !before) return null;
|
|
156
|
+
const diff = now[key] - before[key];
|
|
157
|
+
const same = now[dKey] === before[dKey];
|
|
158
|
+
if (diff === 0) return h("span", { class: "delta flat", title: "Önceki koşuyla aynı" }, "→ aynı");
|
|
159
|
+
const worse = diff > 0;
|
|
160
|
+
return h(
|
|
161
|
+
"span",
|
|
162
|
+
{ class: `delta ${worse ? "worse" : "better"}`, title: same ? "Önceki koşuya göre" : "Önceki koşuya göre (payda farklı)" },
|
|
163
|
+
`${worse ? "↑" : "↓"} ${fmtInt(Math.abs(diff))}`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function screenRuns() {
|
|
168
|
+
const runs = (await api("/api/runs")).slice().sort(byNewest);
|
|
169
|
+
const out = [pageHead("Yerel çalışma alanı", "Koşular", h("p", { class: "lede" }, "Her koşu, bir hedefin bir sete verdiği cevapların tarihli kaydıdır. Rakamlar motorun özetinden gelir; rapor ile aynıdır."))];
|
|
170
|
+
if (runs.length === 0) {
|
|
171
|
+
out.push(emptyState("Henüz koşu yok.", "Claude oturumunda bir seti koşturun ya da komut satırından bir koşu başlatın; koşu burada görünür."));
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
const judged = runs.filter((r) => r.headline);
|
|
175
|
+
const [latest, previous] = judged;
|
|
176
|
+
const list = h("ol", { class: "runs" });
|
|
177
|
+
for (const r of runs) {
|
|
178
|
+
// Arrow: the newest judged run against the judged run before it (spec §10, "son iki koşu").
|
|
179
|
+
const prev = r === latest ? previous : undefined;
|
|
180
|
+
const hl = r.headline;
|
|
181
|
+
const li = h(
|
|
182
|
+
"li",
|
|
183
|
+
{ class: `run-row${r.error ? " broken" : ""}`, "data-run": r.name },
|
|
184
|
+
h(
|
|
185
|
+
"div",
|
|
186
|
+
{ class: "run-id" },
|
|
187
|
+
h("a", { href: runHref(r.name), class: "run-name" }, r.name),
|
|
188
|
+
h("div", { class: "run-sub" }, h("span", {}, fmtDate(r.startedAt)), h("span", { class: "dot" }, "·"), h("span", {}, r.target), h("span", { class: "dot" }, "·"), h("span", {}, "Set "), h("a", { href: setHref(r.set) }, r.set)),
|
|
189
|
+
h("div", { class: "run-stamps" }, runStamps(r), r.error ? h("span", { class: "run-error" }, r.error) : null),
|
|
190
|
+
),
|
|
191
|
+
h(
|
|
192
|
+
"div",
|
|
193
|
+
{ class: "run-progress" },
|
|
194
|
+
h("span", { class: "k" }, "Cevap"),
|
|
195
|
+
h("span", { class: "v num" }, `${fmtInt(r.answers)} / ${fmtInt(r.total)}`),
|
|
196
|
+
),
|
|
197
|
+
h(
|
|
198
|
+
"div",
|
|
199
|
+
{ class: "run-num" },
|
|
200
|
+
h("span", { class: "k" }, "Kendinden emin yanlış"),
|
|
201
|
+
hl ? fraction("confidentWrong", hl.confidentWrong, hl.judgedPairs) : h("span", { class: "v muted" }, "—"),
|
|
202
|
+
prev ? delta(hl, prev.headline, "confidentWrong", "judgedPairs") : null,
|
|
203
|
+
),
|
|
204
|
+
h(
|
|
205
|
+
"div",
|
|
206
|
+
{ class: "run-num" },
|
|
207
|
+
h("span", { class: "k" }, "Başarılı saldırı"),
|
|
208
|
+
hl ? fraction("breached", hl.breached, hl.securityPairs) : h("span", { class: "v muted" }, "—"),
|
|
209
|
+
prev ? delta(hl, prev.headline, "breached", "securityPairs") : null,
|
|
210
|
+
),
|
|
211
|
+
);
|
|
212
|
+
list.append(li);
|
|
213
|
+
}
|
|
214
|
+
out.push(list);
|
|
215
|
+
if (latest && previous) {
|
|
216
|
+
out.push(
|
|
217
|
+
h(
|
|
218
|
+
"p",
|
|
219
|
+
{ class: "aside" },
|
|
220
|
+
"Oklar en yeni koşuyu bir öncekiyle karşılaştırır. ",
|
|
221
|
+
h("a", { href: `#compare/${enc(previous.name)}/${enc(latest.name)}` }, `${previous.name} → ${latest.name} farkını aç`),
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function emptyState(title, text) {
|
|
229
|
+
return h(
|
|
230
|
+
"div",
|
|
231
|
+
{ class: "empty" },
|
|
232
|
+
h("img", { src: "/assets/mark.svg", alt: "", width: 112, height: 82, class: "empty-mark light-only" }),
|
|
233
|
+
h("img", { src: "/assets/mark-on-dark.svg", alt: "", width: 112, height: 82, class: "empty-mark dark-only" }),
|
|
234
|
+
h("p", { class: "empty-title" }, title),
|
|
235
|
+
h("p", {}, text),
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// ---- run detail --------------------------------------------------------------------
|
|
240
|
+
|
|
241
|
+
async function screenRun(name) {
|
|
242
|
+
const [detail, runs] = await Promise.all([api(`/api/runs/${enc(name)}`), api("/api/runs")]);
|
|
243
|
+
const info = runs.find((r) => r.name === name);
|
|
244
|
+
if (!detail.judged) return unjudgedRun(name, detail.info ?? info);
|
|
245
|
+
|
|
246
|
+
const s = detail.summary;
|
|
247
|
+
const hl = detail.headline;
|
|
248
|
+
const langs = [...new Set(s.pairs.map((p) => p.lang))].sort();
|
|
249
|
+
const rounds = s.pairs.reduce((m, p) => Math.max(m, p.classes.length), 0);
|
|
250
|
+
const out = [];
|
|
251
|
+
|
|
252
|
+
out.push(
|
|
253
|
+
pageHead(
|
|
254
|
+
"Koşu raporu",
|
|
255
|
+
name,
|
|
256
|
+
metaLine([
|
|
257
|
+
["Hedef", detail.meta.target],
|
|
258
|
+
["Set", h("a", { href: setHref(detail.meta.set) }, detail.meta.set)],
|
|
259
|
+
["Tarih", fmtDate(info?.startedAt)],
|
|
260
|
+
["Tur", rounds ? String(rounds) : undefined],
|
|
261
|
+
["Diller", langs.join(", ")],
|
|
262
|
+
]),
|
|
263
|
+
),
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
// Stamps and their explanations, in the report's order.
|
|
267
|
+
const notes = [];
|
|
268
|
+
if (s.keys.unapproved > 0) notes.push(["Doğrulanmamış anahtar", `${s.keys.unapproved} maddenin cevap anahtarı onaylanmadı.`]);
|
|
269
|
+
if ((s.keys.disputed ?? 0) > 0) notes.push(["Yanlış alarm", `${s.keys.disputed} maddenin cevap anahtarı itirazla düzeltildi.`]);
|
|
270
|
+
if (s.completeness.answers < s.completeness.expected) notes.push(["Eksik koşu", `${s.completeness.answers} / ${s.completeness.expected} cevap.`]);
|
|
271
|
+
if (hl.unjudged > 0) {
|
|
272
|
+
const top = s.errorReasons.slice(0, 3).map((r) => `${r.reason} ×${r.count}`);
|
|
273
|
+
notes.push(["Yargılanamayan", `${hl.unjudged} çift hata verdi${top.length ? ` (en sık: ${top.join(", ")})` : ""}.`]);
|
|
274
|
+
}
|
|
275
|
+
if (s.textOnlyTarget) notes.push(["Tablo yok", "Bu hedef tablo döndürmüyor: tablo bekleyen sorular yargılanamadı."]);
|
|
276
|
+
if (notes.length) {
|
|
277
|
+
out.push(h("div", { class: "notes" }, notes.map(([t, text]) => h("div", { class: "note" }, stamp(t), h("p", {}, text)))));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// The two headline numbers.
|
|
281
|
+
const cw = h(
|
|
282
|
+
"article",
|
|
283
|
+
{ class: "headline" },
|
|
284
|
+
h("h2", { class: "headline-label" }, "Kendinden emin yanlış"),
|
|
285
|
+
hl.judgedPairs > 0 ? fraction("confidentWrong", hl.confidentWrong, hl.judgedPairs) : h("p", { class: "muted" }, "Yargılanan doğruluk sorusu yok."),
|
|
286
|
+
cellStrip(hl.confidentWrong, hl.judgedPairs, "Kendinden emin yanlış"),
|
|
287
|
+
hl.judgedPairs > 0
|
|
288
|
+
? h(
|
|
289
|
+
"p",
|
|
290
|
+
{ class: "headline-note" },
|
|
291
|
+
"Soru × dil çifti; en az bir turda yanlış ama emin bir cevap. ",
|
|
292
|
+
h("span", { class: "nowrap" }, `Her turda yanlış: ${s.everyRoundWrong}`),
|
|
293
|
+
" · ",
|
|
294
|
+
h("span", { class: "nowrap" }, `Deneme düzeyinde yanlış oranı: ${(s.attemptWrongRate * 100).toFixed(1)}%`),
|
|
295
|
+
)
|
|
296
|
+
: null,
|
|
297
|
+
// Right numbers, other shape: counted apart, never as confidently wrong (older runs have no such count).
|
|
298
|
+
hl.judgedPairs > 0 && (hl.partial ?? 0) > 0
|
|
299
|
+
? h(
|
|
300
|
+
"p",
|
|
301
|
+
{ class: "headline-note partial-note", "data-partial": String(hl.partial) },
|
|
302
|
+
h("span", { class: "mark-warn", "aria-hidden": "true" }, "!"),
|
|
303
|
+
` Kısmen doğru (rakamlar doğru, biçim farklı): ${hl.partial} / ${hl.judgedPairs}. Kendinden emin yanlışa sayılmaz, doğruya da sayılmaz.`,
|
|
304
|
+
)
|
|
305
|
+
: null,
|
|
306
|
+
);
|
|
307
|
+
const br = h(
|
|
308
|
+
"article",
|
|
309
|
+
{ class: "headline" },
|
|
310
|
+
h("h2", { class: "headline-label" }, "Başarılı saldırı"),
|
|
311
|
+
hl.securityPairs > 0 ? fraction("breached", hl.breached, hl.securityPairs) : h("p", { class: "muted" }, "Güvenlik sorusu yok."),
|
|
312
|
+
cellStrip(hl.breached, hl.securityPairs, "Başarılı saldırı"),
|
|
313
|
+
hl.securityPairs > 0 ? h("p", { class: "headline-note" }, "Güvenlik sorusu × dil çifti; saldırı en az bir turda amacına ulaştı.") : null,
|
|
314
|
+
);
|
|
315
|
+
out.push(h("div", { class: "headlines" }, cw, br));
|
|
316
|
+
|
|
317
|
+
// Class distribution, stability, latency.
|
|
318
|
+
const facts = h(
|
|
319
|
+
"div",
|
|
320
|
+
{ class: "facts" },
|
|
321
|
+
fact("Kararlılık", `${s.stability.stable} / ${s.stability.total}`, "çift kararlı"),
|
|
322
|
+
fact("Süre, medyan", `${fmtInt(Math.round(s.latency.medianMs))} ms`),
|
|
323
|
+
fact("Süre, p90", `${fmtInt(Math.round(s.latency.p90Ms))} ms`),
|
|
324
|
+
fact("Cevap", `${s.completeness.answers} / ${s.completeness.expected}`),
|
|
325
|
+
);
|
|
326
|
+
const classBlocks = [classTable("Sınıf", s.attempts)];
|
|
327
|
+
if (CLASSES.some((c) => s.securityAttempts[c] > 0)) classBlocks.push(classTable("Güvenlik sınıfı", s.securityAttempts));
|
|
328
|
+
out.push(section("Sınıf dağılımı", h("div", { class: "split" }, classBlocks), facts));
|
|
329
|
+
|
|
330
|
+
const cat = breakdown("Kategori", s.byCategory);
|
|
331
|
+
const trap = breakdown("Tuzak", s.byTrap);
|
|
332
|
+
if (cat || trap) out.push(section("Kırılım", h("div", { class: "split" }, cat, trap)));
|
|
333
|
+
|
|
334
|
+
if (s.leaks.length > 0) {
|
|
335
|
+
out.push(
|
|
336
|
+
h(
|
|
337
|
+
"section",
|
|
338
|
+
{ class: "block leaks" },
|
|
339
|
+
h("h2", { class: "block-title" }, "Sızıntı bulguları"),
|
|
340
|
+
h(
|
|
341
|
+
"ul",
|
|
342
|
+
{ class: "leak-list" },
|
|
343
|
+
s.leaks.map((l) =>
|
|
344
|
+
l.leak === "(holdout)"
|
|
345
|
+
? h("li", {}, h("span", { class: "mono" }, l.id), " ", h("span", { class: "tag" }, "holdout"), h("span", { class: "muted" }, " ayrıntı gizli"))
|
|
346
|
+
: h("li", {}, h("span", { class: "mono" }, l.id), h("span", { class: "lang" }, l.lang), h("span", { class: "leak-kind" }, l.leak)),
|
|
347
|
+
),
|
|
348
|
+
),
|
|
349
|
+
h("p", { class: "aside" }, "Değerler gösterilmez; yalnız sızıntının türü (forbidden, unmasked, canary)."),
|
|
350
|
+
),
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
out.push(await worstSection(name, detail.worst, s.pairs.filter((p) => p.anyWrong).length));
|
|
355
|
+
if ((detail.partial ?? []).length > 0) out.push(partialSection(detail.partial));
|
|
356
|
+
if (detail.answers) out.push(allSection(name, detail.answers));
|
|
357
|
+
out.push(h("p", { class: "disclaimer" }, "Bu belge tarihli bir test kaydıdır, sertifika değildir."));
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function fact(label, value, unit) {
|
|
362
|
+
return h("div", { class: "fact" }, h("span", { class: "k" }, label), h("span", { class: "v num" }, value, unit ? h("span", { class: "unit" }, ` ${unit}`) : null));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function classTable(title, counts) {
|
|
366
|
+
const n = (c) => counts[c] ?? 0;
|
|
367
|
+
// Partly right is listed only when the run has some (older runs have no such count).
|
|
368
|
+
const listed = CLASSES.filter((c) => c !== "partial" || n(c) > 0);
|
|
369
|
+
const total = CLASSES.reduce((sum, c) => sum + n(c), 0);
|
|
370
|
+
const max = Math.max(1, ...CLASSES.map(n));
|
|
371
|
+
return h(
|
|
372
|
+
"table",
|
|
373
|
+
{ class: "data" },
|
|
374
|
+
h("thead", {}, h("tr", {}, h("th", { scope: "col" }, title), h("th", { scope: "col", class: "r" }, "Deneme"), h("th", { scope: "col", class: "r" }, "Oran"), h("th", { scope: "col", class: "bar-col" }, h("span", { class: "sr" }, "Dağılım")))),
|
|
375
|
+
h(
|
|
376
|
+
"tbody",
|
|
377
|
+
{},
|
|
378
|
+
listed.map((c) =>
|
|
379
|
+
h(
|
|
380
|
+
"tr",
|
|
381
|
+
{ class: `c-row c-${c}` },
|
|
382
|
+
h("th", { scope: "row" }, h("span", { class: `swatch c-${c}` }), h("span", { class: "mono" }, c), h("span", { class: "gloss" }, CLASS_TR[c])),
|
|
383
|
+
h("td", { class: "r num" }, fmtInt(n(c))),
|
|
384
|
+
h("td", { class: "r num" }, pct(n(c), total)),
|
|
385
|
+
h("td", { class: "bar-col" }, bar(n(c), max)),
|
|
386
|
+
),
|
|
387
|
+
),
|
|
388
|
+
),
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function breakdown(title, data) {
|
|
393
|
+
const keys = Object.keys(data).sort();
|
|
394
|
+
if (keys.length === 0) return null;
|
|
395
|
+
return h(
|
|
396
|
+
"table",
|
|
397
|
+
{ class: "data" },
|
|
398
|
+
h("thead", {}, h("tr", {}, h("th", { scope: "col" }, title), h("th", { scope: "col", class: "r" }, "Soru"), h("th", { scope: "col", class: "r" }, "Yanlış"), h("th", { scope: "col", class: "bar-col" }, h("span", { class: "sr" }, "Yanlış payı")))),
|
|
399
|
+
h(
|
|
400
|
+
"tbody",
|
|
401
|
+
{},
|
|
402
|
+
keys.map((k) =>
|
|
403
|
+
h(
|
|
404
|
+
"tr",
|
|
405
|
+
{},
|
|
406
|
+
h("th", { scope: "row", class: "mono" }, k),
|
|
407
|
+
h("td", { class: "r num" }, fmtInt(data[k].pairs)),
|
|
408
|
+
h("td", { class: `r num${data[k].wrong > 0 ? " hot" : ""}` }, fmtInt(data[k].wrong)),
|
|
409
|
+
h("td", { class: "bar-col" }, bar(data[k].wrong, data[k].pairs)),
|
|
410
|
+
),
|
|
411
|
+
),
|
|
412
|
+
),
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async function worstSection(run, first, total) {
|
|
417
|
+
const list = h("ol", { class: "worst" });
|
|
418
|
+
const sec = section(
|
|
419
|
+
"En kötü çiftler",
|
|
420
|
+
h("p", { class: "aside" }, "En çok turda yanlış olan çiftler önce. Bir satırı açınca soru, beklenen ve gelen tablo görünür."),
|
|
421
|
+
list,
|
|
422
|
+
);
|
|
423
|
+
if (total === 0) {
|
|
424
|
+
list.replaceWith(h("p", { class: "all-clear" }, "Kendinden emin yanlış yok."));
|
|
425
|
+
return sec;
|
|
426
|
+
}
|
|
427
|
+
let shown = 0;
|
|
428
|
+
const addRows = (rows) => {
|
|
429
|
+
for (const w of rows) list.append(worstRow(w));
|
|
430
|
+
shown += rows.length;
|
|
431
|
+
};
|
|
432
|
+
addRows(first);
|
|
433
|
+
if (shown < total) {
|
|
434
|
+
const more = h("button", { class: "more", type: "button" }, `Daha fazla göster (${total - shown} kaldı)`);
|
|
435
|
+
more.addEventListener("click", async () => {
|
|
436
|
+
more.disabled = true;
|
|
437
|
+
try {
|
|
438
|
+
const page = await api(`/api/runs/${enc(run)}?offset=${shown}&limit=50`);
|
|
439
|
+
const rows = page.worst ?? [];
|
|
440
|
+
addRows(rows);
|
|
441
|
+
if (rows.length === 0 || shown >= total) return more.remove();
|
|
442
|
+
more.disabled = false;
|
|
443
|
+
more.textContent = `Daha fazla göster (${total - shown} kaldı)`;
|
|
444
|
+
} catch (e) {
|
|
445
|
+
more.replaceWith(errorCard(e instanceof Error ? e.message : String(e)));
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
sec.append(more);
|
|
449
|
+
}
|
|
450
|
+
return sec;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Partly right pairs (right numbers, different shape): their own list under the wrong ones, each with its reason sentence. */
|
|
454
|
+
function partialSection(pairs) {
|
|
455
|
+
return section(
|
|
456
|
+
"Kısmen doğru",
|
|
457
|
+
h("p", { class: "aside" }, "Rakamlar doğru, biçim farklı: asistan doğru rakamları farklı bir toplama düzeyinde verdi. Kendinden emin yanlışa sayılmaz."),
|
|
458
|
+
h("ol", { class: "worst partial-list" }, pairs.map((w) => worstRow(w, "partial"))),
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// ---- every question ----------------------------------------------------------------
|
|
463
|
+
|
|
464
|
+
const OUTCOMES = ["all", "correct", "partial", "wrong", "refused", "clarified", "error"];
|
|
465
|
+
const OUTCOME_TR = { all: "Tümü", correct: "Doğru", partial: "Kısmen doğru", wrong: "Yanlış", refused: "Reddetti", clarified: "Açıklama istedi", error: "Hata" };
|
|
466
|
+
const OUTCOME_MARK = { correct: "✓", partial: "!", wrong: "×", refused: "–", clarified: "?", error: "!" };
|
|
467
|
+
|
|
468
|
+
/** Every question of the run, right ones too: outcome filter with counts, search, one row each that opens to both answers. */
|
|
469
|
+
function allSection(run, first) {
|
|
470
|
+
let filter = "all";
|
|
471
|
+
let q = "";
|
|
472
|
+
let page = first;
|
|
473
|
+
const list = h("ol", { class: "worst all-list" });
|
|
474
|
+
const chips = h("div", { class: "seg", role: "group", "aria-label": "Sonuca göre süz" });
|
|
475
|
+
const search = h("input", { type: "search", class: "all-search", placeholder: "Soru ara", "aria-label": "Soru ara", maxlength: "200" });
|
|
476
|
+
const foot = h("div", { class: "all-foot" });
|
|
477
|
+
const sec = section(
|
|
478
|
+
"Tüm sorular",
|
|
479
|
+
h("p", { class: "aside" }, "Koşuda sorulan her soru ve sonucu. Bir satırı açınca beklenen ve gelen tablo, asistanın açıklaması ve SQL görünür."),
|
|
480
|
+
h("div", { class: "all-bar" }, chips, search),
|
|
481
|
+
list,
|
|
482
|
+
foot,
|
|
483
|
+
);
|
|
484
|
+
const url = (offset) => {
|
|
485
|
+
const p = new URLSearchParams({ offset: String(offset), limit: "100" });
|
|
486
|
+
if (filter !== "all") p.set("outcome", filter);
|
|
487
|
+
if (q) p.set("q", q);
|
|
488
|
+
return `/api/runs/${enc(run)}/answers?${p}`;
|
|
489
|
+
};
|
|
490
|
+
const draw = () => {
|
|
491
|
+
const counts = page.counts ?? {};
|
|
492
|
+
const all = Object.values(counts).reduce((a, b) => a + b, 0);
|
|
493
|
+
chips.replaceChildren(
|
|
494
|
+
...OUTCOMES.map((o) => {
|
|
495
|
+
const n = o === "all" ? all : (counts[o] ?? 0);
|
|
496
|
+
const b = h("button", { type: "button", "aria-pressed": String(filter === o), "data-outcome": o, class: o === "all" ? "" : `c-${o}` }, o === "all" ? "" : `${OUTCOME_MARK[o]} `, OUTCOME_TR[o], h("span", { class: "num muted" }, ` ${n}`));
|
|
497
|
+
if (o !== "all" && n === 0 && filter !== o) b.disabled = true;
|
|
498
|
+
b.addEventListener("click", () => {
|
|
499
|
+
filter = o;
|
|
500
|
+
void reload();
|
|
501
|
+
});
|
|
502
|
+
return b;
|
|
503
|
+
}),
|
|
504
|
+
);
|
|
505
|
+
list.replaceChildren(...(page.items.length ? page.items.map(answerRow) : [h("li", { class: "muted all-none" }, "Bu süzgece uyan soru yok.")]));
|
|
506
|
+
foot.replaceChildren();
|
|
507
|
+
if (page.items.length < page.total) {
|
|
508
|
+
const more = h("button", { class: "more", type: "button" }, `Daha fazla göster (${page.total - page.items.length} kaldı)`);
|
|
509
|
+
more.addEventListener("click", async () => {
|
|
510
|
+
more.disabled = true;
|
|
511
|
+
try {
|
|
512
|
+
const next = await api(url(page.items.length));
|
|
513
|
+
page = { ...next, items: [...page.items, ...next.items] };
|
|
514
|
+
draw();
|
|
515
|
+
} catch (e) {
|
|
516
|
+
more.replaceWith(errorCard(e instanceof Error ? e.message : String(e)));
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
foot.append(more);
|
|
520
|
+
}
|
|
521
|
+
if (page.holdout > 0) foot.append(h("p", { class: "aside" }, `Gizli tutulan (holdout) ${page.holdout} soru sayıldı; soruları ve cevapları gösterilmez.`));
|
|
522
|
+
};
|
|
523
|
+
const reload = async () => {
|
|
524
|
+
try {
|
|
525
|
+
page = await api(url(0));
|
|
526
|
+
draw();
|
|
527
|
+
} catch (e) {
|
|
528
|
+
list.replaceChildren(h("li", {}, errorCard(e instanceof Error ? e.message : String(e))));
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
let timer;
|
|
532
|
+
search.addEventListener("input", () => {
|
|
533
|
+
clearTimeout(timer);
|
|
534
|
+
timer = setTimeout(() => {
|
|
535
|
+
q = search.value.trim();
|
|
536
|
+
void reload();
|
|
537
|
+
}, 250);
|
|
538
|
+
});
|
|
539
|
+
draw();
|
|
540
|
+
return sec;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function answerRow(a) {
|
|
544
|
+
const body = h("div", { class: "w-body", hidden: true });
|
|
545
|
+
const btn = h(
|
|
546
|
+
"button",
|
|
547
|
+
{ class: "w-head a-head", type: "button", "aria-expanded": "false", "data-answer": a.id },
|
|
548
|
+
h("span", { class: `a-outcome c-${a.outcome}` }, `${OUTCOME_MARK[a.outcome] ?? ""} ${OUTCOME_TR[a.outcome] ?? a.outcome}`),
|
|
549
|
+
h("span", { class: "lang" }, a.lang),
|
|
550
|
+
a.category ? h("span", { class: "tag" }, a.category) : h("span"),
|
|
551
|
+
h("span", { class: "w-q" }, a.question ?? ""),
|
|
552
|
+
h("span", { class: "w-id mono" }, a.id),
|
|
553
|
+
classChips(a.classes),
|
|
554
|
+
);
|
|
555
|
+
btn.addEventListener("click", () => {
|
|
556
|
+
const open = btn.getAttribute("aria-expanded") === "true";
|
|
557
|
+
btn.setAttribute("aria-expanded", String(!open));
|
|
558
|
+
if (!open && !body.firstChild) {
|
|
559
|
+
fillWorst(body, a);
|
|
560
|
+
if (a.expectedMore || a.gotMore) body.append(h("p", { class: "aside" }, `Listede en çok 20 satır var; beklenen ${a.expectedMore ?? 0}, gelen ${a.gotMore ?? 0} satır daha.`));
|
|
561
|
+
if (a.outcome === "error" && a.reason) body.append(h("p", { class: "aside" }, `Servis hatası: ${a.reason}`));
|
|
562
|
+
}
|
|
563
|
+
body.hidden = open;
|
|
564
|
+
});
|
|
565
|
+
return h("li", { class: "w-row" }, btn, body);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function worstRow(w, shown = "wrong") {
|
|
569
|
+
const wrongN = w.classes.filter((c) => c === shown).length;
|
|
570
|
+
const scoreTitle = shown === "partial" ? "Kısmen doğru tur / tur" : "Yanlış tur / tur";
|
|
571
|
+
if (w.holdout) {
|
|
572
|
+
return h(
|
|
573
|
+
"li",
|
|
574
|
+
{ class: "w-row holdout" },
|
|
575
|
+
h(
|
|
576
|
+
"div",
|
|
577
|
+
{ class: "w-head static" },
|
|
578
|
+
h("span", { class: "w-id mono" }, w.id),
|
|
579
|
+
h("span", { class: "lang" }, w.lang),
|
|
580
|
+
h("span", { class: "tag" }, "holdout"),
|
|
581
|
+
h("span", { class: "w-q muted" }, "Ayrıntı gizli: holdout maddeler yalnız sayıya katılır."),
|
|
582
|
+
h("span", { class: "w-score num" }, `${wrongN} / ${w.classes.length}`),
|
|
583
|
+
classChips(w.classes),
|
|
584
|
+
),
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
const body = h("div", { class: "w-body", hidden: true });
|
|
588
|
+
const btn = h(
|
|
589
|
+
"button",
|
|
590
|
+
{ class: "w-head", type: "button", "aria-expanded": "false", [shown === "partial" ? "data-partial" : "data-worst"]: w.id },
|
|
591
|
+
h("span", { class: "w-id mono" }, w.id),
|
|
592
|
+
h("span", { class: "lang" }, w.lang),
|
|
593
|
+
w.category ? h("span", { class: "tag" }, w.category) : h("span"),
|
|
594
|
+
h("span", { class: "w-q" }, w.question ?? ""),
|
|
595
|
+
h("span", { class: "w-score num", title: scoreTitle }, `${wrongN} / ${w.classes.length}`),
|
|
596
|
+
classChips(w.classes),
|
|
597
|
+
);
|
|
598
|
+
btn.addEventListener("click", () => {
|
|
599
|
+
const open = btn.getAttribute("aria-expanded") === "true";
|
|
600
|
+
btn.setAttribute("aria-expanded", String(!open));
|
|
601
|
+
if (!open && !body.firstChild) fillWorst(body, w);
|
|
602
|
+
body.hidden = open;
|
|
603
|
+
});
|
|
604
|
+
return h("li", { class: "w-row" }, btn, body);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function fillWorst(body, w) {
|
|
608
|
+
append(body, [
|
|
609
|
+
w.question !== undefined ? h("blockquote", { class: "question" }, w.question) : null,
|
|
610
|
+
w.note ? h("p", { class: "partial-note" }, h("span", { class: "mark-warn", "aria-hidden": "true" }, "!"), ` Kısmen doğru: ${w.note}`) : null,
|
|
611
|
+
h(
|
|
612
|
+
"div",
|
|
613
|
+
{ class: "compare-tables" },
|
|
614
|
+
rowsTable("Beklenen", "expected", w.expected),
|
|
615
|
+
rowsTable("Gelen", "got", w.got),
|
|
616
|
+
),
|
|
617
|
+
w.text ? h("figure", { class: "said" }, h("figcaption", { class: "mini" }, "Asistanın açıklaması"), h("blockquote", {}, w.text)) : null,
|
|
618
|
+
w.sql ? h("div", { class: "sql" }, h("h3", { class: "mini" }, "Gelen SQL"), h("pre", {}, h("code", {}, w.sql))) : null,
|
|
619
|
+
h(
|
|
620
|
+
"div",
|
|
621
|
+
{ class: "turns" },
|
|
622
|
+
h("h3", { class: "mini" }, "Turlar"),
|
|
623
|
+
h(
|
|
624
|
+
"ol",
|
|
625
|
+
{ class: "turn-list" },
|
|
626
|
+
w.classes.map((c, i) => h("li", { class: `turn c-${c}` }, h("span", { class: "turn-n" }, `Tur ${i + 1}`), h("span", { class: "mono" }, c), h("span", { class: "gloss" }, CLASS_TR[c] ?? ""))),
|
|
627
|
+
),
|
|
628
|
+
),
|
|
629
|
+
]);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const MAX_ROWS = 50;
|
|
633
|
+
function rowsTable(title, key, rows) {
|
|
634
|
+
const wrap = h("figure", { class: `rows rows-${key}` }, h("figcaption", {}, title, rows ? h("span", { class: "count" }, ` ${rows.length} satır`) : null));
|
|
635
|
+
const table = h("table", { class: "data cells-table", "data-table": key });
|
|
636
|
+
const tbody = h("tbody");
|
|
637
|
+
if (!rows || rows.length === 0) {
|
|
638
|
+
tbody.append(h("tr", {}, h("td", { class: "muted" }, "—")));
|
|
639
|
+
} else {
|
|
640
|
+
rows.slice(0, MAX_ROWS).forEach((r, i) => {
|
|
641
|
+
tbody.append(h("tr", {}, h("td", { class: "ix num" }, String(i + 1)), r.length ? r.map((v) => h("td", { class: typeof v === "number" ? "num r" : "" }, cellText(v))) : h("td", { class: "muted" }, "—")));
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
table.append(tbody);
|
|
645
|
+
wrap.append(h("div", { class: "scroll" }, table));
|
|
646
|
+
if (rows && rows.length > MAX_ROWS) wrap.append(h("p", { class: "aside" }, `İlk ${MAX_ROWS} satır gösteriliyor.`));
|
|
647
|
+
return wrap;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function unjudgedRun(name, info) {
|
|
651
|
+
const out = [pageHead("Koşu raporu", name)];
|
|
652
|
+
if (info) {
|
|
653
|
+
out.push(
|
|
654
|
+
metaLine([
|
|
655
|
+
["Hedef", info.target],
|
|
656
|
+
["Set", info.set],
|
|
657
|
+
["Tarih", fmtDate(info.startedAt)],
|
|
658
|
+
["Cevap", `${info.answers} / ${info.total}`],
|
|
659
|
+
]),
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
const notes = [];
|
|
663
|
+
if (info?.error) notes.push(h("div", { class: "note" }, stamp("Okunamadı"), h("p", {}, info.error)));
|
|
664
|
+
else notes.push(h("div", { class: "note" }, stamp("Yargılanmadı"), h("p", {}, info && !info.ended ? "Koşu sürüyor ya da yarım kaldı; yargılanınca rakamlar burada görünür." : "Bu koşu henüz yargılanmadı.")));
|
|
665
|
+
out.push(h("div", { class: "notes" }, notes));
|
|
666
|
+
return out;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// ---- compare ---------------------------------------------------------------------
|
|
670
|
+
|
|
671
|
+
async function screenCompare(a, b) {
|
|
672
|
+
const runs = (await api("/api/runs")).filter((r) => r.headline).sort(byNewest);
|
|
673
|
+
const out = [pageHead("İki koşu", "Karşılaştır", h("p", { class: "lede" }, "Aynı setin iki koşusu: hangi çiftler düzeldi, hangileri bozuldu, hangileri turdan tura değişiyor."))];
|
|
674
|
+
if (runs.length < 1) {
|
|
675
|
+
out.push(emptyState("Karşılaştırılacak koşu yok.", "Karşılaştırma için en az bir yargılanmış koşu gerekir."));
|
|
676
|
+
return out;
|
|
677
|
+
}
|
|
678
|
+
const pickA = a ?? runs[1]?.name ?? runs[0].name;
|
|
679
|
+
const pickB = b ?? runs[0].name;
|
|
680
|
+
const select = (id, label, value) =>
|
|
681
|
+
h(
|
|
682
|
+
"label",
|
|
683
|
+
{ class: "field", for: id },
|
|
684
|
+
h("span", { class: "k" }, label),
|
|
685
|
+
h("select", { id }, runs.map((r) => h("option", { value: r.name, selected: r.name === value }, `${r.name} · ${fmtDate(r.startedAt)}`))),
|
|
686
|
+
);
|
|
687
|
+
const form = h(
|
|
688
|
+
"form",
|
|
689
|
+
{ class: "pick" },
|
|
690
|
+
select("cmp-a", "Önce", pickA),
|
|
691
|
+
h("span", { class: "arrow", "aria-hidden": "true" }, "→"),
|
|
692
|
+
select("cmp-b", "Sonra", pickB),
|
|
693
|
+
h("button", { type: "submit" }, "Karşılaştır"),
|
|
694
|
+
);
|
|
695
|
+
form.addEventListener("submit", (e) => {
|
|
696
|
+
e.preventDefault();
|
|
697
|
+
location.hash = `#compare/${enc(form.querySelector("#cmp-a").value)}/${enc(form.querySelector("#cmp-b").value)}`;
|
|
698
|
+
});
|
|
699
|
+
out.push(form);
|
|
700
|
+
if (!a || !b) {
|
|
701
|
+
out.push(h("p", { class: "aside" }, "İki koşu seçip Karşılaştır'a basın."));
|
|
702
|
+
return out;
|
|
703
|
+
}
|
|
704
|
+
let c;
|
|
705
|
+
try {
|
|
706
|
+
c = await api(`/api/compare?a=${enc(a)}&b=${enc(b)}`);
|
|
707
|
+
} catch (e) {
|
|
708
|
+
// A refusal (license) or a read error: its one sentence, as text, under the picker.
|
|
709
|
+
out.push(h("div", { class: "notice", role: "alert", "data-refusal": "" }, h("span", {}, e instanceof Error ? e.message : String(e))));
|
|
710
|
+
return out;
|
|
711
|
+
}
|
|
712
|
+
const ra = runs.find((r) => r.name === a);
|
|
713
|
+
const rb = runs.find((r) => r.name === b);
|
|
714
|
+
if (ra && rb) {
|
|
715
|
+
out.push(
|
|
716
|
+
h(
|
|
717
|
+
"div",
|
|
718
|
+
{ class: "versus" },
|
|
719
|
+
versusRow("Kendinden emin yanlış", ra.headline, rb.headline, "confidentWrong", "judgedPairs", a, b),
|
|
720
|
+
versusRow("Başarılı saldırı", ra.headline, rb.headline, "breached", "securityPairs", a, b),
|
|
721
|
+
),
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
out.push(
|
|
725
|
+
h(
|
|
726
|
+
"div",
|
|
727
|
+
{ class: "cmp-lists" },
|
|
728
|
+
cmpList("fixed", "Düzelen", "Önce yanlış ya da kısmen doğruydu, şimdi doğru.", c.fixed, b),
|
|
729
|
+
cmpList("broke", "Bozulan", "Önce yanlış değildi, şimdi yanlış.", c.broke, b),
|
|
730
|
+
cmpList("partial", "Kısmen doğru", "Şimdi rakamları doğru ama biçimi farklı; önce yanlış ya da doğruydu.", c.partial ?? [], b),
|
|
731
|
+
cmpList("unstable", "Kararsız", "Turdan tura farklı sınıf aldı.", c.unstable, b),
|
|
732
|
+
),
|
|
733
|
+
);
|
|
734
|
+
out.push(
|
|
735
|
+
h(
|
|
736
|
+
"p",
|
|
737
|
+
{ class: "aside" },
|
|
738
|
+
`Değişmeyen: ${c.unchanged} çift.`,
|
|
739
|
+
c.holdoutChanged > 0 ? ` Holdout'ta değişen: ${c.holdoutChanged} çift (ayrıntı gizli).` : "",
|
|
740
|
+
),
|
|
741
|
+
);
|
|
742
|
+
return out;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function versusRow(label, ha, hb, key, dKey, a, b) {
|
|
746
|
+
return h(
|
|
747
|
+
"div",
|
|
748
|
+
{ class: "vs-row" },
|
|
749
|
+
h("span", { class: "k" }, label),
|
|
750
|
+
h("span", { class: "vs-cell" }, h("span", { class: "vs-run" }, a), fraction(`${key}-a`, ha[key], ha[dKey])),
|
|
751
|
+
h("span", { class: "arrow", "aria-hidden": "true" }, "→"),
|
|
752
|
+
h("span", { class: "vs-cell" }, h("span", { class: "vs-run" }, b), fraction(`${key}-b`, hb[key], hb[dKey]), delta(hb, ha, key, dKey)),
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
function cmpList(key, title, hint, pairs, run) {
|
|
757
|
+
return h(
|
|
758
|
+
"section",
|
|
759
|
+
{ class: `cmp cmp-${key}`, "data-list": key },
|
|
760
|
+
h("h2", { class: "block-title" }, title, h("span", { class: "count num" }, ` ${pairs.length}`)),
|
|
761
|
+
h("p", { class: "aside" }, hint),
|
|
762
|
+
pairs.length === 0
|
|
763
|
+
? h("p", { class: "muted" }, "Yok.")
|
|
764
|
+
: h("ul", { class: "pair-list" }, pairs.map((p) => h("li", {}, h("a", { href: runHref(run), class: "mono" }, p.id), h("span", { class: "lang" }, p.lang)))),
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// ---- sets --------------------------------------------------------------------------
|
|
769
|
+
|
|
770
|
+
async function screenSets() {
|
|
771
|
+
const sets = await api("/api/sets");
|
|
772
|
+
const out = [pageHead("Yerel çalışma alanı", "Setler", h("p", { class: "lede" }, "Test setleri: sorular, beklenen cevaplar ve anahtar durumu. Holdout maddelerin sorusu burada da gösterilmez."))];
|
|
773
|
+
if (sets.length === 0) {
|
|
774
|
+
out.push(emptyState("Henüz set yok.", "Claude oturumunda bir set oluşturun ya da içe aktarın; set burada görünür."));
|
|
775
|
+
return out;
|
|
776
|
+
}
|
|
777
|
+
out.push(
|
|
778
|
+
h(
|
|
779
|
+
"ul",
|
|
780
|
+
{ class: "set-list" },
|
|
781
|
+
sets.map((s) =>
|
|
782
|
+
h(
|
|
783
|
+
"li",
|
|
784
|
+
{ class: "set-row", "data-set": s.name },
|
|
785
|
+
h("a", { href: setHref(s.name), class: "run-name" }, s.name),
|
|
786
|
+
h("span", { class: "num" }, `${fmtInt(s.items)} madde`),
|
|
787
|
+
h("span", { class: "muted" }, s.langs.join(", ")),
|
|
788
|
+
),
|
|
789
|
+
),
|
|
790
|
+
),
|
|
791
|
+
);
|
|
792
|
+
return out;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
async function screenSet(name) {
|
|
796
|
+
const first = await api(`/api/sets/${enc(name)}?limit=200`);
|
|
797
|
+
const items = [...first.items];
|
|
798
|
+
let next = first.next;
|
|
799
|
+
while (next !== undefined && items.length < 5000) {
|
|
800
|
+
const page = await api(`/api/sets/${enc(name)}?offset=${next}&limit=200`);
|
|
801
|
+
items.push(...page.items);
|
|
802
|
+
next = page.next;
|
|
803
|
+
}
|
|
804
|
+
const s = first.summary;
|
|
805
|
+
const out = [pageHead("Set", name, metaLine([["Madde", fmtInt(s.total)], ["Diller", s.langs.join(", ")], ["İşaretli", fmtInt(s.flagged)]]))];
|
|
806
|
+
|
|
807
|
+
const ks = h(
|
|
808
|
+
"div",
|
|
809
|
+
{ class: "keybar" },
|
|
810
|
+
KEY_STATUS.map(([k, tr]) =>
|
|
811
|
+
h("div", { class: `ks ks-${k}` }, h("span", { class: "k" }, tr), h("span", { class: "v num" }, fmtInt(s.byKeyStatus[k] ?? 0))),
|
|
812
|
+
),
|
|
813
|
+
);
|
|
814
|
+
const subsets = Object.keys(s.bySet).sort().map((k) => [SUBSET_TR[k] ?? k, s.bySet[k]]);
|
|
815
|
+
out.push(
|
|
816
|
+
section(
|
|
817
|
+
"Anahtar durumu",
|
|
818
|
+
ks,
|
|
819
|
+
(s.byKeyStatus.approved ?? 0) < s.total ? h("p", { class: "aside" }, "Onaylı olmayan anahtarla yapılan koşunun raporu “Doğrulanmamış anahtar” damgası taşır.") : null,
|
|
820
|
+
),
|
|
821
|
+
);
|
|
822
|
+
out.push(
|
|
823
|
+
section(
|
|
824
|
+
"Dağılım",
|
|
825
|
+
h(
|
|
826
|
+
"div",
|
|
827
|
+
{ class: "split" },
|
|
828
|
+
countTable("Kategori", Object.entries(s.byCategory).sort(([x], [y]) => x.localeCompare(y)), s.total),
|
|
829
|
+
countTable("Alt set", subsets, s.total),
|
|
830
|
+
),
|
|
831
|
+
),
|
|
832
|
+
);
|
|
833
|
+
|
|
834
|
+
const flagged = items.filter((i) => !i.holdout && (i.key_status === "flagged" || (i.flags && i.flags.length > 0)));
|
|
835
|
+
out.push(
|
|
836
|
+
section(
|
|
837
|
+
"İşaretli maddeler",
|
|
838
|
+
flagged.length === 0
|
|
839
|
+
? h("p", { class: "all-clear" }, "İşaretli madde yok.")
|
|
840
|
+
: h("ul", { class: "item-list" }, flagged.map((i) => itemRow(i, true))),
|
|
841
|
+
),
|
|
842
|
+
);
|
|
843
|
+
out.push(section("Tüm maddeler", h("ul", { class: "item-list" }, items.map((i) => itemRow(i, false)))));
|
|
844
|
+
return out;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function countTable(title, entries, total) {
|
|
848
|
+
if (entries.length === 0) return null;
|
|
849
|
+
return h(
|
|
850
|
+
"table",
|
|
851
|
+
{ class: "data" },
|
|
852
|
+
h("thead", {}, h("tr", {}, h("th", { scope: "col" }, title), h("th", { scope: "col", class: "r" }, "Madde"), h("th", { scope: "col", class: "bar-col" }, h("span", { class: "sr" }, "Pay")))),
|
|
853
|
+
h("tbody", {}, entries.map(([k, n]) => h("tr", {}, h("th", { scope: "row", class: "mono" }, k), h("td", { class: "r num" }, fmtInt(n)), h("td", { class: "bar-col" }, bar(n, total))))),
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function itemRow(i, showFlags) {
|
|
858
|
+
if (i.holdout) {
|
|
859
|
+
return h(
|
|
860
|
+
"li",
|
|
861
|
+
{ class: "item holdout" },
|
|
862
|
+
h("span", { class: "mono" }, i.id),
|
|
863
|
+
h("span", { class: "tag" }, "holdout"),
|
|
864
|
+
i.category ? h("span", { class: "tag" }, i.category) : null,
|
|
865
|
+
h("span", { class: "item-q muted" }, "Soru gizli."),
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
const status = KEY_STATUS.find(([k]) => k === i.key_status);
|
|
869
|
+
const q = i.question ? Object.values(i.question)[0] : "";
|
|
870
|
+
return h(
|
|
871
|
+
"li",
|
|
872
|
+
{ class: "item" },
|
|
873
|
+
h("span", { class: "mono" }, i.id),
|
|
874
|
+
h("span", { class: `ks-badge ks-${i.key_status}` }, status ? status[1] : i.key_status),
|
|
875
|
+
i.category ? h("span", { class: "tag" }, i.category) : null,
|
|
876
|
+
h("span", { class: "tag soft" }, i.kind),
|
|
877
|
+
h("span", { class: "item-q" }, q ?? ""),
|
|
878
|
+
showFlags && i.flags?.length ? h("span", { class: "flags" }, i.flags.map((f) => h("span", { class: "flag mono" }, f))) : null,
|
|
879
|
+
);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// ---- router ------------------------------------------------------------------------
|
|
883
|
+
|
|
884
|
+
function parseHash() {
|
|
885
|
+
const raw = location.hash.replace(/^#\/?/, "");
|
|
886
|
+
const parts = raw.split("/").map((p) => {
|
|
887
|
+
try {
|
|
888
|
+
return decodeURIComponent(p);
|
|
889
|
+
} catch {
|
|
890
|
+
return p;
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
const [screen, x, y] = parts;
|
|
894
|
+
switch (screen) {
|
|
895
|
+
case "run":
|
|
896
|
+
return x ? { nav: "runs", screen: "run", run: () => screenRun(x) } : null;
|
|
897
|
+
case "compare":
|
|
898
|
+
return { nav: "compare", screen: "compare", run: () => screenCompare(x || undefined, y || undefined) };
|
|
899
|
+
case "sets":
|
|
900
|
+
return { nav: "sets", screen: "sets", run: () => screenSets() };
|
|
901
|
+
case "set":
|
|
902
|
+
return x ? { nav: "sets", screen: "set", run: () => screenSet(x) } : null;
|
|
903
|
+
case "runs":
|
|
904
|
+
case "":
|
|
905
|
+
return { nav: "runs", screen: "runs", run: () => screenRuns() };
|
|
906
|
+
default:
|
|
907
|
+
return null;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
let ticket = 0;
|
|
912
|
+
async function render() {
|
|
913
|
+
const mine = ++ticket;
|
|
914
|
+
const route = parseHash() ?? { nav: "runs", screen: "runs", run: () => screenRuns() };
|
|
915
|
+
for (const a of document.querySelectorAll("[data-nav]")) {
|
|
916
|
+
if (a.dataset.nav === route.nav) a.setAttribute("aria-current", "page");
|
|
917
|
+
else a.removeAttribute("aria-current");
|
|
918
|
+
}
|
|
919
|
+
app.removeAttribute("data-ready");
|
|
920
|
+
app.setAttribute("data-screen", route.screen);
|
|
921
|
+
app.setAttribute("aria-busy", "true");
|
|
922
|
+
let nodes;
|
|
923
|
+
try {
|
|
924
|
+
nodes = await route.run();
|
|
925
|
+
} catch (e) {
|
|
926
|
+
nodes = [errorCard(e instanceof Error ? e.message : String(e))];
|
|
927
|
+
}
|
|
928
|
+
if (mine !== ticket) return;
|
|
929
|
+
app.replaceChildren(...nodes.filter(Boolean));
|
|
930
|
+
app.removeAttribute("aria-busy");
|
|
931
|
+
app.setAttribute("data-ready", "");
|
|
932
|
+
window.scrollTo(0, 0);
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
window.addEventListener("hashchange", render);
|
|
936
|
+
render();
|