@action-state-group/capsule-viewer 0.1.0 → 0.4.0
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 +74 -2
- package/dist/alias-interpreters.d.ts +18 -0
- package/dist/alias-interpreters.js +50 -0
- package/dist/alias-interpreters.js.map +1 -0
- package/dist/browser.d.ts +5 -2
- package/dist/browser.js +19 -5
- package/dist/browser.js.map +1 -1
- package/dist/builtin-manifests.d.ts +51 -0
- package/dist/builtin-manifests.js +196 -0
- package/dist/builtin-manifests.js.map +1 -0
- package/dist/chart-dataset.d.ts +23 -0
- package/dist/chart-dataset.js +191 -0
- package/dist/chart-dataset.js.map +1 -0
- package/dist/chart-spec.d.ts +130 -0
- package/dist/chart-spec.js +638 -0
- package/dist/chart-spec.js.map +1 -0
- package/dist/chart-view.d.ts +27 -0
- package/dist/chart-view.js +374 -0
- package/dist/chart-view.js.map +1 -0
- package/dist/compliance-styles.d.ts +1 -8
- package/dist/compliance-styles.js +40 -3
- package/dist/compliance-styles.js.map +1 -1
- package/dist/compliance-view.d.ts +41 -1
- package/dist/compliance-view.js +773 -303
- package/dist/compliance-view.js.map +1 -1
- package/dist/compliance.d.ts +33 -4
- package/dist/compliance.js +92 -13
- package/dist/compliance.js.map +1 -1
- package/dist/composed-styles.d.ts +12 -0
- package/dist/composed-styles.js +20 -0
- package/dist/composed-styles.js.map +1 -0
- package/dist/composed-view.d.ts +1 -1
- package/dist/composed-view.js +9 -2
- package/dist/composed-view.js.map +1 -1
- package/dist/contract-report-wording.d.ts +195 -0
- package/dist/contract-report-wording.js +1177 -0
- package/dist/contract-report-wording.js.map +1 -0
- package/dist/contract-report.d.ts +92 -0
- package/dist/contract-report.js +63 -0
- package/dist/contract-report.js.map +1 -0
- package/dist/core-strip.d.ts +38 -0
- package/dist/core-strip.js +183 -0
- package/dist/core-strip.js.map +1 -0
- package/dist/emitter-shell.html +181 -3
- package/dist/emitter.d.ts +36 -0
- package/dist/emitter.js +77 -4
- package/dist/emitter.js.map +1 -1
- package/dist/evidence-graph-view.d.ts +66 -7
- package/dist/evidence-graph-view.js +1483 -127
- package/dist/evidence-graph-view.js.map +1 -1
- package/dist/evidence-graph.iife.js +17741 -6812
- package/dist/frame-tokens.generated.d.ts +3 -0
- package/dist/frame-tokens.generated.js +5 -0
- package/dist/frame-tokens.generated.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/outcome-report-presentation.d.ts +48 -0
- package/dist/outcome-report-presentation.js +90 -0
- package/dist/outcome-report-presentation.js.map +1 -0
- package/dist/outcome-report-styles.d.ts +1 -16
- package/dist/outcome-report-styles.js +48 -45
- package/dist/outcome-report-styles.js.map +1 -1
- package/dist/outcome-report-view.d.ts +75 -2
- package/dist/outcome-report-view.js +1063 -436
- package/dist/outcome-report-view.js.map +1 -1
- package/dist/presentation-builder.d.ts +70 -6
- package/dist/presentation-builder.js +198 -70
- package/dist/presentation-builder.js.map +1 -1
- package/dist/presentation-fragment.d.ts +129 -0
- package/dist/presentation-fragment.js +213 -0
- package/dist/presentation-fragment.js.map +1 -0
- package/dist/presentation-mount.d.ts +4 -2
- package/dist/presentation-mount.js +2 -1
- package/dist/presentation-mount.js.map +1 -1
- package/dist/presentation-registry.d.ts +277 -0
- package/dist/presentation-registry.js +416 -0
- package/dist/presentation-registry.js.map +1 -0
- package/dist/record-content.d.ts +68 -0
- package/dist/record-content.js +153 -0
- package/dist/record-content.js.map +1 -0
- package/dist/record-dating.d.ts +10 -0
- package/dist/record-dating.js +76 -0
- package/dist/record-dating.js.map +1 -0
- package/dist/report-front-styles.d.ts +9 -0
- package/dist/report-front-styles.js +43 -0
- package/dist/report-front-styles.js.map +1 -0
- package/dist/report-front.d.ts +56 -0
- package/dist/report-front.js +140 -0
- package/dist/report-front.js.map +1 -0
- package/dist/report-levels.d.ts +238 -0
- package/dist/report-levels.js +874 -0
- package/dist/report-levels.js.map +1 -0
- package/dist/report-provenance.d.ts +111 -0
- package/dist/report-provenance.js +535 -0
- package/dist/report-provenance.js.map +1 -0
- package/dist/viewer-build.d.ts +37 -0
- package/dist/viewer-build.js +29 -0
- package/dist/viewer-build.js.map +1 -0
- package/dist/wording/contract-report-eu-ai-act.en.json +319 -0
- package/dist/wording/contract-report-outcomes.en.json +418 -0
- package/package.json +6 -3
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { buildOutcomeReportModel, NOT_STATED, verifyJudgePin, } from "@action-state-group/agent-action-capsule";
|
|
2
2
|
import { OUTCOME_REPORT_CSS } from "./outcome-report-styles.js";
|
|
3
|
+
import { judgedOf, lazyBody, levelToggle, proofList, conversationFold, evidenceAction, ruleWord, wordPill, caseParts, judgeNote, assuranceRow, reportSummary, } from "./report-levels.js";
|
|
3
4
|
import { buildVerificationPageModel } from "@action-state-group/agent-action-capsule";
|
|
5
|
+
import { provenanceLines, renderProvenance } from "./report-provenance.js";
|
|
6
|
+
import { expandableRow, leadWithProvenance, renderCheckYourself, } from "./report-front.js";
|
|
4
7
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* The contract-report module's `lines` grouping (contract-report.ts): a
|
|
9
|
+
* report read as result lines, results rule by rule, day by day and human
|
|
10
|
+
* spot checks, rendered from a verified `ResultRoot`. The Outcomes report is
|
|
11
|
+
* this grouping with the Outcomes wording pack. Drawn by the module in place
|
|
12
|
+
* of `renderResultPage` when the bundle's `outcome-report/v1` extension opts
|
|
13
|
+
* in (see `readOutcomeReportPresentation`) -- after the same verify-first
|
|
14
|
+
* gate every other root family goes through: nothing here ever runs on a
|
|
15
|
+
* bundle that did not verify.
|
|
11
16
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* Every word on it is the wording pack's (`w`); nothing here chooses a word.
|
|
18
|
+
*
|
|
19
|
+
* The card renders into the host's three regions, one `.oi`-classed
|
|
20
|
+
* wrapper in each; the L0 wrapper holds its `<style>` (`OUTCOME_REPORT_CSS`)
|
|
21
|
+
* as its first child. Every selector in that stylesheet is scoped under
|
|
22
|
+
* `.oi`, so it can never affect, or be affected by, the rest of the page
|
|
23
|
+
* (the core's verification section, which opens L2 before the card's own
|
|
24
|
+
* L2 detail, or the generic Result page this bundle opted out of).
|
|
17
25
|
* No external reference of any kind: no `<link>`, no web font, no image.
|
|
18
26
|
*/
|
|
19
27
|
function element(tag, text) {
|
|
@@ -84,102 +92,70 @@ function icon(name) {
|
|
|
84
92
|
return svg;
|
|
85
93
|
}
|
|
86
94
|
const fmtCount = (n) => n.toLocaleString();
|
|
87
|
-
function fmtShare(count, total, percentages) {
|
|
95
|
+
function fmtShare(count, total, percentages, w) {
|
|
88
96
|
if (percentages)
|
|
89
|
-
return total === 0
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
unknown: "tier unknown — no claims observed",
|
|
96
|
-
mixed: "tier differs across conversations",
|
|
97
|
-
};
|
|
98
|
-
const VERDICT_TEXT = {
|
|
99
|
-
met: "met",
|
|
100
|
-
not_met: "not met",
|
|
101
|
-
not_evaluable: "not evaluable",
|
|
102
|
-
failed: "failed verification",
|
|
103
|
-
unsupported: "unsupported",
|
|
104
|
-
not_applicable: "not applicable",
|
|
105
|
-
};
|
|
106
|
-
/** `tau2:airline:task-20:trial-0` reads "task 20"; any other id is shown whole. */
|
|
107
|
-
function caseLabel(conversationId) {
|
|
108
|
-
const match = /task-([0-9]+)/u.exec(conversationId);
|
|
109
|
-
return match === null ? conversationId : `task ${match[1]}`;
|
|
97
|
+
return total === 0
|
|
98
|
+
? "–"
|
|
99
|
+
: w.t("lines.share.percent", {
|
|
100
|
+
p: String(Math.round((count / total) * 100)),
|
|
101
|
+
});
|
|
102
|
+
return w.t("lines.share", { count: fmtCount(count), total: fmtCount(total) });
|
|
110
103
|
}
|
|
111
|
-
|
|
104
|
+
const tierLabel = (tier, w) => w.t(`lines.tier.${tier}`);
|
|
105
|
+
/**
|
|
106
|
+
* A rule's name and wording. The name is the pack's `row.<check>.<rule>.label`
|
|
107
|
+
* when it sets one (contract-report/v1 section 3), else the contract's label.
|
|
108
|
+
*/
|
|
109
|
+
function criterionLabel(model, checkId, criterionId, w) {
|
|
112
110
|
const check = model.terms.checks.find((c) => c.id === checkId);
|
|
113
111
|
const criterion = check?.criteria.find((c) => c.id === criterionId);
|
|
114
112
|
const wording = model.criterionWording.get(`${checkId}.${criterionId}`);
|
|
115
113
|
return {
|
|
116
|
-
label:
|
|
114
|
+
label: w.row(`${checkId}.${criterionId}`, "label") ??
|
|
115
|
+
criterion?.label ??
|
|
116
|
+
`${checkId}.${criterionId}`,
|
|
117
117
|
text: wording?.text ?? criterion?.text ?? "",
|
|
118
118
|
question: check?.question ?? checkId,
|
|
119
119
|
source: wording?.source ?? "unstated",
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
/** The label a criterion's wording carries when it is NOT the sealed text. */
|
|
123
|
-
const
|
|
124
|
-
sealed: "",
|
|
125
|
-
unstated: "Wording not stated: no report in this bundle states it.",
|
|
126
|
-
mixed: "Wording not shown: the reports in this bundle state different wordings.",
|
|
127
|
-
};
|
|
123
|
+
const wordingFallback = (source, w) => w.t(`lines.wording.${source}`);
|
|
128
124
|
/** One sentence on where the criterion wording on this page comes from. */
|
|
129
|
-
function wordingNote(model) {
|
|
130
|
-
const sources = new Set([...model.criterionWording.values()].map((
|
|
125
|
+
function wordingNote(model, w) {
|
|
126
|
+
const sources = new Set([...model.criterionWording.values()].map((c) => c.source));
|
|
131
127
|
if (sources.size === 1 && sources.has("sealed"))
|
|
132
|
-
return "
|
|
128
|
+
return w.t("lines.wording-note.sealed");
|
|
133
129
|
if (!sources.has("sealed"))
|
|
134
|
-
return "
|
|
135
|
-
return "
|
|
130
|
+
return w.t("lines.wording-note.unstated");
|
|
131
|
+
return w.t("lines.wording-note.partly");
|
|
136
132
|
}
|
|
137
133
|
/** The producer's "edited" badge for a criterion, when its presentation
|
|
138
134
|
* extension marks one -- presentation text, titled as such, never evidence. */
|
|
139
|
-
function editedBadge(model, ref) {
|
|
135
|
+
function editedBadge(model, ref, w) {
|
|
140
136
|
const edited = model.options.editedCriteria?.find((e) => e.criterion === ref);
|
|
141
137
|
if (edited === undefined)
|
|
142
138
|
return undefined;
|
|
143
139
|
const badge = el("span", "edited", edited.badge);
|
|
144
140
|
badge.dataset.edited = ref;
|
|
145
|
-
badge.title = "
|
|
141
|
+
badge.title = w.t("lines.edited.title");
|
|
146
142
|
return badge;
|
|
147
143
|
}
|
|
148
|
-
function renderProducerNote(host, model) {
|
|
144
|
+
function renderProducerNote(host, model, w) {
|
|
149
145
|
const note = model.options.producerNote;
|
|
150
146
|
if (note === undefined)
|
|
151
147
|
return;
|
|
152
148
|
const box = el("aside", "pnote");
|
|
153
149
|
box.dataset.producerNote = "true";
|
|
154
|
-
box.append(el("div", "pn-k", "
|
|
150
|
+
box.append(el("div", "pn-k", w.t("lines.producer-note.kicker")));
|
|
155
151
|
box.append(el("h2", "pn-t", note.title));
|
|
156
152
|
const list = el("ul", "pn-l");
|
|
157
153
|
for (const line of note.lines)
|
|
158
154
|
list.append(element("li", line));
|
|
159
155
|
box.append(list);
|
|
160
|
-
box.append(el("p", "pn-src", "
|
|
156
|
+
box.append(el("p", "pn-src", w.t("lines.producer-note.source")));
|
|
161
157
|
host.append(box);
|
|
162
158
|
}
|
|
163
|
-
function isMiss(verdict) {
|
|
164
|
-
return (verdict === "not_met" || verdict === "failed" || verdict === "unsupported");
|
|
165
|
-
}
|
|
166
|
-
function pill(verdict) {
|
|
167
|
-
const text = verdict === "resolved"
|
|
168
|
-
? "resolved"
|
|
169
|
-
: verdict === "missed"
|
|
170
|
-
? "missed"
|
|
171
|
-
: VERDICT_TEXT[verdict];
|
|
172
|
-
const tone = verdict === "met" || verdict === "resolved"
|
|
173
|
-
? "ok"
|
|
174
|
-
: verdict === "not_applicable"
|
|
175
|
-
? "na"
|
|
176
|
-
: verdict === "not_evaluable"
|
|
177
|
-
? "ne"
|
|
178
|
-
: "bad";
|
|
179
|
-
const value = el("span", `pill ${tone}`, text);
|
|
180
|
-
value.dataset.pill = verdict;
|
|
181
|
-
return value;
|
|
182
|
-
}
|
|
183
159
|
const fmtP = (p) => p.toFixed(2);
|
|
184
160
|
/** The probability the judge gave the verdict it returned, from the sealed rationale text; undefined when the text carries none. */
|
|
185
161
|
function verdictProbability(criterion) {
|
|
@@ -189,271 +165,675 @@ function verdictProbability(criterion) {
|
|
|
189
165
|
const key = criterion.claim?.verdict ?? criterion.verdict;
|
|
190
166
|
return probs[key];
|
|
191
167
|
}
|
|
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
|
-
|
|
168
|
+
/** The raw verdict names, kept for the proofs (what the sealed record says). */
|
|
169
|
+
const verdictText = (verdict, w) => w.t(`lines.pf.verdict.${verdict}`);
|
|
170
|
+
/** A rule result the judge returned as not met. A failed or unsupported claim is not one: its verdict was never drawn (see `isUnverified`). */
|
|
171
|
+
function isMiss(verdict) {
|
|
172
|
+
return verdict === "not_met";
|
|
173
|
+
}
|
|
174
|
+
/** A claim that failed verification, or whose cited evidence this bundle does not resolve: the records do not say whether the rule was met or not. */
|
|
175
|
+
function isUnverified(verdict) {
|
|
176
|
+
return verdict === "failed" || verdict === "unsupported";
|
|
177
|
+
}
|
|
178
|
+
/** A rule that did not apply: not applicable, or judged out of scope ("did not arise", Result v0 section 4.2). Never met; out of scope is still counted on its own. */
|
|
179
|
+
function notApplying(verdict) {
|
|
180
|
+
return verdict === "not_applicable" || verdict === "out_of_scope";
|
|
181
|
+
}
|
|
182
|
+
export function conversationStatus(conversation) {
|
|
183
|
+
if (conversation.verdict === "met")
|
|
184
|
+
return "resolved";
|
|
185
|
+
if (conversation.criteria.some((c) => isMiss(c.verdict)))
|
|
186
|
+
return "missed";
|
|
187
|
+
if (conversation.criteria.some((c) => isUnverified(c.verdict)))
|
|
188
|
+
return "unverified";
|
|
189
|
+
if (conversation.verdict === "not_met")
|
|
190
|
+
return "missed";
|
|
191
|
+
return conversation.criteria.length > 0 &&
|
|
192
|
+
conversation.criteria.every((c) => notApplying(c.verdict))
|
|
193
|
+
? "nothing-applied"
|
|
194
|
+
: "undecided";
|
|
195
|
+
}
|
|
196
|
+
// Result words never come from the bundle (presentation contract section
|
|
197
|
+
// 6): they are the card's wording pack's.
|
|
198
|
+
export function statusWord(status, conversation, w) {
|
|
199
|
+
if (status === "resolved")
|
|
200
|
+
return { word: w.t("lines.status.resolved"), tone: "ok" };
|
|
201
|
+
if (status === "missed")
|
|
202
|
+
return { word: w.t("lines.status.missed"), tone: "bad" };
|
|
203
|
+
if (status === "unverified")
|
|
204
|
+
return { word: w.t("lines.status.unverified"), tone: "ne" };
|
|
205
|
+
if (status === "nothing-applied")
|
|
206
|
+
return { word: w.t("lines.status.nothing-applied"), tone: "na" };
|
|
207
|
+
// Three-valued: a judge ran on an undecided rule, none did, or the
|
|
208
|
+
// withheld reports cannot say which. Since e1a44e0 the default pack gives
|
|
209
|
+
// all of these the same plain word ("could not decide"); only the key
|
|
210
|
+
// tells them apart.
|
|
211
|
+
// A `no_claim` rule is undecided with no judge run on it (no claim, so no
|
|
212
|
+
// report): it counts as unjudged.
|
|
213
|
+
const judged = conversation.criteria
|
|
214
|
+
.filter((c) => c.verdict === "not_evaluable" || c.verdict === "no_claim")
|
|
215
|
+
.map((c) => c.verdict === "no_claim"
|
|
216
|
+
? "no"
|
|
217
|
+
: judgedOf(c.reportState, c.judgePinDigest));
|
|
218
|
+
if (judged.includes("yes"))
|
|
219
|
+
return { word: w.t("lines.status.undecided.judged"), tone: "ne" };
|
|
220
|
+
if (judged.length > 0 && judged.every((j) => j === "no"))
|
|
221
|
+
return { word: w.t("lines.status.undecided.unjudged"), tone: "ne" };
|
|
222
|
+
// No rule result at all for this conversation (no not_evaluable criterion
|
|
223
|
+
// to point to a report state): the plain word set's own bare "could not
|
|
224
|
+
// decide", never a report-specific claim this conversation's records
|
|
225
|
+
// don't support.
|
|
226
|
+
if (judged.length === 0)
|
|
227
|
+
return { word: w.t("lines.status.undecided.none"), tone: "ne" };
|
|
228
|
+
// "withheld" only when every report that would say is withheld; a report
|
|
229
|
+
// in the bundle that cannot be read as sealed is never called withheld.
|
|
230
|
+
return judged.every((j) => j === "withheld" || j === "no")
|
|
231
|
+
? { word: w.t("lines.status.undecided.withheld"), tone: "ne" }
|
|
232
|
+
: { word: w.t("lines.status.undecided.unavailable"), tone: "ne" };
|
|
233
|
+
}
|
|
234
|
+
function criterionWord(c, w) {
|
|
235
|
+
// agent-action-capsule 0.8.0's `no_claim` (a missing claim the Result's
|
|
236
|
+
// exclusions do not account for) is a gap that rolls up as not_evaluable,
|
|
237
|
+
// so it takes not_evaluable's words. It carries no claim and so no report:
|
|
238
|
+
// no judge ran on it, which is not_evaluable's unjudged word.
|
|
239
|
+
return c.verdict === "no_claim"
|
|
240
|
+
? ruleWord("not_evaluable", "no", w)
|
|
241
|
+
: ruleWord(c.verdict, judgedOf(c.reportState, c.judgePinDigest), w);
|
|
242
|
+
}
|
|
243
|
+
/** The plain note for a rule whose report carries no rationale: why there is none. */
|
|
244
|
+
function noNoteText(c, w) {
|
|
245
|
+
switch (c.reportState) {
|
|
246
|
+
case "withheld":
|
|
247
|
+
case "mismatch":
|
|
248
|
+
case "unreadable":
|
|
249
|
+
case "invalid":
|
|
250
|
+
return w.t(`lines.no-note.${c.reportState}`);
|
|
251
|
+
default:
|
|
252
|
+
return w.t("lines.no-note.none");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function names(model, list, w) {
|
|
256
|
+
return list
|
|
257
|
+
.map((c) => criterionLabel(model, c.checkId, c.criterionId, w).label)
|
|
258
|
+
.join(", ");
|
|
259
|
+
}
|
|
260
|
+
/** A count in words up to twelve, in digits above. */
|
|
261
|
+
function countWord(n, w) {
|
|
262
|
+
return Number.isInteger(n) && n >= 0 && n <= 12
|
|
263
|
+
? w.t(`lines.count.${n}`)
|
|
264
|
+
: String(n);
|
|
265
|
+
}
|
|
266
|
+
/** The rules whose claim failed verification or whose evidence is missing, as one sentence: their verdict was never drawn. */
|
|
267
|
+
function unverifiedClause(model, list, w, lower = false) {
|
|
268
|
+
const failed = list.filter((c) => c.verdict === "failed");
|
|
269
|
+
const unsupported = list.filter((c) => c.verdict === "unsupported");
|
|
270
|
+
const parts = [];
|
|
271
|
+
if (failed.length > 0)
|
|
272
|
+
parts.push(w.t("lines.sentence.unverified.failed", {
|
|
273
|
+
names: names(model, failed, w),
|
|
225
274
|
}));
|
|
226
|
-
|
|
227
|
-
|
|
275
|
+
if (unsupported.length > 0)
|
|
276
|
+
parts.push(w.t("lines.sentence.unverified.unsupported", {
|
|
277
|
+
names: names(model, unsupported, w),
|
|
278
|
+
}));
|
|
279
|
+
const text = `${parts.join(", and ")}, so the records do not say whether ${w.p("lines.word.that-rule-was", list.length)} met.`;
|
|
280
|
+
return lower ? text : text.charAt(0).toUpperCase() + text.slice(1);
|
|
228
281
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
282
|
+
/** One plain sentence: the conversation's result and the rules behind it. */
|
|
283
|
+
function resultSentence(conversation, model, w) {
|
|
284
|
+
const all = conversation.criteria;
|
|
285
|
+
const applied = all.filter((c) => !notApplying(c.verdict));
|
|
286
|
+
const outOfScope = all.filter((c) => c.verdict === "out_of_scope").length;
|
|
287
|
+
const na = all.length - applied.length - outOfScope;
|
|
288
|
+
const misses = all.filter((c) => isMiss(c.verdict));
|
|
289
|
+
const unverified = all.filter((c) => isUnverified(c.verdict));
|
|
290
|
+
// Undecided rules a judge could not decide, and gaps (`no_claim`): rules
|
|
291
|
+
// the Result holds no claim for, which no judge ran on.
|
|
292
|
+
const undecided = all.filter((c) => c.verdict === "not_evaluable");
|
|
293
|
+
const gaps = all.filter((c) => c.verdict === "no_claim");
|
|
294
|
+
const gapNote = gaps.length > 0
|
|
295
|
+
? w.t("lines.sentence.undecided.gap-note", {
|
|
296
|
+
names: names(model, gaps, w),
|
|
297
|
+
})
|
|
298
|
+
: "";
|
|
299
|
+
const naText = `${na > 0 ? ` ${w.t("lines.sentence.na", { n: String(na) })}` : ""}${outOfScope > 0
|
|
300
|
+
? ` ${w.t("lines.sentence.out-of-scope", { n: String(outOfScope) })}`
|
|
301
|
+
: ""}`;
|
|
302
|
+
const unverifiedText = unverified.length > 0 ? ` ${unverifiedClause(model, unverified, w)}` : "";
|
|
303
|
+
switch (conversationStatus(conversation)) {
|
|
304
|
+
case "resolved":
|
|
305
|
+
return `${w.p("lines.sentence.resolved", applied.length, { n: String(applied.length) })}${naText}`;
|
|
306
|
+
case "missed":
|
|
307
|
+
return `${w.t("lines.sentence.missed", {
|
|
308
|
+
misses: String(misses.length),
|
|
309
|
+
applied: String(applied.length),
|
|
310
|
+
rule: w.p("lines.word.rule", applied.length),
|
|
311
|
+
was: w.p("lines.word.was", misses.length),
|
|
312
|
+
names: names(model, misses, w),
|
|
313
|
+
})}${unverifiedText}${naText}`;
|
|
314
|
+
case "unverified":
|
|
315
|
+
return `${w.t("lines.sentence.unverified", {
|
|
316
|
+
clause: unverifiedClause(model, unverified, w, true),
|
|
317
|
+
undecidedNote: `${undecided.length > 0
|
|
318
|
+
? w.t("lines.sentence.unverified.undecided-note", {
|
|
319
|
+
names: names(model, undecided, w),
|
|
320
|
+
})
|
|
321
|
+
: ""}${gapNote}`,
|
|
322
|
+
})}${naText}`;
|
|
323
|
+
case "undecided":
|
|
324
|
+
return undecided.length > 0
|
|
325
|
+
? `${w.t("lines.sentence.undecided", {
|
|
326
|
+
names: names(model, undecided, w),
|
|
327
|
+
thatRuleWas: w.p("lines.word.that-rule-was", undecided.length),
|
|
328
|
+
})}${gapNote}${naText}`
|
|
329
|
+
: gaps.length > 0
|
|
330
|
+
? `${w.t("lines.sentence.undecided.gaps", {
|
|
331
|
+
names: names(model, gaps, w),
|
|
332
|
+
})}${naText}`
|
|
333
|
+
: w.t("lines.sentence.undecided.none");
|
|
334
|
+
case "nothing-applied":
|
|
335
|
+
return w.t("lines.sentence.nothing-applied");
|
|
238
336
|
}
|
|
239
|
-
wrap.append(el("p", "small", `Sealed in record ${t.transcriptRecordId}. Its content digest equals what the judged case capsule ${conversation.sourceCapsuleId} committed to (${t.inputDigest}), checked on this page: this is the conversation the judge read. ${t.turns.length} messages, in order.`));
|
|
240
|
-
const list = el("ol", "turns");
|
|
241
|
-
t.turns.forEach((turn, index) => {
|
|
242
|
-
const item = el("li", `turn ${turn.role === "user" || turn.role === "assistant" || turn.role === "tool" ? turn.role : "other"}`);
|
|
243
|
-
item.dataset.turn = String(index);
|
|
244
|
-
item.dataset.role = turn.role;
|
|
245
|
-
const head = el("div", "who", `msg[${index}] ${turn.role}`);
|
|
246
|
-
item.append(head);
|
|
247
|
-
if (turn.content !== undefined && turn.content.length > 0)
|
|
248
|
-
item.append(el(turn.role === "tool" ? "pre" : "div", "say", turn.content));
|
|
249
|
-
for (const call of turn.toolCalls) {
|
|
250
|
-
const callEl = el("pre", "call", `${call.name}(${call.arguments})`);
|
|
251
|
-
callEl.dataset.toolCall = call.name;
|
|
252
|
-
item.append(callEl);
|
|
253
|
-
}
|
|
254
|
-
list.append(item);
|
|
255
|
-
});
|
|
256
|
-
wrap.append(list);
|
|
257
|
-
return wrap;
|
|
258
337
|
}
|
|
259
|
-
|
|
260
|
-
|
|
338
|
+
/**
|
|
339
|
+
* One conversation, in place inside a level-1 toggle: a header line (case,
|
|
340
|
+
* result, why, model) and its body right below it, never a toggle of its
|
|
341
|
+
* own. The body is built when it scrolls near the view (`lazyBody`).
|
|
342
|
+
*/
|
|
343
|
+
function renderConversation(conversation, model, runInfo, w) {
|
|
344
|
+
const status = conversationStatus(conversation);
|
|
345
|
+
const item = el("article", "conv");
|
|
346
|
+
item.dataset.conversation = conversation.conversationId;
|
|
347
|
+
item.dataset.conversationVerdict = conversation.verdict;
|
|
348
|
+
item.dataset.status = status;
|
|
349
|
+
const head = el("div", "conv-h");
|
|
350
|
+
const parts = caseParts(conversation.conversationId, w);
|
|
351
|
+
head.append(el("span", "cid", parts.label));
|
|
352
|
+
head.append(wordPill(statusWord(status, conversation, w), status));
|
|
353
|
+
const misses = conversation.criteria.filter((c) => isMiss(c.verdict));
|
|
354
|
+
const unverified = conversation.criteria.filter((c) => isUnverified(c.verdict));
|
|
355
|
+
const undecided = conversation.criteria.filter((c) => c.verdict === "not_evaluable" || c.verdict === "no_claim");
|
|
356
|
+
const outOfScope = conversation.criteria.filter((c) => c.verdict === "out_of_scope");
|
|
357
|
+
head.append(el("span", "cwhy", status === "missed"
|
|
358
|
+
? w.t("lines.why.missed", { names: names(model, misses, w) })
|
|
359
|
+
: status === "unverified"
|
|
360
|
+
? w.t("lines.why.unverified", { names: names(model, unverified, w) })
|
|
361
|
+
: status === "undecided"
|
|
362
|
+
? undecided.length === 0
|
|
363
|
+
? w.t("lines.why.undecided.none")
|
|
364
|
+
: w.t("lines.why.undecided", {
|
|
365
|
+
names: names(model, undecided, w),
|
|
366
|
+
})
|
|
367
|
+
: status === "nothing-applied"
|
|
368
|
+
? w.t("lines.why.nothing-applied")
|
|
369
|
+
: outOfScope.length === 0
|
|
370
|
+
? w.t("lines.why.resolved")
|
|
371
|
+
: w.p("lines.why.resolved-out-of-scope", conversation.criteria.length - outOfScope.length, {
|
|
372
|
+
n: fmtCount(conversation.criteria.length - outOfScope.length),
|
|
373
|
+
oos: fmtCount(outOfScope.length),
|
|
374
|
+
})));
|
|
375
|
+
head.append(el("span", "cmodel", parts.model ?? ""));
|
|
376
|
+
item.append(head);
|
|
377
|
+
const body = el("div", "conv-slot");
|
|
378
|
+
item.append(body);
|
|
379
|
+
lazyBody(body, () => conversationBody(conversation, model, runInfo, w));
|
|
380
|
+
return item;
|
|
381
|
+
}
|
|
382
|
+
function conversationBody(conversation, model, runInfo, w) {
|
|
261
383
|
const body = el("div", "conv-b");
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
body.append(
|
|
265
|
-
//
|
|
266
|
-
body.append(el("h4", "", "
|
|
267
|
-
|
|
268
|
-
|
|
384
|
+
const sentence = el("p", "verdict-line", resultSentence(conversation, model, w));
|
|
385
|
+
sentence.dataset.why = conversationStatus(conversation);
|
|
386
|
+
body.append(sentence);
|
|
387
|
+
// Rule by rule, in plain words
|
|
388
|
+
body.append(el("h4", "", w.t("lines.h.rule-by-rule")));
|
|
389
|
+
// The judge's notes and the rule wording are shown per rule only when the
|
|
390
|
+
// bundle carries them; otherwise one line says so, not one per rule.
|
|
391
|
+
const hasNotes = conversation.criteria.some((c) => c.rationale !== undefined);
|
|
392
|
+
const wordings = conversation.criteria.map((c) => criterionLabel(model, c.checkId, c.criterionId, w).source);
|
|
393
|
+
const anyWording = wordings.some((source) => source === "sealed");
|
|
269
394
|
const table = el("table", "crit");
|
|
270
395
|
table.dataset.criteriaTable = conversation.conversationId;
|
|
271
396
|
const head = element("thead");
|
|
272
397
|
const headRow = element("tr");
|
|
273
|
-
headRow.append(element("th",
|
|
398
|
+
headRow.append(element("th", w.t("lines.col.rule")), element("th", w.t("lines.col.result")));
|
|
399
|
+
if (hasNotes)
|
|
400
|
+
headRow.append(element("th", w.t("lines.col.note")));
|
|
274
401
|
head.append(headRow);
|
|
275
402
|
table.append(head);
|
|
276
403
|
const tbody = element("tbody");
|
|
277
404
|
for (const criterion of conversation.criteria) {
|
|
405
|
+
const ref = `${criterion.checkId}.${criterion.criterionId}`;
|
|
278
406
|
const tr = element("tr");
|
|
279
|
-
tr.dataset.crit =
|
|
407
|
+
tr.dataset.crit = ref;
|
|
280
408
|
tr.dataset.critVerdict = criterion.verdict;
|
|
281
|
-
const
|
|
409
|
+
const label = criterionLabel(model, criterion.checkId, criterion.criterionId, w);
|
|
282
410
|
const nameCell = el("td", "cn");
|
|
283
|
-
nameCell.append(el("b", "",
|
|
284
|
-
const rowBadge = editedBadge(model,
|
|
411
|
+
nameCell.append(el("b", "", label.label));
|
|
412
|
+
const rowBadge = editedBadge(model, ref, w);
|
|
285
413
|
if (rowBadge !== undefined)
|
|
286
414
|
nameCell.append(rowBadge);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
415
|
+
if (label.source === "sealed") {
|
|
416
|
+
const wording = el("small", "", label.text);
|
|
417
|
+
wording.dataset.wording = label.source;
|
|
418
|
+
nameCell.append(wording);
|
|
419
|
+
}
|
|
420
|
+
else if (anyWording) {
|
|
421
|
+
const wording = el("small", "wsrc", wordingFallback(label.source, w));
|
|
422
|
+
wording.dataset.wording = label.source;
|
|
423
|
+
nameCell.append(wording);
|
|
424
|
+
}
|
|
292
425
|
tr.append(nameCell);
|
|
293
426
|
const verdictCell = element("td");
|
|
294
|
-
verdictCell.append(
|
|
427
|
+
verdictCell.append(wordPill(criterionWord(criterion, w), criterion.verdict));
|
|
295
428
|
tr.append(verdictCell);
|
|
429
|
+
if (!hasNotes) {
|
|
430
|
+
tbody.append(tr);
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
const noteCell = el("td", "rat");
|
|
434
|
+
if (criterion.verdict === "not_applicable")
|
|
435
|
+
noteCell.append(el("span", "muted", w.t("lines.note.not-applicable")));
|
|
436
|
+
else if (criterion.rationale !== undefined)
|
|
437
|
+
noteCell.append(el("span", "sealed", judgeNote(criterion.rationale, criterion.claim?.verdict ?? criterion.verdict, w)));
|
|
438
|
+
else
|
|
439
|
+
noteCell.append(el("span", "muted", noNoteText(criterion, w)));
|
|
440
|
+
tr.append(noteCell);
|
|
441
|
+
tbody.append(tr);
|
|
442
|
+
}
|
|
443
|
+
table.append(tbody);
|
|
444
|
+
const scroll = el("div", "tscroll");
|
|
445
|
+
scroll.append(table);
|
|
446
|
+
body.append(scroll);
|
|
447
|
+
const gaps = [];
|
|
448
|
+
if (!anyWording)
|
|
449
|
+
gaps.push(w.t(wordings.includes("mixed")
|
|
450
|
+
? "lines.gap.wording.mixed"
|
|
451
|
+
: "lines.gap.wording.none"));
|
|
452
|
+
if (!hasNotes)
|
|
453
|
+
gaps.push(notesGap(conversation.criteria.flatMap((c) => c.claim === undefined ? [] : [c.reportState]), w));
|
|
454
|
+
if (gaps.length > 0) {
|
|
455
|
+
const gap = el("p", "small", gaps.join(" "));
|
|
456
|
+
gap.dataset.gaps = "true";
|
|
457
|
+
body.append(gap);
|
|
458
|
+
}
|
|
459
|
+
// The conversation itself
|
|
460
|
+
body.append(conversationFold(conversation.transcript, conversation.sourceCapsuleId, w));
|
|
461
|
+
// Toggle 2: the proofs
|
|
462
|
+
body.append(levelToggle(2, w.t("card.proofs.toggle"), () => conversationProofs(conversation, model, runInfo, w), { className: "proofs" }));
|
|
463
|
+
return body;
|
|
464
|
+
}
|
|
465
|
+
/** Why a conversation or session shows no judge's notes, from its reports' states. */
|
|
466
|
+
export function notesGap(states, w) {
|
|
467
|
+
const set = new Set(states);
|
|
468
|
+
return w.t(set.size === 1 && set.has("withheld")
|
|
469
|
+
? "card.gap.notes.withheld"
|
|
470
|
+
: set.has("mismatch") || set.has("unreadable") || set.has("invalid")
|
|
471
|
+
? "card.gap.notes.unread"
|
|
472
|
+
: set.has("withheld")
|
|
473
|
+
? "card.gap.notes.some-withheld"
|
|
474
|
+
: "card.gap.notes.none");
|
|
475
|
+
}
|
|
476
|
+
/** The proofs rows for a case's transcript, shared by both groupings. */
|
|
477
|
+
export function transcriptRows(t, w) {
|
|
478
|
+
if (t.state === "verified")
|
|
479
|
+
return [
|
|
480
|
+
[w.t("card.pf.transcript-record"), t.transcriptRecordId],
|
|
481
|
+
[
|
|
482
|
+
w.t("card.pf.input-digest"),
|
|
483
|
+
w.t("card.pf.input-digest.verified", { digest: t.inputDigest }),
|
|
484
|
+
],
|
|
485
|
+
];
|
|
486
|
+
if (t.state === "cited")
|
|
487
|
+
return [
|
|
488
|
+
[w.t("card.pf.transcript-record"), t.transcriptRecordId],
|
|
489
|
+
[
|
|
490
|
+
w.t("card.pf.input-digest"),
|
|
491
|
+
w.t("card.pf.input-digest.cited", { digest: t.inputDigest }),
|
|
492
|
+
],
|
|
493
|
+
];
|
|
494
|
+
return [
|
|
495
|
+
[
|
|
496
|
+
w.t("card.pf.transcript"),
|
|
497
|
+
t.state === "absent"
|
|
498
|
+
? w.t("card.pf.transcript.absent")
|
|
499
|
+
: w.t("card.pf.transcript.not-shown", {
|
|
500
|
+
reason: t.reason ?? w.t("card.pf.transcript.default-reason"),
|
|
501
|
+
}),
|
|
502
|
+
],
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
/** How a case is dated, in the proofs: the date as given, its zone, and the basis. */
|
|
506
|
+
export function datedText(dated, w) {
|
|
507
|
+
return w.t(dated.zone === "not-stated" ? "card.pf.dated.no-zone" : "card.pf.dated", { date: dated.stated ?? dated.date, basis: basisText(dated.basis, w) });
|
|
508
|
+
}
|
|
509
|
+
function conversationProofs(conversation, model, runInfo, w) {
|
|
510
|
+
const box = el("div", "pf-b");
|
|
511
|
+
box.dataset.proofsFor = conversation.conversationId;
|
|
512
|
+
const rows = [];
|
|
513
|
+
rows.push([w.t("lines.pf.case"), conversation.conversationId]);
|
|
514
|
+
rows.push([
|
|
515
|
+
w.t("card.pf.case-record"),
|
|
516
|
+
conversation.sourceCapsuleId === undefined
|
|
517
|
+
? w.t("card.pf.case-record.not-stated")
|
|
518
|
+
: conversation.caseFrom === "claims"
|
|
519
|
+
? w.t("lines.pf.case-record.from-claims", {
|
|
520
|
+
record: conversation.sourceCapsuleId,
|
|
521
|
+
})
|
|
522
|
+
: conversation.sourceCapsuleId,
|
|
523
|
+
]);
|
|
524
|
+
const dated = conversation.dated;
|
|
525
|
+
if (dated.basis !== "judged") {
|
|
526
|
+
rows.push([
|
|
527
|
+
w.t("lines.pf.dated-by"),
|
|
528
|
+
datedText(dated, w),
|
|
529
|
+
{ dated: dated.basis },
|
|
530
|
+
]);
|
|
531
|
+
if (dated.importedAt !== undefined)
|
|
532
|
+
rows.push([w.t("card.pf.imported"), dated.importedAt]);
|
|
533
|
+
rows.push([w.t("card.pf.judged-sealed"), conversation.judgedDay]);
|
|
534
|
+
}
|
|
535
|
+
rows.push([w.t("card.pf.result-capsule"), model.capsuleId]);
|
|
536
|
+
rows.push(...transcriptRows(conversation.transcript, w));
|
|
537
|
+
rows.push([
|
|
538
|
+
w.t("lines.pf.judge-pin"),
|
|
539
|
+
runInfo.judgePinDigest === undefined
|
|
540
|
+
? pinNotShown(runInfo, w)
|
|
541
|
+
: runInfo.judgePinRecomputes === true && runInfo.judgePin !== undefined
|
|
542
|
+
? w.t("lines.pf.judge-pin.recomputed", {
|
|
543
|
+
digest: runInfo.judgePinDigest,
|
|
544
|
+
model: runInfo.judgePin.modelId,
|
|
545
|
+
prompt: runInfo.judgePin.promptDigest,
|
|
546
|
+
axes: runInfo.judgePin.axesDigest,
|
|
547
|
+
})
|
|
548
|
+
: runInfo.judgePinDigest,
|
|
549
|
+
]);
|
|
550
|
+
const dl = proofList(rows);
|
|
551
|
+
dl.dataset.checkIt = conversation.conversationId;
|
|
552
|
+
box.append(dl);
|
|
553
|
+
box.append(el("h5", "", w.t("lines.pf.h.each-report")));
|
|
554
|
+
const table = el("table", "crit pft");
|
|
555
|
+
const head = element("thead");
|
|
556
|
+
const headRow = element("tr");
|
|
557
|
+
headRow.append(element("th", w.t("lines.pf.col.rule")), element("th", w.t("lines.pf.col.verdict")), el("th", "n", w.t("lines.pf.col.p")), element("th", w.t("lines.pf.col.report")), element("th", w.t("lines.pf.col.rationale")), element("th", w.t("card.pf.assurance")));
|
|
558
|
+
head.append(headRow);
|
|
559
|
+
table.append(head);
|
|
560
|
+
const tbody = element("tbody");
|
|
561
|
+
for (const criterion of conversation.criteria) {
|
|
562
|
+
const tr = element("tr");
|
|
563
|
+
tr.dataset.proofCrit = `${criterion.checkId}.${criterion.criterionId}`;
|
|
564
|
+
// The sealed verdict as data, whatever the pack's word for it.
|
|
565
|
+
tr.dataset.verdict = criterion.verdict;
|
|
566
|
+
tr.append(element("td", criterionLabel(model, criterion.checkId, criterion.criterionId, w)
|
|
567
|
+
.label), element("td", verdictText(criterion.verdict, w)));
|
|
296
568
|
const p = verdictProbability(criterion);
|
|
297
569
|
const pCell = el("td", "n", p === undefined ? "–" : fmtP(p));
|
|
298
570
|
if (p !== undefined)
|
|
299
571
|
pCell.dataset.p = fmtP(p);
|
|
300
572
|
tr.append(pCell);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
573
|
+
tr.append(el("td", "mono", criterion.claim === undefined
|
|
574
|
+
? w.t("lines.pf.no-claim")
|
|
575
|
+
: `${criterion.reportCapsuleId ?? w.t("lines.pf.not-cited")}${criterion.reportRecordId === undefined ? "" : ` (${criterion.reportRecordId})`}`));
|
|
576
|
+
const rationale = el("td", "rat");
|
|
577
|
+
if (criterion.rationale !== undefined) {
|
|
306
578
|
const sealed = el("code", "sealed", criterion.rationale);
|
|
307
579
|
sealed.dataset.rationale = "sealed";
|
|
308
|
-
|
|
580
|
+
rationale.append(sealed);
|
|
309
581
|
}
|
|
582
|
+
else
|
|
583
|
+
rationale.append(el("span", "muted", "–"));
|
|
584
|
+
tr.append(rationale);
|
|
585
|
+
// contract-report/v1 section 2: assurance stays on the claim.
|
|
586
|
+
if (criterion.claim === undefined)
|
|
587
|
+
tr.append(el("td", "muted", "–"));
|
|
310
588
|
else {
|
|
311
|
-
|
|
589
|
+
const [, text, data] = assuranceRow(criterion.claim, w);
|
|
590
|
+
const cell = element("td", text);
|
|
591
|
+
for (const [key, value] of Object.entries(data))
|
|
592
|
+
cell.dataset[key] = value;
|
|
593
|
+
tr.append(cell);
|
|
312
594
|
}
|
|
313
|
-
tr.append(rationaleCell);
|
|
314
595
|
tbody.append(tr);
|
|
315
596
|
}
|
|
316
597
|
table.append(tbody);
|
|
317
598
|
const scroll = el("div", "tscroll");
|
|
318
599
|
scroll.append(table);
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
else {
|
|
332
|
-
for (const criterion of misses.length > 0 ? misses : unjudged) {
|
|
333
|
-
const names = criterionLabel(model, criterion.checkId, criterion.criterionId);
|
|
334
|
-
const p = verdictProbability(criterion);
|
|
335
|
-
const item = element("li", `${names.label} (${names.question}): ${VERDICT_TEXT[criterion.verdict]}${p === undefined ? "" : `, P ${fmtP(p)}`}${criterion.confidence === undefined ? "" : `, confidence ${fmtP(criterion.confidence)}`}.`);
|
|
336
|
-
item.dataset.whyCriterion = `${criterion.checkId}.${criterion.criterionId}`;
|
|
337
|
-
why.append(item);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
why.append(el("li", "muted", "Turns cited: none. The judge returns a verdict and probabilities per criterion, with no reference to any turn of the conversation."));
|
|
341
|
-
body.append(why);
|
|
342
|
-
// 4. Check it
|
|
343
|
-
body.append(el("h4", "", "Check it"));
|
|
344
|
-
const check = el("dl", "chk");
|
|
345
|
-
check.dataset.checkIt = conversation.conversationId;
|
|
346
|
-
const row = (label, value) => {
|
|
347
|
-
check.append(element("dt", label), element("dd", value));
|
|
348
|
-
};
|
|
349
|
-
row("Case", conversation.conversationId);
|
|
350
|
-
row("Case record", conversation.sourceCapsuleId ?? "not stated by the reports");
|
|
351
|
-
// A conversation dated by its judged day (no case record date) adds no
|
|
352
|
-
// rows: the page reads exactly as it did before record dating.
|
|
353
|
-
const dated = conversation.dated;
|
|
354
|
-
if (dated.basis !== "judged") {
|
|
355
|
-
row("Dated by", `${dated.stated ?? dated.date}${dated.zone === "not-stated" ? " (timezone not stated)" : ""}: ${BASIS_TEXT[dated.basis]}`);
|
|
356
|
-
check.lastElementChild.setAttribute("data-dated", dated.basis);
|
|
357
|
-
if (dated.importedAt !== undefined)
|
|
358
|
-
row("Imported", dated.importedAt);
|
|
359
|
-
row("Judged and sealed", conversation.judgedDay);
|
|
360
|
-
}
|
|
361
|
-
row("Result capsule", model.capsuleId);
|
|
362
|
-
if (conversation.transcript.state === "verified") {
|
|
363
|
-
row("Transcript record", conversation.transcript.transcriptRecordId);
|
|
364
|
-
row("Case input digest", conversation.transcript.inputDigest);
|
|
600
|
+
box.append(scroll);
|
|
601
|
+
// "Derived from its probabilities" holds only when every sealed rationale
|
|
602
|
+
// is the judge backend's own synthesized line; any other rationale is
|
|
603
|
+
// shown as sealed, and `judgeNote` passes it through unchanged.
|
|
604
|
+
const rationales = conversation.criteria
|
|
605
|
+
.map((c) => c.rationale)
|
|
606
|
+
.filter((r) => r !== undefined);
|
|
607
|
+
if (rationales.length > 0 &&
|
|
608
|
+
rationales.every((r) => /^jev choice:/u.test(r))) {
|
|
609
|
+
const derived = el("p", "", w.t("lines.pf.derived"));
|
|
610
|
+
derived.dataset.rationaleLabel = "derived";
|
|
611
|
+
box.append(derived);
|
|
365
612
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (criterion.claim === undefined)
|
|
371
|
-
continue;
|
|
372
|
-
row(`Report: ${criterionLabel(model, criterion.checkId, criterion.criterionId).label}`, `${criterion.reportCapsuleId ?? "not cited"}${criterion.reportRecordId === undefined ? "" : ` (book record ${criterion.reportRecordId})`}`);
|
|
613
|
+
else if (rationales.length > 0) {
|
|
614
|
+
const shown = el("p", "", w.t("lines.pf.sealed-rationale"));
|
|
615
|
+
shown.dataset.rationaleLabel = "sealed";
|
|
616
|
+
box.append(shown);
|
|
373
617
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
618
|
+
box.append(el("p", "", w.t("lines.pf.recompute", {
|
|
619
|
+
verdicts: w.p("lines.pf.verdicts", conversation.criteria.length, {
|
|
620
|
+
n: countWord(conversation.criteria.length, w),
|
|
621
|
+
}),
|
|
622
|
+
})));
|
|
623
|
+
return box;
|
|
377
624
|
}
|
|
378
|
-
|
|
625
|
+
/**
|
|
626
|
+
* The reasons a judge pin is not in the bundle, shared by both groupings:
|
|
627
|
+
* withheld reports are not the same as an unstated pin, and a mismatched
|
|
628
|
+
* report is neither. Empty when there is no such reason.
|
|
629
|
+
*/
|
|
630
|
+
export function pinAbsence(info, w) {
|
|
631
|
+
const unread = (info.reportsMismatched ?? 0) +
|
|
632
|
+
(info.reportsUnreadable ?? 0) +
|
|
633
|
+
(info.reportsInvalid ?? 0);
|
|
634
|
+
const cited = fmtCount(info.reportsCited ?? 0);
|
|
635
|
+
const parts = [];
|
|
636
|
+
if (info.reportsWithheld !== undefined)
|
|
637
|
+
parts.push(w.t("card.pin.withheld", {
|
|
638
|
+
count: fmtCount(info.reportsWithheld),
|
|
639
|
+
total: cited,
|
|
640
|
+
}));
|
|
641
|
+
if (unread > 0)
|
|
642
|
+
parts.push(w.t("card.pin.unread", { count: fmtCount(unread), total: cited }));
|
|
643
|
+
return parts.length === 0
|
|
644
|
+
? undefined
|
|
645
|
+
: w.t("card.pin.not-in-bundle", { reasons: parts.join("; ") });
|
|
646
|
+
}
|
|
647
|
+
/** What a page says when no judge pin is drawn. */
|
|
648
|
+
function pinNotShown(runInfo, w) {
|
|
649
|
+
if (!runInfo.pinned)
|
|
650
|
+
return w.t("lines.pin.differs");
|
|
651
|
+
return pinAbsence(runInfo, w) ?? w.t("lines.pin.not-stated");
|
|
652
|
+
}
|
|
653
|
+
function renderConversationList(conversations, model, runInfo, key, w) {
|
|
379
654
|
const list = el("div", "convs");
|
|
380
655
|
list.dataset.conversationsFor = key;
|
|
381
656
|
list.dataset.conversationCount = String(conversations.length);
|
|
382
657
|
if (conversations.length === 0)
|
|
383
|
-
list.append(el("p", "small", "
|
|
658
|
+
list.append(el("p", "small", w.t("lines.list.empty")));
|
|
384
659
|
for (const conversation of conversations)
|
|
385
|
-
list.append(renderConversation(conversation, model, runInfo));
|
|
660
|
+
list.append(renderConversation(conversation, model, runInfo, w));
|
|
386
661
|
return list;
|
|
387
662
|
}
|
|
388
|
-
|
|
389
|
-
|
|
663
|
+
/** Toggle 1 on a summary line: the conversations behind it, listed in place, built on open. */
|
|
664
|
+
function drill(label, build, key) {
|
|
665
|
+
const details = levelToggle(1, label, build, { className: "line" });
|
|
390
666
|
details.dataset.drill = key;
|
|
391
|
-
details.append(el("summary", "", label));
|
|
392
|
-
details.append(renderConversationList(conversations, model, runInfo, key));
|
|
393
667
|
return details;
|
|
394
668
|
}
|
|
669
|
+
function conversationsDrill(label, conversations, model, runInfo, key, w) {
|
|
670
|
+
return drill(label, () => renderConversationList(conversations, model, runInfo, key, w), key);
|
|
671
|
+
}
|
|
672
|
+
/** A criterion's label for a missed-reason group, from the terms; the id itself when the terms don't name it. */
|
|
673
|
+
function missedReasonLabel(terms, checkId, criterionId, w) {
|
|
674
|
+
const check = terms.checks.find((c) => c.id === checkId);
|
|
675
|
+
const criterion = check?.criteria.find((c) => c.id === criterionId);
|
|
676
|
+
return check === undefined || criterion === undefined
|
|
677
|
+
? `${checkId}.${criterionId}`
|
|
678
|
+
: `${w?.row(`${checkId}.${criterionId}`, "label") ?? criterion.label} (${w === undefined ? check.question : groupTitle(check, w)})`;
|
|
679
|
+
}
|
|
680
|
+
/** A rule group's heading: the pack's `group.<check>.title` when it sets one (contract-report/v1 section 3), else the contract's question. */
|
|
681
|
+
function groupTitle(check, w) {
|
|
682
|
+
return w.group(check.id) ?? check.question;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Group missed conversations by THIS view's own reason: the first criterion
|
|
686
|
+
* where `isMiss` is true -- never AAC's `missedReasonGroups`, whose notion of
|
|
687
|
+
* "missed" still includes `failed`/`unsupported` (0.5.0's `missedReasonGroups`
|
|
688
|
+
* picks the first not_met/failed/unsupported criterion in criteria order, so
|
|
689
|
+
* a conversation with [c1 failed, c2 not_met] files under c1, though this
|
|
690
|
+
* view counts it missed only for c2's sake -- see `isMiss`, `isUnverified`).
|
|
691
|
+
* A reason is the producer's sealed reason code when the terms give it a
|
|
692
|
+
* label (`terms.reasonCodes`), else the first rule not met; a raw code is
|
|
693
|
+
* never shown.
|
|
694
|
+
*/
|
|
695
|
+
export function groupMissedReasons(missed, terms, w) {
|
|
696
|
+
const labelledReasonCode = (code) => code === undefined ? undefined : terms.reasonCodes[code];
|
|
697
|
+
const groups = new Map();
|
|
698
|
+
const structured = new Map();
|
|
699
|
+
const labels = new Map();
|
|
700
|
+
for (const conversation of missed) {
|
|
701
|
+
const first = conversation.criteria.find((c) => isMiss(c.verdict));
|
|
702
|
+
if (first === undefined)
|
|
703
|
+
continue;
|
|
704
|
+
const label = labelledReasonCode(first.reasonCode);
|
|
705
|
+
const key = label !== undefined
|
|
706
|
+
? first.reasonCode
|
|
707
|
+
: `${first.checkId}.${first.criterionId}`;
|
|
708
|
+
const list = groups.get(key) ?? [];
|
|
709
|
+
list.push(conversation);
|
|
710
|
+
groups.set(key, list);
|
|
711
|
+
structured.set(key, label !== undefined);
|
|
712
|
+
labels.set(key, label ?? missedReasonLabel(terms, first.checkId, first.criterionId, w));
|
|
713
|
+
}
|
|
714
|
+
return [...groups.entries()]
|
|
715
|
+
.map(([key, conversations]) => ({
|
|
716
|
+
key,
|
|
717
|
+
label: labels.get(key),
|
|
718
|
+
structured: structured.get(key),
|
|
719
|
+
conversations,
|
|
720
|
+
}))
|
|
721
|
+
.sort((a, b) => b.conversations.length - a.conversations.length);
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* The missed line's toggle: why conversations missed, then the missed
|
|
725
|
+
* conversations under each reason, in place. A reason is the producer's
|
|
726
|
+
* sealed reason code when the terms give it a label (`terms.reasonCodes`),
|
|
727
|
+
* else the first rule not met; a raw code is never shown. Content of the
|
|
728
|
+
* one level-1 toggle, never a level of its own.
|
|
729
|
+
*/
|
|
730
|
+
function whyMissed(missed, model, runInfo, w) {
|
|
731
|
+
const box = el("div", "why-missed");
|
|
732
|
+
box.dataset.section = "why-missed";
|
|
733
|
+
const groups = groupMissedReasons(missed, model.terms, w);
|
|
734
|
+
box.dataset.reasons = String(groups.length);
|
|
735
|
+
box.append(el("h5", "", w.t("lines.why-missed.h")));
|
|
736
|
+
const table = element("table");
|
|
737
|
+
const tbody = element("tbody");
|
|
738
|
+
for (const group of groups) {
|
|
739
|
+
const tr = element("tr");
|
|
740
|
+
tr.dataset.reasonKey = group.key;
|
|
741
|
+
tr.dataset.reasonStructured = String(group.structured);
|
|
742
|
+
tr.dataset.count = String(group.conversations.length);
|
|
743
|
+
tr.append(element("td", group.label), el("td", "n", fmtCount(group.conversations.length)));
|
|
744
|
+
tbody.append(tr);
|
|
745
|
+
}
|
|
746
|
+
table.append(tbody);
|
|
747
|
+
box.append(table);
|
|
748
|
+
const anyStructured = groups.some((g) => g.structured);
|
|
749
|
+
box.append(el("p", "small", w.t(anyStructured
|
|
750
|
+
? "lines.why-missed.structured"
|
|
751
|
+
: "lines.why-missed.unstructured")));
|
|
752
|
+
for (const group of groups) {
|
|
753
|
+
const head = el("div", "rsn-h", w.t("lines.why-missed.reason", {
|
|
754
|
+
reason: group.label,
|
|
755
|
+
count: fmtCount(group.conversations.length),
|
|
756
|
+
}));
|
|
757
|
+
head.dataset.reasonFor = group.key;
|
|
758
|
+
box.append(head);
|
|
759
|
+
box.append(renderConversationList(group.conversations, model, runInfo, `reason:${group.key}`, w));
|
|
760
|
+
}
|
|
761
|
+
return box;
|
|
762
|
+
}
|
|
395
763
|
// ---------------------------------------------------------------------------
|
|
396
764
|
// The sheet: header meta, report lines, stamp, tamper note
|
|
397
765
|
// ---------------------------------------------------------------------------
|
|
398
766
|
/** The pack and version as one line: both come from the claims' `contract_ref` (see `readOutcomeReportTerms`), or read "not stated". */
|
|
399
|
-
function packLine(model) {
|
|
767
|
+
function packLine(model, w) {
|
|
400
768
|
const { id, version } = model.terms.pack;
|
|
401
|
-
return id === NOT_STATED
|
|
769
|
+
return id === NOT_STATED
|
|
770
|
+
? w.t("card.not-stated")
|
|
771
|
+
: w.t("lines.pack-line", { id, version });
|
|
402
772
|
}
|
|
403
773
|
// ---------------------------------------------------------------------------
|
|
404
774
|
// Dating: which date the calendar and period count a conversation under, and
|
|
405
775
|
// the plain label that says so (see `ConversationDate`)
|
|
406
776
|
// ---------------------------------------------------------------------------
|
|
407
|
-
function span(days) {
|
|
777
|
+
export function span(days, w) {
|
|
408
778
|
const first = days[0];
|
|
409
779
|
const last = days[days.length - 1];
|
|
410
780
|
if (first === undefined || last === undefined)
|
|
411
|
-
return "unknown";
|
|
412
|
-
return first === last ? first :
|
|
781
|
+
return w.t("card.span.unknown");
|
|
782
|
+
return first === last ? first : w.t("card.span", { from: first, to: last });
|
|
413
783
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
record: "the case record's own timestamp",
|
|
417
|
-
judged: "the day the judgments were sealed (no case record date to read)",
|
|
418
|
-
};
|
|
784
|
+
/** What a case's date is, in words. */
|
|
785
|
+
export const basisText = (basis, w) => w.t(`card.basis.${basis}`);
|
|
419
786
|
/** The page's one plain statement of what its dates are, or undefined when every conversation is dated by the day it was judged (the card's behaviour before record dating). */
|
|
420
|
-
function datingNote(model) {
|
|
421
|
-
|
|
787
|
+
function datingNote(model, w) {
|
|
788
|
+
return datingStatement(model.dating, model.totalCount, w);
|
|
789
|
+
}
|
|
790
|
+
/** `datingNote` over any card's dating (both groupings share it), `total` being the conversations it counts. */
|
|
791
|
+
export function datingStatement(dating, total, w) {
|
|
792
|
+
const { basis, counts, judgedDays, zoneNotStated } = dating;
|
|
422
793
|
if (basis === "judged")
|
|
423
794
|
return undefined;
|
|
424
|
-
const sealed =
|
|
795
|
+
const sealed = w.t("card.dating.sealed", { span: span(judgedDays, w) });
|
|
425
796
|
const parts = [];
|
|
426
797
|
if (basis === "source")
|
|
427
|
-
parts.push(
|
|
798
|
+
parts.push(w.t("card.dating.source"));
|
|
428
799
|
else if (basis === "record")
|
|
429
|
-
parts.push("
|
|
800
|
+
parts.push(w.t("card.dating.record"));
|
|
430
801
|
else {
|
|
431
|
-
parts.push("
|
|
802
|
+
parts.push(w.t("card.dating.mixed"));
|
|
432
803
|
if (counts.source > 0)
|
|
433
|
-
parts.push(
|
|
804
|
+
parts.push(w.t("card.dating.mixed.source", { n: String(counts.source) }));
|
|
434
805
|
if (counts.record > 0)
|
|
435
|
-
parts.push(
|
|
806
|
+
parts.push(w.t("card.dating.mixed.record", { n: String(counts.record) }));
|
|
436
807
|
if (counts.judged > 0)
|
|
437
|
-
parts.push(
|
|
808
|
+
parts.push(w.t("card.dating.mixed.judged", { n: String(counts.judged) }));
|
|
438
809
|
}
|
|
439
810
|
parts.push(sealed);
|
|
440
811
|
if (counts.source > 0)
|
|
441
|
-
parts.push("
|
|
812
|
+
parts.push(w.t("card.dating.self-attested"));
|
|
442
813
|
if (zoneNotStated > 0)
|
|
443
|
-
parts.push(
|
|
814
|
+
parts.push(w.t("card.dating.tz", {
|
|
815
|
+
count: String(zoneNotStated),
|
|
816
|
+
total: String(total),
|
|
817
|
+
}));
|
|
444
818
|
return parts.join(" ");
|
|
445
819
|
}
|
|
446
|
-
function renderMeta(host, model) {
|
|
820
|
+
function renderMeta(host, model, w, notes) {
|
|
447
821
|
const section = el("section", "");
|
|
448
822
|
section.dataset.section = "meta";
|
|
449
823
|
const row1 = el("div", "ih-row");
|
|
450
824
|
const bill = el("div", "party");
|
|
451
|
-
bill.append(el("div", "k", "
|
|
452
|
-
bill.append(el("div", "v", packLine(model)));
|
|
825
|
+
bill.append(el("div", "k", w.t("lines.meta.pack")));
|
|
826
|
+
bill.append(el("div", "v", packLine(model, w)));
|
|
453
827
|
row1.append(bill);
|
|
454
828
|
const title = el("div", "ih-title");
|
|
455
|
-
title.append(el("h1", "inv-title", "
|
|
456
|
-
|
|
829
|
+
title.append(el("h1", "inv-title", w.t("lines.title")));
|
|
830
|
+
const summary = reportSummary(w);
|
|
831
|
+
if (summary !== undefined)
|
|
832
|
+
title.append(summary);
|
|
833
|
+
// No Evidence Contract field states when the terms were locked; the line
|
|
834
|
+
// is drawn only when one does, never as a standing "not stated".
|
|
835
|
+
if (model.terms.pack.locked !== NOT_STATED)
|
|
836
|
+
title.append(el("div", "inv-sub", w.t("lines.meta.locked", { locked: model.terms.pack.locked })));
|
|
457
837
|
row1.append(title);
|
|
458
838
|
section.append(row1);
|
|
459
839
|
const row2 = el("div", "ih-row");
|
|
@@ -465,29 +845,41 @@ function renderMeta(host, model) {
|
|
|
465
845
|
line.append(element("span", label), element("span", value));
|
|
466
846
|
details.append(line);
|
|
467
847
|
};
|
|
468
|
-
metaRow("
|
|
469
|
-
? "no
|
|
470
|
-
:
|
|
471
|
-
|
|
848
|
+
metaRow(w.t("lines.meta.period"), first === undefined || last === undefined
|
|
849
|
+
? w.t("lines.meta.no-conversations")
|
|
850
|
+
: first === last
|
|
851
|
+
? first
|
|
852
|
+
: w.t("card.span", { from: first, to: last }));
|
|
853
|
+
const note = datingNote(model, w);
|
|
472
854
|
if (note !== undefined) {
|
|
473
|
-
metaRow("
|
|
855
|
+
metaRow(w.t("lines.meta.sealed"), span(model.dating.judgedDays, w));
|
|
474
856
|
details.lastElementChild.setAttribute("data-sealed", "");
|
|
475
857
|
}
|
|
476
|
-
metaRow("
|
|
477
|
-
|
|
478
|
-
|
|
858
|
+
metaRow(w.t("lines.meta.conversations"), fmtCount(model.totalCount));
|
|
859
|
+
const checked = el("div", "party");
|
|
860
|
+
const rules = model.terms.checks.reduce((n, c) => n + c.criteria.length, 0);
|
|
861
|
+
checked.append(el("div", "k", w.t("lines.meta.what-checked")));
|
|
862
|
+
const groups = model.terms.checks.length;
|
|
863
|
+
const what = el("div", "d", w.t("lines.meta.what-checked.text", {
|
|
864
|
+
rules: w.p("lines.meta.rules", rules, { n: String(rules) }),
|
|
865
|
+
groups: w.p("lines.meta.groups", groups, { n: String(groups) }),
|
|
866
|
+
questions: model.terms.checks.map((c) => groupTitle(c, w)).join(" · "),
|
|
867
|
+
}));
|
|
868
|
+
what.dataset.whatChecked = String(rules);
|
|
869
|
+
checked.append(what);
|
|
870
|
+
row2.append(checked, details);
|
|
479
871
|
section.append(row2);
|
|
480
872
|
if (note !== undefined) {
|
|
481
873
|
const label = el("p", "date-note", note);
|
|
482
874
|
label.dataset.dateNote = model.dating.basis;
|
|
483
|
-
|
|
875
|
+
notes.append(label);
|
|
484
876
|
}
|
|
485
877
|
host.append(section);
|
|
486
878
|
}
|
|
487
879
|
// ---------------------------------------------------------------------------
|
|
488
|
-
//
|
|
880
|
+
// Summary: report lines
|
|
489
881
|
// ---------------------------------------------------------------------------
|
|
490
|
-
function renderLines(host, model, runInfo) {
|
|
882
|
+
function renderLines(host, model, runInfo, w, notes) {
|
|
491
883
|
const section = el("section", "");
|
|
492
884
|
section.dataset.section = "lines";
|
|
493
885
|
const table = document.createElement("table");
|
|
@@ -495,91 +887,262 @@ function renderLines(host, model, runInfo) {
|
|
|
495
887
|
table.dataset.rows = "report-lines";
|
|
496
888
|
const thead = document.createElement("thead");
|
|
497
889
|
const headRow = document.createElement("tr");
|
|
498
|
-
headRow.append(element("th", "
|
|
890
|
+
headRow.append(element("th", w.t("lines.col.result")), el("th", "n", w.t("lines.lines.col.conversations")));
|
|
499
891
|
thead.append(headRow);
|
|
500
892
|
table.append(thead);
|
|
501
893
|
const tbody = document.createElement("tbody");
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
894
|
+
const byStatus = (status) => model.conversations.filter((c) => conversationStatus(c) === status);
|
|
895
|
+
const resolved = byStatus("resolved");
|
|
896
|
+
const missed = byStatus("missed");
|
|
897
|
+
const unverified = byStatus("unverified");
|
|
898
|
+
const undecided = [...byStatus("undecided"), ...byStatus("nothing-applied")];
|
|
899
|
+
const share = (n) => fmtShare(n, model.totalCount, model.options.percentages, w);
|
|
900
|
+
const line = (key, count, shown, behind) => ({
|
|
901
|
+
key,
|
|
902
|
+
label: w.t(`lines.line.${key}`),
|
|
903
|
+
help: w.t(`lines.line.${key}.help`),
|
|
904
|
+
count,
|
|
905
|
+
shown,
|
|
906
|
+
...(behind === undefined ? {} : { behind }),
|
|
907
|
+
});
|
|
505
908
|
const lines = [
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
"Conversations resolved correctly",
|
|
509
|
-
model.resolvedCount,
|
|
510
|
-
fmtShare(model.resolvedCount, model.totalCount, model.options.percentages),
|
|
511
|
-
],
|
|
512
|
-
[
|
|
513
|
-
"missed",
|
|
514
|
-
"Conversations missed",
|
|
515
|
-
model.missedCount,
|
|
516
|
-
fmtShare(model.missedCount, model.totalCount, model.options.percentages),
|
|
517
|
-
],
|
|
518
|
-
[
|
|
519
|
-
"held",
|
|
520
|
-
"Held pending adjudication",
|
|
521
|
-
model.heldCount,
|
|
522
|
-
fmtCount(model.heldCount),
|
|
523
|
-
],
|
|
524
|
-
[
|
|
525
|
-
"added",
|
|
526
|
-
"Added after adjudication",
|
|
527
|
-
model.addedCount,
|
|
528
|
-
fmtCount(model.addedCount),
|
|
529
|
-
],
|
|
530
|
-
[
|
|
531
|
-
"not-applicable",
|
|
532
|
-
"Criterion judgments not applicable",
|
|
533
|
-
model.notApplicableCount,
|
|
534
|
-
fmtCount(model.notApplicableCount),
|
|
535
|
-
],
|
|
909
|
+
line("resolved", resolved.length, share(resolved.length), resolved),
|
|
910
|
+
line("missed", missed.length, share(missed.length), missed),
|
|
536
911
|
];
|
|
537
|
-
|
|
912
|
+
if (unverified.length > 0)
|
|
913
|
+
lines.push(line("unverified", unverified.length, share(unverified.length), unverified));
|
|
914
|
+
if (undecided.length > 0)
|
|
915
|
+
lines.push(line("undecided", undecided.length, share(undecided.length), undecided));
|
|
916
|
+
// A person's re-grades are lines only when this bundle has one; their
|
|
917
|
+
// absence is said where the re-grade records are (renderHumanChecks).
|
|
918
|
+
if (model.heldCount > 0)
|
|
919
|
+
lines.push(line("held", model.heldCount, fmtCount(model.heldCount)));
|
|
920
|
+
if (model.addedCount > 0)
|
|
921
|
+
lines.push(line("added", model.addedCount, fmtCount(model.addedCount)));
|
|
922
|
+
for (const line of lines) {
|
|
538
923
|
const tr = document.createElement("tr");
|
|
539
|
-
tr.dataset.line = key;
|
|
540
|
-
tr.dataset.count = String(count);
|
|
924
|
+
tr.dataset.line = line.key;
|
|
925
|
+
tr.dataset.count = String(line.count);
|
|
541
926
|
const desc = el("td", "desc");
|
|
542
|
-
desc.append(el("b", "", label));
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
927
|
+
desc.append(el("b", "", line.label));
|
|
928
|
+
desc.append(el("small", "", line.help));
|
|
929
|
+
if (line.behind !== undefined && line.behind.length > 0) {
|
|
930
|
+
const label = w.p("lines.drill.show", line.behind.length, {
|
|
931
|
+
n: fmtCount(line.behind.length),
|
|
932
|
+
});
|
|
933
|
+
const behind = line.behind;
|
|
934
|
+
desc.append(line.key === "missed"
|
|
935
|
+
? drill(label, () => whyMissed(behind, model, runInfo, w), line.key)
|
|
936
|
+
: conversationsDrill(label, behind, model, runInfo, line.key, w));
|
|
937
|
+
}
|
|
938
|
+
tr.append(desc, el("td", "n", line.shown));
|
|
553
939
|
tbody.append(tr);
|
|
554
940
|
}
|
|
555
941
|
table.append(tbody);
|
|
556
942
|
section.append(table);
|
|
943
|
+
const na = el("p", "na-note", w.p("lines.na-note", model.notApplicableCount, {
|
|
944
|
+
n: fmtCount(model.notApplicableCount),
|
|
945
|
+
}));
|
|
946
|
+
na.dataset.line = "not-applicable";
|
|
947
|
+
na.dataset.count = String(model.notApplicableCount);
|
|
948
|
+
notes.append(na);
|
|
949
|
+
// Result v0 section 4.2: out of scope is counted on its own, never as not
|
|
950
|
+
// applicable and never as met; said only when a bundle has one.
|
|
951
|
+
if (model.outOfScopeCount > 0) {
|
|
952
|
+
const oos = el("p", "na-note", w.p("lines.oos-note", model.outOfScopeCount, {
|
|
953
|
+
n: fmtCount(model.outOfScopeCount),
|
|
954
|
+
}));
|
|
955
|
+
oos.dataset.line = "out-of-scope";
|
|
956
|
+
oos.dataset.count = String(model.outOfScopeCount);
|
|
957
|
+
notes.append(oos);
|
|
958
|
+
}
|
|
959
|
+
host.append(section);
|
|
960
|
+
}
|
|
961
|
+
// ---------------------------------------------------------------------------
|
|
962
|
+
// Summary: results rule by rule
|
|
963
|
+
// ---------------------------------------------------------------------------
|
|
964
|
+
function renderRules(host, model, runInfo, result, w) {
|
|
965
|
+
const section = el("section", "sec");
|
|
966
|
+
section.dataset.section = "rules";
|
|
967
|
+
section.append(el("h2", "", w.t("lines.rules.h")));
|
|
968
|
+
section.append(el("p", "lede", w.t("lines.rules.lede")));
|
|
969
|
+
const table = el("table", "rules");
|
|
970
|
+
table.dataset.rows = "rules";
|
|
971
|
+
const thead = element("thead");
|
|
972
|
+
const headRow = element("tr");
|
|
973
|
+
// Not met leads; "did not apply" is in each row's expansion, and "could
|
|
974
|
+
// not decide" stays on the row as its own count (Result v0 section 3).
|
|
975
|
+
const columnWord = {
|
|
976
|
+
not_met: ruleWord("not_met", "yes", w).word,
|
|
977
|
+
met: ruleWord("met", "yes", w).word,
|
|
978
|
+
undecided: w.t("lines.rules.col.undecided"),
|
|
979
|
+
unverified: w.t("lines.rules.col.unverified"),
|
|
980
|
+
out_of_scope: ruleWord("out_of_scope", "yes", w).word,
|
|
981
|
+
};
|
|
982
|
+
headRow.append(element("th", w.t("lines.col.rule")), el("th", "n", columnWord.not_met), el("th", "n", columnWord.met), el("th", "n", columnWord.undecided));
|
|
983
|
+
// A claim that failed verification or whose evidence is missing has its
|
|
984
|
+
// own column, never folded into "not met"; drawn only when a bundle has
|
|
985
|
+
// one.
|
|
986
|
+
const anyUnverified = model.conversations.some((c) => c.criteria.some((cr) => isUnverified(cr.verdict)));
|
|
987
|
+
if (anyUnverified)
|
|
988
|
+
headRow.append(el("th", "n", columnWord.unverified));
|
|
989
|
+
// Judged out of scope (Result v0 section 4.2) is its own column, never
|
|
990
|
+
// folded into "did not apply" or "met"; drawn only when a bundle has one.
|
|
991
|
+
const anyOutOfScope = model.outOfScopeCount > 0;
|
|
992
|
+
if (anyOutOfScope)
|
|
993
|
+
headRow.append(el("th", "n", columnWord.out_of_scope));
|
|
994
|
+
const columns = String(4 + (anyUnverified ? 1 : 0) + (anyOutOfScope ? 1 : 0));
|
|
995
|
+
thead.append(headRow);
|
|
996
|
+
table.append(thead);
|
|
997
|
+
const tbody = element("tbody");
|
|
998
|
+
for (const check of model.terms.checks) {
|
|
999
|
+
const group = el("tr", "grp");
|
|
1000
|
+
group.dataset.checkId = check.id;
|
|
1001
|
+
group.dataset.passCount = String(model.checkPassCounts.get(check.id) ?? 0);
|
|
1002
|
+
const cell = el("td", "", groupTitle(check, w));
|
|
1003
|
+
cell.setAttribute("colspan", columns);
|
|
1004
|
+
group.append(cell);
|
|
1005
|
+
tbody.append(group);
|
|
1006
|
+
for (const criterion of check.criteria) {
|
|
1007
|
+
const ref = `${check.id}.${criterion.id}`;
|
|
1008
|
+
const of = (pick) => model.conversations.filter((c) => c.criteria.some((cr) => cr.checkId === check.id &&
|
|
1009
|
+
cr.criterionId === criterion.id &&
|
|
1010
|
+
pick(cr.verdict)));
|
|
1011
|
+
// Each count column's verdicts, read once: a cell's number and the
|
|
1012
|
+
// claims its Show-evidence action lists come from the same pick.
|
|
1013
|
+
const picks = {
|
|
1014
|
+
not_met: isMiss,
|
|
1015
|
+
met: (v) => v === "met",
|
|
1016
|
+
undecided: (v) => v === "not_evaluable" || v === "no_claim",
|
|
1017
|
+
unverified: isUnverified,
|
|
1018
|
+
out_of_scope: (v) => v === "out_of_scope",
|
|
1019
|
+
};
|
|
1020
|
+
const met = of(picks.met);
|
|
1021
|
+
const notMet = of(picks.not_met);
|
|
1022
|
+
const unverifiedHere = of(picks.unverified);
|
|
1023
|
+
const na = of((v) => v === "not_applicable");
|
|
1024
|
+
const outOfScopeHere = of(picks.out_of_scope);
|
|
1025
|
+
const undecided = of(picks.undecided);
|
|
1026
|
+
// One count cell: the number, and its Show-evidence action (or the
|
|
1027
|
+
// label that stands in for one) over the claims behind it on this rule.
|
|
1028
|
+
const countCell = (className, column, counted) => {
|
|
1029
|
+
const pick = picks[column];
|
|
1030
|
+
const cell = el("td", className);
|
|
1031
|
+
cell.dataset.column = column;
|
|
1032
|
+
cell.append(el("span", "nv", fmtCount(counted.length)));
|
|
1033
|
+
const action = evidenceAction(`rule:${ref}:${column}`, `${label.label} · ${columnWord[column]}: ${fmtCount(counted.length)}`, counted.map((c) => c.criteria.find((cr) => cr.checkId === check.id &&
|
|
1034
|
+
cr.criterionId === criterion.id &&
|
|
1035
|
+
pick(cr.verdict))?.claim), result, w);
|
|
1036
|
+
if (action !== undefined)
|
|
1037
|
+
cell.append(action);
|
|
1038
|
+
return cell;
|
|
1039
|
+
};
|
|
1040
|
+
const tr = el("tr", "rule");
|
|
1041
|
+
tr.dataset.rule = ref;
|
|
1042
|
+
tr.dataset.tier = model.criterionTiers.get(ref) ?? "unknown";
|
|
1043
|
+
const label = criterionLabel(model, check.id, criterion.id, w);
|
|
1044
|
+
const nameCell = el("td", "cn");
|
|
1045
|
+
const ruleName = el("b", "", label.label);
|
|
1046
|
+
nameCell.append(ruleName);
|
|
1047
|
+
const badge = editedBadge(model, ref, w);
|
|
1048
|
+
if (badge !== undefined)
|
|
1049
|
+
nameCell.append(badge);
|
|
1050
|
+
if (label.source === "sealed")
|
|
1051
|
+
nameCell.append(el("small", "", label.text));
|
|
1052
|
+
// contract-report/v1 section 3: the pack's explanation of the rule,
|
|
1053
|
+
// and its note for a rule whose claims could not be decided.
|
|
1054
|
+
const detail = w.row(ref, "detail");
|
|
1055
|
+
if (detail !== undefined) {
|
|
1056
|
+
const line = el("small", "rdet", detail);
|
|
1057
|
+
line.dataset.wording = "pack";
|
|
1058
|
+
nameCell.append(line);
|
|
1059
|
+
}
|
|
1060
|
+
const undecidedNote = w.row(ref, "not_evaluable");
|
|
1061
|
+
if (undecidedNote !== undefined && undecided.length > 0) {
|
|
1062
|
+
const line = el("small", "rdet", undecidedNote);
|
|
1063
|
+
line.dataset.wording = "pack";
|
|
1064
|
+
line.dataset.note = "not-evaluable";
|
|
1065
|
+
nameCell.append(line);
|
|
1066
|
+
}
|
|
1067
|
+
const problems = [
|
|
1068
|
+
...notMet,
|
|
1069
|
+
...unverifiedHere.filter((c) => !notMet.includes(c)),
|
|
1070
|
+
...undecided.filter((c) => !notMet.includes(c) && !unverifiedHere.includes(c)),
|
|
1071
|
+
];
|
|
1072
|
+
tr.append(nameCell, countCell(`n${notMet.length > 0 ? " bad" : ""}`, "not_met", notMet), countCell("n ok", "met", met), countCell("n", "undecided", undecided));
|
|
1073
|
+
if (anyUnverified)
|
|
1074
|
+
tr.append(countCell("n", "unverified", unverifiedHere));
|
|
1075
|
+
if (anyOutOfScope)
|
|
1076
|
+
tr.append(countCell("n", "out_of_scope", outOfScopeHere));
|
|
1077
|
+
tbody.append(tr);
|
|
1078
|
+
// The row opens: a full-width row below it holds how many
|
|
1079
|
+
// conversations the rule did not apply to and the conversations
|
|
1080
|
+
// behind its problems, each read at the table's width. A rule with
|
|
1081
|
+
// neither has nothing to open.
|
|
1082
|
+
if (problems.length === 0 && na.length === 0)
|
|
1083
|
+
continue;
|
|
1084
|
+
const drillRow = el("tr", "drill-row");
|
|
1085
|
+
drillRow.dataset.drillFor = ref;
|
|
1086
|
+
const cell = element("td");
|
|
1087
|
+
cell.setAttribute("colspan", columns);
|
|
1088
|
+
drillRow.append(cell);
|
|
1089
|
+
// The not-applicable count is drawn now, so a static page (which runs
|
|
1090
|
+
// no script to build a body) still shows it when the row opens.
|
|
1091
|
+
if (na.length > 0) {
|
|
1092
|
+
const naLine = el("p", "rule-na", w.p("lines.rules.expand.na", na.length, {
|
|
1093
|
+
n: fmtCount(na.length),
|
|
1094
|
+
}));
|
|
1095
|
+
naLine.dataset.count = String(na.length);
|
|
1096
|
+
cell.append(naLine);
|
|
1097
|
+
}
|
|
1098
|
+
const toggle = expandableRow(tr, ruleName, drillRow, () => problems.length > 0
|
|
1099
|
+
? renderConversationList(problems, model, runInfo, `rule:${ref}`, w)
|
|
1100
|
+
: document.createDocumentFragment(), `rule-${ref}`);
|
|
1101
|
+
toggle.dataset.drill = `rule:${ref}`;
|
|
1102
|
+
tbody.append(drillRow);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
// Requirements of the cited contract the run did not cover (Result v0
|
|
1106
|
+
// section 3, `requirements_covered`): one row each, "not covered", under a group
|
|
1107
|
+
// of their own. They are in no conversation, count or column above: the
|
|
1108
|
+
// run never judged them, so no number on this page speaks for them.
|
|
1109
|
+
if (model.notRun.length > 0) {
|
|
1110
|
+
const group = el("tr", "grp");
|
|
1111
|
+
group.dataset.group = "not-run";
|
|
1112
|
+
const heading = el("td", "", w.t("lines.rules.not-run.h"));
|
|
1113
|
+
heading.setAttribute("colspan", columns);
|
|
1114
|
+
group.append(heading);
|
|
1115
|
+
tbody.append(group);
|
|
1116
|
+
for (const ref of model.notRun) {
|
|
1117
|
+
const [checkId = "", ...rest] = ref.split(".");
|
|
1118
|
+
const label = criterionLabel(model, checkId, rest.join("."), w);
|
|
1119
|
+
const tr = el("tr", "rule not-run");
|
|
1120
|
+
tr.dataset.rule = ref;
|
|
1121
|
+
tr.dataset.notRun = "true";
|
|
1122
|
+
const nameCell = el("td", "cn");
|
|
1123
|
+
nameCell.append(el("b", "", label.label));
|
|
1124
|
+
const status = el("td", "nr", w.t("lines.rules.not-run"));
|
|
1125
|
+
status.setAttribute("colspan", String(Number(columns) - 1));
|
|
1126
|
+
tr.append(nameCell, status);
|
|
1127
|
+
tbody.append(tr);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
table.append(tbody);
|
|
1131
|
+
const scroll = el("div", "tscroll");
|
|
1132
|
+
scroll.append(table);
|
|
1133
|
+
section.append(scroll);
|
|
557
1134
|
host.append(section);
|
|
558
|
-
const stamps = el("div", "stamps inl");
|
|
559
|
-
const stamp = el("div", "stamp rec", "Verified · recomputed from the sealed bundle");
|
|
560
|
-
stamp.append(el("small", "", "every count and share above is recomputed from result.claims and the records they cite, never read from a stated total"));
|
|
561
|
-
stamps.append(stamp);
|
|
562
|
-
host.append(stamps);
|
|
563
|
-
const tamper = el("p", "tamper-note", 'This card only ever renders a bundle that already verified: there is no interactive "try tampering" control here, because this viewer never shows content first and checks second. Tamper with any claim, record, or checkpoint in the underlying bundle and the whole page — this card included — is replaced by the verification-failed banner, before anything here is drawn.');
|
|
564
|
-
tamper.dataset.tamperNote = "verify-first";
|
|
565
|
-
host.append(tamper);
|
|
566
1135
|
}
|
|
567
1136
|
// ---------------------------------------------------------------------------
|
|
568
1137
|
// Day by day
|
|
569
1138
|
// ---------------------------------------------------------------------------
|
|
570
|
-
function renderCalendar(host, model) {
|
|
1139
|
+
function renderCalendar(host, model, w) {
|
|
571
1140
|
const section = el("section", "sec");
|
|
572
1141
|
section.dataset.section = "calendar";
|
|
573
|
-
section.append(el("h2", "", "
|
|
574
|
-
const note = datingNote(model);
|
|
575
|
-
section.append(el("p", "lede", note === undefined
|
|
576
|
-
|
|
577
|
-
: "Resolved conversations per day, by each conversation's own date, cited by this bundle's claims."));
|
|
578
|
-
if (note !== undefined) {
|
|
579
|
-
const label = el("p", "date-note", note);
|
|
580
|
-
label.dataset.dateNote = model.dating.basis;
|
|
581
|
-
section.append(label);
|
|
582
|
-
}
|
|
1142
|
+
section.append(el("h2", "", w.t("lines.cal.h")));
|
|
1143
|
+
const note = datingNote(model, w);
|
|
1144
|
+
section.append(el("p", "lede", w.t(note === undefined ? "lines.cal.lede" : "lines.cal.lede.dated")));
|
|
1145
|
+
// The dating note itself is said once, in the sheet's footnotes.
|
|
583
1146
|
const list = el("div", "cal");
|
|
584
1147
|
list.dataset.days = String(model.days.length);
|
|
585
1148
|
for (const day of model.days) {
|
|
@@ -591,18 +1154,18 @@ function renderCalendar(host, model) {
|
|
|
591
1154
|
if (note !== undefined) {
|
|
592
1155
|
const bases = new Set(day.conversations.map((c) => c.dated.basis));
|
|
593
1156
|
if (bases.has("source")) {
|
|
594
|
-
const chip = el("div", "src-says", "source
|
|
1157
|
+
const chip = el("div", "src-says", w.t("lines.cal.source-says"));
|
|
595
1158
|
chip.dataset.sourceSays = String(day.conversations.filter((c) => c.dated.basis === "source").length);
|
|
596
1159
|
item.append(chip);
|
|
597
1160
|
}
|
|
598
1161
|
const notStated = day.conversations.filter((c) => c.dated.zone === "not-stated").length;
|
|
599
1162
|
if (notStated > 0) {
|
|
600
|
-
const tz = el("div", "tz", "
|
|
1163
|
+
const tz = el("div", "tz", w.t("lines.cal.tz"));
|
|
601
1164
|
tz.dataset.tzMarker = "not-stated";
|
|
602
1165
|
item.append(tz);
|
|
603
1166
|
}
|
|
604
1167
|
}
|
|
605
|
-
item.append(el("div", "v", fmtShare(day.resolvedCount, day.conversations.length, model.options.percentages)));
|
|
1168
|
+
item.append(el("div", "v", fmtShare(day.resolvedCount, day.conversations.length, model.options.percentages, w)));
|
|
606
1169
|
const mini = el("div", "mini");
|
|
607
1170
|
const share = day.conversations.length === 0
|
|
608
1171
|
? 0
|
|
@@ -612,12 +1175,12 @@ function renderCalendar(host, model) {
|
|
|
612
1175
|
mini.append(fill);
|
|
613
1176
|
item.append(mini);
|
|
614
1177
|
if (note !== undefined) {
|
|
615
|
-
const sealed = el("div", "sealed",
|
|
1178
|
+
const sealed = el("div", "sealed", w.t("lines.cal.sealed", { span: span(day.judgedDays, w) }));
|
|
616
1179
|
sealed.dataset.sealed = day.judgedDays.join(" ");
|
|
617
1180
|
item.append(sealed);
|
|
618
1181
|
}
|
|
619
1182
|
if (day.policyChanged !== null) {
|
|
620
|
-
const flag = el("div", "flag", "policy
|
|
1183
|
+
const flag = el("div", "flag", w.t("lines.cal.policy-changed"));
|
|
621
1184
|
flag.dataset.policyChanged = day.policyChanged;
|
|
622
1185
|
item.append(flag);
|
|
623
1186
|
}
|
|
@@ -629,13 +1192,13 @@ function renderCalendar(host, model) {
|
|
|
629
1192
|
// ---------------------------------------------------------------------------
|
|
630
1193
|
// Human spot checks
|
|
631
1194
|
// ---------------------------------------------------------------------------
|
|
632
|
-
function renderHumanChecks(host, calibration) {
|
|
1195
|
+
function renderHumanChecks(host, calibration, w) {
|
|
633
1196
|
const section = el("section", "sec");
|
|
634
1197
|
section.dataset.section = "human-checks";
|
|
635
|
-
section.append(el("h2", "", "
|
|
636
|
-
section.append(el("p", "lede", "
|
|
1198
|
+
section.append(el("h2", "", w.t("lines.hc.h")));
|
|
1199
|
+
section.append(el("p", "lede", w.t("lines.hc.lede")));
|
|
637
1200
|
if (calibration.length === 0) {
|
|
638
|
-
section.append(el("p", "", "
|
|
1201
|
+
section.append(el("p", "", w.t("lines.hc.none")));
|
|
639
1202
|
host.append(section);
|
|
640
1203
|
return;
|
|
641
1204
|
}
|
|
@@ -644,7 +1207,7 @@ function renderHumanChecks(host, calibration) {
|
|
|
644
1207
|
table.dataset.weeks = String(calibration.length);
|
|
645
1208
|
const thead = document.createElement("thead");
|
|
646
1209
|
const headRow = document.createElement("tr");
|
|
647
|
-
headRow.append(element("th", "
|
|
1210
|
+
headRow.append(element("th", w.t("lines.hc.col.week")), el("th", "n", w.t("lines.hc.col.agreed")), el("th", "n", w.t("lines.hc.col.held")), el("th", "n", w.t("lines.hc.col.added")));
|
|
648
1211
|
thead.append(headRow);
|
|
649
1212
|
table.append(thead);
|
|
650
1213
|
const tbody = document.createElement("tbody");
|
|
@@ -654,7 +1217,7 @@ function renderHumanChecks(host, calibration) {
|
|
|
654
1217
|
tr.dataset.k = String(week.k);
|
|
655
1218
|
tr.dataset.n = String(week.n);
|
|
656
1219
|
tr.append(el("td", "", week.weekId));
|
|
657
|
-
tr.append(el("td", "n",
|
|
1220
|
+
tr.append(el("td", "n", w.t("lines.hc.agreed", { k: String(week.k), n: String(week.n) })));
|
|
658
1221
|
const held = week.sample.filter((s) => s.aiVerdict === "met" && s.humanVerdict !== "met").length;
|
|
659
1222
|
const added = week.sample.filter((s) => s.aiVerdict !== "met" && s.humanVerdict === "met").length;
|
|
660
1223
|
const heldCell = el("td", "n", String(held));
|
|
@@ -669,54 +1232,17 @@ function renderHumanChecks(host, calibration) {
|
|
|
669
1232
|
host.append(section);
|
|
670
1233
|
}
|
|
671
1234
|
// ---------------------------------------------------------------------------
|
|
672
|
-
// Why conversations missed
|
|
673
|
-
// ---------------------------------------------------------------------------
|
|
674
|
-
function renderWhyMissed(host, model, runInfo) {
|
|
675
|
-
const section = el("section", "sec");
|
|
676
|
-
section.dataset.section = "why-missed";
|
|
677
|
-
section.append(el("h2", "", "Why conversations missed"));
|
|
678
|
-
const bars = el("div", "bars");
|
|
679
|
-
bars.dataset.checkBars = "true";
|
|
680
|
-
for (const check of model.terms.checks) {
|
|
681
|
-
const count = model.checkPassCounts.get(check.id) ?? 0;
|
|
682
|
-
const item = el("div", "bar");
|
|
683
|
-
item.dataset.checkId = check.id;
|
|
684
|
-
item.dataset.passCount = String(count);
|
|
685
|
-
const nm = el("div", "nm", check.question);
|
|
686
|
-
const track = el("div", "track");
|
|
687
|
-
const share = model.totalCount === 0 ? 0 : count / model.totalCount;
|
|
688
|
-
const fill = element("i");
|
|
689
|
-
fill.style.width = `${Math.round(share * 100)}%`;
|
|
690
|
-
track.append(fill);
|
|
691
|
-
const num = el("div", "num", fmtShare(count, model.totalCount, model.options.percentages));
|
|
692
|
-
item.append(nm, track, num);
|
|
693
|
-
bars.append(item);
|
|
694
|
-
}
|
|
695
|
-
section.append(bars);
|
|
696
|
-
const reasons = el("div", "reasons");
|
|
697
|
-
reasons.dataset.reasons = String(model.missedReasons.length);
|
|
698
|
-
for (const group of model.missedReasons) {
|
|
699
|
-
const item = el("details", "rsn-d");
|
|
700
|
-
item.dataset.reasonKey = group.key;
|
|
701
|
-
item.dataset.reasonStructured = String(group.structured);
|
|
702
|
-
item.dataset.count = String(group.conversations.length);
|
|
703
|
-
const row = el("summary", "rsn");
|
|
704
|
-
row.append(element("span", group.label), el("span", "c", `${fmtCount(group.conversations.length)} · see them ›`));
|
|
705
|
-
item.append(row);
|
|
706
|
-
item.append(renderConversationList(group.conversations, model, runInfo, `reason:${group.key}`));
|
|
707
|
-
reasons.append(item);
|
|
708
|
-
}
|
|
709
|
-
section.append(reasons);
|
|
710
|
-
host.append(section);
|
|
711
|
-
}
|
|
712
|
-
// ---------------------------------------------------------------------------
|
|
713
1235
|
// The terms
|
|
714
1236
|
// ---------------------------------------------------------------------------
|
|
715
|
-
function renderTerms(host, model) {
|
|
716
|
-
const section = el("
|
|
1237
|
+
function renderTerms(host, model, w) {
|
|
1238
|
+
const section = el("div", "rp-s");
|
|
717
1239
|
section.dataset.section = "terms";
|
|
718
|
-
section.append(el("
|
|
719
|
-
const lede = el("p", "lede",
|
|
1240
|
+
section.append(el("h3", "", w.t("lines.terms.h")));
|
|
1241
|
+
const lede = el("p", "lede", model.terms.pack.agreement === NOT_STATED
|
|
1242
|
+
? w.t("lines.terms.lede")
|
|
1243
|
+
: w.t("lines.terms.lede.agreed", {
|
|
1244
|
+
agreement: model.terms.pack.agreement,
|
|
1245
|
+
}));
|
|
720
1246
|
lede.dataset.termsSource = "bundle";
|
|
721
1247
|
section.append(lede);
|
|
722
1248
|
const pack = el("div", "pack");
|
|
@@ -725,11 +1251,14 @@ function renderTerms(host, model) {
|
|
|
725
1251
|
box.append(el("div", "k", label), el("div", "v", value));
|
|
726
1252
|
pack.append(box);
|
|
727
1253
|
};
|
|
728
|
-
packField("
|
|
729
|
-
packField("
|
|
730
|
-
?
|
|
731
|
-
:
|
|
732
|
-
|
|
1254
|
+
packField(w.t("lines.meta.pack"), model.terms.pack.id);
|
|
1255
|
+
packField(w.t("lines.terms.version"), model.terms.pack.version === NOT_STATED
|
|
1256
|
+
? w.t("card.not-stated")
|
|
1257
|
+
: w.t("lines.terms.version.value", {
|
|
1258
|
+
version: model.terms.pack.version,
|
|
1259
|
+
}));
|
|
1260
|
+
if (model.terms.pack.locked !== NOT_STATED)
|
|
1261
|
+
packField(w.t("lines.terms.locked"), model.terms.pack.locked);
|
|
733
1262
|
section.append(pack);
|
|
734
1263
|
const outcome = el("div", "outcome");
|
|
735
1264
|
const outcomeIcon = el("div", "oic");
|
|
@@ -738,7 +1267,7 @@ function renderTerms(host, model) {
|
|
|
738
1267
|
outcomeIcon.append(target);
|
|
739
1268
|
outcome.append(outcomeIcon);
|
|
740
1269
|
const outcomeBody = element("div");
|
|
741
|
-
outcomeBody.append(el("div", "t", "
|
|
1270
|
+
outcomeBody.append(el("div", "t", w.t("lines.terms.outcome")));
|
|
742
1271
|
outcomeBody.append(el("div", "v", model.terms.pack.outcomeStatement));
|
|
743
1272
|
outcome.append(outcomeBody);
|
|
744
1273
|
section.append(outcome);
|
|
@@ -752,7 +1281,7 @@ function renderTerms(host, model) {
|
|
|
752
1281
|
if (drawn !== undefined)
|
|
753
1282
|
checkIcon.append(drawn);
|
|
754
1283
|
card.append(checkIcon);
|
|
755
|
-
card.append(el("div", "q", check
|
|
1284
|
+
card.append(el("div", "q", groupTitle(check, w)));
|
|
756
1285
|
card.append(el("div", "d", check.description));
|
|
757
1286
|
const criteria = el("ul", "subs");
|
|
758
1287
|
for (const criterion of check.criteria) {
|
|
@@ -766,21 +1295,24 @@ function renderTerms(host, model) {
|
|
|
766
1295
|
source: "unstated",
|
|
767
1296
|
};
|
|
768
1297
|
item.dataset.wording = wording.source;
|
|
769
|
-
const label = el("b", "", criterion.label);
|
|
770
|
-
const termsBadge = editedBadge(model, ref);
|
|
1298
|
+
const label = el("b", "", w.row(ref, "label") ?? criterion.label);
|
|
1299
|
+
const termsBadge = editedBadge(model, ref, w);
|
|
771
1300
|
if (termsBadge !== undefined)
|
|
772
1301
|
label.append(termsBadge);
|
|
773
1302
|
item.append(label);
|
|
774
|
-
item.append(element("span",
|
|
1303
|
+
item.append(element("span", w.t("lines.terms.criterion", {
|
|
1304
|
+
text: wording.text,
|
|
1305
|
+
tier: tierLabel(tier, w),
|
|
1306
|
+
})));
|
|
775
1307
|
if (wording.source !== "sealed")
|
|
776
|
-
item.append(el("small", "wsrc",
|
|
1308
|
+
item.append(el("small", "wsrc", wordingFallback(wording.source, w)));
|
|
777
1309
|
criteria.append(item);
|
|
778
1310
|
}
|
|
779
1311
|
card.append(criteria);
|
|
780
1312
|
checks.append(card);
|
|
781
1313
|
}
|
|
782
1314
|
section.append(checks);
|
|
783
|
-
const note = el("p", "small", wordingNote(model));
|
|
1315
|
+
const note = el("p", "small", wordingNote(model, w));
|
|
784
1316
|
note.dataset.wordingNote = "true";
|
|
785
1317
|
section.append(note);
|
|
786
1318
|
section.append(el("div", "rule", model.terms.pack.resolutionRule));
|
|
@@ -789,10 +1321,10 @@ function renderTerms(host, model) {
|
|
|
789
1321
|
// ---------------------------------------------------------------------------
|
|
790
1322
|
// What ran
|
|
791
1323
|
// ---------------------------------------------------------------------------
|
|
792
|
-
function renderWhatRan(host, runInfo) {
|
|
793
|
-
const section = el("
|
|
1324
|
+
function renderWhatRan(host, runInfo, w) {
|
|
1325
|
+
const section = el("div", "rp-s");
|
|
794
1326
|
section.dataset.section = "what-ran";
|
|
795
|
-
section.append(el("
|
|
1327
|
+
section.append(el("h3", "", w.t("lines.ran.h")));
|
|
796
1328
|
const ran = el("div", "ran");
|
|
797
1329
|
ran.dataset.pinned = String(runInfo.pinned);
|
|
798
1330
|
if (runInfo.judgePinRecomputes !== undefined)
|
|
@@ -808,30 +1340,33 @@ function renderWhatRan(host, runInfo) {
|
|
|
808
1340
|
// digest (verifyJudgePin); otherwise they are "not stated", never shown
|
|
809
1341
|
// beside a digest they do not produce.
|
|
810
1342
|
const pin = runInfo.judgePinRecomputes === true ? runInfo.judgePin : undefined;
|
|
811
|
-
|
|
812
|
-
box("
|
|
813
|
-
|
|
1343
|
+
const notStated = w.t("card.not-stated");
|
|
1344
|
+
box(w.t("lines.ran.contract"), runInfo.contract ?? notStated, "contract");
|
|
1345
|
+
box(w.t("lines.ran.judge-model"), pin === undefined
|
|
1346
|
+
? notStated
|
|
814
1347
|
: pin.modelVersion === undefined
|
|
815
1348
|
? pin.modelId
|
|
816
1349
|
: `${pin.modelId} ${pin.modelVersion}`, "judge-model");
|
|
817
|
-
box("
|
|
818
|
-
?
|
|
1350
|
+
box(w.t("lines.ran.judge-pin"), runInfo.judgePinDigest === undefined
|
|
1351
|
+
? pinNotShown(runInfo, w)
|
|
819
1352
|
: pin === undefined
|
|
820
1353
|
? runInfo.judgePinDigest
|
|
821
|
-
:
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
box("
|
|
1354
|
+
: w.t("lines.ran.judge-pin.recomputed", {
|
|
1355
|
+
digest: runInfo.judgePinDigest,
|
|
1356
|
+
}), "judge-pin-digest");
|
|
1357
|
+
box(w.t("lines.ran.judge-prompt"), pin?.promptDigest ?? notStated, "judge-prompt-digest");
|
|
1358
|
+
box(w.t("lines.ran.judge-axes"), pin?.axesDigest ?? notStated, "judge-axes-digest");
|
|
1359
|
+
box(w.t("lines.ran.agent"), w.t("lines.ran.agent.value"), "agent");
|
|
825
1360
|
section.append(ran);
|
|
826
1361
|
if (runInfo.judgePinRecomputes === false) {
|
|
827
|
-
const warning = el("p", "", "
|
|
1362
|
+
const warning = el("p", "", w.t("lines.ran.components-mismatch"));
|
|
828
1363
|
warning.dataset.pinComponentsMismatch = "true";
|
|
829
1364
|
section.append(warning);
|
|
830
1365
|
}
|
|
831
|
-
const lock = el("div", "lock", "
|
|
1366
|
+
const lock = el("div", "lock", w.t("lines.ran.lock"));
|
|
832
1367
|
section.append(lock);
|
|
833
1368
|
if (!runInfo.pinned) {
|
|
834
|
-
const warning = el("p", "", "
|
|
1369
|
+
const warning = el("p", "", w.t("lines.ran.pin-mismatch"));
|
|
835
1370
|
warning.dataset.pinMismatch = "true";
|
|
836
1371
|
section.append(warning);
|
|
837
1372
|
}
|
|
@@ -840,46 +1375,138 @@ function renderWhatRan(host, runInfo) {
|
|
|
840
1375
|
// ---------------------------------------------------------------------------
|
|
841
1376
|
// Verification details
|
|
842
1377
|
// ---------------------------------------------------------------------------
|
|
843
|
-
function renderVerificationDetails(host, bundle, verified) {
|
|
844
|
-
const section = el("
|
|
1378
|
+
function renderVerificationDetails(host, bundle, verified, w) {
|
|
1379
|
+
const section = el("div", "rp-s");
|
|
845
1380
|
section.dataset.section = "verification-details";
|
|
846
|
-
section.append(el("
|
|
847
|
-
section.append(el("p", "lede", "
|
|
1381
|
+
section.append(el("h3", "", w.t("card.vd.h")));
|
|
1382
|
+
section.append(el("p", "lede", w.t("lines.vd.lede")));
|
|
848
1383
|
const model = buildVerificationPageModel(bundle, verified);
|
|
849
1384
|
const tech = el("div", "tech");
|
|
850
1385
|
const field = (label, value) => {
|
|
851
1386
|
tech.append(el("div", "k", label), el("div", "v", value));
|
|
852
1387
|
};
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
field("Checkpoint size", String(model.checkpointSize ?? "absent"));
|
|
1388
|
+
for (const [label, value] of verificationRows(model, w))
|
|
1389
|
+
field(label, value);
|
|
856
1390
|
section.append(tech);
|
|
857
|
-
const note = el("p", "note", "
|
|
1391
|
+
const note = el("p", "note", w.t("lines.vd.note"));
|
|
858
1392
|
note.dataset.checkpointKind = "mmr";
|
|
859
1393
|
section.append(note);
|
|
860
1394
|
host.append(section);
|
|
861
1395
|
}
|
|
862
|
-
|
|
1396
|
+
// ---------------------------------------------------------------------------
|
|
1397
|
+
// Proofs for the whole report: one toggle at the foot of the page
|
|
1398
|
+
// ---------------------------------------------------------------------------
|
|
1399
|
+
/** The bundle's digest and checkpoint, for the report proofs of either grouping. */
|
|
1400
|
+
export function verificationRows(model, w) {
|
|
1401
|
+
return [
|
|
1402
|
+
[
|
|
1403
|
+
w.t("card.vd.bundle-digest"),
|
|
1404
|
+
model.bundleDigest ?? w.t("card.vd.uncomputable"),
|
|
1405
|
+
],
|
|
1406
|
+
[
|
|
1407
|
+
w.t("card.vd.checkpoint-root"),
|
|
1408
|
+
model.checkpointRoot ?? w.t("card.vd.absent"),
|
|
1409
|
+
],
|
|
1410
|
+
[
|
|
1411
|
+
w.t("card.vd.checkpoint-size"),
|
|
1412
|
+
model.checkpointSize === undefined
|
|
1413
|
+
? w.t("card.vd.absent")
|
|
1414
|
+
: String(model.checkpointSize),
|
|
1415
|
+
],
|
|
1416
|
+
];
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Which wording pack drew this card, in its report proofs: every layer
|
|
1420
|
+
* applied, by digest, not only the final one -- the base layer's digest is
|
|
1421
|
+
* named even on a default-only page (contract-report/v1 §3 records every
|
|
1422
|
+
* layer applied).
|
|
1423
|
+
*/
|
|
1424
|
+
export function wordingRow(w) {
|
|
1425
|
+
const refused = w.source.refused;
|
|
1426
|
+
return [
|
|
1427
|
+
w.t("card.pf.wording"),
|
|
1428
|
+
refused !== undefined
|
|
1429
|
+
? w.t("card.pf.wording.refused", {
|
|
1430
|
+
sha256: refused.sha256,
|
|
1431
|
+
reason: w.t(`card.wording.refused.${refused.reason}`),
|
|
1432
|
+
baseId: w.source.base?.id ?? w.source.id,
|
|
1433
|
+
baseSha256: w.source.base?.sha256 ?? w.source.sha256 ?? "",
|
|
1434
|
+
})
|
|
1435
|
+
: w.source.base === undefined
|
|
1436
|
+
? w.t("card.pf.wording.default", {
|
|
1437
|
+
id: w.source.id,
|
|
1438
|
+
sha256: w.source.sha256 ?? "",
|
|
1439
|
+
})
|
|
1440
|
+
: w.t("card.pf.wording.supplied.layered", {
|
|
1441
|
+
id: w.source.id,
|
|
1442
|
+
sha256: w.source.sha256 ?? "",
|
|
1443
|
+
baseId: w.source.base.id,
|
|
1444
|
+
baseSha256: w.source.base.sha256,
|
|
1445
|
+
}),
|
|
1446
|
+
];
|
|
1447
|
+
}
|
|
1448
|
+
function renderReportProofs(host, model, runInfo, bundle, verified, w) {
|
|
1449
|
+
const section = el("section", "sec rp");
|
|
1450
|
+
section.dataset.section = "report-proofs";
|
|
1451
|
+
// Built on first open, like every other toggle.
|
|
1452
|
+
const toggle = levelToggle(2, w.t("lines.rp.toggle"), () => {
|
|
1453
|
+
const box = el("div", "pf-b");
|
|
1454
|
+
const ids = proofList([
|
|
1455
|
+
[w.t("card.pf.result-capsule"), model.capsuleId],
|
|
1456
|
+
[w.t("lines.meta.pack"), packLine(model, w)],
|
|
1457
|
+
wordingRow(w),
|
|
1458
|
+
]);
|
|
1459
|
+
ids.dataset.reportIds = "true";
|
|
1460
|
+
box.append(ids);
|
|
1461
|
+
renderTerms(box, model, w);
|
|
1462
|
+
renderWhatRan(box, runInfo, w);
|
|
1463
|
+
renderVerificationDetails(box, bundle, verified, w);
|
|
1464
|
+
const tamper = el("p", "tamper-note", w.t("lines.rp.tamper"));
|
|
1465
|
+
tamper.dataset.tamperNote = "verify-first";
|
|
1466
|
+
box.append(tamper);
|
|
1467
|
+
return box;
|
|
1468
|
+
}, { className: "proofs" });
|
|
1469
|
+
section.append(toggle);
|
|
1470
|
+
host.append(section);
|
|
1471
|
+
}
|
|
1472
|
+
/** The `lines` grouping's page wrapper: its element, class, page name and stylesheet. */
|
|
1473
|
+
export const LINES_FRAME = {
|
|
1474
|
+
tag: "section",
|
|
1475
|
+
className: "oi",
|
|
1476
|
+
page: "outcome-report",
|
|
1477
|
+
css: OUTCOME_REPORT_CSS,
|
|
1478
|
+
};
|
|
1479
|
+
/**
|
|
1480
|
+
* Draw the `lines` grouping into `wrapper` (contract-report.ts made it and
|
|
1481
|
+
* put its stylesheet in it). Every word is `w`'s.
|
|
1482
|
+
*/
|
|
1483
|
+
export async function drawLines(levels, result, options, bundle, verified, w) {
|
|
863
1484
|
const model = buildOutcomeReportModel(result, options);
|
|
864
1485
|
const runInfo = await verifyJudgePin(model.runInfo);
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
wrapper.append(style);
|
|
870
|
-
renderProducerNote(wrapper, model);
|
|
1486
|
+
const claims = model.conversations.flatMap((c) => c.criteria.flatMap((cr) => (cr.claim === undefined ? [] : [cr.claim])));
|
|
1487
|
+
// L0, what matters, after the core's strip (the mock-judge mark and the
|
|
1488
|
+
// sealed aggregate, core-strip.ts): the header, then the per-conversation
|
|
1489
|
+
// lines, each opening its list.
|
|
871
1490
|
const sheet = el("div", "sheet");
|
|
872
1491
|
const pad = el("div", "pad");
|
|
873
|
-
|
|
874
|
-
|
|
1492
|
+
// Notes that explain a figure sit under the sheet, in small type, never
|
|
1493
|
+
// between the reader and the figures.
|
|
1494
|
+
const notes = el("aside", "footnotes");
|
|
1495
|
+
notes.dataset.section = "footnotes";
|
|
1496
|
+
renderMeta(pad, model, w, notes);
|
|
1497
|
+
renderLines(pad, model, runInfo, w, notes);
|
|
1498
|
+
if (notes.childElementCount > 0)
|
|
1499
|
+
pad.append(notes);
|
|
875
1500
|
sheet.append(pad);
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
1501
|
+
levels.L0.append(sheet);
|
|
1502
|
+
// L1, why: rule by rule, led by who judged, who witnessed, what verified.
|
|
1503
|
+
renderRules(levels.L1, model, runInfo, result, w);
|
|
1504
|
+
leadWithProvenance(levels.L1, levels.L1.querySelector('[data-section="rules"]'), renderProvenance(await provenanceLines(result.records, claims, bundle, verified, w)));
|
|
1505
|
+
// L2, module detail after the core's verification section.
|
|
1506
|
+
levels.L2.append(renderCheckYourself(bundle, w));
|
|
1507
|
+
renderCalendar(levels.L2, model, w);
|
|
1508
|
+
renderHumanChecks(levels.L2, model.calibration, w);
|
|
1509
|
+
renderProducerNote(levels.L2, model, w);
|
|
1510
|
+
renderReportProofs(levels.L2, model, runInfo, bundle, verified, w);
|
|
884
1511
|
}
|
|
885
1512
|
//# sourceMappingURL=outcome-report-view.js.map
|