@action-state-group/capsule-viewer 0.7.0 → 0.9.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 +6 -1
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +5 -0
- package/dist/browser.js.map +1 -1
- package/dist/compliance-styles.js +7 -0
- package/dist/compliance-styles.js.map +1 -1
- package/dist/compliance-view.d.ts +4 -3
- package/dist/compliance-view.js +145 -90
- package/dist/compliance-view.js.map +1 -1
- package/dist/contract-report-wording.d.ts +2 -1
- package/dist/contract-report-wording.js +41 -3
- package/dist/contract-report-wording.js.map +1 -1
- package/dist/contract-report.d.ts +16 -1
- package/dist/contract-report.js +31 -3
- package/dist/contract-report.js.map +1 -1
- package/dist/core-strip.d.ts +1 -1
- package/dist/core-strip.js +7 -4
- package/dist/core-strip.js.map +1 -1
- package/dist/emitter-shell.html +16 -0
- package/dist/evidence-contract.d.ts +61 -0
- package/dist/evidence-contract.js +83 -0
- package/dist/evidence-contract.js.map +1 -0
- package/dist/evidence-graph-view.d.ts +10 -0
- package/dist/evidence-graph-view.js +48 -26
- package/dist/evidence-graph-view.js.map +1 -1
- package/dist/evidence-graph.iife.js +2872 -1289
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/outcome-report-styles.js +9 -0
- package/dist/outcome-report-styles.js.map +1 -1
- package/dist/outcome-report-view.d.ts +21 -6
- package/dist/outcome-report-view.js +350 -154
- package/dist/outcome-report-view.js.map +1 -1
- package/dist/presentation-builder.d.ts +14 -0
- package/dist/presentation-builder.js +45 -1
- package/dist/presentation-builder.js.map +1 -1
- package/dist/presentation-fragment.d.ts +3 -0
- package/dist/presentation-fragment.js +9 -0
- package/dist/presentation-fragment.js.map +1 -1
- package/dist/presentation-mount.d.ts +3 -0
- package/dist/presentation-mount.js +2 -0
- package/dist/presentation-mount.js.map +1 -1
- package/dist/reader-witnesses.d.ts +39 -0
- package/dist/reader-witnesses.js +111 -0
- package/dist/reader-witnesses.js.map +1 -0
- package/dist/report-legend.d.ts +6 -7
- package/dist/report-legend.js +16 -9
- package/dist/report-legend.js.map +1 -1
- package/dist/report-levels.d.ts +11 -0
- package/dist/report-levels.js +24 -1
- package/dist/report-levels.js.map +1 -1
- package/dist/spot-check.js +10 -5
- package/dist/spot-check.js.map +1 -1
- package/dist/subject-history.d.ts +77 -0
- package/dist/subject-history.js +439 -0
- package/dist/subject-history.js.map +1 -0
- package/dist/viewer-build.js +2 -2
- package/dist/wording/contract-report-eu-ai-act.en.json +18 -1
- package/dist/wording/contract-report-outcomes.en.json +73 -6
- package/package.json +2 -2
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { disclosureOf, verifiedBundleContext, } from "@action-state-group/agent-action-capsule";
|
|
1
2
|
import { buildOutcomeReportModel, NOT_STATED, verifyJudgePin, } from "@action-state-group/agent-action-capsule";
|
|
2
3
|
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";
|
|
4
|
+
import { judgedOf, lazyBody, levelToggle, proofList, conversationFold, evidenceAction, ruleWord, wordPill, caseParts, judgeNote, assuranceRow, withheldMark, reportSummary, } from "./report-levels.js";
|
|
4
5
|
import { buildVerificationPageModel } from "@action-state-group/agent-action-capsule";
|
|
5
6
|
import { renderLegend, tagSource } from "./report-legend.js";
|
|
6
7
|
import { provenanceLines, renderProvenance } from "./report-provenance.js";
|
|
7
8
|
import { expandableRow, leadWithProvenance, renderCheckYourself, } from "./report-front.js";
|
|
8
9
|
import { spotCheckToggle } from "./spot-check.js";
|
|
10
|
+
import { readSubjectHistory, renderSubjectHistory, } from "./subject-history.js";
|
|
11
|
+
import { ROW_TIERS } from "./evidence-contract.js";
|
|
9
12
|
/**
|
|
10
13
|
* The contract-report module's `lines` grouping (contract-report.ts): a
|
|
11
14
|
* report read as result lines, results rule by rule, day by day and human
|
|
@@ -181,7 +184,55 @@ function isUnverified(verdict) {
|
|
|
181
184
|
function notApplying(verdict) {
|
|
182
185
|
return verdict === "not_applicable" || verdict === "out_of_scope";
|
|
183
186
|
}
|
|
184
|
-
|
|
187
|
+
/** A conversation as the derived lines read it (`Gating`). */
|
|
188
|
+
function counted(conversation, gating) {
|
|
189
|
+
return gating?.counted.get(conversation) ?? conversation;
|
|
190
|
+
}
|
|
191
|
+
/** A row's requirement tier chip (contract-report/v1 section 3, `requirement_tier.*`). */
|
|
192
|
+
function tierChip(tier, w) {
|
|
193
|
+
const chip = el("span", "rtier", w.t(`requirement_tier.${tier}`));
|
|
194
|
+
chip.dataset.requirementTier = tier;
|
|
195
|
+
return chip;
|
|
196
|
+
}
|
|
197
|
+
/** A rule's requirement tier, when the page has a contract. */
|
|
198
|
+
function criterionTier(c, gating) {
|
|
199
|
+
return gating?.tierOf(c.claim?.contractRef, `${c.checkId}.${c.criterionId}`);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The roll-up agent-action-capsule's outcome model applies to a
|
|
203
|
+
* conversation (outcome-report.js `rollUp`), over the rules left in.
|
|
204
|
+
*/
|
|
205
|
+
function rollUp(verdicts) {
|
|
206
|
+
if (verdicts.length === 0)
|
|
207
|
+
return "not_evaluable";
|
|
208
|
+
if (verdicts.some((v) => v === "not_met" || isUnverified(v)))
|
|
209
|
+
return "not_met";
|
|
210
|
+
if (verdicts.some((v) => v === "not_evaluable" || v === "no_claim"))
|
|
211
|
+
return "not_evaluable";
|
|
212
|
+
if (!verdicts.some((v) => v === "met"))
|
|
213
|
+
return "not_evaluable";
|
|
214
|
+
return "met";
|
|
215
|
+
}
|
|
216
|
+
export function gating(conversations, tierOf) {
|
|
217
|
+
const map = new Map();
|
|
218
|
+
const out = { tierOf, counted: map };
|
|
219
|
+
for (const conversation of conversations) {
|
|
220
|
+
const kept = conversation.criteria.filter((c) => criterionTier(c, out) !== "informational");
|
|
221
|
+
if (kept.length === conversation.criteria.length)
|
|
222
|
+
continue;
|
|
223
|
+
map.set(conversation, {
|
|
224
|
+
...conversation,
|
|
225
|
+
criteria: kept,
|
|
226
|
+
verdict: rollUp(kept.map((c) => c.verdict)),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return out;
|
|
230
|
+
}
|
|
231
|
+
export function conversationStatus(given, gating) {
|
|
232
|
+
const conversation = counted(given, gating);
|
|
233
|
+
// Every rule it has is informational: none of them is in its answer.
|
|
234
|
+
if (conversation !== given && conversation.criteria.length === 0)
|
|
235
|
+
return "nothing-applied";
|
|
185
236
|
if (conversation.verdict === "met")
|
|
186
237
|
return "resolved";
|
|
187
238
|
if (conversation.criteria.some((c) => isMiss(c.verdict)))
|
|
@@ -197,7 +248,7 @@ export function conversationStatus(conversation) {
|
|
|
197
248
|
}
|
|
198
249
|
// Result words never come from the bundle (presentation contract section
|
|
199
250
|
// 6): they are the card's wording pack's.
|
|
200
|
-
export function statusWord(status, conversation, w) {
|
|
251
|
+
export function statusWord(status, conversation, w, gating) {
|
|
201
252
|
if (status === "resolved")
|
|
202
253
|
return { word: w.t("lines.status.resolved"), tone: "ok" };
|
|
203
254
|
if (status === "missed")
|
|
@@ -212,8 +263,8 @@ export function statusWord(status, conversation, w) {
|
|
|
212
263
|
// tells them apart.
|
|
213
264
|
// A `no_claim` rule is undecided with no judge run on it (no claim, so no
|
|
214
265
|
// report): it counts as unjudged.
|
|
215
|
-
const judged = conversation
|
|
216
|
-
.filter((c) => c.verdict === "not_evaluable" || c.verdict === "no_claim")
|
|
266
|
+
const judged = counted(conversation, gating)
|
|
267
|
+
.criteria.filter((c) => c.verdict === "not_evaluable" || c.verdict === "no_claim")
|
|
217
268
|
.map((c) => c.verdict === "no_claim"
|
|
218
269
|
? "no"
|
|
219
270
|
: judgedOf(c.reportState, c.judgePinDigest));
|
|
@@ -283,7 +334,7 @@ function unverifiedClause(model, list, w, lower = false) {
|
|
|
283
334
|
}
|
|
284
335
|
/** One plain sentence: the conversation's result and the rules behind it. */
|
|
285
336
|
function resultSentence(conversation, model, w) {
|
|
286
|
-
const all = conversation.criteria;
|
|
337
|
+
const all = counted(conversation, model.gating).criteria;
|
|
287
338
|
const applied = all.filter((c) => !notApplying(c.verdict));
|
|
288
339
|
const outOfScope = all.filter((c) => c.verdict === "out_of_scope").length;
|
|
289
340
|
const na = all.length - applied.length - outOfScope;
|
|
@@ -302,7 +353,7 @@ function resultSentence(conversation, model, w) {
|
|
|
302
353
|
? ` ${w.t("lines.sentence.out-of-scope", { n: String(outOfScope) })}`
|
|
303
354
|
: ""}`;
|
|
304
355
|
const unverifiedText = unverified.length > 0 ? ` ${unverifiedClause(model, unverified, w)}` : "";
|
|
305
|
-
switch (conversationStatus(conversation)) {
|
|
356
|
+
switch (conversationStatus(conversation, model.gating)) {
|
|
306
357
|
case "resolved":
|
|
307
358
|
return `${w.p("lines.sentence.resolved", applied.length, { n: String(applied.length) })}${naText}`;
|
|
308
359
|
case "missed":
|
|
@@ -343,19 +394,21 @@ function resultSentence(conversation, model, w) {
|
|
|
343
394
|
* own. The body is built when it scrolls near the view (`lazyBody`).
|
|
344
395
|
*/
|
|
345
396
|
function renderConversation(conversation, model, runInfo, w) {
|
|
346
|
-
const status = conversationStatus(conversation);
|
|
397
|
+
const status = conversationStatus(conversation, model.gating);
|
|
347
398
|
const item = el("article", "conv");
|
|
348
399
|
item.dataset.conversation = conversation.conversationId;
|
|
349
|
-
|
|
400
|
+
// The header's line is a derived one: it reads the rules in the answer.
|
|
401
|
+
const inAnswer = counted(conversation, model.gating);
|
|
402
|
+
item.dataset.conversationVerdict = inAnswer.verdict;
|
|
350
403
|
item.dataset.status = status;
|
|
351
404
|
const head = el("div", "conv-h");
|
|
352
405
|
const parts = caseParts(conversation.conversationId, w);
|
|
353
406
|
head.append(el("span", "cid", parts.label));
|
|
354
|
-
head.append(wordPill(statusWord(status, conversation, w), status));
|
|
355
|
-
const misses =
|
|
356
|
-
const unverified =
|
|
357
|
-
const undecided =
|
|
358
|
-
const outOfScope =
|
|
407
|
+
head.append(wordPill(statusWord(status, conversation, w, model.gating), status));
|
|
408
|
+
const misses = inAnswer.criteria.filter((c) => isMiss(c.verdict));
|
|
409
|
+
const unverified = inAnswer.criteria.filter((c) => isUnverified(c.verdict));
|
|
410
|
+
const undecided = inAnswer.criteria.filter((c) => c.verdict === "not_evaluable" || c.verdict === "no_claim");
|
|
411
|
+
const outOfScope = inAnswer.criteria.filter((c) => c.verdict === "out_of_scope");
|
|
359
412
|
head.append(el("span", "cwhy", status === "missed"
|
|
360
413
|
? w.t("lines.why.missed", { names: names(model, misses, w) })
|
|
361
414
|
: status === "unverified"
|
|
@@ -370,8 +423,8 @@ function renderConversation(conversation, model, runInfo, w) {
|
|
|
370
423
|
? w.t("lines.why.nothing-applied")
|
|
371
424
|
: outOfScope.length === 0
|
|
372
425
|
? w.t("lines.why.resolved")
|
|
373
|
-
: w.p("lines.why.resolved-out-of-scope",
|
|
374
|
-
n: fmtCount(
|
|
426
|
+
: w.p("lines.why.resolved-out-of-scope", inAnswer.criteria.length - outOfScope.length, {
|
|
427
|
+
n: fmtCount(inAnswer.criteria.length - outOfScope.length),
|
|
375
428
|
oos: fmtCount(outOfScope.length),
|
|
376
429
|
})));
|
|
377
430
|
head.append(el("span", "cmodel", parts.model ?? ""));
|
|
@@ -384,7 +437,7 @@ function renderConversation(conversation, model, runInfo, w) {
|
|
|
384
437
|
function conversationBody(conversation, model, runInfo, w) {
|
|
385
438
|
const body = el("div", "conv-b");
|
|
386
439
|
const sentence = el("p", "verdict-line", resultSentence(conversation, model, w));
|
|
387
|
-
sentence.dataset.why = conversationStatus(conversation);
|
|
440
|
+
sentence.dataset.why = conversationStatus(conversation, model.gating);
|
|
388
441
|
body.append(sentence);
|
|
389
442
|
// Rule by rule, in plain words
|
|
390
443
|
body.append(el("h4", "", w.t("lines.h.rule-by-rule")));
|
|
@@ -414,6 +467,13 @@ function conversationBody(conversation, model, runInfo, w) {
|
|
|
414
467
|
const rowBadge = editedBadge(model, ref, w);
|
|
415
468
|
if (rowBadge !== undefined)
|
|
416
469
|
nameCell.append(rowBadge);
|
|
470
|
+
// The rule's tier, so a conversation resolved over an informational
|
|
471
|
+
// rule not met says why that rule did not count.
|
|
472
|
+
const tier = criterionTier(criterion, model.gating);
|
|
473
|
+
if (tier !== undefined) {
|
|
474
|
+
tr.dataset.requirementTier = tier;
|
|
475
|
+
nameCell.append(tierChip(tier, w));
|
|
476
|
+
}
|
|
417
477
|
if (label.source === "sealed") {
|
|
418
478
|
const wording = tagSource(el("small", "", label.text), "producer");
|
|
419
479
|
wording.dataset.wording = label.source;
|
|
@@ -618,6 +678,9 @@ function conversationProofs(conversation, model, runInfo, w) {
|
|
|
618
678
|
const cell = element("td", text);
|
|
619
679
|
for (const [key, value] of Object.entries(data))
|
|
620
680
|
cell.dataset[key] = value;
|
|
681
|
+
const mark = withheldMark(criterion.claim, w);
|
|
682
|
+
if (mark !== undefined)
|
|
683
|
+
cell.append(el("br", ""), mark);
|
|
621
684
|
tr.append(cell);
|
|
622
685
|
}
|
|
623
686
|
tbody.append(tr);
|
|
@@ -720,13 +783,13 @@ function groupTitle(check, w) {
|
|
|
720
783
|
* label (`terms.reasonCodes`), else the first rule not met; a raw code is
|
|
721
784
|
* never shown.
|
|
722
785
|
*/
|
|
723
|
-
export function groupMissedReasons(missed, terms, w) {
|
|
786
|
+
export function groupMissedReasons(missed, terms, w, gating) {
|
|
724
787
|
const labelledReasonCode = (code) => code === undefined ? undefined : terms.reasonCodes[code];
|
|
725
788
|
const groups = new Map();
|
|
726
789
|
const structured = new Map();
|
|
727
790
|
const labels = new Map();
|
|
728
791
|
for (const conversation of missed) {
|
|
729
|
-
const first = conversation.criteria.find((c) => isMiss(c.verdict));
|
|
792
|
+
const first = counted(conversation, gating).criteria.find((c) => isMiss(c.verdict));
|
|
730
793
|
if (first === undefined)
|
|
731
794
|
continue;
|
|
732
795
|
const label = labelledReasonCode(first.reasonCode);
|
|
@@ -758,7 +821,7 @@ export function groupMissedReasons(missed, terms, w) {
|
|
|
758
821
|
function whyMissed(missed, model, runInfo, w) {
|
|
759
822
|
const box = el("div", "why-missed");
|
|
760
823
|
box.dataset.section = "why-missed";
|
|
761
|
-
const groups = groupMissedReasons(missed, model.terms, w);
|
|
824
|
+
const groups = groupMissedReasons(missed, model.terms, w, model.gating);
|
|
762
825
|
box.dataset.reasons = String(groups.length);
|
|
763
826
|
box.append(el("h5", "", w.t("lines.why-missed.h")));
|
|
764
827
|
const table = element("table");
|
|
@@ -922,7 +985,7 @@ function renderLines(host, model, runInfo, w, notes) {
|
|
|
922
985
|
thead.append(headRow);
|
|
923
986
|
table.append(thead);
|
|
924
987
|
const tbody = document.createElement("tbody");
|
|
925
|
-
const byStatus = (status) => model.conversations.filter((c) => conversationStatus(c) === status);
|
|
988
|
+
const byStatus = (status) => model.conversations.filter((c) => conversationStatus(c, model.gating) === status);
|
|
926
989
|
const resolved = byStatus("resolved");
|
|
927
990
|
const missed = byStatus("missed");
|
|
928
991
|
const unverified = byStatus("unverified");
|
|
@@ -1019,6 +1082,7 @@ function renderLines(host, model, runInfo, w, notes) {
|
|
|
1019
1082
|
// Summary: results rule by rule
|
|
1020
1083
|
// ---------------------------------------------------------------------------
|
|
1021
1084
|
function renderRules(host, model, runInfo, result, w) {
|
|
1085
|
+
const tierOf = model.gating?.tierOf;
|
|
1022
1086
|
const section = el("section", "sec");
|
|
1023
1087
|
section.dataset.section = "rules";
|
|
1024
1088
|
section.append(el("h2", "", w.t("lines.rules.h")));
|
|
@@ -1052,111 +1116,151 @@ function renderRules(host, model, runInfo, result, w) {
|
|
|
1052
1116
|
thead.append(headRow);
|
|
1053
1117
|
table.append(thead);
|
|
1054
1118
|
const tbody = element("tbody");
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1119
|
+
// With a contract, each rule's requirement tier (contract-report/v1
|
|
1120
|
+
// section 2), read by the contract_ref of the rule's claims: rules are
|
|
1121
|
+
// drawn in tier sections, must-have first, then informational, then
|
|
1122
|
+
// those whose tier is not stated. Without one, one section, as before.
|
|
1123
|
+
const ruleTier = (ref) => {
|
|
1124
|
+
if (tierOf === undefined)
|
|
1125
|
+
return undefined;
|
|
1126
|
+
const claim = model.conversations
|
|
1127
|
+
.flatMap((c) => c.criteria)
|
|
1128
|
+
.find((c) => `${c.checkId}.${c.criterionId}` === ref && c.claim)?.claim;
|
|
1129
|
+
return tierOf(claim?.contractRef, ref);
|
|
1130
|
+
};
|
|
1131
|
+
const tiers = new Map();
|
|
1132
|
+
for (const check of model.terms.checks)
|
|
1063
1133
|
for (const criterion of check.criteria) {
|
|
1064
1134
|
const ref = `${check.id}.${criterion.id}`;
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1084
|
-
// label that stands in for one) over the claims behind it on this rule.
|
|
1085
|
-
const countCell = (className, column, counted) => {
|
|
1086
|
-
const pick = picks[column];
|
|
1087
|
-
const cell = el("td", className);
|
|
1088
|
-
cell.dataset.column = column;
|
|
1089
|
-
cell.append(el("span", "nv", fmtCount(counted.length)));
|
|
1090
|
-
const action = evidenceAction(`rule:${ref}:${column}`, `${label.label} · ${columnWord[column]}: ${fmtCount(counted.length)}`, counted.map((c) => c.criteria.find((cr) => cr.checkId === check.id &&
|
|
1091
|
-
cr.criterionId === criterion.id &&
|
|
1092
|
-
pick(cr.verdict))?.claim), result, w);
|
|
1093
|
-
if (action !== undefined)
|
|
1094
|
-
cell.append(action);
|
|
1095
|
-
return cell;
|
|
1096
|
-
};
|
|
1097
|
-
const tr = el("tr", "rule");
|
|
1098
|
-
tr.dataset.rule = ref;
|
|
1099
|
-
tr.dataset.tier = model.criterionTiers.get(ref) ?? "unknown";
|
|
1100
|
-
const label = criterionLabel(model, check.id, criterion.id, w);
|
|
1101
|
-
const nameCell = el("td", "cn");
|
|
1102
|
-
const ruleName = el("b", "", label.label);
|
|
1103
|
-
nameCell.append(ruleName);
|
|
1104
|
-
const badge = editedBadge(model, ref, w);
|
|
1105
|
-
if (badge !== undefined)
|
|
1106
|
-
nameCell.append(badge);
|
|
1107
|
-
if (label.source === "sealed")
|
|
1108
|
-
nameCell.append(el("small", "", label.text));
|
|
1109
|
-
// contract-report/v1 section 3: the pack's explanation of the rule,
|
|
1110
|
-
// and its note for a rule whose claims could not be decided.
|
|
1111
|
-
const detail = w.row(ref, "detail");
|
|
1112
|
-
if (detail !== undefined) {
|
|
1113
|
-
const line = el("small", "rdet", detail);
|
|
1114
|
-
line.dataset.wording = "pack";
|
|
1115
|
-
nameCell.append(line);
|
|
1116
|
-
}
|
|
1117
|
-
const undecidedNote = w.row(ref, "not_evaluable");
|
|
1118
|
-
if (undecidedNote !== undefined && undecided.length > 0) {
|
|
1119
|
-
const line = el("small", "rdet", undecidedNote);
|
|
1120
|
-
line.dataset.wording = "pack";
|
|
1121
|
-
line.dataset.note = "not-evaluable";
|
|
1122
|
-
nameCell.append(line);
|
|
1123
|
-
}
|
|
1124
|
-
const problems = [
|
|
1125
|
-
...notMet,
|
|
1126
|
-
...unverifiedHere.filter((c) => !notMet.includes(c)),
|
|
1127
|
-
...undecided.filter((c) => !notMet.includes(c) && !unverifiedHere.includes(c)),
|
|
1128
|
-
];
|
|
1129
|
-
tr.append(nameCell, countCell(`n${notMet.length > 0 ? " bad" : ""}`, "not_met", notMet), countCell("n ok", "met", met), countCell("n", "undecided", undecided));
|
|
1130
|
-
if (anyUnverified)
|
|
1131
|
-
tr.append(countCell("n", "unverified", unverifiedHere));
|
|
1132
|
-
if (anyOutOfScope)
|
|
1133
|
-
tr.append(countCell("n", "out_of_scope", outOfScopeHere));
|
|
1134
|
-
tbody.append(tr);
|
|
1135
|
-
// The row opens: a full-width row below it holds how many
|
|
1136
|
-
// conversations the rule did not apply to and the conversations
|
|
1137
|
-
// behind its problems, each read at the table's width. A rule with
|
|
1138
|
-
// neither has nothing to open.
|
|
1139
|
-
if (problems.length === 0 && na.length === 0)
|
|
1135
|
+
tiers.set(ref, ruleTier(ref));
|
|
1136
|
+
}
|
|
1137
|
+
const sections = tierOf === undefined
|
|
1138
|
+
? [undefined]
|
|
1139
|
+
: ROW_TIERS.filter((tier) => [...tiers.values()].includes(tier));
|
|
1140
|
+
for (const tier of sections) {
|
|
1141
|
+
if (tier !== undefined) {
|
|
1142
|
+
const inTier = [...tiers.values()].filter((t) => t === tier).length;
|
|
1143
|
+
const heading = el("tr", "tier");
|
|
1144
|
+
heading.dataset.requirementTier = tier;
|
|
1145
|
+
const cell = el("td", "");
|
|
1146
|
+
cell.setAttribute("colspan", columns);
|
|
1147
|
+
cell.append(el("b", "", w.t(`lines.rtier.${tier}.title`, { n: fmtCount(inTier) })), el("small", "", w.t(`lines.rtier.${tier}.note`)));
|
|
1148
|
+
heading.append(cell);
|
|
1149
|
+
tbody.append(heading);
|
|
1150
|
+
}
|
|
1151
|
+
for (const check of model.terms.checks) {
|
|
1152
|
+
const criteria = check.criteria.filter((criterion) => tiers.get(`${check.id}.${criterion.id}`) === tier);
|
|
1153
|
+
if (criteria.length === 0)
|
|
1140
1154
|
continue;
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1155
|
+
const group = el("tr", "grp");
|
|
1156
|
+
group.dataset.checkId = check.id;
|
|
1157
|
+
group.dataset.passCount = String(model.checkPassCounts.get(check.id) ?? 0);
|
|
1158
|
+
const cell = el("td", "", groupTitle(check, w));
|
|
1144
1159
|
cell.setAttribute("colspan", columns);
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1160
|
+
group.append(cell);
|
|
1161
|
+
tbody.append(group);
|
|
1162
|
+
for (const criterion of criteria) {
|
|
1163
|
+
const ref = `${check.id}.${criterion.id}`;
|
|
1164
|
+
const of = (pick) => model.conversations.filter((c) => c.criteria.some((cr) => cr.checkId === check.id &&
|
|
1165
|
+
cr.criterionId === criterion.id &&
|
|
1166
|
+
pick(cr.verdict)));
|
|
1167
|
+
// Each count column's verdicts, read once: a cell's number and the
|
|
1168
|
+
// claims its Show-evidence action lists come from the same pick.
|
|
1169
|
+
const picks = {
|
|
1170
|
+
not_met: isMiss,
|
|
1171
|
+
met: (v) => v === "met",
|
|
1172
|
+
undecided: (v) => v === "not_evaluable" || v === "no_claim",
|
|
1173
|
+
unverified: isUnverified,
|
|
1174
|
+
out_of_scope: (v) => v === "out_of_scope",
|
|
1175
|
+
};
|
|
1176
|
+
const met = of(picks.met);
|
|
1177
|
+
const notMet = of(picks.not_met);
|
|
1178
|
+
const unverifiedHere = of(picks.unverified);
|
|
1179
|
+
const na = of((v) => v === "not_applicable");
|
|
1180
|
+
const outOfScopeHere = of(picks.out_of_scope);
|
|
1181
|
+
const undecided = of(picks.undecided);
|
|
1182
|
+
// One count cell: the number, and its Show-evidence action (or the
|
|
1183
|
+
// label that stands in for one) over the claims behind it on this rule.
|
|
1184
|
+
const countCell = (className, column, counted) => {
|
|
1185
|
+
const pick = picks[column];
|
|
1186
|
+
const cell = el("td", className);
|
|
1187
|
+
cell.dataset.column = column;
|
|
1188
|
+
cell.append(el("span", "nv", fmtCount(counted.length)));
|
|
1189
|
+
const action = evidenceAction(`rule:${ref}:${column}`, `${label.label} · ${columnWord[column]}: ${fmtCount(counted.length)}`, counted.map((c) => c.criteria.find((cr) => cr.checkId === check.id &&
|
|
1190
|
+
cr.criterionId === criterion.id &&
|
|
1191
|
+
pick(cr.verdict))?.claim), result, w);
|
|
1192
|
+
if (action !== undefined)
|
|
1193
|
+
cell.append(action);
|
|
1194
|
+
return cell;
|
|
1195
|
+
};
|
|
1196
|
+
const tr = el("tr", "rule");
|
|
1197
|
+
tr.dataset.rule = ref;
|
|
1198
|
+
tr.dataset.tier = model.criterionTiers.get(ref) ?? "unknown";
|
|
1199
|
+
const label = criterionLabel(model, check.id, criterion.id, w);
|
|
1200
|
+
const nameCell = el("td", "cn");
|
|
1201
|
+
const ruleName = el("b", "", label.label);
|
|
1202
|
+
nameCell.append(ruleName);
|
|
1203
|
+
const badge = editedBadge(model, ref, w);
|
|
1204
|
+
if (badge !== undefined)
|
|
1205
|
+
nameCell.append(badge);
|
|
1206
|
+
if (tier !== undefined) {
|
|
1207
|
+
tr.dataset.requirementTier = tier;
|
|
1208
|
+
nameCell.append(tierChip(tier, w));
|
|
1209
|
+
}
|
|
1210
|
+
if (label.source === "sealed")
|
|
1211
|
+
nameCell.append(el("small", "", label.text));
|
|
1212
|
+
// contract-report/v1 section 3: the pack's explanation of the rule,
|
|
1213
|
+
// and its note for a rule whose claims could not be decided.
|
|
1214
|
+
const detail = w.row(ref, "detail");
|
|
1215
|
+
if (detail !== undefined) {
|
|
1216
|
+
const line = el("small", "rdet", detail);
|
|
1217
|
+
line.dataset.wording = "pack";
|
|
1218
|
+
nameCell.append(line);
|
|
1219
|
+
}
|
|
1220
|
+
const undecidedNote = w.row(ref, "not_evaluable");
|
|
1221
|
+
if (undecidedNote !== undefined && undecided.length > 0) {
|
|
1222
|
+
const line = el("small", "rdet", undecidedNote);
|
|
1223
|
+
line.dataset.wording = "pack";
|
|
1224
|
+
line.dataset.note = "not-evaluable";
|
|
1225
|
+
nameCell.append(line);
|
|
1226
|
+
}
|
|
1227
|
+
const problems = [
|
|
1228
|
+
...notMet,
|
|
1229
|
+
...unverifiedHere.filter((c) => !notMet.includes(c)),
|
|
1230
|
+
...undecided.filter((c) => !notMet.includes(c) && !unverifiedHere.includes(c)),
|
|
1231
|
+
];
|
|
1232
|
+
tr.append(nameCell, countCell(`n${notMet.length > 0 ? " bad" : ""}`, "not_met", notMet), countCell("n ok", "met", met), countCell("n", "undecided", undecided));
|
|
1233
|
+
if (anyUnverified)
|
|
1234
|
+
tr.append(countCell("n", "unverified", unverifiedHere));
|
|
1235
|
+
if (anyOutOfScope)
|
|
1236
|
+
tr.append(countCell("n", "out_of_scope", outOfScopeHere));
|
|
1237
|
+
tbody.append(tr);
|
|
1238
|
+
// The row opens: a full-width row below it holds how many
|
|
1239
|
+
// conversations the rule did not apply to and the conversations
|
|
1240
|
+
// behind its problems, each read at the table's width. A rule with
|
|
1241
|
+
// neither has nothing to open.
|
|
1242
|
+
if (problems.length === 0 && na.length === 0)
|
|
1243
|
+
continue;
|
|
1244
|
+
const drillRow = el("tr", "drill-row");
|
|
1245
|
+
drillRow.dataset.drillFor = ref;
|
|
1246
|
+
const cell = element("td");
|
|
1247
|
+
cell.setAttribute("colspan", columns);
|
|
1248
|
+
drillRow.append(cell);
|
|
1249
|
+
// The not-applicable count is drawn now, so a static page (which runs
|
|
1250
|
+
// no script to build a body) still shows it when the row opens.
|
|
1251
|
+
if (na.length > 0) {
|
|
1252
|
+
const naLine = el("p", "rule-na", w.p("lines.rules.expand.na", na.length, {
|
|
1253
|
+
n: fmtCount(na.length),
|
|
1254
|
+
}));
|
|
1255
|
+
naLine.dataset.count = String(na.length);
|
|
1256
|
+
cell.append(naLine);
|
|
1257
|
+
}
|
|
1258
|
+
const toggle = expandableRow(tr, ruleName, drillRow, () => problems.length > 0
|
|
1259
|
+
? renderConversationList(problems, model, runInfo, `rule:${ref}`, w)
|
|
1260
|
+
: document.createDocumentFragment(), `rule-${ref}`);
|
|
1261
|
+
toggle.dataset.drill = `rule:${ref}`;
|
|
1262
|
+
tbody.append(drillRow);
|
|
1154
1263
|
}
|
|
1155
|
-
const toggle = expandableRow(tr, ruleName, drillRow, () => problems.length > 0
|
|
1156
|
-
? renderConversationList(problems, model, runInfo, `rule:${ref}`, w)
|
|
1157
|
-
: document.createDocumentFragment(), `rule-${ref}`);
|
|
1158
|
-
toggle.dataset.drill = `rule:${ref}`;
|
|
1159
|
-
tbody.append(drillRow);
|
|
1160
1264
|
}
|
|
1161
1265
|
}
|
|
1162
1266
|
// Requirements of the cited contract the run did not cover (Result v0
|
|
@@ -1203,9 +1307,13 @@ function renderCalendar(host, model, w) {
|
|
|
1203
1307
|
const list = el("div", "cal");
|
|
1204
1308
|
list.dataset.days = String(model.days.length);
|
|
1205
1309
|
for (const day of model.days) {
|
|
1310
|
+
// Resolved as the page's lines count it (`conversationStatus`), which
|
|
1311
|
+
// leaves out informational rules; the model's own count is the same
|
|
1312
|
+
// when a contract marks none.
|
|
1313
|
+
const resolved = day.conversations.filter((c) => conversationStatus(c, model.gating) === "resolved").length;
|
|
1206
1314
|
const item = el("div", "day");
|
|
1207
1315
|
item.dataset.day = day.date;
|
|
1208
|
-
item.dataset.resolved = String(
|
|
1316
|
+
item.dataset.resolved = String(resolved);
|
|
1209
1317
|
item.dataset.total = String(day.conversations.length);
|
|
1210
1318
|
item.append(el("div", "dn", day.date));
|
|
1211
1319
|
if (note !== undefined) {
|
|
@@ -1222,11 +1330,9 @@ function renderCalendar(host, model, w) {
|
|
|
1222
1330
|
item.append(tz);
|
|
1223
1331
|
}
|
|
1224
1332
|
}
|
|
1225
|
-
item.append(el("div", "v", fmtShare(
|
|
1333
|
+
item.append(el("div", "v", fmtShare(resolved, day.conversations.length, model.options.percentages, w)));
|
|
1226
1334
|
const mini = el("div", "mini");
|
|
1227
|
-
const share = day.conversations.length === 0
|
|
1228
|
-
? 0
|
|
1229
|
-
: day.resolvedCount / day.conversations.length;
|
|
1335
|
+
const share = day.conversations.length === 0 ? 0 : resolved / day.conversations.length;
|
|
1230
1336
|
const fill = element("i");
|
|
1231
1337
|
fill.style.width = `${Math.round(share * 100)}%`;
|
|
1232
1338
|
mini.append(fill);
|
|
@@ -1259,33 +1365,46 @@ function renderHumanChecks(host, calibration, w) {
|
|
|
1259
1365
|
host.append(section);
|
|
1260
1366
|
return;
|
|
1261
1367
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
const
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1368
|
+
// One table per calibration claim, one row per clause the summary tallies.
|
|
1369
|
+
// Every figure is k of n as the record states it; no rate is computed. A
|
|
1370
|
+
// summary the reader did not read draws no counts and says why.
|
|
1371
|
+
for (const reading of calibration) {
|
|
1372
|
+
if (reading.state !== "read") {
|
|
1373
|
+
const note = el("p", "", w.t(reading.state === "ambiguous"
|
|
1374
|
+
? "lines.hc.ambiguous"
|
|
1375
|
+
: "lines.hc.not-matching"));
|
|
1376
|
+
note.dataset.calibration = reading.state;
|
|
1377
|
+
section.append(note);
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
const table = document.createElement("table");
|
|
1381
|
+
table.className = "hct";
|
|
1382
|
+
table.dataset.calibration = "read";
|
|
1383
|
+
table.dataset.clauses = String(reading.clauses.length);
|
|
1384
|
+
const thead = document.createElement("thead");
|
|
1385
|
+
const headRow = document.createElement("tr");
|
|
1386
|
+
headRow.append(element("th", w.t("lines.hc.col.clause")), el("th", "n", w.t("lines.hc.col.agreed")), el("th", "n", w.t("lines.hc.col.drift")), element("th", w.t("lines.hc.col.recount")));
|
|
1387
|
+
thead.append(headRow);
|
|
1388
|
+
table.append(thead);
|
|
1389
|
+
const tbody = document.createElement("tbody");
|
|
1390
|
+
for (const clause of reading.clauses) {
|
|
1391
|
+
const tr = document.createElement("tr");
|
|
1392
|
+
tr.dataset.clause = clause.clauseRef;
|
|
1393
|
+
tr.dataset.k = String(clause.agreement.k);
|
|
1394
|
+
tr.dataset.n = String(clause.agreement.n);
|
|
1395
|
+
tr.dataset.agreementCheck = clause.agreementCheck;
|
|
1396
|
+
tr.append(el("td", "", clause.clauseRef), el("td", "n", w.t("lines.hc.agreed", {
|
|
1397
|
+
k: String(clause.agreement.k),
|
|
1398
|
+
n: String(clause.agreement.n),
|
|
1399
|
+
})), el("td", "n", w.t("lines.hc.drift", {
|
|
1400
|
+
k: String(clause.drift.k),
|
|
1401
|
+
n: String(clause.drift.n),
|
|
1402
|
+
})), el("td", "", w.t(`lines.hc.recount.${clause.agreementCheck}`)));
|
|
1403
|
+
tbody.append(tr);
|
|
1404
|
+
}
|
|
1405
|
+
table.append(tbody);
|
|
1406
|
+
section.append(table);
|
|
1286
1407
|
}
|
|
1287
|
-
table.append(tbody);
|
|
1288
|
-
section.append(table);
|
|
1289
1408
|
host.append(section);
|
|
1290
1409
|
}
|
|
1291
1410
|
// ---------------------------------------------------------------------------
|
|
@@ -1526,6 +1645,72 @@ function renderReportProofs(host, model, runInfo, bundle, verified, w) {
|
|
|
1526
1645
|
section.append(toggle);
|
|
1527
1646
|
host.append(section);
|
|
1528
1647
|
}
|
|
1648
|
+
/**
|
|
1649
|
+
* The Result document the root carries, from the verified disclosures: the
|
|
1650
|
+
* member itself, or a book header's statement. Undefined when it is withheld
|
|
1651
|
+
* or is not an object.
|
|
1652
|
+
*/
|
|
1653
|
+
async function resultDocument(result, bundle) {
|
|
1654
|
+
try {
|
|
1655
|
+
const context = await verifiedBundleContext(bundle);
|
|
1656
|
+
const member = disclosureOf(context, result.capsuleId, result.member);
|
|
1657
|
+
if (member.state !== "disclosed")
|
|
1658
|
+
return undefined;
|
|
1659
|
+
const payload = member.payload;
|
|
1660
|
+
return result.form === "book" &&
|
|
1661
|
+
payload !== null &&
|
|
1662
|
+
typeof payload === "object"
|
|
1663
|
+
? payload.statement
|
|
1664
|
+
: payload;
|
|
1665
|
+
}
|
|
1666
|
+
catch {
|
|
1667
|
+
return undefined;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
/** Each conversation as Same customer in this report draws it (subject-history.ts). */
|
|
1671
|
+
function subjectConversations(model, w) {
|
|
1672
|
+
return model.conversations.map((c) => {
|
|
1673
|
+
const status = conversationStatus(c, model.gating);
|
|
1674
|
+
const outcome = statusWord(status, c, w, model.gating);
|
|
1675
|
+
const time = /T(\d{2}:\d{2})/u.exec(c.dated.stated ?? "")?.[1];
|
|
1676
|
+
const turns = c.transcript.state === "verified" || c.transcript.state === "cited"
|
|
1677
|
+
? c.transcript.turns
|
|
1678
|
+
: undefined;
|
|
1679
|
+
return {
|
|
1680
|
+
id: c.conversationId,
|
|
1681
|
+
date: c.day,
|
|
1682
|
+
...(time === undefined ? {} : { time }),
|
|
1683
|
+
status,
|
|
1684
|
+
outcome,
|
|
1685
|
+
terms: c.criteria.map((cr) => ({
|
|
1686
|
+
ref: `${cr.checkId}.${cr.criterionId}`,
|
|
1687
|
+
label: criterionLabel(model, cr.checkId, cr.criterionId, w).label,
|
|
1688
|
+
tone: criterionWord(cr, w).tone,
|
|
1689
|
+
})),
|
|
1690
|
+
open: c.criteria
|
|
1691
|
+
.filter((cr) => cr.verdict !== "met" && cr.verdict !== "not_applicable")
|
|
1692
|
+
.map((cr) => {
|
|
1693
|
+
const label = criterionLabel(model, cr.checkId, cr.criterionId, w);
|
|
1694
|
+
const worded = criterionWord(cr, w);
|
|
1695
|
+
return {
|
|
1696
|
+
label: label.label,
|
|
1697
|
+
wording: label.source === "sealed" ? label.text : "",
|
|
1698
|
+
verdict: worded.word,
|
|
1699
|
+
tone: worded.tone,
|
|
1700
|
+
note: cr.rationale === undefined
|
|
1701
|
+
? noNoteText(cr, w)
|
|
1702
|
+
: judgeNote(cr.rationale, cr.claim?.verdict ?? cr.verdict, w),
|
|
1703
|
+
};
|
|
1704
|
+
}),
|
|
1705
|
+
...(turns === undefined
|
|
1706
|
+
? {}
|
|
1707
|
+
: {
|
|
1708
|
+
turns: turns.length,
|
|
1709
|
+
calls: turns.reduce((n, t) => n + t.toolCalls.length, 0),
|
|
1710
|
+
}),
|
|
1711
|
+
};
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1529
1714
|
/** The `lines` grouping's page wrapper: its element, class, page name and stylesheet. */
|
|
1530
1715
|
export const LINES_FRAME = {
|
|
1531
1716
|
tag: "section",
|
|
@@ -1537,8 +1722,11 @@ export const LINES_FRAME = {
|
|
|
1537
1722
|
* Draw the `lines` grouping into `wrapper` (contract-report.ts made it and
|
|
1538
1723
|
* put its stylesheet in it). Every word is `w`'s.
|
|
1539
1724
|
*/
|
|
1540
|
-
export async function drawLines(levels, result, options, bundle, verified, w) {
|
|
1541
|
-
const
|
|
1725
|
+
export async function drawLines(levels, result, options, bundle, verified, w, tierOf) {
|
|
1726
|
+
const built = buildOutcomeReportModel(result, options);
|
|
1727
|
+
const model = tierOf === undefined
|
|
1728
|
+
? built
|
|
1729
|
+
: { ...built, gating: gating(built.conversations, tierOf) };
|
|
1542
1730
|
const runInfo = await verifyJudgePin(model.runInfo);
|
|
1543
1731
|
const claims = model.conversations.flatMap((c) => c.criteria.flatMap((cr) => (cr.claim === undefined ? [] : [cr.claim])));
|
|
1544
1732
|
// L0, what matters, after the core's strip (the mock-judge mark and the
|
|
@@ -1557,6 +1745,14 @@ export async function drawLines(levels, result, options, bundle, verified, w) {
|
|
|
1557
1745
|
pad.append(notes);
|
|
1558
1746
|
sheet.append(pad);
|
|
1559
1747
|
levels.L0.append(sheet);
|
|
1748
|
+
// Same customer in this report (Outcomes frame 5), when the Result carries
|
|
1749
|
+
// the producer's slice; every count in it is of this report's conversations.
|
|
1750
|
+
const slice = readSubjectHistory(await resultDocument(result, bundle));
|
|
1751
|
+
if (slice !== undefined) {
|
|
1752
|
+
const subject = renderSubjectHistory(subjectConversations(model, w), slice, model.totalCount, w);
|
|
1753
|
+
if (subject !== undefined)
|
|
1754
|
+
levels.L0.append(subject);
|
|
1755
|
+
}
|
|
1560
1756
|
// L1, why: rule by rule, led by who judged, who witnessed, what verified.
|
|
1561
1757
|
renderRules(levels.L1, model, runInfo, result, w);
|
|
1562
1758
|
leadWithProvenance(levels.L1, levels.L1.querySelector('[data-section="rules"]'), renderProvenance(await provenanceLines(result.records, claims, bundle, verified, w)));
|