@action-state-group/capsule-viewer 0.1.0 → 0.3.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.
Files changed (90) hide show
  1. package/README.md +73 -2
  2. package/dist/alias-interpreters.d.ts +18 -0
  3. package/dist/alias-interpreters.js +50 -0
  4. package/dist/alias-interpreters.js.map +1 -0
  5. package/dist/browser.d.ts +5 -2
  6. package/dist/browser.js +19 -5
  7. package/dist/browser.js.map +1 -1
  8. package/dist/builtin-manifests.d.ts +51 -0
  9. package/dist/builtin-manifests.js +196 -0
  10. package/dist/builtin-manifests.js.map +1 -0
  11. package/dist/compliance-styles.d.ts +1 -8
  12. package/dist/compliance-styles.js +41 -3
  13. package/dist/compliance-styles.js.map +1 -1
  14. package/dist/compliance-view.d.ts +41 -1
  15. package/dist/compliance-view.js +737 -303
  16. package/dist/compliance-view.js.map +1 -1
  17. package/dist/compliance.d.ts +33 -4
  18. package/dist/compliance.js +92 -13
  19. package/dist/compliance.js.map +1 -1
  20. package/dist/composed-styles.d.ts +12 -0
  21. package/dist/composed-styles.js +20 -0
  22. package/dist/composed-styles.js.map +1 -0
  23. package/dist/composed-view.d.ts +1 -1
  24. package/dist/composed-view.js +9 -2
  25. package/dist/composed-view.js.map +1 -1
  26. package/dist/contract-report-wording.d.ts +195 -0
  27. package/dist/contract-report-wording.js +1141 -0
  28. package/dist/contract-report-wording.js.map +1 -0
  29. package/dist/contract-report.d.ts +92 -0
  30. package/dist/contract-report.js +63 -0
  31. package/dist/contract-report.js.map +1 -0
  32. package/dist/emitter-shell.html +176 -2
  33. package/dist/emitter.d.ts +36 -0
  34. package/dist/emitter.js +64 -1
  35. package/dist/emitter.js.map +1 -1
  36. package/dist/evidence-graph-view.d.ts +60 -7
  37. package/dist/evidence-graph-view.js +1344 -106
  38. package/dist/evidence-graph-view.js.map +1 -1
  39. package/dist/evidence-graph.iife.js +12410 -5624
  40. package/dist/frame-tokens.generated.d.ts +3 -0
  41. package/dist/frame-tokens.generated.js +5 -0
  42. package/dist/frame-tokens.generated.js.map +1 -0
  43. package/dist/index.d.ts +3 -0
  44. package/dist/index.js +5 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/outcome-report-presentation.d.ts +48 -0
  47. package/dist/outcome-report-presentation.js +90 -0
  48. package/dist/outcome-report-presentation.js.map +1 -0
  49. package/dist/outcome-report-styles.d.ts +1 -16
  50. package/dist/outcome-report-styles.js +48 -45
  51. package/dist/outcome-report-styles.js.map +1 -1
  52. package/dist/outcome-report-view.d.ts +75 -2
  53. package/dist/outcome-report-view.js +1039 -436
  54. package/dist/outcome-report-view.js.map +1 -1
  55. package/dist/presentation-builder.d.ts +55 -6
  56. package/dist/presentation-builder.js +163 -69
  57. package/dist/presentation-builder.js.map +1 -1
  58. package/dist/presentation-fragment.d.ts +129 -0
  59. package/dist/presentation-fragment.js +213 -0
  60. package/dist/presentation-fragment.js.map +1 -0
  61. package/dist/presentation-mount.d.ts +2 -2
  62. package/dist/presentation-mount.js +1 -1
  63. package/dist/presentation-mount.js.map +1 -1
  64. package/dist/presentation-registry.d.ts +277 -0
  65. package/dist/presentation-registry.js +416 -0
  66. package/dist/presentation-registry.js.map +1 -0
  67. package/dist/record-content.d.ts +68 -0
  68. package/dist/record-content.js +153 -0
  69. package/dist/record-content.js.map +1 -0
  70. package/dist/record-dating.d.ts +10 -0
  71. package/dist/record-dating.js +76 -0
  72. package/dist/record-dating.js.map +1 -0
  73. package/dist/report-front-styles.d.ts +9 -0
  74. package/dist/report-front-styles.js +55 -0
  75. package/dist/report-front-styles.js.map +1 -0
  76. package/dist/report-front.d.ts +78 -0
  77. package/dist/report-front.js +274 -0
  78. package/dist/report-front.js.map +1 -0
  79. package/dist/report-levels.d.ts +206 -0
  80. package/dist/report-levels.js +739 -0
  81. package/dist/report-levels.js.map +1 -0
  82. package/dist/report-provenance.d.ts +111 -0
  83. package/dist/report-provenance.js +535 -0
  84. package/dist/report-provenance.js.map +1 -0
  85. package/dist/viewer-build.d.ts +37 -0
  86. package/dist/viewer-build.js +29 -0
  87. package/dist/viewer-build.js.map +1 -0
  88. package/dist/wording/contract-report-eu-ai-act.en.json +295 -0
  89. package/dist/wording/contract-report-outcomes.en.json +394 -0
  90. package/package.json +3 -2
@@ -1,19 +1,33 @@
1
1
  import { buildComplianceModel, } from "./compliance.js";
2
2
  import { COMPLIANCE_CSS } from "./compliance-styles.js";
3
+ import { datedText, datingStatement, notesGap, pinAbsence, span, transcriptRows, verificationRows, wordingRow, } from "./outcome-report-view.js";
3
4
  import { NOT_STATED } from "@action-state-group/agent-action-capsule";
5
+ import { DEFAULT_WORDS } from "./contract-report-wording.js";
6
+ import { caseParts, judgedOf, judgeNote, lazyBody, levelToggle, proofList, conversationFold, ruleWord, wordPill, assuranceRow, reportSummary, } from "./report-levels.js";
7
+ import { provenanceLines, renderProvenance, tallyJudges, } from "./report-provenance.js";
8
+ import { renderAggregate, renderCheckYourself, expandableRow, leadWithProvenance, placeMockMark, renderMockJudgeLine, } from "./report-front.js";
9
+ import { buildVerificationPageModel } from "@action-state-group/agent-action-capsule";
4
10
  /**
5
- * The EU AI Act obligations-report card. Called from
6
- * `evidence-graph-view.ts` in place of `renderResultPage` when the bundle's
7
- * `eu-ai-act-compliance/v1` extension opts in, after the same verify-first
11
+ * The contract-report module's `groups` grouping (contract-report.ts): a
12
+ * report read as requirement groups and the tests under each. The EU AI Act
13
+ * Results are this grouping with the EU AI Act wording pack; every word on
14
+ * it is the pack's (`w`). Drawn by the module in place of `renderResultPage`
15
+ * when the bundle's `eu-ai-act-compliance/v1` extension opts in, after the same verify-first
8
16
  * gate every other root family goes through -- nothing here ever runs on a
9
17
  * bundle that did not verify. See compliance.ts for where every value on the
10
18
  * page comes from: counts, verdicts, test wording, tiers and the pack from
11
19
  * the sealed records (or "not stated"); the regulatory mapping from the
12
20
  * producer's extension, labelled as such.
13
21
  *
22
+ * Two levels and no more (report-levels.ts): the summary states what was
23
+ * checked and the result per obligation and test; toggle 1 on a test opens
24
+ * the sessions behind its exceptions, listed in place and each readable as
25
+ * it stands (every test's result by name, the conversation and its tool
26
+ * calls); toggle 2 in a session opens its proofs. The methodology, mapping and bundle checks sit
27
+ * in one proofs toggle at the foot of the page.
28
+ *
14
29
  * The whole card renders inside one `.cc`-classed wrapper with its own
15
- * `<style>` (`COMPLIANCE_CSS`) as its first child. Drill-down uses native
16
- * `<details>`/`<summary>`: keyboard-accessible, no script-driven modal.
30
+ * `<style>` (`COMPLIANCE_CSS`) as its first child.
17
31
  */
