@calibrate-ds/core 0.1.75 → 0.1.77

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 (33) hide show
  1. package/dist/context/get-component-context.d.ts.map +1 -1
  2. package/dist/context/get-component-context.js +86 -18
  3. package/dist/context/get-component-context.js.map +1 -1
  4. package/dist/docs/generate-component-stories.d.ts.map +1 -1
  5. package/dist/docs/generate-component-stories.js +9 -19
  6. package/dist/docs/generate-component-stories.js.map +1 -1
  7. package/dist/mappings/naming-strategy.d.ts +11 -0
  8. package/dist/mappings/naming-strategy.d.ts.map +1 -1
  9. package/dist/mappings/naming-strategy.js +14 -0
  10. package/dist/mappings/naming-strategy.js.map +1 -1
  11. package/dist/normalizer/instance-resolver.d.ts.map +1 -1
  12. package/dist/normalizer/instance-resolver.js +29 -7
  13. package/dist/normalizer/instance-resolver.js.map +1 -1
  14. package/dist/normalizer/layout-tree.d.ts.map +1 -1
  15. package/dist/normalizer/layout-tree.js +11 -6
  16. package/dist/normalizer/layout-tree.js.map +1 -1
  17. package/dist/normalizer/variant-diff.d.ts.map +1 -1
  18. package/dist/normalizer/variant-diff.js +5 -1
  19. package/dist/normalizer/variant-diff.js.map +1 -1
  20. package/dist/prompt/generate-component-prompt.d.ts.map +1 -1
  21. package/dist/prompt/generate-component-prompt.js +15 -5
  22. package/dist/prompt/generate-component-prompt.js.map +1 -1
  23. package/dist/verify/pixel-diff.d.ts.map +1 -1
  24. package/dist/verify/pixel-diff.js +18 -8
  25. package/dist/verify/pixel-diff.js.map +1 -1
  26. package/dist/verify/structure-check.d.ts.map +1 -1
  27. package/dist/verify/structure-check.js +4 -1
  28. package/dist/verify/structure-check.js.map +1 -1
  29. package/dist/verify/verdict.d.ts +23 -3
  30. package/dist/verify/verdict.d.ts.map +1 -1
  31. package/dist/verify/verdict.js +44 -19
  32. package/dist/verify/verdict.js.map +1 -1
  33. package/package.json +3 -3
@@ -8,33 +8,58 @@
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
+ * If a pixel score falls below this floor while a token/structure primary exists,
12
+ * the pixel evidence hard-vetos the result — no token score can rescue past it.
13
+ * Catches the scaffold false-positive: a default prop value (aria-label="Button")
14
+ * inflates tokenScore to 1.0 on a blank shell, while pixel exposes the emptiness.
15
+ */
16
+ export const PIXEL_FLOOR_VETO = 0.10;
17
+ /**
18
+ * Computes a single verdict from a VerifyReport.
19
+ *
20
+ * Primary signal: design-content token match (immune to font/AA differences),
21
+ * falling back to structural slot presence when no text tokens exist.
22
+ *
23
+ * NEW-3 (Session 5 audit): the primary used to be a strict override — tokenScore,
24
+ * when defined, was used *exclusively*. But the token scanner has known blind
25
+ * spots (attribute text, short badge text), so a pixel-perfect render could stamp
26
+ * verified:false / 0% because its visible text lived in a placeholder attribute.
27
+ * The PIXEL score may now rescue a low primary — the two corroborate each other:
28
+ * - low pixel + high token → font/AA rendering noise; token is right
29
+ * - high pixel + low token → scanner blind spot; pixel is right
30
+ * structureScore deliberately can NOT rescue a low tokenScore: it only counts
31
+ * slots, so "right number of text nodes, wrong content" would max it out — a
32
+ * false-pass vector with no corroborating evidence behind it. Pixel rescue never
33
+ * downgrades a result the old chain passed (if token was highest, it still wins).
14
34
  */
15
35
  export function computeVerifyVerdict(report) {
16
- let score = null;
17
- let metric = "none";
36
+ let primary = null;
18
37
  if (report.tokenScore !== undefined) {
19
- score = report.tokenScore;
20
- metric = "token";
38
+ primary = { score: report.tokenScore, metric: "token" };
21
39
  }
22
40
  else if (report.structureScore !== undefined) {
23
- score = report.structureScore;
24
- metric = "structure";
41
+ primary = { score: report.structureScore, metric: "structure" };
42
+ }
43
+ let pixel = null;
44
+ if (report.pixelMatch) {
45
+ pixel = report.pixelMatch.contentScore !== undefined
46
+ ? { score: report.pixelMatch.contentScore, metric: "pixel-content" }
47
+ : { score: report.pixelMatch.score, metric: "pixel" };
25
48
  }
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
- }
49
+ // Pixel floor veto: catastrophically low pixel evidence (< 10%) with an existing
50
+ // primary means the scaffold's default prop values inflated the token/structure
51
+ // score while the render was visually empty. Pixel wins — the component failed.
52
+ if (primary && pixel && pixel.score < PIXEL_FLOOR_VETO) {
53
+ const verdict = "fail";
54
+ return { verdict, score: pixel.score, metric: pixel.metric };
35
55
  }
36
- if (score === null)
56
+ // Prefer the primary; let pixel evidence rescue when it is strictly better.
57
+ const best = primary && pixel
58
+ ? (pixel.score > primary.score ? pixel : primary)
59
+ : (primary ?? pixel);
60
+ if (!best)
37
61
  return { verdict: "no-comparison", score: null, metric: "none" };
62
+ const { score, metric } = best;
38
63
  const verdict = score >= VERIFY_PASS_THRESHOLD ? "pass"
39
64
  : score >= VERIFY_WARN_THRESHOLD ? "warn"
40
65
  : "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,cAA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AC;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.75",
3
+ "version": "0.1.77",
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.75",
43
- "@calibrate-ds/figma-client": "^0.1.75"
42
+ "@calibrate-ds/shared-types": "^0.1.77",
43
+ "@calibrate-ds/figma-client": "^0.1.77"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsc -p tsconfig.json",