@action-state-group/capsule-viewer 0.3.0 → 0.5.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 (60) hide show
  1. package/README.md +3 -2
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +5 -3
  4. package/dist/browser.js.map +1 -1
  5. package/dist/chart-dataset.d.ts +23 -0
  6. package/dist/chart-dataset.js +195 -0
  7. package/dist/chart-dataset.js.map +1 -0
  8. package/dist/chart-spec.d.ts +141 -0
  9. package/dist/chart-spec.js +646 -0
  10. package/dist/chart-spec.js.map +1 -0
  11. package/dist/chart-view.d.ts +34 -0
  12. package/dist/chart-view.js +389 -0
  13. package/dist/chart-view.js.map +1 -0
  14. package/dist/compliance-styles.js +0 -1
  15. package/dist/compliance-styles.js.map +1 -1
  16. package/dist/compliance-view.js +53 -17
  17. package/dist/compliance-view.js.map +1 -1
  18. package/dist/contract-report-wording.js +51 -2
  19. package/dist/contract-report-wording.js.map +1 -1
  20. package/dist/core-strip.d.ts +38 -0
  21. package/dist/core-strip.js +183 -0
  22. package/dist/core-strip.js.map +1 -0
  23. package/dist/emitter-shell.html +10 -1
  24. package/dist/emitter.js +13 -3
  25. package/dist/emitter.js.map +1 -1
  26. package/dist/evidence-graph-view.d.ts +6 -0
  27. package/dist/evidence-graph-view.js +244 -91
  28. package/dist/evidence-graph-view.js.map +1 -1
  29. package/dist/evidence-graph.iife.js +6351 -1633
  30. package/dist/outcome-report-view.js +49 -25
  31. package/dist/outcome-report-view.js.map +1 -1
  32. package/dist/presentation-builder.d.ts +15 -0
  33. package/dist/presentation-builder.js +36 -2
  34. package/dist/presentation-builder.js.map +1 -1
  35. package/dist/presentation-mount.d.ts +2 -0
  36. package/dist/presentation-mount.js +1 -0
  37. package/dist/presentation-mount.js.map +1 -1
  38. package/dist/report-front-styles.d.ts +2 -2
  39. package/dist/report-front-styles.js +3 -15
  40. package/dist/report-front-styles.js.map +1 -1
  41. package/dist/report-front.d.ts +2 -24
  42. package/dist/report-front.js +11 -145
  43. package/dist/report-front.js.map +1 -1
  44. package/dist/report-levels.d.ts +33 -1
  45. package/dist/report-levels.js +135 -0
  46. package/dist/report-levels.js.map +1 -1
  47. package/dist/report-provenance.d.ts +28 -0
  48. package/dist/report-provenance.js +60 -11
  49. package/dist/report-provenance.js.map +1 -1
  50. package/dist/report-view-render.d.ts +13 -0
  51. package/dist/report-view-render.js +280 -0
  52. package/dist/report-view-render.js.map +1 -0
  53. package/dist/report-view.d.ts +29 -0
  54. package/dist/report-view.js +170 -0
  55. package/dist/report-view.js.map +1 -0
  56. package/dist/viewer-build.js +3 -3
  57. package/dist/viewer-build.js.map +1 -1
  58. package/dist/wording/contract-report-eu-ai-act.en.json +36 -0
  59. package/dist/wording/contract-report-outcomes.en.json +36 -0
  60. package/package.json +5 -3