18
32
  function element(tag, text) {
19
33
  const value = document.createElement(tag);
@@ -26,369 +40,789 @@ function el(tag, className, text) {
26
40
  value.className = className;
27
41
  return value;
28
42
  }
43
+ /**
44
+ * Producer text: the eu-ai-act-compliance/v1 mapping, carried beside the
45
+ * signed records and signed by no one. Set in italics (`<i>`, the browser's
46
+ * own style) and tagged `data-source="producer"`, so it never reads as a
47
+ * sealed finding; the summary's basis line says what the italics mean.
48
+ */
49
+ function producerText(w, ...content) {
50
+ const value = element("i");
51
+ value.append(...content);
52
+ value.dataset.source = "producer";
53
+ // The tooltip comes from the card's own pack, per render.
54
+ value.title = w.t("groups.producer.title");
55
+ return value;
56
+ }
57
+ /** `text` in an element of its own, as producer text when `producer` is true. */
58
+ function maybeProducer(w, tag, className, text, producer) {
59
+ if (!producer)
60
+ return el(tag, className, text);
61
+ const value = el(tag, className);
62
+ value.append(producerText(w, text));
63
+ return value;
64
+ }
29
65
  const fmt = (n) => n.toLocaleString();
66
+ /** `{n} <noun>` from the pack's `groups.count.<noun>.one|other`. */
67
+ const count = (w, noun, n) => w.p(`groups.count.${noun}`, n, { n: fmt(n) });
30
68
  const SEVERITY_CLASS = {
31
69
  High: "high",
32
70
  Medium: "medium",
33
71
  Low: "low",
34
72
  };
35
- function severityPill(severity) {
36
- const cls = SEVERITY_CLASS[severity] ?? "medium";
37
- return el("span", `sev ${cls}`, severity);
38
- }
39
- function tierBadge(tier) {
40
- const text = tier === "judged"
41
- ? "judged"
42
- : tier === "recomputed"
43
- ? "recomputed"
44
- : tier === "mixed"
45
- ? "tier differs across reports"
46
- : "tier not stated";
47
- const badge = el("span", `kind ${tier === "judged" || tier === "recomputed" ? tier : "unstated"}`, text);
73
+ /** The producer's severity, as the producer's: an unknown value gets no colour of its own, never "medium". */
74
+ function severityPill(severity, w) {
75
+ const cls = Object.hasOwn(SEVERITY_CLASS, severity)
76
+ ? SEVERITY_CLASS[severity]
77
+ : undefined;
78
+ const pill = el("span", cls === undefined ? "sev" : `sev ${cls}`);
79
+ pill.append(producerText(w, severity));
80
+ return pill;
81
+ }
82
+ function tierBadge(tier, w) {
83
+ const key = tier === "judged" || tier === "recomputed" || tier === "mixed"
84
+ ? tier
85
+ : "unstated";
86
+ const badge = el("span", `kind ${tier === "judged" || tier === "recomputed" ? tier : "unstated"}`, w.t(`groups.tier.${key}`));
48
87
  badge.dataset.tier = tier;
88
+ badge.title =
89
+ tier === "judged" || tier === "recomputed"
90
+ ? w.t(`groups.tier.${tier}.title`)
91
+ : "";
49
92
  return badge;
50
93
  }
51
94
  function statusPill(statusClass, text) {
52
95
  return el("span", `st ${statusClass}`, text);
53
96
  }
97
+ /**
98
+ * A word a host pack sets for this contract (contract-report/v1 section 3:
99
+ * `group.<segment>.title`, `row.<requirement_ref>.label` and the rest),
100
+ * drawn in the page's own voice and tagged `data-wording="pack"`: never
101
+ * producer text, never a sealed record.
102
+ */
103
+ function packWord(tag, className, text) {
104
+ const value = el(tag, className, text);
105
+ value.dataset.wording = "pack";
106
+ return value;
107
+ }
108
+ /** A test's name: the pack's `row.<ref>.label` when it sets one, else the producer's label or the test id made readable. */
109
+ function rowName(w, tag, className, row) {
110
+ const label = w.row(row.criterionId, "label");
111
+ return label !== undefined
112
+ ? packWord(tag, className, label)
113
+ : maybeProducer(w, tag, className, row.name, row.producerName);
114
+ }
115
+ /** An obligation's heading after its article: the pack's `group.<segment>.title` when it sets one, else the producer's title. */
116
+ function obligationName(w, obligation, article) {
117
+ const title = w.group(obligation.key);
118
+ if (title !== undefined)
119
+ return [article, packWord("span", "", ` · ${title}`)];
120
+ return obligation.mapped
121
+ ? [producerText(w, article, ` · ${obligation.title}`)]
122
+ : [article, element("span", ` · ${obligation.title}`)];
123
+ }
124
+ /** Each test's short name, by its criterion id, as producer text when it is the producer's label. */
125
+ function testNames(model, w) {
126
+ const rows = new Map(model.obligations.flatMap((o) => o.rows.map((r) => [r.criterionId, r])));
127
+ return (criterionId, tag, className) => {
128
+ const row = rows.get(criterionId);
129
+ return rowName(w, tag, className, {
130
+ criterionId,
131
+ name: row?.name ?? criterionId,
132
+ producerName: row?.producerName === true,
133
+ });
134
+ };
135
+ }
136
+ function sessionSpan(model, w) {
137
+ const days = model.sessions
138
+ .map((s) => s.day)
139
+ .filter((d) => d !== NOT_STATED)
140
+ .sort();
141
+ const first = days[0];
142
+ const last = days[days.length - 1];
143
+ if (first === undefined || last === undefined)
144
+ return undefined;
145
+ return first === last ? first : w.t("card.span", { from: first, to: last });
146
+ }
54
147
  // ---------------------------------------------------------------------------
55
148
  // Header
56
149
  // ---------------------------------------------------------------------------
57
- function renderHeader(host, model) {
150
+ function renderHeader(host, model, w) {
58
151
  const hd = el("div", "hd");
59
152
  hd.dataset.section = "header";
60
- hd.append(el("div", "kicker", "EU AI Act obligations report"));
61
- hd.append(el("h1", "", model.regulation));
153
+ // The report's name is the pack's (`groups.kicker`). The regulation is
154
+ // the producer's mapping, so it opens L1 (renderSummary), never L0
155
+ // (presentation contract section 6).
156
+ hd.append(el("h1", "", w.t("groups.kicker")));
157
+ const summary = reportSummary(w);
158
+ if (summary !== undefined)
159
+ hd.append(summary);
62
160
  const pack = model.pack.id === NOT_STATED
63
- ? `Pack ${NOT_STATED}`
64
- : `Pack ${model.pack.id} v${model.pack.version}`;
65
- hd.append(el("div", "sub", `${pack} · ${fmt(model.obligations.length)} obligations · ${fmt(model.totalSessions)} sessions · Result capsule ${model.capsuleId}`));
66
- const basis = el("p", "na", `Counts, verdicts, test wording, tiers and the pack are read from the sealed claims and reports in this bundle, or marked "${NOT_STATED}". The article, applicability, method and finding recommendations are the producer's mapping, carried on this bundle's eu-ai-act-compliance/v1 extension outside the signed records.`);
67
- basis.dataset.basis = "terms";
68
- hd.append(basis);
161
+ ? w.t("groups.pack.not-stated")
162
+ : w.t("groups.pack", { id: model.pack.id, version: model.pack.version });
163
+ const period = sessionSpan(model, w);
164
+ const vars = {
165
+ pack,
166
+ obligations: count(w, "obligation", model.obligations.length),
167
+ sessions: count(w, "session", model.totalSessions),
168
+ };
169
+ hd.append(el("div", "sub", period === undefined
170
+ ? w.t("groups.sub", vars)
171
+ : w.t(model.dating.basis === "judged"
172
+ ? "groups.sub.judged"
173
+ : "groups.sub.dated", { ...vars, period })));
69
174
  host.append(hd);
70
175
  }
71
176
  // ---------------------------------------------------------------------------
72
- // Section 1: summary
177
+ // Summary: what was checked and what we found
73
178
  // ---------------------------------------------------------------------------
74
- function obligationStatus(obligation) {
179
+ /** A test no session has a met, not-met, undecided or unverified result for: nothing was checked. */
180
+ function nothingChecked(row) {
181
+ return (row.metCount +
182
+ row.notMetCount +
183
+ row.notEvaluableCount +
184
+ row.outOfScopeCount +
185
+ row.unverifiedCount ===
186
+ 0);
187
+ }
188
+ /** No session with a result for this test met it, did not, or was judged out of scope: every one was undecided or could not be verified. */
189
+ function noneDecided(row) {
190
+ return (row.metCount === 0 && row.notMetCount === 0 && row.outOfScopeCount === 0);
191
+ }
192
+ /** The sessions a test's population counts: not the ones it did not apply to, and not the ones whose claim is not yet in force (Result v0 section 4.3). */
193
+ function population(row, totalSessions) {
194
+ return totalSessions - row.notApplicableCount - row.notYetInForceCount;
195
+ }
196
+ /** Every claim for this test is not yet in force: readiness only, nothing in force to count (Result v0 section 4.3). */
197
+ function allLater(row) {
198
+ return nothingChecked(row) && row.notYetInForceCount > 0;
199
+ }
200
+ /**
201
+ * An obligation's status, from the sealed counts alone. Its applicability
202
+ * (in force, or from a later date) is the producer's mapping: it is never
203
+ * drawn in this pill, which speaks only for the records, and is shown
204
+ * instead in the producer's own italic line beside the title.
205
+ *
206
+ * "No exceptions", in the ok tone, only when every one of its tests was met
207
+ * by at least one session and no session's result for it was not met: an
208
+ * obligation one of whose tests no session met (every result undecided,
209
+ * unverified or absent) does not read clean. When none of its tests could
210
+ * be checked it reads "Could not be checked"; when some could not, the pill
211
+ * is neutral and says how many.
212
+ */
213
+ export function obligationStatus(obligation, w = DEFAULT_WORDS.groups) {
75
214
  const exceptions = obligation.rows.reduce((sum, r) => sum + r.notMetCount, 0);
76
- if (obligation.applicability.status === "not stated")
77
- return exceptions > 0
78
- ? { cls: "exc", text: `Exceptions noted (${fmt(exceptions)})` }
79
- : { cls: "ok", text: "No exceptions" };
80
- if (obligation.applicability.status === "future")
81
- return exceptions > 0
82
- ? {
83
- cls: "future",
84
- text: `Not yet applicable · ${fmt(exceptions)} exceptions (readiness)`,
85
- }
86
- : { cls: "future", text: "Not yet applicable · no exceptions" };
87
- return exceptions > 0
88
- ? { cls: "exc", text: `Exceptions noted (${fmt(exceptions)})` }
89
- : { cls: "ok", text: "No exceptions" };
215
+ // Result v0 section 4.3: only when every test is wholly later is there no
216
+ // population to have no exceptions in. A test in force whose claims all
217
+ // failed verification is still in force: its failure is never hidden
218
+ // behind "Not yet in force".
219
+ if (obligation.rows.length > 0 && obligation.rows.every(allLater))
220
+ return { cls: "na", text: w.t("groups.ob.later") };
221
+ // A wholly later test was not "could not be checked": it is not in force
222
+ // yet, so it is left out of both counts.
223
+ const inForce = obligation.rows.filter((r) => !allLater(r));
224
+ const unchecked = inForce.filter((r) => noneDecided(r)).length;
225
+ const unverified = obligation.rows.reduce((sum, r) => sum + r.unverifiedCount, 0);
226
+ const total = inForce.length;
227
+ const uncheckedText = unchecked > 0
228
+ ? w.t("groups.ob.unchecked-of", {
229
+ unchecked: fmt(unchecked),
230
+ total: count(w, "test", total),
231
+ })
232
+ : "";
233
+ if (exceptions > 0)
234
+ return {
235
+ cls: "exc",
236
+ text: `${count(w, "exception", exceptions)}${unchecked > 0 && unchecked < total ? uncheckedText : ""}`,
237
+ };
238
+ if (unchecked === total)
239
+ return { cls: "ne", text: w.t("groups.ob.unchecked") };
240
+ if (unchecked > 0)
241
+ return { cls: "ne", text: `${w.t("groups.ob.ok.found")}${uncheckedText}` };
242
+ if (unverified > 0)
243
+ return {
244
+ cls: "ne",
245
+ text: w.t("groups.ob.ok.unverified", {
246
+ unverified: count(w, "result", unverified),
247
+ }),
248
+ };
249
+ return { cls: "ok", text: w.t("groups.ob.ok") };
90
250
  }
91
- function renderSummary(host, model) {
251
+ /** A test's result in the summary: a status, and an optional note under it. */
252
+ export function rowStatus(row, w = DEFAULT_WORDS.groups) {
253
+ if (allLater(row))
254
+ return {
255
+ cls: "na",
256
+ text: w.t("groups.row.later"),
257
+ note: w.t("groups.row.later-note", { n: fmt(row.notYetInForceCount) }),
258
+ };
259
+ if (nothingChecked(row))
260
+ return { cls: "ne", text: w.t("groups.row.nothing") };
261
+ if (noneDecided(row)) {
262
+ const packNotEvaluable = row.notEvaluableCount > 0
263
+ ? w.row(row.criterionId, "not_evaluable")
264
+ : undefined;
265
+ // Module-only notes a producer or pack word never speaks for: unverified
266
+ // and not-yet-in-force claims can coexist with an undecided row, and
267
+ // both must still be said, whichever of the two branches below applies.
268
+ const moduleNotes = [
269
+ ...(row.unverifiedCount > 0
270
+ ? [w.t("groups.row.unverified-note", { n: fmt(row.unverifiedCount) })]
271
+ : []),
272
+ ...(row.notYetInForceCount > 0
273
+ ? [w.t("groups.row.later-note", { n: fmt(row.notYetInForceCount) })]
274
+ : []),
275
+ ];
276
+ if (packNotEvaluable !== undefined)
277
+ return {
278
+ cls: "ne",
279
+ text: w.t("groups.row.none-decided"),
280
+ note: [packNotEvaluable, ...moduleNotes].join("; "),
281
+ };
282
+ if (row.notEvaluableNote !== undefined && row.notEvaluableCount > 0)
283
+ return {
284
+ cls: "ne",
285
+ text: w.t("groups.row.none-decided"),
286
+ note: row.notEvaluableNote,
287
+ producerNote: true,
288
+ };
289
+ return {
290
+ cls: "ne",
291
+ text: w.t("groups.row.none-decided"),
292
+ ...(moduleNotes.length > 0 ? { note: moduleNotes.join("; ") } : {}),
293
+ };
294
+ }
295
+ const notes = [
296
+ ...(row.notEvaluableCount > 0
297
+ ? [w.t("groups.row.undecided-note", { n: fmt(row.notEvaluableCount) })]
298
+ : []),
299
+ ...(row.unverifiedCount > 0
300
+ ? [w.t("groups.row.unverified-note", { n: fmt(row.unverifiedCount) })]
301
+ : []),
302
+ ...(row.outOfScopeCount > 0
303
+ ? [w.t("groups.row.out-of-scope-note", { n: fmt(row.outOfScopeCount) })]
304
+ : []),
305
+ ...(row.notYetInForceCount > 0
306
+ ? [w.t("groups.row.later-note", { n: fmt(row.notYetInForceCount) })]
307
+ : []),
308
+ ];
309
+ const undecided = notes.length > 0 ? { note: notes.join("; ") } : {};
310
+ if (row.notMetCount > 0)
311
+ return {
312
+ cls: "exc",
313
+ text: w.p("groups.row.exceptions", row.notMetCount, {
314
+ n: fmt(row.notMetCount),
315
+ }),
316
+ ...undecided,
317
+ };
318
+ // Every decided result was judged out of scope: it did not arise, which
319
+ // is never met (Result v0 section 4.2), so never "no exceptions" either.
320
+ if (row.metCount === 0)
321
+ return { cls: "na", text: w.t("groups.row.out-of-scope"), ...undecided };
322
+ // Neither word set says more than "no exceptions": a session's result
323
+ // that was met is all the records show, never "established in every
324
+ // session".
325
+ return {
326
+ cls: row.unverifiedCount > 0 ? "ne" : "ok",
327
+ text: w.t(row.notEvaluableCount === 0
328
+ ? "groups.row.ok.all-decided"
329
+ : "groups.row.ok"),
330
+ ...undecided,
331
+ };
332
+ }
333
+ function rowResult(row, w) {
334
+ const cell = document.createElement("td");
335
+ const status = rowStatus(row, w);
336
+ cell.append(statusPill(status.cls, status.text));
337
+ if (status.note !== undefined)
338
+ cell.append(maybeProducer(w, "div", "applic", status.note, status.producerNote === true));
339
+ return cell;
340
+ }
341
+ function renderSummary(host, model, presentation, w) {
92
342
  const section = el("section", "");
93
343
  section.dataset.section = "summary";
94
- section.append(el("h2", "", "1. Summary"));
95
- section.append(el("p", "lede", "Results are stated as counts of sessions; no overall compliance percentage is given."));
344
+ const regulation = maybeProducer(w, "p", "kicker", model.regulation, true);
345
+ regulation.dataset.regulation = "";
346
+ section.append(regulation, el("h2", "", w.t("groups.summary.h")));
347
+ const tests = model.obligations.reduce((n, o) => n + o.rows.length, 0);
348
+ section.append(el("p", "lede", w.t("groups.summary.lede", {
349
+ tests: count(w, "test", tests),
350
+ obligations: count(w, "obligation", model.obligations.length),
351
+ })));
96
352
  const table = document.createElement("table");
97
- table.className = "grid";
353
+ table.className = "grid sum";
98
354
  table.dataset.rows = "summary";
99
355
  const thead = document.createElement("thead");
100
356
  const headRow = document.createElement("tr");
101
- headRow.append(element("th", "Article"), element("th", "Obligation"), element("th", "Applicability"), element("th", "Status"));
357
+ headRow.append(element("th", w.t("groups.summary.col.test")), el("th", "n", w.t("groups.summary.col.checked-in")), element("th", w.t("groups.summary.col.result")));
102
358
  thead.append(headRow);
103
359
  table.append(thead);
104
- const tbody = document.createElement("tbody");
105
360
  for (const obligation of model.obligations) {
106
- const row = document.createElement("tr");
361
+ const tbody = document.createElement("tbody");
362
+ tbody.dataset.obligationGroup = obligation.key;
363
+ const row = el("tr", "ob");
107
364
  row.dataset.obligation = obligation.key;
108
- const status = obligationStatus(obligation);
109
- row.append(el("td", "b", obligation.article), element("td", obligation.title), element("td", obligation.applicability.note));
110
- const statusCell = document.createElement("td");
111
- statusCell.append(statusPill(status.cls, status.text));
112
- row.append(statusCell);
365
+ // A group heading (contract-report/v1 section 2): its tests are the
366
+ // rows. No tally sums the tests' sessions here. The heading opens to
367
+ // the obligation's plain-language text and when it applies, kept
368
+ // together (decision D3).
369
+ const title = el("td", "");
370
+ title.setAttribute("colspan", "3");
371
+ const name = el("b", "obn");
372
+ name.append(...obligationName(w, obligation, el("span", "art", obligation.article)));
373
+ title.append(name);
374
+ row.append(title);
113
375
  tbody.append(row);
376
+ const about = el("tr", "drill-row ob-about");
377
+ about.dataset.aboutFor = obligation.key;
378
+ const aboutCell = el("td", "");
379
+ aboutCell.setAttribute("colspan", "3");
380
+ about.append(aboutCell);
381
+ expandableRow(row, name, about, () => {
382
+ const body = el("div", "ob-x");
383
+ if (obligation.plain !== NOT_STATED)
384
+ body.append(maybeProducer(w, "div", "plain", obligation.plain, true));
385
+ body.append(maybeProducer(w, "div", "applic", obligation.applicability.note, obligation.mapped));
386
+ return body;
387
+ }, `ob-${obligation.key}`, true);
388
+ tbody.append(about);
389
+ for (const test of obligation.rows) {
390
+ const tr = el("tr", "test");
391
+ tr.dataset.criterion = test.criterionId;
392
+ const counted = population(test, model.totalSessions);
393
+ tr.dataset.population = String(counted);
394
+ tr.dataset.outOfScope = String(test.outOfScopeCount);
395
+ tr.dataset.notYetInForce = String(test.notYetInForceCount);
396
+ tr.dataset.exceptions = String(test.notMetCount);
397
+ tr.dataset.notEvaluable = String(test.notEvaluableCount);
398
+ const nameCell = el("td", "tn");
399
+ const head = el("div", "tnh");
400
+ const testName = rowName(w, "b", "", test);
401
+ head.append(testName, tierBadge(test.tier, w));
402
+ nameCell.append(head);
403
+ const detail = w.row(test.criterionId, "detail");
404
+ if (detail !== undefined)
405
+ nameCell.append(packWord("div", "plain", detail));
406
+ const sessionIds = [
407
+ ...(test.sessionsByVerdict.get("not_met") ?? []),
408
+ ...(test.sessionsByVerdict.get("unverified") ?? []),
409
+ ...(test.sessionsByVerdict.get("not_evaluable") ?? []),
410
+ ];
411
+ tr.append(nameCell, el("td", "n", count(w, "session", counted)), rowResult(test, w));
412
+ tbody.append(tr);
413
+ // The row itself opens the sessions behind it, in a full-width row
414
+ // below it, so each one reads at the table's width.
415
+ if (sessionIds.length > 0) {
416
+ const drillRow = el("tr", "drill-row");
417
+ drillRow.dataset.drillFor = test.criterionId;
418
+ const cell = document.createElement("td");
419
+ cell.setAttribute("colspan", "3");
420
+ drillRow.append(cell);
421
+ const toggle = expandableRow(tr, testName, drillRow, () => renderSessionList(sessionIds, model, presentation, w), `test-${obligation.key}-${test.criterionId}`);
422
+ toggle.dataset.records = "sessions";
423
+ toggle.dataset.drill = test.criterionId;
424
+ tbody.append(drillRow);
425
+ }
426
+ }
427
+ table.append(tbody);
114
428
  }
115
- table.append(tbody);
116
429
  section.append(table);
430
+ const notes = el("aside", "footnotes");
431
+ notes.dataset.section = "footnotes";
432
+ const basis = el("p", "", w.t("groups.summary.basis"));
433
+ basis.dataset.basis = "terms";
434
+ notes.append(basis);
435
+ section.append(notes);
117
436
  host.append(section);
118
437
  }
119
- // ---------------------------------------------------------------------------
120
- // Sessions drill-down (shared by test rows and findings)
121
- // ---------------------------------------------------------------------------
122
- function checkItBlock(test) {
123
- const box = el("div", "ck");
124
- box.dataset.crit = test.criterionId;
125
- box.dataset.critVerdict = test.verdict;
126
- const head = el("div", "h");
127
- const label = test.verdict === "met"
128
- ? "✓ met"
129
- : test.verdict === "not_met"
130
- ? "✗ not met"
131
- : test.verdict === "not_applicable"
132
- ? "— not applicable"
133
- : test.verdict === "failed"
134
- ? "✗ failed verification (counted as an exception)"
135
- : test.verdict === "unsupported"
136
- ? "✗ unsupported: its evidence is not in this bundle (counted as an exception)"
137
- : "– not evaluable";
138
- head.append(element("span", label));
139
- head.append(tierBadge(test.tier));
140
- box.append(head);
141
- if (test.rationale !== undefined)
142
- box.append(el("div", "why", test.rationale));
143
- const ev = el("div", "ev");
144
- ev.append(element("span", "Evidence: "));
145
- if (test.reportDigest !== undefined)
146
- ev.append(element("code", test.reportDigest));
147
- if (test.contract !== undefined)
148
- ev.append(element("code", test.contract));
149
- if (test.judgePinDigest !== undefined)
150
- ev.append(element("code", test.judgePinDigest));
151
- if (test.reportDigest === undefined)
152
- ev.append(element("span", "absent"));
153
- box.append(ev);
438
+ /**
439
+ * The producer's findings (severity, recommendation), in one block under a
440
+ * fixed label: presentation text, not evidence (presentation contract
441
+ * section 6). Each finding's session count is the claims'; nothing here
442
+ * tallies the findings themselves.
443
+ */
444
+ function renderFindings(host, model, w) {
445
+ if (model.findings.length === 0)
446
+ return;
447
+ const section = el("section", "findings");
448
+ section.dataset.section = "findings";
449
+ section.dataset.producer = "";
450
+ section.append(el("div", "plabel", w.t("front.findings.label")), el("h2", "", w.t("front.findings.h")));
451
+ for (const finding of model.findings)
452
+ section.append(renderFinding(finding, w));
453
+ host.append(section);
454
+ }
455
+ function renderFinding(finding, w) {
456
+ const box = el("div", "fnd");
457
+ box.dataset.finding = finding.id;
458
+ const fh = el("div", "fh");
459
+ fh.append(maybeProducer(w, "b", "", w.t("groups.finding", { id: finding.id }), true), severityPill(finding.severity, w), element("span", count(w, "session", finding.sessionIds.length)));
460
+ box.append(fh);
461
+ box.append(maybeProducer(w, "div", "rec", finding.recommendation, true));
462
+ const own = el("div", "own", w.t("groups.finding.owner"));
463
+ own.append(producerText(w, finding.ownerDue));
464
+ box.append(own);
154
465
  return box;
155
466
  }
156
- function renderTranscript(session) {
157
- const t = session.transcript;
158
- const wrap = el("div", "tx");
159
- wrap.dataset.transcript = t.state;
160
- if (t.state !== "verified") {
161
- wrap.append(el("div", "ev", t.state === "absent"
162
- ? `Transcript: not in this bundle. The conversation is sealed in the case record ${session.sourceCapsuleId ?? "(not stated by the reports)"}; this page cannot show it and does not vouch for it.`
163
- : `Transcript: not shown: ${t.reason ?? "the cited transcript does not check"}.`));
164
- return wrap;
165
- }
166
- wrap.append(el("div", "ev", `Transcript: sealed in record ${t.transcriptRecordId}; its digest equals what the judged case capsule committed to (${t.inputDigest}), checked on this page. ${t.turns.length} messages, in order.`));
167
- for (const turn of t.turns) {
168
- const line = el("div", `turn ${turn.role}`);
169
- line.append(el("b", "", `${turn.role}: `));
170
- if (turn.content !== undefined)
171
- line.append(element("span", turn.content));
172
- for (const call of turn.toolCalls)
173
- line.append(el("code", "", ` ${call.name}(${call.arguments})`));
174
- wrap.append(line);
175
- }
176
- return wrap;
177
- }
178
- function renderSessionDetails(session) {
179
- const details = document.createElement("details");
180
- details.className = "session";
181
- details.dataset.session = session.conversationId;
182
- const summary = document.createElement("summary");
183
- summary.textContent = `${session.conversationId} · ${session.day}`;
184
- details.append(summary);
185
- for (const test of session.tests)
186
- details.append(checkItBlock(test));
187
- details.append(renderTranscript(session));
188
- return details;
189
- }
190
- function renderSessionList(host, conversationIds, sessions) {
191
- const byId = new Map(sessions.map((s) => [s.conversationId, s]));
192
- const details = document.createElement("details");
193
- details.dataset.records = "sessions";
194
- const summary = document.createElement("summary");
195
- summary.textContent = `${fmt(conversationIds.length)} sessions`;
196
- details.append(summary);
467
+ // ---------------------------------------------------------------------------
468
+ // Level 1: sessions, listed in place, each readable as it stands
469
+ // ---------------------------------------------------------------------------
470
+ function renderSessionList(conversationIds, model, presentation, w) {
471
+ const byId = new Map(model.sessions.map((s) => [s.conversationId, s]));
472
+ const list = el("div", "convs");
473
+ list.dataset.sessionCount = String(conversationIds.length);
197
474
  for (const id of conversationIds) {
198
475
  const session = byId.get(id);
199
476
  if (session !== undefined)
200
- details.append(renderSessionDetails(session));
477
+ list.append(renderSession(session, model, presentation, w));
201
478
  }
202
- host.append(details);
479
+ return list;
203
480
  }
204
- // ---------------------------------------------------------------------------
205
- // Section 2: test results
206
- // ---------------------------------------------------------------------------
207
- function renderTests(host, model) {
208
- const section = el("section", "");
209
- section.dataset.section = "tests";
210
- section.append(el("h2", "", "2. Test results"));
211
- section.append(el("p", "lede", "Population is the sessions a test has a sealed result for; a session with none for a test is not applicable to it and is not counted. Recomputed tests are deterministic checks anyone " +
212
- "can repeat from the records. Judged tests apply a frozen rubric with a pinned model."));
213
- const table = document.createElement("table");
214
- table.className = "grid";
215
- table.dataset.rows = "tests";
216
- const thead = document.createElement("thead");
217
- const headRow = document.createElement("tr");
218
- headRow.append(element("th", "Test"), element("th", "Requirement"), element("th", "Type"), el("th", "n", "Population"), el("th", "n", "Exceptions"), el("th", "n", "Not evaluable"), element("th", "Result"));
219
- thead.append(headRow);
220
- table.append(thead);
221
- const tbody = document.createElement("tbody");
222
- for (const obligation of model.obligations)
223
- for (const row of obligation.rows) {
224
- const tr = document.createElement("tr");
225
- tr.dataset.criterion = row.criterionId;
226
- const typeCell = document.createElement("td");
227
- typeCell.append(tierBadge(row.tier));
228
- const resultCell = document.createElement("td");
229
- const population = model.totalSessions - row.notApplicableCount;
230
- if (population > 0 &&
231
- row.notEvaluableCount === population &&
232
- row.notMetCount === 0 &&
233
- row.metCount === 0) {
234
- resultCell.append(statusPill("ne", "Not evaluable"));
235
- if (row.notEvaluableNote !== undefined)
236
- resultCell.append(el("div", "applic", row.notEvaluableNote));
237
- }
238
- else {
239
- resultCell.append(statusPill(row.notMetCount > 0 ? "exc" : "ok", row.notMetCount > 0 ? "Exceptions" : "No exceptions"));
481
+ /**
482
+ * A claim not yet in force, in words: its date as the producer copied it
483
+ * from the contract, never checked here, and never counted; beside it, the
484
+ * conditions that narrow when or to whom the obligation binds, in the
485
+ * pack's words (`row.<ref>.detail`), never the presentation block's (a
486
+ * hint with dates of its own). The date is never drawn alone (decision
487
+ * D3): with no such words, the line says the conditions are not stated.
488
+ */
489
+ function laterNote(test, w, tag) {
490
+ // A claim is later only when it carries applies_from (Result v0 4.3).
491
+ const note = el(tag, "applic", w.t("groups.later.note", { date: test.claim?.appliesFrom ?? "" }));
492
+ const conditions = w.row(test.criterionId, "detail");
493
+ note.append(" ", conditions === undefined
494
+ ? w.t("groups.later.conditions-not-stated")
495
+ : packWord("span", "", conditions));
496
+ return note;
497
+ }
498
+ function isException(test) {
499
+ return test.verdict === "not_met";
500
+ }
501
+ function isUnverified(test) {
502
+ return test.verdict === "failed" || test.verdict === "unsupported";
503
+ }
504
+ /** One session, in place inside a level-1 toggle: a header line and its body right below it, never a toggle of its own; the body is built when it scrolls near the view. */
505
+ function renderSession(session, model, presentation, w) {
506
+ const names = testNames(model, w);
507
+ const exceptions = session.tests.filter(isException);
508
+ const unverified = session.tests.filter(isUnverified);
509
+ const undecided = session.tests.filter((t) => t.verdict === "not_evaluable");
510
+ const parts = caseParts(session.conversationId, w);
511
+ const item = el("article", "conv session");
512
+ item.dataset.session = session.conversationId;
513
+ const head = el("div", "conv-h");
514
+ head.append(el("span", "cid", parts.label));
515
+ head.append(exceptions.length > 0
516
+ ? wordPill({ word: count(w, "exception", exceptions.length), tone: "bad" }, "exceptions")
517
+ : unverified.length > 0
518
+ ? wordPill({ word: w.t("groups.session.unverified"), tone: "ne" }, "unverified")
519
+ : undecided.length > 0
520
+ ? wordPill({ word: w.t("groups.session.undecided"), tone: "ne" }, "undecided")
521
+ : session.tests.some((t) => t.verdict === "met")
522
+ ? wordPill({ word: w.t("groups.session.ok"), tone: "ok" }, "ok")
523
+ : wordPill({ word: w.t("groups.session.none"), tone: "na" }, "none"));
524
+ const why = el("span", "cwhy");
525
+ (exceptions.length > 0
526
+ ? exceptions
527
+ : unverified.length > 0
528
+ ? unverified
529
+ : undecided).forEach((t, i) => {
530
+ if (i > 0)
531
+ why.append(", ");
532
+ why.append(names(t.criterionId, "span", ""));
533
+ });
534
+ head.append(why);
535
+ head.append(el("span", "cmodel", parts.model ?? session.day));
536
+ item.append(head);
537
+ const body = el("div", "conv-slot");
538
+ item.append(body);
539
+ lazyBody(body, () => sessionBody(session, model, presentation, w));
540
+ return item;
541
+ }
542
+ function sessionBody(session, model, presentation, w) {
543
+ const names = testNames(model, w);
544
+ const body = el("div", "conv-b");
545
+ body.append(el("h4", "", w.t("groups.h.test-by-test")));
546
+ for (const test of session.tests) {
547
+ const box = el("div", "ck");
548
+ box.dataset.crit = test.criterionId;
549
+ box.dataset.critVerdict = test.verdict;
550
+ const h = el("div", "h");
551
+ h.append(wordPill(ruleWord(test.verdict, judgedOf(test.reportState, test.judgePinDigest), w), test.verdict));
552
+ h.append(names(test.criterionId, "span", "tname"));
553
+ if (test.verdict !== "not_applicable" &&
554
+ test.verdict !== "not_yet_in_force")
555
+ h.append(tierBadge(test.tier, w));
556
+ if (test.verdict === "failed" || test.verdict === "unsupported")
557
+ h.append(el("span", "applic", w.t("groups.unverified-note")));
558
+ if (test.verdict === "not_yet_in_force")
559
+ h.append(laterNote(test, w, "span"));
560
+ box.append(h);
561
+ if (test.rationale !== undefined)
562
+ box.append(el("div", "why", judgeNote(test.rationale, test.claim?.verdict ?? test.verdict, w)));
563
+ body.append(box);
564
+ }
565
+ if (session.tests.every((t) => t.rationale === undefined)) {
566
+ const gap = el("p", "small", notesGap(session.tests.flatMap((t) => t.claim === undefined ? [] : [t.reportState]), w));
567
+ gap.dataset.gaps = "true";
568
+ body.append(gap);
569
+ }
570
+ body.append(conversationFold(session.transcript, session.sourceCapsuleId, w));
571
+ body.append(levelToggle(2, w.t("card.proofs.toggle"), () => sessionProofs(session, model, w), { className: "proofs" }));
572
+ return body;
573
+ }
574
+ function sessionProofs(session, model, w) {
575
+ const names = testNames(model, w);
576
+ const box = el("div", "pf-b");
577
+ box.dataset.proofsFor = session.conversationId;
578
+ // Which date the session is counted under, verbatim, beside the sealed day:
579
+ // the outcome card's rule, so a backfilled session never reads as if it
580
+ // happened on the day it was sealed.
581
+ const dated = session.dated;
582
+ const dating = dated.basis === "judged"
583
+ ? []
584
+ : [
585
+ [w.t("groups.pf.dated"), datedText(dated, w), { dated: dated.basis }],
586
+ ...(dated.importedAt === undefined
587
+ ? []
588
+ : [
589
+ [
590
+ w.t("card.pf.imported"),
591
+ dated.importedAt,
592
+ { imported: "" },
593
+ ],
594
+ ]),
595
+ ];
596
+ const rows = [
597
+ [w.t("groups.pf.session"), session.conversationId],
598
+ ...dating,
599
+ [w.t("card.pf.judged-sealed"), session.judgedDay, { sealed: "" }],
600
+ [
601
+ w.t("card.pf.case-record"),
602
+ session.sourceCapsuleId === undefined
603
+ ? w.t("card.pf.case-record.not-stated")
604
+ : session.caseFrom === "claims"
605
+ ? w.t("groups.pf.case-record.from-claims", {
606
+ record: session.sourceCapsuleId,
607
+ })
608
+ : session.sourceCapsuleId,
609
+ ],
610
+ ];
611
+ rows.push(...transcriptRows(session.transcript, w));
612
+ rows.push([w.t("card.pf.result-capsule"), model.capsuleId]);
613
+ const dl = proofList(rows);
614
+ dl.dataset.checkIt = session.conversationId;
615
+ box.append(dl);
616
+ box.append(el("h5", "", w.t("groups.pf.h.each-report")));
617
+ for (const test of session.tests) {
618
+ const ev = el("div", "ev");
619
+ ev.dataset.proofCrit = test.criterionId;
620
+ const label = names(test.criterionId, "b", "");
621
+ label.append(": ");
622
+ ev.append(label);
623
+ if (test.verdict === "not_applicable") {
624
+ ev.append(element("span", w.t("groups.pf.no-claim")));
625
+ }
626
+ else if (test.verdict === "not_yet_in_force") {
627
+ ev.append(laterNote(test, w, "span"));
628
+ }
629
+ else {
630
+ if (test.reportDigest !== undefined)
631
+ ev.append(element("code", test.reportDigest));
632
+ if (test.contract !== undefined)
633
+ ev.append(element("code", test.contract));
634
+ if (test.judgePinDigest !== undefined)
635
+ ev.append(element("code", w.t("groups.pf.judge-pin", { digest: test.judgePinDigest })));
636
+ if (test.rationale !== undefined) {
637
+ const sealed = el("div", "sealed", w.t("groups.pf.rationale", { rationale: test.rationale }));
638
+ sealed.dataset.rationale = "sealed";
639
+ ev.append(sealed);
240
640
  }
241
- tr.append(el("td", "b", `${obligation.article}`), element("td", row.name), typeCell, el("td", "n", fmt(population)), el("td", "n", fmt(row.notMetCount)), el("td", "n", fmt(row.notEvaluableCount)), resultCell);
242
- tbody.append(tr);
243
- const drill = document.createElement("tr");
244
- const drillCell = document.createElement("td");
245
- drillCell.colSpan = 7;
246
- const sessionIds = [
247
- ...(row.sessionsByVerdict.get("not_met") ?? []),
248
- ...(row.sessionsByVerdict.get("not_evaluable") ?? []),
249
- ];
250
- if (sessionIds.length > 0)
251
- renderSessionList(drillCell, sessionIds, model.sessions);
252
- drill.append(drillCell);
253
- tbody.append(drill);
641
+ if (test.reportDigest === undefined)
642
+ ev.append(element("span", w.t("groups.pf.absent")));
254
643
  }
255
- table.append(tbody);
256
- section.append(table);
257
- host.append(section);
644
+ // contract-report/v1 section 2: assurance stays on the claim.
645
+ if (test.claim !== undefined)
646
+ ev.append(proofList([assuranceRow(test.claim, w)]));
647
+ box.append(ev);
648
+ }
649
+ return box;
258
650
  }
259
651
  // ---------------------------------------------------------------------------
260
- // Section 3: findings
652
+ // Proofs for the whole report
261
653
  // ---------------------------------------------------------------------------
262
- function renderFindings(host, model) {
263
- const section = el("section", "");
264
- section.dataset.section = "findings";
265
- section.append(el("h2", "", "3. Findings"));
266
- if (model.findings.length === 0) {
267
- section.append(el("p", "lede", "No findings: every test with a not-met session count above zero would have produced one."));
268
- host.append(section);
269
- return;
270
- }
271
- for (const finding of model.findings) {
272
- const box = el("div", "fnd");
273
- box.dataset.finding = finding.id;
274
- const fh = el("div", "fh");
275
- fh.append(el("b", "", finding.id), severityPill(finding.severity), element("span", finding.article), el("span", "", finding.testName));
276
- box.append(fh);
277
- const table = document.createElement("table");
278
- table.className = "fk";
279
- const evRow = document.createElement("tr");
280
- evRow.append(element("th", "Evidence"), element("td", `${fmt(finding.sessionIds.length)} sessions`));
281
- const recRow = document.createElement("tr");
282
- recRow.append(element("th", "Recommendation"), el("td", "", finding.recommendation));
283
- const ownerRow = document.createElement("tr");
284
- ownerRow.append(element("th", "Owner · due"), element("td", finding.ownerDue));
285
- table.append(evRow, recRow, ownerRow);
286
- box.append(table);
287
- renderSessionList(box, finding.sessionIds, model.sessions);
288
- section.append(box);
289
- }
654
+ function pinText(model, w) {
655
+ if (model.runInfo.judgePinDigest !== undefined)
656
+ return model.runInfo.judgePinDigest;
657
+ if (!model.runInfo.pinned)
658
+ return w.t("groups.pin.differs");
659
+ return pinAbsence(model.runInfo, w) ?? w.t("groups.pin.none");
660
+ }
661
+ function renderReportProofs(host, model, bundle, verified, w) {
662
+ const section = el("section", "rp");
663
+ section.dataset.section = "report-proofs";
664
+ section.append(levelToggle(2, w.t("groups.rp.toggle"), () => {
665
+ const box = el("div", "pf-b");
666
+ renderObligationDetails(box, model, w);
667
+ renderQuality(box, model, w);
668
+ renderWhatRan(box, model, w);
669
+ renderVerificationDetails(box, bundle, verified, w);
670
+ return box;
671
+ }, { className: "proofs" }));
290
672
  host.append(section);
291
673
  }
292
- // ---------------------------------------------------------------------------
293
- // Section 4: quality of judged results
294
- // ---------------------------------------------------------------------------
295
- function renderQuality(host, model) {
296
- const section = el("section", "");
297
- section.dataset.section = "quality";
298
- section.append(el("h2", "", "4. Quality of judged results"));
674
+ function renderObligationDetails(host, model, w) {
675
+ const part = el("div", "rp-s");
676
+ part.dataset.section = "obligation-detail";
677
+ part.append(el("h3", "", w.t("groups.od.h")));
678
+ for (const obligation of model.obligations) {
679
+ const box = el("div", "obd");
680
+ box.dataset.obligationDetail = obligation.key;
681
+ box.dataset.mapped = String(obligation.mapped);
682
+ const heading = element("h5");
683
+ heading.append(...obligationName(w, obligation, element("span", obligation.article)));
684
+ box.append(heading);
685
+ box.append(el("p", "na", w.t(obligation.mapped ? "groups.od.mapped" : "groups.od.unmapped")));
686
+ if (obligation.judgedTerms.length > 0) {
687
+ const terms = el("p", "applic", w.t("groups.od.judged-terms"));
688
+ terms.append(producerText(w, obligation.judgedTerms.join(", ")));
689
+ box.append(terms);
690
+ }
691
+ box.append(maybeProducer(w, "p", "", obligation.method, obligation.mapped));
692
+ for (const row of obligation.rows) {
693
+ const rowBox = el("div", "ck");
694
+ rowBox.dataset.wording = row.wording.source;
695
+ const h = el("div", "h");
696
+ h.append(rowName(w, "span", "", row), tierBadge(row.tier, w));
697
+ rowBox.append(h);
698
+ rowBox.append(el("div", "why", row.wording.source === "sealed"
699
+ ? w.t("groups.od.wording.sealed", { text: row.wording.text })
700
+ : w.t(row.wording.source === "mixed"
701
+ ? "groups.od.wording.mixed"
702
+ : "groups.od.wording.unstated")));
703
+ const packNote = w.row(row.criterionId, "not_evaluable");
704
+ if (packNote !== undefined)
705
+ rowBox.append(packWord("div", "ev", packNote));
706
+ else if (row.notEvaluableNote !== undefined)
707
+ rowBox.append(maybeProducer(w, "div", "ev", row.notEvaluableNote, true));
708
+ box.append(rowBox);
709
+ }
710
+ part.append(box);
711
+ }
712
+ host.append(part);
713
+ }
714
+ function renderQuality(host, model, w) {
715
+ const part = el("div", "rp-s");
716
+ part.dataset.section = "quality";
717
+ part.append(el("h3", "", w.t("groups.q.h")));
299
718
  const protocol = model.qualityProtocol;
300
719
  if (protocol === undefined) {
301
- section.append(el("p", "lede", "No quality protocol declared in this pack."));
302
- host.append(section);
720
+ part.append(el("p", "", w.t("groups.q.none")));
721
+ host.append(part);
303
722
  return;
304
723
  }
305
- section.append(el("p", "lede", `Protocol ${protocol.protocol ?? "unspecified"}${protocol.cadence === undefined ? "" : `, ${protocol.cadence}`}. Recomputed tests are not sampled.`));
724
+ const line = el("p", "", w.t("groups.q.protocol"));
725
+ line.append(protocol.protocol === undefined
726
+ ? w.t("groups.q.unspecified")
727
+ : producerText(w, protocol.protocol));
728
+ if (protocol.cadence !== undefined)
729
+ line.append(", ", producerText(w, protocol.cadence));
730
+ line.append(w.t("groups.q.tail"));
731
+ part.append(line);
306
732
  if (protocol.note !== undefined)
307
- section.append(el("p", "na", protocol.note));
308
- host.append(section);
733
+ part.append(maybeProducer(w, "p", "na", protocol.note, true));
734
+ host.append(part);
309
735
  }
310
- // ---------------------------------------------------------------------------
311
- // Section 5: methodology / what ran
312
- // ---------------------------------------------------------------------------
313
- function renderWhatRan(host, model) {
314
- const section = el("section", "");
315
- section.dataset.section = "methodology";
316
- section.append(el("h2", "", "5. Methodology"));
317
- const ran = el("div", "ran");
318
- const field = (label, value) => {
319
- const it = el("div", "it");
320
- it.append(el("div", "k", label), el("div", "v", value));
321
- ran.append(it);
322
- };
323
- field("Contract", model.runInfo.contract ??
324
- (model.runInfo.pinned ? "no conversations" : "disagrees across sessions"));
325
- field("Judge pin digest", model.runInfo.judgePinDigest ??
326
- (model.runInfo.pinned
327
- ? "no judged sessions cited"
328
- : "disagrees across sessions"));
329
- field("Sessions", fmt(model.totalSessions));
330
- section.append(ran);
331
- host.append(section);
332
- }
333
- // ---------------------------------------------------------------------------
334
- // Per-obligation detail (plain-language text, method, judged terms)
335
- // ---------------------------------------------------------------------------
336
- function renderObligationDetail(host, obligation) {
337
- const details = document.createElement("details");
338
- details.dataset.obligationDetail = obligation.key;
339
- const summary = document.createElement("summary");
340
- summary.textContent = `${obligation.article} · ${obligation.title}`;
341
- details.append(summary);
342
- details.dataset.mapped = String(obligation.mapped);
343
- details.append(el("p", "na", obligation.mapped
344
- ? "Article, summary and method: the producer's mapping, not a sealed record."
345
- : `The producer's extension does not map this obligation: article, summary and method ${NOT_STATED}.`));
346
- details.append(el("p", "", obligation.plain));
347
- if (obligation.judgedTerms.length > 0)
348
- details.append(el("p", "applic", `Judged terms: ${obligation.judgedTerms.join(", ")}`));
349
- details.append(el("p", "", obligation.method));
350
- for (const row of obligation.rows) {
351
- const rowBox = el("div", "ck");
352
- rowBox.dataset.wording = row.wording.source;
353
- const h = el("div", "h");
354
- h.append(element("span", row.name), tierBadge(row.tier));
355
- rowBox.append(h);
356
- rowBox.append(el("div", "why", row.wording.source === "sealed"
357
- ? `Wording run (sealed): ${row.wording.text}`
358
- : row.wording.source === "mixed"
359
- ? `Wording ${NOT_STATED}: the cited reports state different wordings.`
360
- : `Wording ${NOT_STATED}: no cited report states it.`));
361
- if (row.notEvaluableNote !== undefined)
362
- rowBox.append(el("div", "ev", row.notEvaluableNote));
363
- details.append(rowBox);
736
+ function renderWhatRan(host, model, w) {
737
+ const part = el("div", "rp-s");
738
+ part.dataset.section = "methodology";
739
+ part.append(el("h3", "", w.t("groups.ran.h")));
740
+ const dl = proofList([
741
+ [
742
+ w.t("groups.ran.contract"),
743
+ model.runInfo.contract ??
744
+ w.t(model.runInfo.pinned
745
+ ? "groups.ran.contract.none"
746
+ : "groups.ran.contract.differs"),
747
+ ],
748
+ [w.t("groups.ran.judge-pin"), pinText(model, w)],
749
+ [w.t("groups.ran.sessions"), fmt(model.totalSessions)],
750
+ ...(model.dating.from === undefined || model.dating.to === undefined
751
+ ? []
752
+ : [
753
+ [
754
+ w.t("groups.ran.period"),
755
+ span([model.dating.from, model.dating.to], w),
756
+ { period: "" },
757
+ ],
758
+ ]),
759
+ ...(model.dating.basis === "judged"
760
+ ? []
761
+ : [
762
+ [
763
+ w.t("groups.ran.sealed"),
764
+ span(model.dating.judgedDays, w),
765
+ { sealed: "" },
766
+ ],
767
+ ]),
768
+ [w.t("card.pf.result-capsule"), model.capsuleId],
769
+ wordingRow(w),
770
+ ]);
771
+ dl.dataset.ran = "true";
772
+ part.append(dl);
773
+ const note = datingStatement(model.dating, model.totalSessions, w);
774
+ if (note !== undefined) {
775
+ const p = el("p", "na", note);
776
+ p.dataset.dateNote = model.dating.basis;
777
+ part.append(p);
364
778
  }
365
- host.append(details);
779
+ host.append(part);
366
780
  }
367
- function renderObligationDetails(host, model) {
368
- const section = el("section", "");
369
- section.dataset.section = "obligation-detail";
370
- section.append(el("h2", "", "Obligation detail"));
371
- for (const obligation of model.obligations)
372
- renderObligationDetail(section, obligation);
373
- host.append(section);
781
+ function renderVerificationDetails(host, bundle, verified, w) {
782
+ const part = el("div", "rp-s");
783
+ part.dataset.section = "verification-details";
784
+ part.append(el("h3", "", w.t("card.vd.h")));
785
+ const model = buildVerificationPageModel(bundle, verified);
786
+ part.append(proofList(verificationRows(model, w)));
787
+ part.append(el("p", "", w.t("groups.vd.note")));
788
+ host.append(part);
374
789
  }
375
790
  // ---------------------------------------------------------------------------
376
791
  // Assembly
377
792
  // ---------------------------------------------------------------------------
378
- export function renderCompliancePage(result, presentation, _bundle, _verified, root) {
793
+ /** The `groups` grouping's page wrapper: its element, class, page name and stylesheet. */
794
+ export const GROUPS_FRAME = {
795
+ tag: "div",
796
+ className: "cc",
797
+ page: "compliance",
798
+ css: COMPLIANCE_CSS,
799
+ };
800
+ /**
801
+ * Draw the `groups` grouping into `wrapper` (contract-report.ts made it and
802
+ * put its stylesheet in it). Every word is `w`'s.
803
+ */
804
+ export async function drawGroups(levels, result, presentation, bundle, verified, w) {
379
805
  const model = buildComplianceModel(result, presentation);
380
- const wrapper = el("div", "cc");
381
- wrapper.dataset.page = "compliance";
382
- const style = document.createElement("style");
383
- style.textContent = COMPLIANCE_CSS;
384
- wrapper.append(style);
385
- renderHeader(wrapper, model);
386
- renderSummary(wrapper, model);
387
- renderObligationDetails(wrapper, model);
388
- renderTests(wrapper, model);
389
- renderFindings(wrapper, model);
390
- renderQuality(wrapper, model);
391
- renderWhatRan(wrapper, model);
392
- root.append(wrapper);
806
+ const claims = model.sessions.flatMap((s) => s.tests.flatMap((t) => (t.claim === undefined ? [] : [t.claim])));
807
+ // L0, what matters: the header with the mock-judge mark (D5 b), the
808
+ // sealed aggregate.
809
+ const mock = renderMockJudgeLine(await tallyJudges(result.records, claims), w);
810
+ // One L0 card: the header (with the mark) and the aggregate.
811
+ const sheet = el("div", "l0-card");
812
+ renderHeader(sheet, model, w);
813
+ const header = sheet.querySelector(".hd");
814
+ if (header !== null)
815
+ placeMockMark(header, mock);
816
+ else if (mock !== undefined)
817
+ sheet.prepend(mock);
818
+ sheet.append(renderAggregate(result, w));
819
+ levels.L0.append(sheet);
820
+ // L1, why: the tests, led by who judged, who witnessed, what verified.
821
+ renderSummary(levels.L1, model, presentation, w);
822
+ leadWithProvenance(levels.L1, levels.L1.querySelector('[data-section="summary"]'), renderProvenance(await provenanceLines(result.records, claims, bundle, verified, w)));
823
+ renderFindings(levels.L1, model, w);
824
+ // L2, module detail after the core's verification section.
825
+ levels.L2.append(renderCheckYourself(bundle, w));
826
+ renderReportProofs(levels.L2, model, bundle, verified, w);
393
827
  }
394
828
  //# sourceMappingURL=compliance-view.js.map