@calibrate-ds/core 0.1.74 → 0.1.76

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.
@@ -8,33 +8,44 @@
8
8
  export const VERIFY_PASS_THRESHOLD = 0.90;
9
9
  export const VERIFY_WARN_THRESHOLD = 0.70;
10
10
  /**
11
- * Computes a single verdict from a VerifyReport, preferring the most meaningful
12
- * available signal: design-content token match (immune to font/AA differences) →
13
- * structural slot presence → content-region pixel score raw pixel score.
11
+ * Computes a single verdict from a VerifyReport.
12
+ *
13
+ * Primary signal: design-content token match (immune to font/AA differences),
14
+ * falling back to structural slot presence when no text tokens exist.
15
+ *
16
+ * NEW-3 (Session 5 audit): the primary used to be a strict override — tokenScore,
17
+ * when defined, was used *exclusively*. But the token scanner has known blind
18
+ * spots (attribute text, short badge text), so a pixel-perfect render could stamp
19
+ * verified:false / 0% because its visible text lived in a placeholder attribute.
20
+ * The PIXEL score may now rescue a low primary — the two corroborate each other:
21
+ * - low pixel + high token → font/AA rendering noise; token is right
22
+ * - high pixel + low token → scanner blind spot; pixel is right
23
+ * structureScore deliberately can NOT rescue a low tokenScore: it only counts
24
+ * slots, so "right number of text nodes, wrong content" would max it out — a
25
+ * false-pass vector with no corroborating evidence behind it. Pixel rescue never
26
+ * downgrades a result the old chain passed (if token was highest, it still wins).
14
27
  */
15
28
  export function computeVerifyVerdict(report) {
16
- let score = null;
17
- let metric = "none";
29
+ let primary = null;
18
30
  if (report.tokenScore !== undefined) {
19
- score = report.tokenScore;
20
- metric = "token";
31
+ primary = { score: report.tokenScore, metric: "token" };
21
32
  }
22
33
  else if (report.structureScore !== undefined) {
23
- score = report.structureScore;
24
- metric = "structure";
34
+ primary = { score: report.structureScore, metric: "structure" };
25
35
  }
26
- else if (report.pixelMatch) {
27
- if (report.pixelMatch.contentScore !== undefined) {
28
- score = report.pixelMatch.contentScore;
29
- metric = "pixel-content";
30
- }
31
- else {
32
- score = report.pixelMatch.score;
33
- metric = "pixel";
34
- }
36
+ let pixel = null;
37
+ if (report.pixelMatch) {
38
+ pixel = report.pixelMatch.contentScore !== undefined
39
+ ? { score: report.pixelMatch.contentScore, metric: "pixel-content" }
40
+ : { score: report.pixelMatch.score, metric: "pixel" };
35
41
  }
36
- if (score === null)
42
+ // Prefer the primary; let pixel evidence rescue when it is strictly better.
43
+ const best = primary && pixel
44
+ ? (pixel.score > primary.score ? pixel : primary)
45
+ : (primary ?? pixel);
46
+ if (!best)
37
47
  return { verdict: "no-comparison", score: null, metric: "none" };
48
+ const { score, metric } = best;
38
49
  const verdict = score >= VERIFY_PASS_THRESHOLD ? "pass"
39
50
  : score >= VERIFY_WARN_THRESHOLD ? "warn"
40
51
  : "fail";
@@ -1 +1 @@
1
- {"version":3,"file":"verdict.js","sourceRoot":"","sources":["../../src/verify/verdict.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAY1C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MACc;IAC/C,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,IAAI,MAAM,GAAkC,MAAM,CAAC;IAEnD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QAClC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAC1B,MAAM,GAAG,OAAO,CAAC;IACrB,CAAC;SAAM,IAAI,MAAM,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QAC7C,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;QAC9B,MAAM,GAAG,WAAW,CAAC;IACzB,CAAC;SAAM,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/C,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC;YACv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MAAM,CAAC,UAAU,CAAC,YAAY,KAAK,SAAS;YAChD,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE;YACpE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED,4EAA4E;IAC5E,MAAM,IAAI,GAAG,OAAO,IAAI,KAAK;QACzB,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;QACjD,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;IAEzB,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE/B,MAAM,OAAO,GAAkB,KAAK,IAAI,qBAAqB,CAAC,CAAC,CAAC,MAAM;QAClE,CAAC,CAAC,KAAK,IAAI,qBAAqB,CAAC,CAAC,CAAC,MAAM;YACzC,CAAC,CAAC,MAAM,CAAC;IAEb,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calibrate-ds/core",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -39,8 +39,8 @@
39
39
  "pixelmatch": "^6.0.0",
40
40
  "pngjs": "^7.0.0",
41
41
  "zod": "^4.3.6",
42
- "@calibrate-ds/shared-types": "^0.1.74",
43
- "@calibrate-ds/figma-client": "^0.1.74"
42
+ "@calibrate-ds/shared-types": "^0.1.76",
43
+ "@calibrate-ds/figma-client": "^0.1.76"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsc -p tsconfig.json",