@@ -3,19 +3,26 @@ import { AGENT_INPUT_ORIGINALS_EXTENSION, BOOK_PAYLOADS_EXTENSION, buildVerified
3
3
  import { BUILTIN_MANIFEST_COMPOSED, BUILTIN_MANIFEST_EVALUATION_SUMMARY_GRAPH, BUILTIN_MANIFEST_NO_AGGREGATE, BUILTIN_MANIFEST_REPORT_ROWS, BUILTIN_MANIFEST_RESULT, BUILTIN_MANIFEST_RESULT_COMPLIANCE, BUILTIN_MANIFEST_RESULT_CONTRACT_REPORT, BUILTIN_MANIFEST_RESULT_OUTCOME_REPORT, } from "./builtin-manifests.js";
4
4
  import { classifyCountersignatures, declaredProducerKeys, } from "@action-state-group/agent-action-capsule";
5
5
  import { buildEvidenceGraph, EvidenceGraphError, zoneStatement, } from "@action-state-group/agent-action-capsule";
6
- import { digestCapability } from "@action-state-group/agent-action-capsule";
7
- import { renderContractReport, } from "./contract-report.js";
6
+ import { digestCapability, JcsFloatError, JcsUnsafeIntegerError, jsonDigest, } from "@action-state-group/agent-action-capsule";
7
+ import { chartDatasetOf } from "./chart-dataset.js";
8
+ import { ChartRefusal, checkChart } from "./chart-spec.js";
9
+ import { renderChart, renderChartRefused, renderCharts } from "./chart-view.js";
10
+ import { checkView, isView } from "./report-view.js";
11
+ import { renderView } from "./report-view-render.js";
12
+ import { citesOneContract, renderContractReport, } from "./contract-report.js";
8
13
  import { readOutcomeReportPresentation, } from "./outcome-report-presentation.js";
9
14
  import { composedSectionModule } from "./composed-view.js";
10
- import { DEFAULT_WORDS } from "./contract-report-wording.js";
15
+ import { DEFAULT_WORDS, contractReportWords, } from "./contract-report-wording.js";
16
+ import { CORE_STRIP_ATTRIBUTE, coreStripModel, renderCoreStrip, } from "./core-strip.js";
11
17
  import { RECORD_CONTENT_CSS, renderContent } from "./record-content.js";
18
+ import { WITNESS_NOTICE_LINES, witnessNotice, } from "./report-provenance.js";
12
19
  import { deferBody, recordAddress, revealRecord, revealRecordsByHash, } from "./report-levels.js";
13
20
  import { readCompliancePresentation, } from "./compliance-presentation.js";
14
21
  import { readPresentationBlock } from "@action-state-group/agent-action-capsule";
15
22
  import { bundleVerified, PresentationAmbiguityError, PresentationRegistry, presentationExtensionRows, presentationRefusalNotices, } from "./presentation-registry.js";
16
23
  import { aacInterpreters, aliasExtensionRows, } from "./alias-interpreters.js";
17
24
  import { buildReportRows, } from "@action-state-group/agent-action-capsule";
18
- import { buildResultRoot, isResultRoot, UNVERIFIED_KEY_LABEL, utcDateOf, } from "@action-state-group/agent-action-capsule";
25
+ import { buildResultRoot, isResultRoot, UNVERIFIED_KEY_LABEL, } from "@action-state-group/agent-action-capsule";
19
26
  import { buildVerificationPageModel, CHECKED_ON_THIS_PAGE, CHECKS_SCOPE_LINE, FAILED_ON_THIS_PAGE, FULL_VERIFIER_LINE, NOT_CHECKED_ON_THIS_PAGE, RECEIPT_GRADE_DISPLAY, VERIFICATION_BANNER_LINES, verificationBanner, verificationCheckWords, } from "@action-state-group/agent-action-capsule";
20
27
  function element(tag, text) {
21
28
  const value = document.createElement(tag);
@@ -62,8 +69,6 @@ function appendTime(parent, label, value, absent) {
62
69
  parent.append(cell);
63
70
  }
64
71
  const recordsWord = (count) => `${count} ${count === 1 ? "record" : "records"}`;
65
- const evaluationsWord = (count) => `${count} ${count === 1 ? "evaluation" : "evaluations"}`;
66
- const requirementsWord = (count) => `${count} ${count === 1 ? "requirement" : "requirements"}`;
67
72
  // The banner is drawn from AAC's banner model alone (presentation contract
68
73
  // section 6.2) and precedes every row in the DOM; a bundle that fails the
69
74
  // page's own checks gets the refusal line here and no rows at all, so a
@@ -74,7 +79,9 @@ const requirementsWord = (count) => `${count} ${count === 1 ? "requirement" : "r
74
79
  // signature. Its line is the core's fixed text for the state; the details
75
80
  // line under the bar names the findings. The bar also says, from the
76
81
  // verification section, how many checks passed, and links down to it.
77
- function renderVerificationBanner(root, model, coverage) {
82
+ // `witness` is the notice drawn under the bar when no witness receipt was
83
+ // checked (bannerWitnessNotice): the pill alone would read as checked.
84
+ function renderVerificationBanner(root, model, coverage, witness) {
78
85
  const bar = element("div");
79
86
  // A failed bundle's bar is a callout on every page, with or without a
80
87
  // report's frame (the shell's .cv-failed); in a report's frame an
@@ -122,6 +129,14 @@ function renderVerificationBanner(root, model, coverage) {
122
129
  detail.dataset.bannerDetail = "";
123
130
  root.append(detail);
124
131
  }
132
+ if (witness !== undefined) {
133
+ const notice = element("p", WITNESS_NOTICE_LINES[witness]);
134
+ // In the warning colour, as an incomplete banner: the bundle checks,
135
+ // but only against its holder's own signatures.
136
+ notice.className = "cv-banner-detail cv-witness-notice";
137
+ notice.dataset.witnessNotice = witness;
138
+ root.append(notice);
139
+ }
125
140
  if (model.refusal === undefined)
126
141
  return bar;
127
142
  const refusal = element("p", model.refusal);
@@ -129,6 +144,21 @@ function renderVerificationBanner(root, model, coverage) {
129
144
  root.append(refusal);
130
145
  return bar;
131
146
  }
147
+ /**
148
+ * The witness notice a banner carries (capsule-viewer#162, from
149
+ * evidencebook#209): only on a verified or incomplete banner whose
150
+ * checkpoint signature verified, since a failed banner already says the
151
+ * witness check failed and with no signed checkpoint there is nothing for a
152
+ * witness to cover. Which notice, from AAC's strict witness status, is
153
+ * `witnessNotice`'s, the decision the "Witnessed by" line draws from too.
154
+ */
155
+ function bannerWitnessNotice(model, bundle, verification) {
156
+ if (model.state !== "verified" && model.state !== "incomplete")
157
+ return undefined;
158
+ if (model.checkpoint !== "verified")
159
+ return undefined;
160
+ return witnessNotice(bundle, verification);
161
+ }
132
162
  /**
133
163
  * Draw the `checking` state into `root`, replacing what it held: the
134
164
  * banner alone, with no verdict and no row, until the checks finish
@@ -718,7 +748,7 @@ function renderCheckLists(host, lists, verifierHint) {
718
748
  // `applied` is the set of extension interpreters this rendering ran; an
719
749
  // extension row says "interpreted by" only for one of them. `refused` is
720
750
  // every module this runtime refused that matched (page, then section).
721
- async function renderVerificationPage(root, context, styled, applied, refused, citedSigners, verifierHint, depth, stamps) {
751
+ async function renderVerificationPage(root, context, styled, applied, refused, citedSigners, verifierHint, depth, stamps, charts) {
722
752
  const { bundle, verification: verified } = context;
723
753
  const section = element("section");
724
754
  section.dataset.page = "verification";
@@ -747,6 +777,11 @@ async function renderVerificationPage(root, context, styled, applied, refused, c
747
777
  appendValue(summary, "bundle digest", model.bundleDigest ?? "uncomputable");
748
778
  appendValue(summary, "checkpoint root", model.checkpointRoot ?? "absent");
749
779
  appendValue(summary, "checkpoint size", model.checkpointSize ?? "absent");
780
+ // Each chart spec the page was built with, by the SHA-256 of its JCS, and
781
+ // whether it was drawn (docs/design/chart-spec.md section 1).
782
+ charts.forEach((chart, i) => appendValue(summary, `chart spec ${i + 1} sha256`, chart.refused === undefined
783
+ ? chart.sha256
784
+ : `${chart.sha256} (not drawn: ${chart.refused})`));
750
785
  page.append(summary);
751
786
  renderReceipts(page, model.receipts);
752
787
  if (model.selfWitnessed) {
@@ -1358,75 +1393,26 @@ const BUCKETS = [
1358
1393
  // ER section 4.2: drawn only when the Result carries the fourth bucket.
1359
1394
  ["outOfScope", "out of scope", "buckets.out_of_scope"],
1360
1395
  ];
1361
- // Coverage is the first thing in the Result section after its heading, and
1362
- // no number precedes it within the section; then the buckets, never a
1363
- // single figure; then one row per claim with its own tier and grade. The
1364
- // bundle-level verification banner, drawn before every section, is the one
1365
- // thing above coverage that can carry digits ("N of M records
1366
- // uncheckpointed"). Every number drawn here is the recomputed one
1367
- // (`result.coverage`, `result.bucketCounts`); a producer figure the claims
1368
- // do not bear out shows as a `count mismatch` marker beside the recomputed
1369
- // value. `excluded as not applicable` is the one figure carried as stated:
1370
- // no claim backs it, by construction. Coverage counts evaluations (one per
1371
- // claim, ER §3), so the line also names how many distinct requirements the
1372
- // claims cite, and an UNKNOWN count is never called unresolved requirements.
1396
+ /**
1397
+ * The marks the core puts on a Result's counts: the strip, the bucket tallies
1398
+ * and lists, and the count-mismatch markers. A page whose root is no Result
1399
+ * shows none of them; a module that draws one there is discarded for the
1400
+ * refusal (renderVerifiedContext).
1401
+ */
1402
+ const RESULT_COUNT_MARKS = `[${CORE_STRIP_ATTRIBUTE}], .cv-strip, [data-bucket], [data-bucket-count], [data-count-mismatch]`;
1373
1403
  /** Said above the generic Result page when a Result opted into a card whose layout cannot hold its claims (`claimsFitCard`). */
1374
1404
  export const CARD_UNFIT_NOTE = "This Result's claims don't fit the report layout, so every claim is listed below instead.";
1405
+ // The Result page lists the claims by verdict, after the core strip, which
1406
+ // draws coverage first and then the buckets, never a single figure
1407
+ // (core-strip.ts). Every count drawn here is the recomputed one
1408
+ // (`result.bucketCounts`); a producer figure the claims do not bear out
1409
+ // shows as a `count mismatch` marker beside it. Each claim keeps its own
1410
+ // tier and grade on its row.
1375
1411
  function renderResultPage(result, root) {
1376
1412
  const section = element("section");
1377
1413
  section.dataset.page = "result";
1378
1414
  section.append(element("h1", "Evidence result"));
1379
- // The requirements the in-force evaluations cover: every claim of one
1380
- // requirement carries the same applies_from, so a requirement is in force
1381
- // or later as a whole (ER section 4.3).
1382
- const requirements = new Set(result.claims
1383
- .filter((claim) => !claim.later)
1384
- .map((claim) => JSON.stringify([claim.contractRef, claim.requirementRef]))).size;
1385
- const coverage = element("p");
1386
- coverage.append(`coverage: ${evaluationsWord(result.coverage.evaluatedPopulation)} of ${requirementsWord(requirements)}`);
1387
- const evaluatedMarker = countMismatchMarker(result, "evaluated_population");
1388
- if (evaluatedMarker !== undefined)
1389
- coverage.append(" ", evaluatedMarker);
1390
- coverage.append(` · ${result.coverage.excludedNotApplicable} excluded as not applicable · ${result.coverage.unknownCount} with an unknown result`);
1391
- const unknownMarker = countMismatchMarker(result, "unknown_count");
1392
- if (unknownMarker !== undefined)
1393
- coverage.append(" ", unknownMarker);
1394
1415
  const later = result.claims.filter((claim) => claim.later);
1395
- const laterMarker = countMismatchMarker(result, "not_yet_in_force");
1396
- if (later.length > 0 || laterMarker !== undefined) {
1397
- coverage.append(` · ${evaluationsWord(later.length)} not yet in force`);
1398
- if (laterMarker !== undefined)
1399
- coverage.append(" ", laterMarker);
1400
- coverage.dataset.notYetInForce = String(later.length);
1401
- }
1402
- coverage.dataset.coverage = "result";
1403
- coverage.dataset.evaluated = String(result.coverage.evaluatedPopulation);
1404
- coverage.dataset.requirements = String(requirements);
1405
- coverage.dataset.excluded = String(result.coverage.excludedNotApplicable);
1406
- coverage.dataset.excludedBasis = "stated";
1407
- coverage.dataset.unknown = String(result.coverage.unknownCount);
1408
- section.append(coverage);
1409
- // ER sections 4.2 and 4.3: whenever a claim is dated, the date "in force"
1410
- // is relative to; and whenever a claim is dated or the out-of-scope switch
1411
- // is on, that these are the producer's copy of the contract, never checked
1412
- // here.
1413
- const dated = result.claims.some((claim) => claim.appliesFrom !== undefined);
1414
- if (dated || result.buckets.outOfScope !== undefined) {
1415
- const copied = element("p");
1416
- if (dated) {
1417
- // A dated Result passed validation, so generated_at parses.
1418
- const date = utcDateOf(result.generatedAt) ?? result.generatedAt;
1419
- copied.append(`In force as of ${date}. `);
1420
- copied.dataset.asOf = date;
1421
- }
1422
- copied.append(dated && result.buckets.outOfScope !== undefined
1423
- ? "The dates and the out-of-scope switch are copied from the contract, not re-checked here."
1424
- : dated
1425
- ? "The dates are copied from the contract, not re-checked here."
1426
- : "The out-of-scope switch is copied from the contract, not re-checked here.");
1427
- copied.dataset.copiedFacts = "contract";
1428
- section.append(copied);
1429
- }
1430
1416
  const byId = new Map(result.claims.map((claim) => [claim.id, claim]));
1431
1417
  const buckets = element("section");
1432
1418
  buckets.dataset.buckets = "verdict";
@@ -1915,6 +1901,57 @@ export function resolvePresentation(context, audience = DEFAULT_AUDIENCE, format
1915
1901
  /** `"*"`: no particular audience, so only modules serving every audience. */
1916
1902
  const DEFAULT_AUDIENCE = "*";
1917
1903
  const DEFAULT_FORMAT = "html";
1904
+ async function chartDigestsOf(charts) {
1905
+ const out = [];
1906
+ for (const spec of charts ?? []) {
1907
+ try {
1908
+ out.push({ sha256: await jsonDigest(spec) });
1909
+ }
1910
+ catch (err) {
1911
+ // A number JCS has no form for: the checker refuses that spec, and the
1912
+ // page goes on with the rest.
1913
+ if (!(err instanceof JcsFloatError || err instanceof JcsUnsafeIntegerError))
1914
+ throw err;
1915
+ out.push({ sha256: "uncomputable" });
1916
+ }
1917
+ }
1918
+ return out;
1919
+ }
1920
+ /**
1921
+ * Check every chart against the Result's dataset and draw it, or the core's
1922
+ * notice for a chart that fails (chart-spec.ts). The page runtime checks
1923
+ * again here even when the builder already did: a page that reaches a reader
1924
+ * with a mismatch never shows the chart.
1925
+ */
1926
+ async function drawCharts(context, result, charts, digests, words) {
1927
+ let dataset;
1928
+ let invalid;
1929
+ try {
1930
+ dataset =
1931
+ result === undefined ? undefined : await chartDatasetOf(context, result);
1932
+ }
1933
+ catch (err) {
1934
+ if (!(err instanceof ChartRefusal))
1935
+ throw err;
1936
+ invalid = err;
1937
+ }
1938
+ const parts = charts.map((spec, i) => {
1939
+ try {
1940
+ if (invalid !== undefined)
1941
+ throw invalid;
1942
+ return isView(spec)
1943
+ ? renderView(checkView(spec, dataset), i, digests[i].sha256, words)
1944
+ : renderChart(checkChart(spec, dataset), i, digests[i].sha256, words);
1945
+ }
1946
+ catch (err) {
1947
+ if (!(err instanceof ChartRefusal))
1948
+ throw err;
1949
+ digests[i].refused = err.reason;
1950
+ return renderChartRefused(i, err.reason, words);
1951
+ }
1952
+ });
1953
+ return renderCharts(parts);
1954
+ }
1918
1955
  /**
1919
1956
  * True when the rendered page module checked the producer signature of the
1920
1957
  * records it cites as signers: the built-in Result page, on a Close (or a
@@ -2059,6 +2096,7 @@ const sameLook = (a, b) => a.look === b.look &&
2059
2096
  box.height >=
2060
2097
  b.clips[i].height - Math.max(0, box.bar - b.clips[i].bar) - 1) &&
2061
2098
  Math.abs(a.place[0] - b.place[0]) <= 2 * SIDE_MARGIN_SLACK &&
2099
+ Math.abs(a.below - b.below) <= SIDE_MARGIN_SLACK &&
2062
2100
  a.place[1] - b.place[1] >= -SIDE_MARGIN_SLACK &&
2063
2101
  a.offsets.length === b.offsets.length &&
2064
2102
  a.offsets.every((m, i) => Math.abs(m - b.offsets[i]) <= SIDE_MARGIN_SLACK);
@@ -2372,6 +2410,34 @@ async function renderVerifiedContext(context, root, options) {
2372
2410
  uncheckpointed: bannerModel.uncheckpointed,
2373
2411
  total: Array.isArray(records) ? records.length : 0,
2374
2412
  };
2413
+ // The core's strip opens L0 on a verified bundle whose root is an
2414
+ // Evidence Result (core-strip.ts; presentation contract section 9.1). Its
2415
+ // words are the contract report's, in the grouping the module draws and
2416
+ // the page's wording pack; a page with no Result draws no strip.
2417
+ let strip;
2418
+ let chartsNode;
2419
+ const chartDigests = await chartDigestsOf(options.charts);
2420
+ const charted = options.charts !== undefined && options.charts.length > 0;
2421
+ if (verified) {
2422
+ const result = await resultRootOf(context);
2423
+ const grouping = contractReportGroupingOf(bundle) ?? "lines";
2424
+ const words = result === undefined && !charted
2425
+ ? undefined
2426
+ : await contractReportWords(grouping, options.wording, {
2427
+ singleContract: result !== undefined && citesOneContract(result),
2428
+ });
2429
+ if (result !== undefined)
2430
+ strip = await coreStripModel(result, words);
2431
+ // With no Result there is no dataset: each chart shows its notice
2432
+ // (chart-no-dataset), never nothing.
2433
+ if (charted)
2434
+ chartsNode = await drawCharts(context, result, options.charts, chartDigests, words);
2435
+ }
2436
+ else
2437
+ // A failed bundle has no L1 (contract I1); the verification page says
2438
+ // why no chart was drawn.
2439
+ for (const digest of chartDigests)
2440
+ digest.refused = "the bundle did not verify";
2375
2441
  // The host's three regions, in order after the banner and the header
2376
2442
  // (presentation contract section 9.1). L2 opens with the core's
2377
2443
  // verification section, drawn last but placed first; a module's L2 detail
@@ -2389,11 +2455,12 @@ async function renderVerifiedContext(context, root, options) {
2389
2455
  core: root,
2390
2456
  };
2391
2457
  let bar;
2458
+ let stripNode;
2392
2459
  const drawFrame = () => {
2393
2460
  root.replaceChildren();
2394
2461
  root.classList.remove("cv-shell-chrome");
2395
2462
  renderPresentationHeader(root, bundle);
2396
- bar = renderVerificationBanner(root, bannerModel, coverage);
2463
+ bar = renderVerificationBanner(root, bannerModel, coverage, bannerWitnessNotice(bannerModel, bundle, withStrict(context)));
2397
2464
  const L2 = region("L2");
2398
2465
  const core = region("L2-core");
2399
2466
  const L2module = region("L2-module");
@@ -2402,6 +2469,12 @@ async function renderVerifiedContext(context, root, options) {
2402
2469
  // section 9.1, I1): no module renders, and a notice goes before L2.
2403
2470
  if (verified) {
2404
2471
  regions = { L0: region("L0"), L1: region("L1"), L2: L2module, core };
2472
+ stripNode = strip === undefined ? undefined : renderCoreStrip(strip);
2473
+ if (stripNode !== undefined)
2474
+ regions.L0.append(stripNode);
2475
+ // The charts open L1, in the order the build gave them (chart-view.ts).
2476
+ if (chartsNode !== undefined)
2477
+ regions.L1.append(chartsNode);
2405
2478
  root.append(regions.L0, regions.L1, L2);
2406
2479
  }
2407
2480
  else {
@@ -2417,10 +2490,11 @@ async function renderVerifiedContext(context, root, options) {
2417
2490
  root.insertBefore(note, regions.core.parentElement);
2418
2491
  };
2419
2492
  drawFrame();
2420
- // The banner and its details line are the core's (contract sections 3 and
2421
- // 6.2). A module that, while it renders, changes their words, structure or
2422
- // attributes, hides or moves them, puts anything before them but the
2423
- // core's own header, or draws a second banner, is discarded for the
2493
+ // The banner, its details line and its witness notice are the core's
2494
+ // (contract sections 3 and 6.2). A module that, while it renders, changes
2495
+ // their words, structure or attributes, hides or moves them, puts anything
2496
+ // before them but the core's own header, or draws a second banner, is
2497
+ // discarded for the
2424
2498
  // refusal like one that throws. The bar's summary line is empty until the
2425
2499
  // verification section fills it, after every module has rendered. These
2426
2500
  // checks catch a module's mistakes; they do not hold against module code
@@ -2442,6 +2516,7 @@ async function renderVerifiedContext(context, root, options) {
2442
2516
  look: "",
2443
2517
  offsets: [],
2444
2518
  place: [0, 0],
2519
+ below: 0,
2445
2520
  readable: "unseen",
2446
2521
  clips: [],
2447
2522
  };
@@ -2453,9 +2528,12 @@ async function renderVerifiedContext(context, root, options) {
2453
2528
  const ancestors = [];
2454
2529
  for (let at = root.parentElement; at !== null; at = at.parentElement)
2455
2530
  ancestors.push(at);
2531
+ // The L0 region's own box too, but not what a module writes in it: a
2532
+ // module that hides or moves the region hides the strip.
2456
2533
  const elements = [
2457
2534
  ...ancestors,
2458
2535
  root,
2536
+ ...(stripNode === undefined ? [] : [regions.L0]),
2459
2537
  ...parts.flatMap((part) => [part, ...part.querySelectorAll("*")]),
2460
2538
  ];
2461
2539
  // A browser also computes each element's ::before and ::after, whose
@@ -2510,7 +2588,15 @@ async function renderVerifiedContext(context, root, options) {
2510
2588
  if (style?.position === "fixed")
2511
2589
  fixed = true;
2512
2590
  }
2591
+ // Every word of the banner and the strip: a module's content laid over
2592
+ // the strip is caught as one laid over the banner is.
2513
2593
  const words = readable(parts, root);
2594
+ // The strip stays where the banner puts it: nothing a module draws, laid
2595
+ // out ahead of it (a flex or grid `order`, a float), pushes it down.
2596
+ const strip = parts.length > 0 ? parts[parts.length - 1] : undefined;
2597
+ const below = jsdom || strip === undefined || strip !== stripNode
2598
+ ? 0
2599
+ : strip.getBoundingClientRect().top - box.top;
2514
2600
  // The visible size of every box that clips the banner, from <html> down
2515
2601
  // to the banner's own elements: a module that shrinks one (a scrolling
2516
2602
  // host's height set to 0) clips the banner wherever the reader has
@@ -2567,32 +2653,55 @@ async function renderVerifiedContext(context, root, options) {
2567
2653
  ];
2568
2654
  });
2569
2655
  root.classList.toggle("cv-shell-chrome", had);
2570
- return { look: seen, offsets, place, readable: words, clips };
2656
+ return { look: seen, offsets, place, below, readable: words, clips };
2571
2657
  };
2658
+ // The core strip (core-strip.ts) is held to the same rules as the
2659
+ // banner: its words, structure and look are the core's, and it stays the
2660
+ // first thing in L0, right after the banner.
2661
+ // The frame is the bar, then its details line and its witness notice
2662
+ // when it has them, in that order.
2572
2663
  const frameOf = () => {
2573
- const detail = bar.nextElementSibling;
2574
- const parts = [
2575
- bar,
2576
- ...(detail?.hasAttribute("data-banner-detail") ? [detail] : []),
2577
- ];
2664
+ const parts = [bar];
2665
+ for (const mark of ["data-banner-detail", "data-witness-notice"]) {
2666
+ const next = parts[parts.length - 1].nextElementSibling;
2667
+ if (next?.hasAttribute(mark))
2668
+ parts.push(next);
2669
+ }
2670
+ const held = [...parts, ...(stripNode === undefined ? [] : [stripNode])];
2578
2671
  return {
2579
2672
  parts,
2673
+ held,
2580
2674
  header: bar.previousElementSibling,
2581
- words: snapshot(parts),
2675
+ words: snapshot(held),
2582
2676
  looks: {
2583
- plain: looks(parts, false),
2584
- chrome: looks(parts, true),
2677
+ plain: looks(held, false),
2678
+ chrome: looks(held, true),
2585
2679
  },
2586
2680
  };
2587
2681
  };
2588
2682
  // Measured only when a module will render: it lays out the page.
2589
2683
  let frame = selected !== undefined || section !== undefined ? frameOf() : undefined;
2684
+ // The strip is L0's first node and L0 follows the banner directly; no
2685
+ // other node on the page carries the strip's marker. On a page with no
2686
+ // Result, nothing on it may carry the marks of the Result's counts
2687
+ // (RESULT_COUNT_MARKS): a module or layout there draws no claim counts,
2688
+ // tallies or coverage (the 2026-10-25 ruling on #81, condition 2).
2689
+ const stripIntact = (last) => {
2690
+ if (stripNode === undefined)
2691
+ return root.querySelector(RESULT_COUNT_MARKS) === null;
2692
+ return (regions.L0.parentNode === root &&
2693
+ regions.L0.previousSibling === last &&
2694
+ regions.L0.firstChild === stripNode &&
2695
+ !stripNode.hidden &&
2696
+ root.querySelectorAll(`[${CORE_STRIP_ATTRIBUTE}], .cv-strip`).length === 1);
2697
+ };
2590
2698
  const assertFrameIntact = () => {
2591
2699
  const at = frame;
2592
- const [top, detail] = at.parts;
2700
+ const [top, ...below] = at.parts;
2701
+ const last = at.parts[at.parts.length - 1];
2593
2702
  const pill = top.querySelector("[data-verify]");
2594
- const banners = root.querySelectorAll("[data-verify], [data-banner-detail]");
2595
- const expected = [pill, ...(detail === undefined ? [] : [detail])];
2703
+ const banners = root.querySelectorAll("[data-verify], [data-banner-detail], [data-witness-notice]");
2704
+ const expected = [pill, ...below];
2596
2705
  if (pill === null ||
2597
2706
  banners.length !== expected.length ||
2598
2707
  expected.some((part, i) => banners[i] !== part) ||
@@ -2601,11 +2710,12 @@ async function renderVerifiedContext(context, root, options) {
2601
2710
  root.firstChild !== (at.header ?? top) ||
2602
2711
  top.previousSibling !== at.header ||
2603
2712
  (at.header !== null && at.header.parentNode !== root) ||
2604
- (detail !== undefined && detail.previousElementSibling !== top) ||
2713
+ below.some((part, i) => part.previousElementSibling !== at.parts[i]) ||
2605
2714
  top.parentNode !== root ||
2606
2715
  top.hidden ||
2607
- snapshot(at.parts) !== at.words ||
2608
- !sameLook(looks(at.parts, root.classList.contains("cv-shell-chrome")), root.classList.contains("cv-shell-chrome")
2716
+ !stripIntact(last) ||
2717
+ snapshot(at.held) !== at.words ||
2718
+ !sameLook(looks(at.held, root.classList.contains("cv-shell-chrome")), root.classList.contains("cv-shell-chrome")
2609
2719
  ? at.looks.chrome
2610
2720
  : at.looks.plain))
2611
2721
  throw new Error("a module altered the verification banner");
@@ -2707,12 +2817,55 @@ async function renderVerifiedContext(context, root, options) {
2707
2817
  if (ran !== undefined)
2708
2818
  for (const id of moduleInterpreters(ran.module.manifest.id, context.bundle))
2709
2819
  applied.add(id);
2710
- const checkedLine = await renderVerificationPage(regions.core, context, chrome === OUTCOME_CHROME, applied, refused, refusal === undefined && citesCheckedSigners(selected), options.verifierHint, depth, stamps);
2820
+ const checkedLine = await renderVerificationPage(regions.core, context, chrome === OUTCOME_CHROME, applied, refused, refusal === undefined && citesCheckedSigners(selected), options.verifierHint, depth, stamps, chartDigests);
2711
2821
  // The banner says the same counts as the section it links to.
2712
2822
  const summary = root.querySelector("[data-verify-summary]");
2713
2823
  if (summary !== null)
2714
2824
  summary.textContent = checkedLine;
2825
+ linkCitedBy(root);
2715
2826
  // A page opened at a record's address shows that record.
2716
2827
  revealRecordsByHash(root.ownerDocument);
2717
2828
  }
2829
+ // "Cited by" (capsule-viewer#83): each record a number on the page counts
2830
+ // links back to that number. The numbers say what they count themselves
2831
+ // (report-levels.ts `evidenceAction`: `data-cites`, the digests their claims
2832
+ // cite that this bundle carries, and `data-evidence-name`); this reads them
2833
+ // back once the module and the records section are drawn, and infers no
2834
+ // citation. The list sits in the record's entry beside its address, outside
2835
+ // the entry's lazily built body, so a page that runs no script carries it.
2836
+ function linkCitedBy(root) {
2837
+ const anchors = new Map();
2838
+ for (const anchor of root.querySelectorAll(".cv-record-anchor"))
2839
+ anchors.set(anchor.id, anchor);
2840
+ const citing = new Map();
2841
+ for (const action of root.querySelectorAll("details.cv-ev[data-cites]"))
2842
+ for (const digest of (action.dataset.cites ?? "").split(" ")) {
2843
+ // One entry may hold two addresses (a book record and the capsule it
2844
+ // carries): its list is one, under the entry's last address.
2845
+ const entry = anchors
2846
+ .get(recordAddress(digest))
2847
+ ?.closest("details.cv-record");
2848
+ if (entry === undefined || entry === null)
2849
+ continue;
2850
+ const list = citing.get(entry) ?? [];
2851
+ if (!list.includes(action))
2852
+ list.push(action);
2853
+ citing.set(entry, list);
2854
+ }
2855
+ for (const [entry, actions] of citing) {
2856
+ const own = entry.querySelectorAll(":scope > .cv-record-anchor");
2857
+ const anchor = own[own.length - 1];
2858
+ const line = element("p", "Cited by: ");
2859
+ line.className = "cv-cited-by";
2860
+ line.dataset.citedBy = actions.map((a) => a.id).join(" ");
2861
+ actions.forEach((action, i) => {
2862
+ if (i > 0)
2863
+ line.append(" · ");
2864
+ const link = element("a", action.dataset.evidenceName ?? action.id);
2865
+ link.setAttribute("href", `#${action.id}`);
2866
+ line.append(link);
2867
+ });
2868
+ anchor.after(line);
2869
+ }
2870
+ }
2718
2871
  //# sourceMappingURL=evidence-graph-view.js.map